using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Web; using System.Web.Mvc; using HcUtility.Comm; using Microsoft.Practices.EnterpriseLibrary.Data; using DSWeb.EntityDA; using DSWeb.Areas.CommMng.Models; using DSWeb.MvcShipping.Models.MsInfoClient; using DSWeb.MvcShipping.Models.MsCtExplan; using DSWeb.MvcShipping.Helper; using DSWeb.MvcShipping.DAL.MsSysParamSet; using DSWeb.MvcShipping.Helper.Repository; using DSWeb.SoftMng.Models.MsInfoClass; using DSWeb.SoftMng.Models.MsInfoClientItem; using System.IO;//用于向数据库中存取图片 using System.Data.SqlClient;//使用sqlcomm namespace DSWeb.Areas.CommMng.DAL { public class BasicDataRefDAL { #region 费用代码 public static List GetFeeTypeRefList() { return GetFeeTypeRefList(String.Empty); } public static List GetFeeTypeRefList(string sCondition) { var strSql = new StringBuilder(); strSql.Append("Select FeeCode,Name,CodeAndName "); strSql.Append(" from vMsTruckFeeType "); if (!string.IsNullOrEmpty(sCondition)) { strSql.Append(" where " + sCondition); } strSql.Append(" order by FeeCode"); Database db = DatabaseFactory.CreateDatabase(); var evList = new List(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { var evData = new FeeTypeRefModel(); evData.FeeCode = Convert.ToString(reader["FeeCode"]); evData.Name = Convert.ToString(reader["Name"]); evData.CodeAndName = Convert.ToString(reader["CodeAndName"]); evList.Add(evData); } reader.Close(); } return evList; } public static List GetFeeGroupRefList ( ) { return GetFeeGroupRefList(String.Empty); } public static List GetFeeGroupRefList ( string sCondition ) { var strSql = new StringBuilder(); strSql.Append("Select feegroupcode FeeCode,feegroupname Name,feegroupcode+'_'+feegroupname CodeAndName "); strSql.Append(" from code_fee_group "); if (!string.IsNullOrEmpty(sCondition)) { strSql.Append(" where " + sCondition); } strSql.Append(" order by feegroupcode"); Database db = DatabaseFactory.CreateDatabase(); var evList = new List(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { var evData = new FeeTypeRefModel(); evData.FeeCode = Convert.ToString(reader["FeeCode"]); evData.Name = Convert.ToString(reader["Name"]); evData.CodeAndName = Convert.ToString(reader["CodeAndName"]); evList.Add(evData); } reader.Close(); } return evList; } #endregion #region 用户 static public List GetUserRefList() { return GetUserRefList(string.Empty); } static public List GetUserRefList(string strCondition, string dbname = "") { var strSql = new StringBuilder(); strSql.Append("SELECT "); strSql.Append("GID,UserCode,UserName,CodeAndName,CORPID,DEPTGID,DEPTNAME"); strSql.Append(" from vMsTruckUser "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" where " + strCondition); } return SetUserRefData(strSql, dbname); } private static List SetUserRefData(StringBuilder strSql,string dbname="") { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); if (dbname != "") db = DatabaseFactory.CreateDatabase(dbname); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { UserRefModel data = new UserRefModel(); #region Set DB data to Object data.GID = Convert.ToString(reader["GID"]); data.UserCode = Convert.ToString(reader["UserCode"]); data.UserName = Convert.ToString(reader["UserName"]); data.CodeAndName = Convert.ToString(reader["CodeAndName"]); data.CORPID = Convert.ToString(reader["CORPID"]); data.DEPTGID = Convert.ToString(reader["DEPTGID"]); data.DEPTNAME = Convert.ToString(reader["DEPTNAME"]); #endregion headList.Add(data); } reader.Close(); } UserRefModel adata = new UserRefModel(); #region Set DB data to Object adata.GID =""; adata.UserCode =""; adata.UserName =""; adata.CodeAndName =""; adata.CORPID =""; adata.DEPTGID =""; adata.DEPTNAME =""; #endregion headList.Add(adata); return headList; } static public List GetUserLinkRefList(string strCondition, string COMPANYID) { var strSql = new StringBuilder(); strSql.Append("SELECT "); strSql.Append("l.USERID GID,u.CODENAME UserCode,u.SHOWNAME UserName,u.CODENAME+'-'+u.SHOWNAME CodeAndName,"); strSql.Append("l.OFFICEPHONE Tel,l.FAX Fax,l.EMAIL1 Email,l.DEPTNAME,c.COMPANYID"); strSql.Append(" from [user] u left join user_baseinfo l on (u.gid=l.USERID) "); strSql.Append(" left join user_company c on (u.gid=c.USERID) "); var SeaeDefaultSort = MsSysParamSetDAL.GetData("PARAMNAME='OPONLYSUBCOMPANY'"); if (SeaeDefaultSort.PARAMVALUE != "" && SeaeDefaultSort.PARAMVALUE == "1") strSql.Append(" where c.companyid='" + COMPANYID + "' "); else strSql.Append(" where 1=1 "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" and " + strCondition); } strSql.Append(" order by u.CODENAME,u.SHOWNAME "); return SetUserLinkRefData(strSql); } private static List SetUserLinkRefData(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { UserLinkRefModel data = new UserLinkRefModel(); #region Set DB data to Object data.GID = Convert.ToString(reader["GID"]); data.UserCode = Convert.ToString(reader["UserCode"]); data.UserName = Convert.ToString(reader["UserName"]); data.CodeAndName = Convert.ToString(reader["CodeAndName"]); data.Tel = Convert.ToString(reader["Tel"]); data.Fax = Convert.ToString(reader["Fax"]); data.Email = Convert.ToString(reader["Email"]); data.DEPTNAME = Convert.ToString(reader["DEPTNAME"]); data.CORPID = Convert.ToString(reader["COMPANYID"]); #endregion headList.Add(data); } reader.Close(); } UserLinkRefModel adata = new UserLinkRefModel(); #region Set DB data to Object adata.GID = ""; adata.UserCode = ""; adata.UserName = ""; adata.CodeAndName = ""; adata.Tel = ""; adata.Fax = ""; adata.Email = ""; #endregion headList.Add(adata); return headList; } #endregion #region 配料 public static List GetPluRefList() { return GetPluRefList(String.Empty); } public static List GetPluRefList(string sCondition) { var strSql = new StringBuilder(); strSql.Append("Select PluCode,PluName,PluCode+'-'+PluName as CodeAndName,Unit,Spec,Price "); strSql.Append(" from tMsTruckPlu "); if (!string.IsNullOrEmpty(sCondition)) { strSql.Append(" where " + sCondition); } strSql.Append(" order by PluCode"); Database db = DatabaseFactory.CreateDatabase(); var evList = new List(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { var evData = new PluRefModel(); evData.PluCode = Convert.ToString(reader["PluCode"]); evData.PluName = Convert.ToString(reader["PluName"]); evData.CodeAndName = Convert.ToString(reader["CodeAndName"]); evData.Unit = Convert.ToString(reader["Unit"]); evData.Spec = Convert.ToString(reader["Spec"]); evData.Price = Convert.ToDecimal(reader["Price"]); evList.Add(evData); } reader.Close(); } return evList; } #endregion #region 客户参照,对应95004(vMsTruckClient) static public List GetCustomRefList() { return GetCustomRefList(string.Empty); } static public List GetCustomRefList(string strCondition,string IsEnableCustRange="0",string userid="") { var strSql = new StringBuilder(); strSql.Append("SELECT "); strSql.Append("Gid,CODENAME AS CustCode, SHORTNAME AS CustName,CODENAME + '-' + SHORTNAME AS CodeAndName,CODENAME + '-' + description AS CodeAndFull,BillRises1"); strSql.Append(",UNITPRICE,description,SHORTNAME+'_'+description KFCodename,SALE,OP,DOC,FEEFRT,BSSOURCE,[EMAIL],[TEL],SALECORPID "); strSql.Append(" from info_Client where 1=1 "); // BLSTATUS=0 if (!string.IsNullOrEmpty(strCondition)) { var InfoClintBlstatus = MsSysParamSetDAL.GetData("PARAMNAME='InfoClintBlstatus'"); if (InfoClintBlstatus.PARAMVALUE != "") { if (InfoClintBlstatus.PARAMVALUE == "1") { strSql.Append(" and BLSTATUS=0 "); } } if (IsEnableCustRange=="1") strSql.Append(" and (SHORTNAME in (SELECT SHORTNAME from info_client_range where USERID='" + userid + "' ) or SHORTNAME not in (SELECT SHORTNAME from info_client_range )) "); strSql.Append(" and " + strCondition); } strSql.Append(" ORDER BY CODENAME "); return SetCustomRefData(strSql); } static public string GetHTStorageName() { var strSql = new StringBuilder(); strSql.Append("SELECT "); strSql.Append("Gid,CODENAME AS CustCode, SHORTNAME AS CustName,CODENAME + '-' + SHORTNAME AS CodeAndName,BillRises1"); strSql.Append(",UNITPRICE,description,SHORTNAME+'_'+description KFCodename,SALE,OP,DOC,FEEFRT,BSSOURCE,[EMAIL],[TEL],SALECORPID "); strSql.Append(" from info_Client where 1=1 AND ISWAREHOUSE = '1' "); // BLSTATUS=0 strSql.Append(" ORDER BY CODENAME "); return SetCustomRefData(strSql)[0].CustName.ToString(); } private static List SetCustomRefData(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { CustomRefModel data = new CustomRefModel(); #region Set DB data to Object data.GId = Convert.ToString(reader["GId"]); data.CustCode = Convert.ToString(reader["CustCode"]); data.CustName = Convert.ToString(reader["CustName"]); data.CodeAndName = Convert.ToString(reader["CodeAndName"]); data.BillRises1 = Convert.ToString(reader["BillRises1"]); data.UNITPRICE = Convert.ToString(reader["UNITPRICE"]); data.DESCRIPTION = Convert.ToString(reader["description"]); data.KFCodename = Convert.ToString(reader["KFCodename"]); data.SALE = Convert.ToString(reader["SALE"]); data.FEEFRT = Convert.ToString(reader["FEEFRT"]); data.BSSOURCE = Convert.ToString(reader["BSSOURCE"]); data.EMAIL = Convert.ToString(reader["EMAIL"]); data.TEL = Convert.ToString(reader["TEL"]); data.SALECORPID = Convert.ToString(reader["SALECORPID"]); data.OP = Convert.ToString(reader["OP"]); data.DOC = Convert.ToString(reader["DOC"]); #endregion headList.Add(data); } reader.Close(); } CustomRefModel adata = new CustomRefModel(); #region Set DB data to Object adata.GId = ""; adata.CustCode = ""; adata.CustName = ""; adata.CodeAndName = ""; adata.BillRises1 = ""; adata.UNITPRICE = ""; adata.DESCRIPTION = ""; adata.KFCodename = ""; adata.SALE = ""; adata.FEEFRT = ""; adata.BSSOURCE = ""; #endregion headList.Add(adata); return headList; } static public List GetCustomYardRefList(string strCondition, string IsEnableCustRange = "0", string userid = "") { var strSql = new StringBuilder(); strSql.Append("SELECT "); strSql.Append("Gid,CODENAME as CustCode,SHORTNAME as CustName,CODENAME+'-'+SHORTNAME as CodeAndName,ADDR"); strSql.Append(" from info_client where 1=1 "); if (!string.IsNullOrEmpty(strCondition)) { var InfoClintBlstatus = MsSysParamSetDAL.GetData("PARAMNAME='InfoClintBlstatus'"); if (InfoClintBlstatus.PARAMVALUE != "") { if (InfoClintBlstatus.PARAMVALUE == "1") { strSql.Append(" and BLSTATUS=0 "); } } //if (IsEnableCustRange == "1") // strSql.Append(" and SHORTNAME in (SELECT SHORTNAME from info_client_range where USERID='" + userid + "' ) "); strSql.Append(" and " + strCondition); } return SetCustomYardRefData(strSql); } private static List SetCustomYardRefData(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { CustomYardRefModel data = new CustomYardRefModel(); #region Set DB data to Object data.GId = Convert.ToString(reader["GId"]); data.CustCode = Convert.ToString(reader["CustCode"]); data.CustName = Convert.ToString(reader["CustName"]); data.CodeAndName = Convert.ToString(reader["CodeAndName"]); data.ADDR = Convert.ToString(reader["ADDR"]); #endregion headList.Add(data); } reader.Close(); } CustomYardRefModel adata = new CustomYardRefModel(); #region Set DB data to Object adata.GId = ""; adata.CustCode = ""; adata.CustName = ""; adata.CodeAndName = ""; #endregion headList.Add(adata); return headList; } static public List GetCustomInvRefList(string strCondition, string IsEnableCustRange = "0", string userid = "") { var strSql = new StringBuilder(); strSql.Append("SELECT "); strSql.Append("Gid,CODENAME as CustCode,SHORTNAME as CustName,CODENAME+'-'+SHORTNAME as CodeAndName,BillRises1,INVADDRTEL,[DESCRIPTION]"); strSql.Append(",RmbBillRises,(select top 1 BANKNAME+' '+ACCOUNT FROM info_client_bank WHERE CURRENCY='RMB' AND LINKID=info_client.GID) Rmbbank,Rmbaccount,usdBillRises,(select top 1 BANKNAME+' '+ACCOUNT FROM info_client_bank WHERE CURRENCY='USD' AND LINKID=info_client.GID) usdbank,usdaccount,TaxNo,Addr,Tel"); strSql.Append(" from info_client where 1=1 "); if (!string.IsNullOrEmpty(strCondition)) { var InfoClintBlstatus = MsSysParamSetDAL.GetData("PARAMNAME='InfoClintBlstatus'"); if (InfoClintBlstatus.PARAMVALUE != "") { if (InfoClintBlstatus.PARAMVALUE == "1") { strSql.Append(" and BLSTATUS=0 "); } } if (IsEnableCustRange == "1") strSql.Append(" and (SHORTNAME in (SELECT SHORTNAME from info_client_range where USERID='" + userid + "' ) or SHORTNAME not in (SELECT SHORTNAME from info_client_range )) "); strSql.Append(" and (" + strCondition+")"); } return SetCustomInvRefData(strSql); } private static List SetCustomInvRefData(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); headList.Add(new CustomInvRefModel()); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { CustomInvRefModel data = new CustomInvRefModel(); #region Set DB data to Object data.GId = Convert.ToString(reader["GId"]); data.CustCode = Convert.ToString(reader["CustCode"]); data.CustName = Convert.ToString(reader["CustName"]); data.CodeAndName = Convert.ToString(reader["CodeAndName"]); data.DESCRIPTION = Convert.ToString(reader["DESCRIPTION"]); data.BillRises1 = Convert.ToString(reader["BillRises1"]); data.RMBBillRises = Convert.ToString(reader["RmbBillRises"]); data.RMBBank = Convert.ToString(reader["Rmbbank"]); data.RMBAccount = Convert.ToString(reader["Rmbaccount"]); data.USDBillRises = Convert.ToString(reader["usdBillRises"]); data.USDBank = Convert.ToString(reader["usdbank"]); data.USDAccount = Convert.ToString(reader["usdaccount"]); data.TaxNo = Convert.ToString(reader["TaxNo"]); data.Addr = Convert.ToString(reader["Addr"]); data.Tel = Convert.ToString(reader["Tel"]); data.INVADDRTEL = Convert.ToString(reader["INVADDRTEL"]); if (data.BillRises1 == "") data.BillRises1 = Convert.ToString(reader["DESCRIPTION"]); if (data.RMBBillRises == "") data.RMBBillRises = Convert.ToString(reader["DESCRIPTION"]); if (data.USDBillRises == "") data.USDBillRises = Convert.ToString(reader["DESCRIPTION"]); #endregion headList.Add(data); } reader.Close(); } return headList; } static public List GetCustomContactRefList(string strCondition) { var strSql = new StringBuilder(); strSql.Append("SELECT "); strSql.Append("LinkId,CODENAME,SHOWNAME,Tel"); strSql.Append(" from info_client_contact "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" where " + strCondition); } return SetCustomContactRefData(strSql); } private static List SetCustomContactRefData(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { CustomContactRefModel data = new CustomContactRefModel(); #region Set DB data to Object data.LinkId = Convert.ToString(reader["LinkId"]); data.Code = Convert.ToString(reader["CODENAME"]); data.Name = Convert.ToString(reader["SHOWNAME"]); data.Tel = Convert.ToString(reader["Tel"]); #endregion headList.Add(data); } reader.Close(); } return headList; } static public List GetAirLinesList ( string strCondition ) { var strSql = new StringBuilder(); strSql.Append("SELECT "); strSql.Append("Gid,CODENAME AS CustCode, SHORTNAME AS CustName,CODENAME + '-' + SHORTNAME AS CodeAndName,BillRises1"); strSql.Append(",UNITPRICE,description,SHORTNAME+'_'+description KFCodename,SALE,ISAGENTCN "); strSql.Append(" from info_Client where 1=1 "); // BLSTATUS=0 if (!string.IsNullOrEmpty(strCondition)) { var InfoClintBlstatus = MsSysParamSetDAL.GetData("PARAMNAME='InfoClintBlstatus'"); if (InfoClintBlstatus.PARAMVALUE != "") { if (InfoClintBlstatus.PARAMVALUE == "1") { strSql.Append(" and BLSTATUS=0 "); } } strSql.Append(" and " + strCondition); } strSql.Append(" ORDER BY CODENAME "); return SetAirLinesData(strSql); } private static List SetAirLinesData ( StringBuilder strSql ) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { CustomRefModel data = new CustomRefModel(); #region Set DB data to Object data.GId = Convert.ToString(reader["GId"]); data.CustCode = Convert.ToString(reader["CustCode"]); data.CustName = Convert.ToString(reader["CustName"]); data.CodeAndName = Convert.ToString(reader["CodeAndName"]); data.BillRises1 = Convert.ToString(reader["BillRises1"]); data.UNITPRICE = Convert.ToString(reader["UNITPRICE"]); data.DESCRIPTION = Convert.ToString(reader["description"]); data.KFCodename = Convert.ToString(reader["KFCodename"]); data.SALE = Convert.ToString(reader["SALE"]); data.ISAGENTCN = Convert.ToString(reader["ISAGENTCN"]); #endregion headList.Add(data); } reader.Close(); } CustomRefModel adata = new CustomRefModel(); #region Set DB data to Object adata.GId = ""; adata.CustCode = ""; adata.CustName = ""; adata.CodeAndName = ""; adata.BillRises1 = ""; adata.UNITPRICE = ""; adata.DESCRIPTION = ""; adata.KFCodename = ""; adata.SALE = ""; #endregion headList.Add(adata); return headList; } #endregion #region 客户参照,对应95004.内贸空运 获取vip价格 static public List GetCustom_SPPrice ( ) { return GetCustom_SPPrice(string.Empty); } static public List GetCustom_SPPrice ( string strCondition ) { var strSql = new StringBuilder(); strSql.Append(" SELECT Gid,CODENAME AS CustCode, SHORTNAME AS CustName,CODENAME + '-' + SHORTNAME AS CodeAndName,BillRises1 "); strSql.Append(" ,UNITPRICE,description,SHORTNAME+'_'+description KFCodename,SALE "); strSql.Append(" ,(case when (select dbo.Get_ClientFee(SHORTNAME,'VIP单价'))>0 "); strSql.Append(" or (select dbo.Get_ClientFee(SHORTNAME,'VIP单票'))>0 then 1 else 0 end )ISVIP "); strSql.Append(" ,(select dbo.Get_ClientFee(SHORTNAME,'VIP单价')) VIPDJ "); strSql.Append(" ,(select dbo.Get_ClientFee(SHORTNAME,'VIP单票')) VIPDP "); strSql.Append(" from info_Client where 1=1 "); if (!string.IsNullOrEmpty(strCondition)) { var InfoClintBlstatus = MsSysParamSetDAL.GetData("PARAMNAME='InfoClintBlstatus'"); if (InfoClintBlstatus.PARAMVALUE != "") { if (InfoClintBlstatus.PARAMVALUE == "1") { strSql.Append(" and BLSTATUS=0 "); } } strSql.Append(" and " + strCondition); } strSql.Append(" ORDER BY CODENAME "); return SetCustom_SPPrice(strSql); } private static List SetCustom_SPPrice ( StringBuilder strSql ) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { CustomVIPModel data = new CustomVIPModel(); #region Set DB data to Object data.GId = Convert.ToString(reader["GId"]); data.CustCode = Convert.ToString(reader["CustCode"]); data.CustName = Convert.ToString(reader["CustName"]); data.CodeAndName = Convert.ToString(reader["CodeAndName"]); data.BillRises1 = Convert.ToString(reader["BillRises1"]); data.UNITPRICE = Convert.ToString(reader["UNITPRICE"]); data.DESCRIPTION = Convert.ToString(reader["description"]); data.KFCodename = Convert.ToString(reader["KFCodename"]); data.SALE = Convert.ToString(reader["SALE"]); data.ISVIP = Convert.ToString(reader["ISVIP"]); data.VIPDJ = Convert.ToString(reader["VIPDJ"]); data.VIPDP = Convert.ToString(reader["VIPDP"]); #endregion headList.Add(data); } reader.Close(); } CustomVIPModel adata = new CustomVIPModel(); #region Set DB data to Object adata.GId = ""; adata.CustCode = ""; adata.CustName = ""; adata.CodeAndName = ""; adata.BillRises1 = ""; adata.UNITPRICE = ""; adata.DESCRIPTION = ""; adata.KFCodename = ""; adata.SALE = ""; #endregion headList.Add(adata); return headList; } #endregion #region 客户银行账户列表 static public List GetMsClientAccount ( string condition ) { return GetMsClientAccountData(condition); } static public List GetMsClientAccountData ( string strCondition ) { var strSql = new StringBuilder(); strSql.Append("SELECT "); strSql.Append("GID,BANKNAME,ACCOUNT,BANKNAME+'-'+ACCOUNT BANKNAME_ACCOUNT"); strSql.Append(" from info_client_bank "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" where " + strCondition); } return SetMsClientAccountData(strSql); } private static List SetMsClientAccountData ( StringBuilder strSql ) { var headList = new List(); MsClientAccount adata = new MsClientAccount(); #region Set DB data to Object adata.GID = ""; adata.BANKNAME = ""; adata.ACCOUNT = ""; adata.BANKNAME_ACCOUNT = ""; #endregion Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { MsClientAccount data = new MsClientAccount(); #region Set DB data to Object data.GID = Convert.ToString(reader["GID"]); data.BANKNAME = Convert.ToString(reader["BANKNAME"]); data.ACCOUNT = Convert.ToString(reader["ACCOUNT"]); data.BANKNAME_ACCOUNT = Convert.ToString(reader["BANKNAME_ACCOUNT"]); #endregion headList.Add(data); } reader.Close(); } headList.Add(adata); return headList; } #endregion #region 业务来源 static public List GetSourceList(string strCondition) { var strSql = new StringBuilder(); strSql.Append("SELECT "); strSql.Append("SOURCEID,SOURCENAME,CORPID"); strSql.Append(" from code_source "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" where " + strCondition); } return SetSourceData(strSql); } private static List SetSourceData(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { SourceModel data = new SourceModel(); #region Set DB data to Object data.SourceID = Convert.ToString(reader["SOURCEID"]); data.SourceName = Convert.ToString(reader["SOURCENAME"]); data.CorpID = Convert.ToString(reader["CORPID"]); #endregion headList.Add(data); } reader.Close(); } SourceModel adata = new SourceModel(); #region Set DB data to Object adata.SourceID = ""; adata.SourceName =""; adata.CorpID =""; #endregion headList.Add(adata); return headList; } static public List GetSourceDetailList(string strCondition) { var strSql = new StringBuilder(); strSql.Append("SELECT "); strSql.Append("SOURCEDETAILID,SOURCEID,SOURCEDETAIL"); strSql.Append(" from code_source_detail "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" where " + strCondition); } return SetSourceDetailData(strSql); } private static List SetSourceDetailData(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { SourceDetailModel data = new SourceDetailModel(); #region Set DB data to Object data.SourceDetailID = Convert.ToString(reader["SOURCEDETAILID"]); data.SourceID = Convert.ToString(reader["SOURCEID"]); data.SourceDetail = Convert.ToString(reader["SOURCEDETAIL"]); #endregion headList.Add(data); } reader.Close(); } SourceDetailModel adata = new SourceDetailModel(); #region Set DB data to Object adata.SourceDetailID =""; adata.SourceID =""; adata.SourceDetail =""; #endregion headList.Add(adata); return headList; } #endregion #region 部门 static public List GetDeptList(string strCondition) { var strSql = new StringBuilder(); strSql.Append("SELECT "); strSql.Append("GID,LINKID,DEPTNO,DEPTNAME,MANAGE1,DEPTNO + '-' + DEPTNAME AS NOANDNAME"); strSql.Append(" from sys_dept "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" where " + strCondition); } return SetDeptData(strSql); } private static List SetDeptData(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { DeptModel data = new DeptModel(); #region Set DB data to Object data.GID = Convert.ToString(reader["GID"]); data.Deptno = Convert.ToString(reader["DEPTNO"]); data.DeptName = Convert.ToString(reader["DEPTNAME"]); data.Manage1 = Convert.ToString(reader["MANAGE1"]); data.NOANDNAME= Convert.ToString(reader["NOANDNAME"]); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 船名航次参照,对应95003(vMsTruckVoyInfo) static public List GetVoyRefList() { return GetVoyRefList(string.Empty); } static public List GetVoyRefList(string strCondition) { var strSql = new StringBuilder(); strSql.Append("SELECT "); strSql.Append("VoyCode,VoyName,CodeAndName"); strSql.Append(" from vMsTruckVoyInfo "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" where " + strCondition); } return SetVoyRefData(strSql); } private static List SetVoyRefData(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { VoyRefModel data = new VoyRefModel(); #region Set DB data to Object data.VoyCode = Convert.ToString(reader["VoyCode"]); data.VoyName = Convert.ToString(reader["VoyName"]); data.CodeAndName = Convert.ToString(reader["CodeAndName"]); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 船名 static public List GetVesselList(string strCondition) { var strSql = new StringBuilder(); strSql.Append("SELECT "); strSql.Append(" VSID,VESSEL,CNAME,CARRIER,EDICODE,VESSEL+' '+CNAME CodeAndName"); strSql.Append(" from code_vessel "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" where " + strCondition); } return SetVesselData(strSql); } private static List SetVesselData(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { VesselModel data = new VesselModel(); #region Set DB data to Object data.VSID = Convert.ToString(reader["VSID"]); data.VESSEL = Convert.ToString(reader["VESSEL"]); data.CNAME = Convert.ToString(reader["CNAME"]); data.EDICODE = Convert.ToString(reader["EDICODE"]); data.CodeAndName = Convert.ToString(reader["CodeAndName"]); #endregion headList.Add(data); } reader.Close(); } return headList; } static public List GetVoyNoList(string strCondition) { var strSql = new StringBuilder(); strSql.Append("SELECT "); strSql.Append(" VOID,VSID,VOYNO,PORTLOAD,PORTDISCHARGE,ETD,CLOSINGDATE,ETA,CORPID,YARDID,ENTREPORT,VESSEL,ATD "); strSql.Append(" from code_voyno "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" where " + strCondition); } return SetVoyNoData(strSql); } private static List SetVoyNoData(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { VoyNoModel data = new VoyNoModel(); #region Set DB data to Object data.VSID = Convert.ToString(reader["VSID"]); data.VOYNO = Convert.ToString(reader["VOYNO"]); data.PORTLOAD = Convert.ToString(reader["PORTLOAD"]); data.PORTDISCHARGE = Convert.ToString(reader["PORTDISCHARGE"]); if (reader["ETD"] != DBNull.Value) data.ETD = Convert.ToDateTime(reader["ETD"]).ToString("yyyy-MM-dd"); if (reader["CLOSINGDATE"] != DBNull.Value) data.CLOSINGDATE = Convert.ToDateTime(reader["CLOSINGDATE"]).ToString("yyyy-MM-dd"); if (reader["ETA"] != DBNull.Value) data.ETA = Convert.ToDateTime(reader["ETA"]).ToString("yyyy-MM-dd"); if (reader["ATD"] != DBNull.Value) data.ATD = Convert.ToDateTime(reader["ATD"]).ToString("yyyy-MM-dd"); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 箱型表参照,对应95005(vMsTruckCtn) static public List GetCtnRefList() { return GetCtnRefList(string.Empty); } static public List GetCtnRefList(string strCondition) { var strSql = new StringBuilder(); strSql.Append("SELECT "); strSql.Append("CtnCode,CtnName,CodeAndName"); strSql.Append(" from vMsTruckCtn "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" where " + strCondition); } return SetCtnRefData(strSql); } private static List SetCtnRefData(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { CtnRefModel data = new CtnRefModel(); #region Set DB data to Object data.CtnCode = Convert.ToString(reader["CtnCode"]); data.CtnName = Convert.ToString(reader["CtnName"]); data.CodeAndName = Convert.ToString(reader["CodeAndName"]); #endregion headList.Add(data); } reader.Close(); } CtnRefModel adata = new CtnRefModel(); #region Set DB data to Object adata.CtnCode =""; adata.CtnName =""; adata.CodeAndName =""; #endregion headList.Add(adata); return headList; } static public List GetCtnDispList ( ) { return GetCtnDispList(string.Empty); } static public List GetCtnDispList ( string strCondition ) { var strSql = new StringBuilder(); strSql.Append("select CtnCode,CtnName,CodeAndName,sort from [vMsImportCtnDisp]"); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" where " + strCondition); } strSql.Append(" order by sort " ); return SetCtnRefData(strSql); } #endregion #region 国家参照,(Import_country) static public List GetCountryRefList() { return GetCountryRefList(string.Empty); } static public List GetCountryRefList(string strCondition) { var strSql = new StringBuilder(); // SELECT id,country_code,country,(country_code+'_'+country) as country_codeandname //from import_country strSql.Append("SELECT countryid,country,(countryid+'_'+country) as country_idandname"); strSql.Append(" from code_country "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" where " + strCondition); } return SetcountryRefData(strSql); } private static List SetcountryRefData(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { CountryModel data = new CountryModel(); #region Set DB data to Object // data.id = Convert.ToString(reader["id"]); data.countryid = Convert.ToString(reader["countryid"]); data.country = Convert.ToString(reader["country"]); data.country_idandname = Convert.ToString(reader["country_idandname"]); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 商品名称参照,(Import_Cargoinfo) static public List GetCargoRefList() { return GetCargoRefList(string.Empty); } static public List GetCargoRefList(string strCondition) { var strSql = new StringBuilder(); strSql.Append(" select *,code+'_'+name codeandname from import_cargoinfo "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" where " + strCondition); } strSql.Append(" order by code "); return SetCargoRefData(strSql); } private static List SetCargoRefData(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { CargoModel data = new CargoModel(); #region Set DB data to Object data.id = Convert.ToString(reader["id"]); data.code = Convert.ToString(reader["code"]); data.name = Convert.ToString(reader["name"]); data.codeandname = Convert.ToString(reader["codeandname"]); // data.tariff = Convert.ToString(reader["tariff"]); // data.tax = Convert.ToString(reader["tax"]); // data.tax_zz = Convert.ToString(reader["tax_zz"]); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 商品名称参照 含tax,(Import_Cargoinfo) static public List GetCargoTax() { return GetCargoTax(string.Empty); } static public List GetCargoTax(string strCondition) { //tariff 关税等级: 0最惠国 1普通 2零关税 var strSql = new StringBuilder(); strSql.Append(" select ci.id,name,code+'_'+name codeandname,code, "); strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 "); strSql.Append("and EnumTypeID=9000 and EnumValueID=cc.tariff) as tariff, "); strSql.Append("case cc.tariff when 0 then ci.tax_zhg/100 when 1 then ci.tax_pt/100 when 2 then 0 end tax, "); strSql.Append("ci.tax_zz/100 as tax_zz,ci.tax_cl as tax_cl from code_country cc,import_cargoinfo ci "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" where " + strCondition); } return SetCargoTax(strSql); } private static List SetCargoTax(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { CargoModel data = new CargoModel(); #region Set DB data to Object data.id = Convert.ToString(reader["id"]); data.code = Convert.ToString(reader["code"]); data.name = Convert.ToString(reader["name"]); data.codeandname = Convert.ToString(reader["codeandname"]); data.tariff = Convert.ToString(reader["tariff"]); data.tax = Convert.ToString(reader["tax"]); data.tax_zz = Convert.ToString(reader["tax_zz"]); data.tax_cl = Convert.ToString(reader["tax_cl"]); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 商品ciq名称参照,(Import_Cargociq) static public List GetCargociqRefList() { return GetCargociqRefList(string.Empty); } static public List GetCargociqRefList(string strCondition) { var strSql = new StringBuilder(); strSql.Append("SELECT *,ciqcode+'_'+ciqname as codeandname"); strSql.Append(" from import_cargociq "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" where " + strCondition); } strSql.Append(" order by ciqcode "); return SetCargociqRefData(strSql); } private static List SetCargociqRefData(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { CargociqModel data = new CargociqModel(); #region Set DB data to Object data.id = Convert.ToString(reader["id"]); data.ciqcode = Convert.ToString(reader["ciqcode"]); data.ciqname = Convert.ToString(reader["ciqname"]); data.codeandname = Convert.ToString(reader["codeandname"]); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 公司名称,(company) static public List GetcompanyList ( ) { return GetcompanyList(string.Empty); } static public List GetcompanyList ( string strCondition ) { var strSql = new StringBuilder(); strSql.Append("SELECT *"); strSql.Append(" from company where isdeleted=0 "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" and " + strCondition); } return SetcompanyData(strSql); } private static List SetcompanyData ( StringBuilder strSql ) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { companyModel data = new companyModel(); #region Set DB data to Object data.gid = Convert.ToString(reader["gid"]); data.code = Convert.ToString(reader["codename"]); data.name = Convert.ToString(reader["name"]); data.isdisable = Convert.ToString(reader["isdisable"]); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 币别,(currid) static public List GetcurrRefList() { return GetcurrRefList(string.Empty); } static public List GetcurrRefList(string strCondition) { var strSql = new StringBuilder(); strSql.Append("select gid,codename,defaultrate from code_currency "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" where " + strCondition); } return SetcurrData(strSql); } private static List SetcurrData(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { currModel data = new currModel(); #region Set DB data to Object data.gid = Convert.ToString(reader["gid"]); data.codename = Convert.ToString(reader["codename"]); data.defaultrate = Convert.ToString(reader["defaultrate"]); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 进口贸易提醒,(import_remind) static public List GetRemindList() { return GetRemindList(string.Empty); } static public List GetRemindList(string strCondition) { var strSql = new StringBuilder(); strSql.Append("select id,Remindname,Remindsql from Import_remind "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" where " + strCondition); } return SetRemindData(strSql); } private static List SetRemindData(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { RemindModel data = new RemindModel(); #region Set DB data to Object data.RemindName = Convert.ToString(reader["Remindname"]); data.RemindSql = Convert.ToString(reader["Remindsql"]); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 贸易商/购货方combox,(seller buyer info_client) static public List GetTrader() { return GetTrader(string.Empty); } static public List GetTrader(string strCondition) { var strSql = new StringBuilder(); strSql.Append(" select gid,shortname as name,codename code,codename+'_'+shortname codename,description,EnFullName "); strSql.Append(" ,codename+'_'+EnFullName codeEnname,ISSTOP,RCVMode from info_client where 1=1 "); if (!string.IsNullOrEmpty(strCondition)) { var InfoClintBlstatus = MsSysParamSetDAL.GetData("PARAMNAME='InfoClintBlstatus'"); if (InfoClintBlstatus.PARAMVALUE != "") { if (InfoClintBlstatus.PARAMVALUE == "1") { strSql.Append(" and BLSTATUS=0 "); } } strSql.Append(" and " + strCondition); } strSql.Append(" order by codename "); return SetTrader(strSql); } private static List SetTrader(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { TraderModel data = new TraderModel(); #region Set DB data to Object data.gid = Convert.ToString(reader["gid"]); data.name = Convert.ToString(reader["name"]); data.code = Convert.ToString(reader["code"]); data.codename = Convert.ToString(reader["codename"]); data.description = Convert.ToString(reader["description"]); data.EnFullName = Convert.ToString(reader["EnFullName"]); data.codeEnName = Convert.ToString(reader["codeEnName"]); data.ISSTOP = Convert.ToString(reader["ISSTOP"]); data.RCVMode = Convert.ToString(reader["RCVMode"]); #endregion headList.Add(data); } reader.Close(); } // TraderModel data1 = new TraderModel(); #region Set DB data to Object data1.gid = ""; data1.name = ""; data1.codename = ""; data1.description = ""; #endregion headList.Add(data1); return headList; } static public List GetPCTrader ( string strCondition ) { var strSql = new StringBuilder(); strSql.Append("select gid,shortname as name,codename+'_'+shortname codename,description,EnFullName,codename+'_'+EnFullName codeEnname,ADDR from info_client where 1=1 "); if (!string.IsNullOrEmpty(strCondition)) { var InfoClintBlstatus = MsSysParamSetDAL.GetData("PARAMNAME='InfoClintBlstatus'"); if (InfoClintBlstatus.PARAMVALUE != "") { if (InfoClintBlstatus.PARAMVALUE == "1") { strSql.Append(" and BLSTATUS=0 "); } } strSql.Append(" and " + strCondition); } strSql.Append(" order by codename "); return SetPCTrader(strSql); } private static List SetPCTrader ( StringBuilder strSql ) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { TraderModel data = new TraderModel(); #region Set DB data to Object data.gid = Convert.ToString(reader["gid"]); data.name = Convert.ToString(reader["name"]); data.codename = Convert.ToString(reader["codename"]); data.description = Convert.ToString(reader["description"]); data.EnFullName = Convert.ToString(reader["EnFullName"]); data.codeEnName = Convert.ToString(reader["codeEnName"]); data.ADDR = Convert.ToString(reader["ADDR"]); #endregion headList.Add(data); } reader.Close(); } // TraderModel data1 = new TraderModel(); #region Set DB data to Object data1.gid = ""; data1.name = ""; data1.codename = ""; data1.description = ""; #endregion headList.Add(data1); return headList; } #endregion #region 获取银行名字列表 static public List GetBank() { return GetBank(string.Empty); } static public List GetBank(string strCondition) { var strSql = new StringBuilder(); strSql.Append("select gid, bankname,FINANCESOFTCODE,FINANCESOFTCODE+'_'+bankname codename from sys_bank "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" where " + strCondition); } return SetBank(strSql); } private static List SetBank(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { BankModel data = new BankModel(); #region Set DB data to Object data.gid = Convert.ToString(reader["gid"]); data.bankname = Convert.ToString(reader["bankname"]); data.codename = Convert.ToString(reader["codename"]); data.FINANCESOFTCODE = Convert.ToString(reader["FINANCESOFTCODE"]); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 获取 其他科目代码 ,用于给科目列表combox提供store static public List GetAccitems(string strUserID) { return GetAccitems(string.Empty, strUserID); } static public List GetAccitems(string strCondition, string strUserID) { string strCwACCDATE = GetCwACCDATE(strUserID); var strSql = new StringBuilder(); strSql.Append("select GID,ACCID,ACCNAME,ACCID+'-'+ACCNAME AS ACCIDNAME,DC,ISFCY,REMARKS,DETAILED,ISFCY,ISDEPTACC,ISEMPLACC,ISCORPACC,ISITEMACC from cw_accitems where ([year]=SUBSTRING('" + strCwACCDATE + "',1,4) or [year]='' or [year] is null)"); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" and " + strCondition); } strSql.Append(" order by ACCID "); return SetAccitems(strSql); } private static List SetAccitems(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { AccitemsModel data = new AccitemsModel(); #region Set DB data to Object data.GID = Convert.ToString(reader["GID"]); data.ACCID = Convert.ToString(reader["ACCID"]); data.ACCNAME = Convert.ToString(reader["ACCNAME"]); data.ACCIDNAME = Convert.ToString(reader["ACCIDNAME"]); data.DC = Convert.ToString(reader["DC"]); data.REMARKS = Convert.ToString(reader["REMARKS"]); data.DETAILED = Convert.ToString(reader["DETAILED"]); data.ISFCY = Convert.ToBoolean(reader["ISFCY"]); data.ISDEPTACC = Convert.ToBoolean(reader["ISDEPTACC"]); data.ISEMPLACC = Convert.ToBoolean(reader["ISEMPLACC"]); data.ISCORPACC = Convert.ToBoolean(reader["ISCORPACC"]); data.ISITEMACC = Convert.ToBoolean(reader["ISITEMACC"]); #endregion headList.Add(data); } reader.Close(); } return headList; } static public List GetMngAccitems(string strCondition) { var strSql = new StringBuilder(); strSql.Append("select GID,ACCID,ACCNAME,ACCID+'-'+ACCNAME AS ACCIDNAME,DC,ISFCY,REMARKS,DETAILED,ISFCY,ISDEPTACC,ISEMPLACC,ISCORPACC,ISITEMACC from cw_accitems where 1=1 "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" and " + strCondition); } return SetAccitems(strSql); } #endregion #region 查询用户权限 static public List GetAR(string modName, string USERID) { var strSql = new StringBuilder(); strSql.Append(" select GID,visiblerange,operaterange from user_authority_range where authorityid=( "); strSql.Append(" select gid from user_authority_info where name='" + modName + "' and isdelete=0 "); strSql.Append(" and userid='" + USERID + "') "); return SetAR(strSql); } private static List SetAR(StringBuilder strSql) { var bodyList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { AuthorityRangemb data = new AuthorityRangemb(); #region Set DB data to Object data.GID = Convert.ToString(reader["GID"]); data.VISIBLERANGE = Convert.ToString(reader["VISIBLERANGE"]); data.OPERATERANGE = Convert.ToString(reader["OPERATERANGE"]); #endregion bodyList.Add(data); } reader.Close(); } return bodyList; } /// /// 获得可视范围的查询子句。相关字段存储的应当都是相应ID /// /// 权限名字 user_authority_info.NAME /// /// 用于查询语句中的,公司ID的字段或表达式 SQL层面的 /// 用于查询语句中的,人的ID的字段或表达式 SQL层面的 /// 用于查询语句中的,部门的ID的字段或表达式 SQL层面的 /// public static string GetVisableRange(string modName, string USERID, string COMPANYFIELDNAME, string USERFIELD = "", string DEPTFIELDNAME = "") { var evList = BasicDataRefDAL.GetAR(modName, USERID); AuthorityRangemb head = null; var result = ""; var VISIBLERANGE = "3"; if (evList.Count > 0) head = evList[0]; if (head == null) { head = new AuthorityRangemb(); } else { VISIBLERANGE = head.VISIBLERANGE; } //0 全部 if (VISIBLERANGE == "0") { result = "1=1"; } else if (VISIBLERANGE == "1") {//1 分公司 if (!string.IsNullOrEmpty(COMPANYFIELDNAME)) { result = COMPANYFIELDNAME + " in(select companyid from vw_user where userid='" + USERID + "')"; } else if (!string.IsNullOrEmpty(USERFIELD)) { result = USERFIELD + " in(select USERID from vw_user where companyid =(select companyid from vw_user where userid='" + USERID + "'))"; } } else if (VISIBLERANGE == "2") { if (!string.IsNullOrEmpty(COMPANYFIELDNAME)) { result = DEPTFIELDNAME + " in(select deptid from vw_user where userid='" + USERID + "')"; } else if (!string.IsNullOrEmpty(USERFIELD)) { result = USERFIELD + " in(select USERID from vw_user where deptid =(select deptid from vw_user where userid='" + USERID + "'))"; } } else if (VISIBLERANGE == "3") { if (!string.IsNullOrEmpty(USERFIELD)) { result = USERFIELD + " ='" + USERID + "' "; } } else if (VISIBLERANGE == "4") { if (!string.IsNullOrEmpty(USERFIELD)) { result = "1=2"; } } else if (VISIBLERANGE == "5") {//选择公司 if (!string.IsNullOrEmpty(COMPANYFIELDNAME)) { result = COMPANYFIELDNAME + " in(select COMPANYID from user_authority_range_company where userid='" + USERID + "' and AUTHORITYID=(select GID from user_authority_info where name='"+ modName + "') and VISIBLERANGE=1)"; } else if (!string.IsNullOrEmpty(USERFIELD)) { result = USERFIELD + " in(select USERID from vw_user where companyid in(select COMPANYID from user_authority_range_company where userid='" + USERID + "' and AUTHORITYID=(select GID from user_authority_info where name='" + modName + "') and VISIBLERANGE=1)"; } } else if (VISIBLERANGE == "6") {//选择个人 if (!string.IsNullOrEmpty(USERFIELD)) { result = USERFIELD + " in(select OPID from user_authority_range_op where userid='" + USERID + "' and AUTHORITYID=(select GID from user_authority_info where name='" + modName + "') and VISIBLERANGE=1)"; } } if (head == null || result == "") { result = "1=2"; } return result; } /// /// 可操作范围查询子句 /// /// /// /// /// /// /// public static string GetOperateRange(string modName, string USERID, string COMPANYFIELDNAME, string USERFIELD = "", string DEPTFIELDNAME = "") { var evList = BasicDataRefDAL.GetAR(modName, USERID); AuthorityRangemb head = null; var result = ""; var OPERATERANGE = "3"; if (evList.Count > 0) head = evList[0]; if (head == null) { head = new AuthorityRangemb(); } else { OPERATERANGE = head.OPERATERANGE; } //0 全部 if (OPERATERANGE == "0") { result = "1=1"; } else if (OPERATERANGE == "1") {//1 分公司 if (!string.IsNullOrEmpty(COMPANYFIELDNAME)) { result = COMPANYFIELDNAME + " in(select companyid from vw_user where userid='" + USERID + "')"; } else if (!string.IsNullOrEmpty(USERFIELD)) { result = USERFIELD + " in(select USERID from vw_user where companyid =(select companyid from vw_user where userid='" + USERID + "'))"; } } else if (OPERATERANGE == "2") { if (!string.IsNullOrEmpty(COMPANYFIELDNAME)) { result = DEPTFIELDNAME + " in(select deptid from vw_user where userid='" + USERID + "')"; } else if (!string.IsNullOrEmpty(USERFIELD)) { result = USERFIELD + " in(select USERID from vw_user where deptid =(select deptid from vw_user where userid='" + USERID + "'))"; } } else if (OPERATERANGE == "3") { if (!string.IsNullOrEmpty(USERFIELD)) { result = USERFIELD + " ='" + USERID + "' "; } } else if (OPERATERANGE == "4") { if (!string.IsNullOrEmpty(USERFIELD)) { result = "1=2"; } } else if (OPERATERANGE == "5") {//选择公司 if (!string.IsNullOrEmpty(COMPANYFIELDNAME)) { result = COMPANYFIELDNAME + " in(select COMPANYID from user_authority_range_company where userid='" + USERID + "' and AUTHORITYID=(select GID from user_authority_info where name='" + modName + "') and VISIBLERANGE=1)"; } else if (!string.IsNullOrEmpty(USERFIELD)) { result = USERFIELD + " in(select USERID from vw_user where companyid in(select COMPANYID from user_authority_range_company where userid='" + USERID + "' and AUTHORITYID=(select GID from user_authority_info where name='" + modName + "') and VISIBLERANGE=1)"; } } else if (OPERATERANGE == "6") {//选择个人 if (!string.IsNullOrEmpty(USERFIELD)) { result = USERFIELD + " in(select OPID from user_authority_range_op where userid='" + USERID + "' and AUTHORITYID=(select GID from user_authority_info where name='" + modName + "') and VISIBLERANGE=1)"; } } if (head == null || result == "") { result = "1=2"; } return result; } /// /// 判断USERID是否具有对【head这条业务】的【ModName权限】的使用权 /// /// /// /// public static string CanOperateStr_INVOICE(string ModName,string USERID) { var rangestr = BasicDataRefDAL.GetOperateRange(ModName, USERID, "COMPANYID", "OPERATOR"); return rangestr; } #endregion #region 获取本部门领取且未支取的支票号 static public List GetUnusedCHEQUENUM(string DEPTID,string BXGID) { var strSql = new StringBuilder(); strSql.Append(" select '外代IC卡' chequeno union all "); strSql.Append(" select '外运IC卡' chequeno union all "); strSql.Append(" select '挂账' chequeno union all "); strSql.Append(" select chequeno from( "); strSql.Append(" select cfc.chequeno,bxgid from ch_fee_cheque cfc "); strSql.Append(" left join ch_fee on ch_fee.chequenum=cfc.chequeno "); strSql.Append(" where cfc.billno in (select gid from OA_Jiekuan where deptid='"+DEPTID+"') "); strSql.Append(" and cfc.chequeno is not null and cfc.chequeno<>'')t "); strSql.Append(" where bxgid is null or bxgid='" + BXGID + "' "); return SetUnusedCHEQUENUM(strSql); } private static List SetUnusedCHEQUENUM(StringBuilder strSql) { var bodyList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { CHEQUENUMmb data = new CHEQUENUMmb(); #region Set DB data to Object data.CHEQUENUM = Convert.ToString(reader["CHEQUENO"]); #endregion bodyList.Add(data); } reader.Close(); } return bodyList; } #endregion #region 获取工作流typeno 用于在工作流管理界面选择typeno #endregion #region 通过工作流名字查找工作流编号 /* static public List GetWorkFlowID(string NAME, string OrgCode) { var strSql = new StringBuilder(); strSql.Append(" select GID,[Name] from workflow where "); strSql.Append(" [type]=(select typeno from workflow_type where name= '" + NAME + "') "); strSql.Append(" and companyid=(select gid from company where codename='" + OrgCode + "' ) "); return SetWorkFlowID(strSql); } private static List SetWorkFlowID(StringBuilder strSql) { var bodyList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { WorkFlowmb data = new WorkFlowmb(); #region Set DB data to Object data.GID = Convert.ToString(reader["GID"]); data.NAME = Convert.ToString(reader["NAME"]); #endregion bodyList.Add(data); } reader.Close(); } return bodyList; }*/ #endregion #region 通过workflow_type.name,userid查找workflow_step的内容 static public List GetWorkFlowStep ( string WorkFlowName, string UserID ) { var strSql = new StringBuilder(); strSql.Append(" select * from workflow_step where WORKFLOWID in "); strSql.Append(" (select gid from workflow where [type]=(select [typeno] from workflow_type where [name]='" + WorkFlowName + "')) "); strSql.Append(" and AUDITOR='" + UserID + "' order by STEPNO"); return SetWorkFlowStep(strSql); } private static List SetWorkFlowStep ( StringBuilder strSql ) { var bodyList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { DSWeb.Areas.CommMng.Models.WorkFlowStepmb data = new DSWeb.Areas.CommMng.Models.WorkFlowStepmb(); #region Set DB data to Object data.GID = Convert.ToString(reader["GID"]); data.NAME = Convert.ToString(reader["NAME"]); data.STEPNO = Convert.ToString(reader["STEPNO"]); data.NEEDALLPASS = Convert.ToString(reader["NEEDALLPASS"]); data.ISMUST = Convert.ToString(reader["ISMUST"]); data.ISLAST = Convert.ToString(reader["ISLAST"]); #endregion bodyList.Add(data); } reader.Close(); } return bodyList; } #endregion #region 获取该用户,在该工作流程的该步骤中 可以操作的业务编号列表 /* static public List GetWorkFlowState(string WorkFlowID, int StepNo, string USERID) { var strSql = new StringBuilder(); strSql.Append(" select * from workflow_using "); strSql.Append(" where workflowid='" + WorkFlowID + "' "); strSql.Append(" and stepno=( "); strSql.Append(" select stepno from workflow_step "); strSql.Append(" where workflowid='" + WorkFlowID + "' "); strSql.Append(" and auditor='" + USERID + "' "); strSql.Append(" and stepno=" + StepNo.ToString() + ") "); return SetWorkFlowState(strSql); } private static List SetWorkFlowState(StringBuilder strSql) { var bodyList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { WorkFlow_Usingmb data = new WorkFlow_Usingmb(); #region Set DB data to Object data.BSNO = Convert.ToString(reader["BSNO"]); data.WORKFLOWID = Convert.ToString(reader["WORKFLOWID"]); data.STEPNO = Convert.ToString(reader["STEPNO"]); data.REJECTOR_ID = Convert.ToString(reader["REJECTOR_ID"]); data.REJECT_TIME = Convert.ToString(reader["REJECT_TIME"]); data.FINISHED = Convert.ToString(reader["FINISHED"]); data.ISDELETE = Convert.ToString(reader["ISDELETE"]); data.DELETEUSER = Convert.ToString(reader["DELETEUSER"]); data.DELETETIME = Convert.ToString(reader["DELETETIME"]); #endregion bodyList.Add(data); } reader.Close(); } return bodyList; } */ #endregion #region 键值维护表 crm_key_code static public List GetCrmKeyCodeList(string strCondition) { String strSql = "SELECT ID as GID,KEYTYPE,KEYVALUE from crm_key_code "; if (!string.IsNullOrEmpty(strCondition)) { strSql += " where 1=1 " + strCondition; } return SetCrmKeyCodeData(strSql); } private static List SetCrmKeyCodeData(String strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql)) { while (reader.Read()) { CrmKeyCodeModel data = new CrmKeyCodeModel(); #region Set DB data to Object data.GID = Convert.ToString(reader["GID"]); data.KEYTYPE = Convert.ToString(reader["KEYTYPE"]); data.KEYVALUE = Convert.ToString(reader["KEYVALUE"]); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 品名 static public List GetCodeGoodsList(string condition) { String strSql = "SELECT GID,GOODCODE,(GOODCODE+'-'+GOODNAME) as CodeAndName,GOODNAME,GoodsTypeGID,GoodsTypeName=(select top 1 GoodsTypeName from code_goodsType where gid=code_goods.GoodsTypeGID) from code_goods "; if (!string.IsNullOrEmpty(condition)) { strSql += " where " + condition; } strSql += " order by CodeAndName"; return SetCodeGoodsData(strSql); } static public List GetImportCodeGoodsList(string condition) { String strSql = "SELECT CNNAME GID,CNNAME GOODCODE,CNNAME as CodeAndName,CNNAME GOODNAME,'' GoodsTypeGID,'' GoodsTypeName from Import_Cargoname "; if (!string.IsNullOrEmpty(condition)) { strSql += " where " + condition; } strSql += " order by CNNAME"; return SetCodeGoodsData(strSql); } private static List SetCodeGoodsData(String strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql)) { while (reader.Read()) { CodeGoodsModel data = new CodeGoodsModel(); #region Set DB data to Object data.GID = Convert.ToString(reader["GID"]);//货物代码 data.CodeAndName = Convert.ToString(reader["CodeAndName"]);//商品编码 data.GOODCODE = Convert.ToString(reader["GOODCODE"]);//商品编码 data.GOODNAME = Convert.ToString(reader["GOODNAME"]);//商品名称 data.GoodsTypeGID = Convert.ToString(reader["GoodsTypeGID"]);// data.GoodsTypeName = Convert.ToString(reader["GoodsTypeName"]);// #endregion headList.Add(data); } reader.Close(); } CodeGoodsModel adata = new CodeGoodsModel(); #region Set DB data to Object adata.GID = "";//货物代码 adata.CodeAndName = "";//商品编码 adata.GOODCODE = "";//商品编码 adata.GOODNAME = "";//商品名称 adata.GoodsTypeGID = ""; adata.GoodsTypeName = ""; #endregion headList.Add(adata); return headList; } #endregion #region 品名明细表 static public List GetCodeGoodsDetailList(string condition) { String strSql = "SELECT *,GOODNAME=(select top 1 GOODNAME from code_goods where gid=code_goods_detail.LINKGID) from code_goods_detail "; if (!string.IsNullOrEmpty(condition)) { strSql += " where " + condition; } strSql += " order by GOODSDETAILNAME"; return SetCodeGoodsDetailData(strSql); } private static List SetCodeGoodsDetailData(String strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql)) { while (reader.Read()) { CodeGoodsDetailModel data = new CodeGoodsDetailModel(); #region Set DB data to Object data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]));//惟一编号 data.LINKGID = (reader["LINKGID"] == null ? "" : Convert.ToString(reader["LINKGID"]));//品名GID data.GOODSDETAILNAME = (reader["GOODSDETAILNAME"] == null ? "" : Convert.ToString(reader["GOODSDETAILNAME"]));//品牌名称 data.REMARK = (reader["REMARK"] == null ? "" : Convert.ToString(reader["REMARK"]));//备注 data.GOODSDETAILPKGS = (reader["GOODSDETAILPKGS"] == null ? 0 : Convert.ToDecimal(reader["GOODSDETAILPKGS"]));//规格件数 data.GOODNAME = (reader["GOODNAME"] == null ? "" : Convert.ToString(reader["GOODNAME"]));//品名 #endregion headList.Add(data); } reader.Close(); } CodeGoodsDetailModel adata = new CodeGoodsDetailModel(); #region Set DB data to Object adata.GID = "";//惟一编号 adata.LINKGID = "";//品名GID adata.GOODSDETAILNAME = "";//品牌名称 adata.REMARK = "";//备注 adata.GOODSDETAILPKGS = 0;//规格件数 adata.GOODNAME = "";//品名 #endregion headList.Add(adata); return headList; } #endregion #region 新版键值维护表 tSysEnumValue static public List GetTSysEnumValueList(string strCondition) { String strSql = "select *,CodeAndName=(EnumValueID+' | '+EnumValueName) from tSysEnumValue";//需求编号:SR2017081100003 if (!string.IsNullOrEmpty(strCondition)) { strSql += " where LangId=0 " + strCondition; } return SetTSysEnumValueData(strSql); } private static List SetTSysEnumValueData(String strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql)) { while (reader.Read()) { TSysEnumValueDataModel data = new TSysEnumValueDataModel(); #region Set DB data to Object data.EnumValueID = Convert.ToString(reader["EnumValueID"]);//需求编号:SR2017081100003 data.EnumValueName = Convert.ToString(reader["EnumValueName"]); data.CodeAndName = Convert.ToString(reader["CodeAndName"]);//需求编号:SR2017081100003 #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 国际港口(进口装货港、出口卸货港) static public List GetCodeDisportList(string condition) { String strSql = "SELECT *,(PORT+'-'+EDICODE) as CodeAndName,(select LANE from code_lanes where GID=Code_Disport.LANEGID) LANE from Code_Disport where "; if (condition != "") strSql = strSql + condition+" and "; strSql = strSql + " EDICODE<>'' ORDER BY PORT "; return SetCodeDisportData(strSql); } static public List GetCodeDisportbyEDICODE (string EDICODE ) { String strSql = "SELECT *,(PORT+'-'+EDICODE) as CodeAndName,(select LANE from code_lanes where GID=Code_Disport.LANEGID) LANE from Code_Disport where EDICODE='" + EDICODE + "'"; return SetCodeDisportData(strSql); } private static List SetCodeDisportData(String strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql)) { while (reader.Read()) { CodeDisportModel data = new CodeDisportModel(); #region Set DB data to Object data.PORT = Convert.ToString(reader["PORT"]);//港口英文名称 data.CNAME = Convert.ToString(reader["CNAME"]);//中文名称 data.EDICODE = Convert.ToString(reader["EDICODE"]);//中文名称 data.CodeAndName = Convert.ToString(reader["CodeAndName"]);//中文名称 data.LANE = Convert.ToString(reader["LANE"]);//航线 #endregion headList.Add(data); } reader.Close(); } CodeDisportModel data2 = new CodeDisportModel(); #region Set DB data to Object data2.PORT = "";//港口英文名称 data2.CNAME ="";//中文名称 data2.EDICODE ="";//中文名称 data2.CodeAndName ="";//中文名称 data2.LANE = "";//中文名称 headList.Add(data2); #endregion return headList; } #endregion #region 国内港口(出口装货港、进口卸货港) static public List GetCodeLoadportList(string condition) { String strSql = "SELECT *,(PORT+'-'+CNAME) as CodeAndName from Code_Loadport WHERE EDICODE<>'' "; if (condition != "") strSql = strSql +" and "+condition ; return SetCodeLoadportData(strSql); } static public List GetCodeLoadportList() { String strSql = "SELECT *,(PORT+'-'+CNAME) as CodeAndName from Code_Loadport WHERE EDICODE<>'' "; return SetCodeLoadportData(strSql); } static public List GetLoadportbyEDI(string EDICODE) { String strSql = "SELECT *,(PORT+'-'+CNAME) as CodeAndName from Code_Loadport WHERE EDICODE='" + EDICODE + "' "; return SetCodeLoadportData(strSql); } private static List SetCodeLoadportData(String strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql)) { while (reader.Read()) { CodeLoadportModel data = new CodeLoadportModel(); #region Set DB data to Object data.PORT = Convert.ToString(reader["PORT"]);//港口英文名称 data.CNAME = Convert.ToString(reader["CNAME"]);//中文名称 data.EDICODE = Convert.ToString(reader["EDICODE"]);//中文名称 data.CodeAndName = Convert.ToString(reader["CodeAndName"]);//中文名称 #endregion headList.Add(data); } reader.Close(); } CodeLoadportModel data2 = new CodeLoadportModel(); #region Set DB data to Object data2.PORT = "";//港口英文名称 data2.CNAME = "";//中文名称 data2.EDICODE = "";//中文名称 data2.CodeAndName = "";//中文名称 headList.Add(data2); #endregion return headList; } #endregion #region 品名类型 static public List Getsys_templateList() { String strSql = "select GID,[TEMPLATE],[TEMPLATETYPE],[COMPANYID],[TEMPLDATE_DESC] from sys_template where TEMPLATETYPE='发票备注'"; return Setsys_templateData(strSql); } private static List Setsys_templateData(String strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql)) { while (reader.Read()) { sys_template data = new sys_template(); #region Set DB data to Object data.GID = Convert.ToString(reader["GID"]);//货物代码 data.TEMPLATE = Convert.ToString(reader["TEMPLATE"]); data.TEMPLATETYPE = Convert.ToString(reader["TEMPLATETYPE"]); data.COMPANYID = Convert.ToString(reader["COMPANYID"]); data.TEMPLDATE_DESC = Convert.ToString(reader["TEMPLDATE_DESC"]); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 品名类型 static public List GetCodeGoodsTypeList() { String strSql = "select *,(GoodsTypeCode+'-'+GoodsTypeName) as CodeAndName from Code_GoodsType"; return SetCodeGoodsTypeData(strSql); } private static List SetCodeGoodsTypeData(String strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql)) { while (reader.Read()) { CodeGoodsTypeModel data = new CodeGoodsTypeModel(); #region Set DB data to Object data.GID = Convert.ToString(reader["GID"]);//货物代码 data.CodeAndName = Convert.ToString(reader["CodeAndName"]); data.GoodsTypeCode = Convert.ToString(reader["GoodsTypeCode"]); data.GoodsTypeName = Convert.ToString(reader["GoodsTypeName"]); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 箱型 static public List GetCodeCtnList() { String strSql = "select * from [code_ctn] ORDER BY CTNID "; return SetCodeCtnData(strSql); } private static List SetCodeCtnData(String strSql, bool isempty = true) { var headList = new List(); if (isempty) { CodeCtnModel data2 = new CodeCtnModel(); data2.CTN = ""; data2.DLIKGS = 0M; headList.Add(data2); } Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql)) { while (reader.Read()) { CodeCtnModel data = new CodeCtnModel(); #region Set DB data to Object data.CTN = Convert.ToString(reader["CTN"]); if (reader["DLIKGS"] != DBNull.Value) data.DLIKGS = Convert.ToDecimal(reader["DLIKGS"]); #endregion headList.Add(data); } reader.Close(); } return headList; } static public List GetCodeCtnList(string condition,bool isempty=true) { String strSql = "select * from [code_ctn] "; if (!string.IsNullOrEmpty(condition)) { strSql += " where " + condition; } strSql += " ORDER BY CTNID"; return SetCodeCtnData(strSql, isempty); } #endregion #region 集装箱显示 static public CtnDispModel GetCtnDisp() { String strSql = "SELECT top 1 * from code_ctn_disp"; return SetCtnDispData(strSql); } private static CtnDispModel SetCtnDispData(String strSql) { var headList = new CtnDispModel(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql)) { while (reader.Read()) { CtnDispModel data = new CtnDispModel(); #region Set DB data to Object data.ID = Convert.ToString(reader["ID"]); data.CNT1 = Convert.ToString(reader["CNT1"]); data.CNT2 = Convert.ToString(reader["CNT2"]); data.CNT3 = Convert.ToString(reader["CNT3"]); data.CNT4 = Convert.ToString(reader["CNT4"]); data.CNT5 = Convert.ToString(reader["CNT5"]); data.CNT6 = Convert.ToString(reader["CNT6"]); data.CNT7 = Convert.ToString(reader["CNT7"]); data.CNT8 = Convert.ToString(reader["CNT8"]); data.CNT9 = Convert.ToString(reader["CNT9"]); data.CNT10 = Convert.ToString(reader["CNT10"]); data.CORPID = Convert.ToString(reader["CORPID"]); #endregion headList = data; } reader.Close(); } return headList; } #endregion #region 航线 static public List GetCodeLaneList() { String strSql = "select * from [code_lanes] ORDER BY LANE"; return SetCodeLaneData(strSql); } private static List SetCodeLaneData(String strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql)) { while (reader.Read()) { LaneModel data = new LaneModel(); #region Set DB data to Object data.GID = Convert.ToString(reader["GID"]); data.LANEID = Convert.ToString(reader["LANEID"]); data.LANE = Convert.ToString(reader["LANE"]); data.LANEEN = Convert.ToString(reader["LANEEN"]); data.EDICODE = Convert.ToString(reader["EDICODE"]); data.OP = Convert.ToString(reader["OP"]); data.DOC = Convert.ToString(reader["DOC"]); #endregion headList.Add(data); } reader.Close(); } LaneModel adata = new LaneModel(); #region Set DB data to Object adata.GID =""; adata.LANEID =""; adata.LANE =""; adata.LANEEN =""; adata.EDICODE =""; #endregion headList.Add(adata); return headList; } #endregion #region 付费方式 static public List GetCodeFrtList() { String strSql = "select * from code_frt ORDER BY FRT"; return SetCodeFrtData(strSql); } private static List SetCodeFrtData(String strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql)) { while (reader.Read()) { CodeFrtModel data = new CodeFrtModel(); #region Set DB data to Object data.FEID = Convert.ToString(reader["FEID"]); data.FRT = Convert.ToString(reader["FRT"]); data.FRTCNAME = Convert.ToString(reader["FRTCNAME"]); data.EDICODE = Convert.ToString(reader["EDICODE"]); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 签单方式 static public List GetCodeBLTYPEList() { String strSql = "select * from code_issutype ORDER BY BLTYPE"; return SetCodeBLTYPEData(strSql); } private static List SetCodeBLTYPEData(String strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql)) { while (reader.Read()) { CodeBLTYPEModel data = new CodeBLTYPEModel(); #region Set DB data to Object data.GID = Convert.ToString(reader["GID"]); data.BLTYPE = Convert.ToString(reader["BLTYPE"]); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 运输条款 static public List GetCodeSERVICEList() { String strSql = "select * from code_service ORDER BY SERVICE"; return SetCodeSERVICEData(strSql); } private static List SetCodeSERVICEData(String strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql)) { while (reader.Read()) { CodeSERVICEModel data = new CodeSERVICEModel(); #region Set DB data to Object data.GID = Convert.ToString(reader["GID"]); data.SERVICE = Convert.ToString(reader["SERVICE"]); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 提单模板 static public List GetCodeTemplateList() { String strSql = "select * from code_template "; return SetCodeTemplateData(strSql); } private static List SetCodeTemplateData(String strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql)) { while (reader.Read()) { CodeTemplateModel data = new CodeTemplateModel(); #region Set DB data to Object data.TEMPLATEID = Convert.ToString(reader["TEMPLATEID"]); data.TEMPLATE = Convert.ToString(reader["TEMPLATE"]); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 件数包装 static public List GetCodePackageList() { String strSql = "select * from [code_package] order by PKGS"; return SetCodePackageData(strSql); } private static List SetCodePackageData(String strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql)) { while (reader.Read()) { CodePackageModel data = new CodePackageModel(); #region Set DB data to Object data.PKGS = Convert.ToString(reader["PKGS"]); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 币别 static public List GetCodeCurrencyList(string condition) { String strSql = "select * from [code_currency]"; if (!string.IsNullOrEmpty(condition)) { strSql += " where " + condition; } return SetCodeCurrencyData(strSql); } private static List SetCodeCurrencyData(String strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql)) { while (reader.Read()) { CodeCurrencyModel data = new CodeCurrencyModel(); #region Set DB data to Object data.CODENAME = Convert.ToString(reader["CODENAME"]); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 委托单位_联系人 static public List GetInfoClientContactList(string condition) { String strSql = "select * from [info_client_contact]"; if (!string.IsNullOrEmpty(condition)) { strSql += " where " + condition; } return SetInfoClientContactData(strSql); } private static List SetInfoClientContactData(String strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql)) { while (reader.Read()) { InfoClientContactModel data = new InfoClientContactModel(); #region Set DB data to Object data.GID = Convert.ToString(reader["GID"]); data.SHOWNAME = Convert.ToString(reader["SHOWNAME"]); data.EMAIL = Convert.ToString(reader["EMAIL"]); data.TEL = Convert.ToString(reader["TEL"]); data.FAX = Convert.ToString(reader["FAX"]); #endregion headList.Add(data); } reader.Close(); } var _blank = new InfoClientContactModel(); headList.Add(_blank); return headList; } #endregion #region 项目 static public List GetCwItemList(string condition, string strUserID) { string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(strUserID); String strSql = "SELECT *,(FINANCESOFTCODE+'-'+ITEMNAME) as CodeAndName from cw_item where [STARTGID]='" + strCwSTARTGID + "' and (ISDELETE=0 or ISDELETE is null) order by ITEMCODE,ITEMNAME"; return SetCwItemData(strSql); } private static List SetCwItemData(String strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql)) { while (reader.Read()) { CwItemModel data = new CwItemModel(); #region Set DB data to Object data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]));//唯一编码 data.ITEMCODE = (reader["ITEMCODE"] == null ? "" : Convert.ToString(reader["ITEMCODE"]));//年 data.ITEMNAME = (reader["ITEMNAME"] == null ? "" : Convert.ToString(reader["ITEMNAME"]));//月 data.FINANCESOFTCODE = (reader["FINANCESOFTCODE"] == null ? "" : Convert.ToString(reader["FINANCESOFTCODE"]));//月 data.CORPID = (reader["CORPID"] == null ? "" : Convert.ToString(reader["CORPID"]));//分公司代码 data.ISDELETE = (reader["ISDELETE"] == null ? false : Convert.ToBoolean(reader["ISDELETE"]));//是否删除 data.DELETEUSER = (reader["DELETEUSER"] == null ? "" : Convert.ToString(reader["DELETEUSER"]));//删除人 string kjdE = reader["DELETETIME"].ToString();//删除时间 if (reader["DELETETIME"] != null && reader["DELETETIME"].ToString().Trim().IndexOf("0001") < 0 && reader["DELETETIME"].ToString().Trim().IndexOf("1900") < 0 && reader["DELETETIME"].ToString().Trim() != "") { data.DELETETIME = Convert.ToDateTime(reader["DELETETIME"]);//删除时间 } data.CREATEUSER = (reader["CREATEUSER"] == null ? "" : Convert.ToString(reader["CREATEUSER"]));//创建人gid if (data.CREATETIME != null) data.CREATETIME = Convert.ToDateTime(reader["CREATETIME"]);//创建时间 data.MODIFIEDUSER = (reader["MODIFIEDUSER"] == null ? "" : Convert.ToString(reader["MODIFIEDUSER"]));//更改操作人gid if (data.MODIFIEDTIME != null) data.MODIFIEDTIME = Convert.ToDateTime(reader["MODIFIEDTIME"]);//更改操作时间 data.CodeAndName = (reader["CodeAndName"] == null ? "" : Convert.ToString(reader["CodeAndName"])); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 获得总账管理的当前账套GID static public String GetCwSTARTGID(string strUSERID) { T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); string strSTARTGID = T_ALL_DA.GetStrSQL("GID", "select top 1 GID from cw_design_startusing WITH(NOLOCK) where (ISDELETE=0 or ISDELETE is null) and ISENABLE=1 and GID=(select top 1 STARTGID from [cw_design_startusing_user] WITH(NOLOCK) where USERGID='" + strUSERID + "')"); return strSTARTGID; } #endregion #region 获得总账管理的当前账套名称 static public String GetCwSTARTNAME(string strUSERID) { T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); string strSTARTNAME = T_ALL_DA.GetStrSQL("STARTNAME", "select top 1 STARTNAME from cw_design_startusing WITH(NOLOCK) where (ISDELETE=0 or ISDELETE is null) and ISENABLE=1 and GID=(select top 1 STARTGID from [cw_design_startusing_user] WITH(NOLOCK) where USERGID='" + strUSERID + "')"); return strSTARTNAME; } #endregion #region 获得总账管理的当前账套启用年月 static public String GetCwSTARTMONTH(string strUSERID) { T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); string strSTARTMONTH = T_ALL_DA.GetStrSQL("STARTMONTH", "select top 1 STARTMONTH from cw_design_startusing WITH(NOLOCK) where (ISDELETE=0 or ISDELETE is null) and ISENABLE=1 and GID=(select top 1 STARTGID from [cw_design_startusing_user] WITH(NOLOCK) where USERGID='" + strUSERID + "') order by STARTMONTH desc"); return strSTARTMONTH; } #endregion #region 获得总账管理的当前会计期间 static public String GetCwACCDATE(string strUSERID) { string strCwSTARTGID = GetCwSTARTGID(strUSERID); string strSTARTMONTH = GetCwSTARTMONTH(strUSERID); T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); string strACCDATE = T_ALL_DA.GetStrSQL("ACCDATE", "select isnull((SELECT top 1 SUBSTRING(convert(varchar,dateadd(month,1,(ACCDATE+'-01')),23),1,7) as ACCDATE from cw_carry_over WITH(NOLOCK) where STARTGID='" + strCwSTARTGID + "' ORDER by ACCDATE DESC),'" + strSTARTMONTH + "') as ACCDATE"); return strACCDATE; } static public String GetCwACCDATE(string strUSERID,string strCwSTARTGID) { string strSTARTMONTH = GetCwSTARTMONTH(strUSERID); T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); string strACCDATE = T_ALL_DA.GetStrSQL("ACCDATE", "select isnull((SELECT top 1 SUBSTRING(convert(varchar,dateadd(month,1,(ACCDATE+'-01')),23),1,7) as ACCDATE from cw_carry_over WITH(NOLOCK) where STARTGID='" + strCwSTARTGID + "' ORDER by ACCDATE DESC),'" + strSTARTMONTH + "') as ACCDATE"); return strACCDATE; } #endregion #region 获得出纳管理的当前账套GID static public String GetCtSTARTGID(string strUSERID) { string strCwSTARTGID = GetCwSTARTGID(strUSERID); T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); string strSTARTGID = T_ALL_DA.GetStrSQL("GID", "select GID from ct_design_startusing WITH(NOLOCK) where ISENABLE=1 and (ISDELETE=0 or ISDELETE is null) and STARTGID='" + strCwSTARTGID + "'"); return strSTARTGID; } #endregion #region 获得出纳管理的当前会计期间 static public String GetCtACCDATE(string strUSERID) { string sCtSTARTGID = GetCtSTARTGID(strUSERID); T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); string strACCDATE = T_ALL_DA.GetStrSQL("ACCDATE", "select isnull((SELECT top 1 SUBSTRING(convert(varchar,dateadd(month,1,(ACCDATE+'-01')),23),1,7) as ACCDATE from ct_carry_over WITH(NOLOCK) where STARTGID='" + sCtSTARTGID + "' and ISCARRY=1 ORDER by STARTGID,ACCDATE DESC),ISNULL((select top 1 STARTMONTH from ct_design_startusing WITH(NOLOCK) where STARTGID='" + sCtSTARTGID + "' and ISENABLE=1 and (ISDELETE=0 or ISDELETE is null) order by STARTMONTH desc),'')) as ACCDATE"); return strACCDATE; } #endregion #region 科目币别表查询 static public List GetCwAccitemsCurrencyList(string strCondition, string strUserID) { string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(strUserID); var strSql = new StringBuilder(); strSql.Append("SELECT CURRENCY from cw_accitems_currency where LINKGID in (SELECT GID from cw_accitems_gl where [STARTGID]='" + strCwSTARTGID + "')"); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" and " + strCondition); } strSql.Append(" group by CURRENCY"); strSql.Append(" order by CURRENCY"); return SetMsCwAccitemsCurrencyData(strSql); } private static List SetMsCwAccitemsCurrencyData(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { int k = 0; while (reader.Read()) { k++; CwAccitemsCurrencyModel data = new CwAccitemsCurrencyModel(); #region Set DB data to Object data.CURRENCY = (reader["CURRENCY"] == null ? "" : Convert.ToString(reader["CURRENCY"]).Trim());//币别 #endregion headList.Add(data); } // if (k == 0) { CwAccitemsCurrencyModel data = new CwAccitemsCurrencyModel(); #region Set DB data to Object data.LINKGID = "";//科目GID data.CURRENCY = "RMB";//币别 #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 业务类型 static public List GetOPLBList(string condition) { String strSql = "SELECT OPLB,OPLBNAME from [v_op_bs]"; if (!string.IsNullOrEmpty(condition)) { strSql += " where " + condition; } strSql += " GROUP by OPLB,OPLBNAME ORDER BY OPLBNAME"; return SetOPLBData(strSql); } private static List SetOPLBData(String strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql)) { while (reader.Read()) { OPLBModel data = new OPLBModel(); #region Set DB data to Object data.OPLB = Convert.ToString(reader["OPLB"]); data.OPLBNAME = Convert.ToString(reader["OPLBNAME"]); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 获取 总账科目信息 static public List GetCwAccitemsGl(string strCondition, string strUserID) { string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(strUserID); string strCwACCDATE = GetCwACCDATE(strUserID); var strSql = new StringBuilder(); strSql.Append("select *,ACCID+'-'+ACCNAME AS ACCIDNAME from cw_accitems_gl where [year]=SUBSTRING('" + strCwACCDATE + "',1,4) and [STARTGID]='" + strCwSTARTGID + "'"); // strSql.Append("select *,ACCID+'-'+ACCNAME+'('+[YEAR]+')' AS ACCIDNAME from cw_accitems_gl where [STARTGID]='" + strCwSTARTGID + "'"); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" and " + strCondition); } // strSql.Append(" ORDER BY [YEAR] DESC "); return SetCwAccitemsGl(strSql); } private static List SetCwAccitemsGl(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { CwAccitemsGlModel data = new CwAccitemsGlModel(); #region Set DB data to Object data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]).Trim());//唯一编码 data.ACCID = (reader["ACCID"] == null ? "" : Convert.ToString(reader["ACCID"]).Trim());//科目代码 data.ACCNAME = (reader["ACCNAME"] == null ? "" : Convert.ToString(reader["ACCNAME"]).Trim());//科目名称 data.ACCIDNAME = Convert.ToString(reader["ACCIDNAME"]); data.DETAILED = (reader["DETAILED"] == null ? false : Convert.ToBoolean(reader["DETAILED"]));//是否末级科目(标志) data.DC = (reader["DC"] == null ? "" : Convert.ToString(reader["DC"]).Trim());//借贷方向 data.ISFCY = (reader["ISFCY"] == null ? false : Convert.ToBoolean(reader["ISFCY"]));//是否核算外币 data.ISDEPTACC = (reader["ISDEPTACC"] == null ? false : Convert.ToBoolean(reader["ISDEPTACC"]));//是否核算部门 data.ISEMPLACC = (reader["ISEMPLACC"] == null ? false : Convert.ToBoolean(reader["ISEMPLACC"]));//是否核算人员 data.ISCORPACC = (reader["ISCORPACC"] == null ? false : Convert.ToBoolean(reader["ISCORPACC"]));//是否算客户门 data.ISITEMACC = (reader["ISITEMACC"] == null ? false : Convert.ToBoolean(reader["ISITEMACC"]));//是否核算项目 data.REMARKS = (reader["REMARKS"] == null ? "" : Convert.ToString(reader["REMARKS"]).Trim());//备注 data.YEAR = (reader["YEAR"] == null ? "" : Convert.ToString(reader["YEAR"]).Trim());//年 data.MONTH = (reader["MONTH"] == null ? "" : Convert.ToString(reader["MONTH"]).Trim());//月 data.PACCGID = (reader["PACCGID"] == null ? "" : Convert.ToString(reader["PACCGID"]).Trim());//父级科目代码 data.ACCATTRIBUTE = (reader["ACCATTRIBUTE"] == null ? "" : Convert.ToString(reader["ACCATTRIBUTE"]).Trim());//科目属性(资产、负债、共同、权益、成本、损益) data.ISENABLE = (reader["ISENABLE"] == null ? false : Convert.ToBoolean(reader["ISENABLE"]));//是否启用 data.ACCTYPE = (reader["ACCTYPE"] == null ? "" : Convert.ToString(reader["ACCTYPE"]).Trim()); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 获取 总账科目信息(包含上级科目) static public List GetCwAccitemsGlAll(string strCondition, string strUserID,string CwSTARTGID="",string CwACCDATE="") { string strCwSTARTGID = CwSTARTGID; if (strCwSTARTGID == "") { strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(strUserID); } string strCwACCDATE = CwACCDATE; if (strCwACCDATE == "") { strCwACCDATE = GetCwACCDATE(strUserID, strCwSTARTGID); } var pacclist = GetCwAccitemsGlPAll(strCwSTARTGID, strCwACCDATE); var strSql = new StringBuilder(); strSql.Append("select *,ACCID+ACCNAME AS ACCIDNAME from cw_accitems_gl where [year]=SUBSTRING('" + strCwACCDATE + "',1,4) and [STARTGID]='" + strCwSTARTGID + "'"); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" and " + strCondition); } return SetCwAccitemsGlAll(strSql, pacclist); } static public CwAccitemsGlModel GetCwAccitems(string accid, List accitemsGlAll) { var accitems = accitemsGlAll.Find(t => t.ACCID == accid); if (accitems == null) accitems = new CwAccitemsGlModel(); return accitems; } private static List SetCwAccitemsGlAll(StringBuilder strSql, List pacclist) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { CwAccitemsGlModel data = new CwAccitemsGlModel(); #region Set DB data to Object data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]).Trim());//唯一编码 data.DETAILED = (reader["DETAILED"] == null ? false : Convert.ToBoolean(reader["DETAILED"]));//是否末级科目(标志) data.DC = (reader["DC"] == null ? "" : Convert.ToString(reader["DC"]).Trim());//借贷方向 data.ISFCY = (reader["ISFCY"] == null ? false : Convert.ToBoolean(reader["ISFCY"]));//是否核算外币 data.ISDEPTACC = (reader["ISDEPTACC"] == null ? false : Convert.ToBoolean(reader["ISDEPTACC"]));//是否核算部门 data.ISEMPLACC = (reader["ISEMPLACC"] == null ? false : Convert.ToBoolean(reader["ISEMPLACC"]));//是否核算人员 data.ISCORPACC = (reader["ISCORPACC"] == null ? false : Convert.ToBoolean(reader["ISCORPACC"]));//是否算客户门 data.ISITEMACC = (reader["ISITEMACC"] == null ? false : Convert.ToBoolean(reader["ISITEMACC"]));//是否核算项目 data.REMARKS = (reader["REMARKS"] == null ? "" : Convert.ToString(reader["REMARKS"]).Trim());//备注 data.YEAR = (reader["YEAR"] == null ? "" : Convert.ToString(reader["YEAR"]).Trim());//年 data.MONTH = (reader["MONTH"] == null ? "" : Convert.ToString(reader["MONTH"]).Trim());//月 data.ACCATTRIBUTE = (reader["ACCATTRIBUTE"] == null ? "" : Convert.ToString(reader["ACCATTRIBUTE"]).Trim());//科目属性(资产、负债、共同、权益、成本、损益) data.ISENABLE = (reader["ISENABLE"] == null ? false : Convert.ToBoolean(reader["ISENABLE"]));//是否启用 data.ACCTYPE = (reader["ACCTYPE"] == null ? "" : Convert.ToString(reader["ACCTYPE"]).Trim()); //data.ACCIDNAME = (reader["ACCIDNAME"] == null ? "" : Convert.ToString(reader["ACCIDNAME"]).Trim());//科目名称 // string sPACCGID = (reader["PACCGID"] == null ? "" : Convert.ToString(reader["PACCGID"]).Trim());//父级科目代码 string sACCID = (reader["ACCID"] == null ? "" : Convert.ToString(reader["ACCID"]).Trim());//科目代码 string sACCNAME = (reader["ACCNAME"] == null ? "" : Convert.ToString(reader["ACCNAME"]).Trim());//科目名称 data.ACCLNAME = sACCNAME; data.PACCGID = sPACCGID;//父级科目代码 data.ACCID = sACCID;//科目代码 data.ACCNAME = setCAGA(sPACCGID, sACCNAME, pacclist);//科目名称 data.ACCIDNAME = sACCID + "-" + data.ACCNAME;//科目名称 #endregion headList.Add(data); } reader.Close(); } return headList; } static public List GetCwAccitemsGlPAll(string strCwSTARTGID, string strCwACCDATE) { var strSql = new StringBuilder(); strSql.Append("select *,ACCID+ACCNAME AS ACCIDNAME from cw_accitems_gl where [year]=SUBSTRING('" + strCwACCDATE + "',1,4) and [STARTGID]='" + strCwSTARTGID + "' AND ISENABLE=1 AND DETAILED<>1"); return SetCwAccitemsGlPAll(strSql); } private static List SetCwAccitemsGlPAll(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { CwAccitemsGlModel data = new CwAccitemsGlModel(); #region Set DB data to Object data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]).Trim());//唯一编码 data.DETAILED = (reader["DETAILED"] == null ? false : Convert.ToBoolean(reader["DETAILED"]));//是否末级科目(标志) data.DC = (reader["DC"] == null ? "" : Convert.ToString(reader["DC"]).Trim());//借贷方向 data.ISFCY = (reader["ISFCY"] == null ? false : Convert.ToBoolean(reader["ISFCY"]));//是否核算外币 data.ISDEPTACC = (reader["ISDEPTACC"] == null ? false : Convert.ToBoolean(reader["ISDEPTACC"]));//是否核算部门 data.ISEMPLACC = (reader["ISEMPLACC"] == null ? false : Convert.ToBoolean(reader["ISEMPLACC"]));//是否核算人员 data.ISCORPACC = (reader["ISCORPACC"] == null ? false : Convert.ToBoolean(reader["ISCORPACC"]));//是否算客户门 data.ISITEMACC = (reader["ISITEMACC"] == null ? false : Convert.ToBoolean(reader["ISITEMACC"]));//是否核算项目 data.REMARKS = (reader["REMARKS"] == null ? "" : Convert.ToString(reader["REMARKS"]).Trim());//备注 data.YEAR = (reader["YEAR"] == null ? "" : Convert.ToString(reader["YEAR"]).Trim());//年 data.MONTH = (reader["MONTH"] == null ? "" : Convert.ToString(reader["MONTH"]).Trim());//月 data.ACCATTRIBUTE = (reader["ACCATTRIBUTE"] == null ? "" : Convert.ToString(reader["ACCATTRIBUTE"]).Trim());//科目属性(资产、负债、共同、权益、成本、损益) data.ISENABLE = (reader["ISENABLE"] == null ? false : Convert.ToBoolean(reader["ISENABLE"]));//是否启用 data.ACCTYPE = (reader["ACCTYPE"] == null ? "" : Convert.ToString(reader["ACCTYPE"]).Trim()); //data.ACCIDNAME = (reader["ACCIDNAME"] == null ? "" : Convert.ToString(reader["ACCIDNAME"]).Trim());//科目名称 // string sPACCGID = (reader["PACCGID"] == null ? "" : Convert.ToString(reader["PACCGID"]).Trim());//父级科目代码 string sACCID = (reader["ACCID"] == null ? "" : Convert.ToString(reader["ACCID"]).Trim());//科目代码 string sACCNAME = (reader["ACCNAME"] == null ? "" : Convert.ToString(reader["ACCNAME"]).Trim());//科目名称 data.PACCGID = sPACCGID;//父级科目代码 data.ACCID = sACCID;//科目代码 data.ACCNAME = sACCNAME;//科目名称 #endregion headList.Add(data); } reader.Close(); } return headList; } static public String setCAGA(string sPACCGID, string sACCNAME) { T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); string sSQL = "select *,(ACCNAME+'_" + sACCNAME + "') AS ACCIDNAME from cw_accitems_gl where gid='" + sPACCGID + "'"; DataSet ds = T_ALL_DA.GetAllSQL(sSQL); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { sPACCGID = ds.Tables[0].Rows[0]["PACCGID"].ToString(); sACCNAME = ds.Tables[0].Rows[0]["ACCIDNAME"].ToString(); if (sPACCGID.Length > 20) { sACCNAME=setCAGA(sPACCGID, sACCNAME); } } } return sACCNAME; } static public String setCAGA(string sPACCGID, string sACCNAME, List pacclist) { pacclist.ForEach(i => { if (i.GID==sPACCGID) { sPACCGID = i.PACCGID; sACCNAME = i.ACCNAME+"_"+ sACCNAME; if (sPACCGID.Length > 26) { sACCNAME=setCAGA(sPACCGID, sACCNAME, pacclist); } } }); return sACCNAME; } #endregion #region 获取 接口科目信息 static public List GetCwAccitems(string strCondition) { var strSql = new StringBuilder(); //strSql.Append("SELECT [GID],[ACCID],[ACCNAME],[DETAILED],[DC],[ISFCY],[ISDEPTACC],[ISEMPLACC],[ISCORPACC],[ISITEMACC],[REMARKS],ACCID+'_'+ACCNAME AS ACCIDNAME FROM ((SELECT [GID],[ACCID],[ACCNAME],[DETAILED],[DC],[ISFCY],[ISDEPTACC],[ISEMPLACC],[ISCORPACC],[ISITEMACC],[REMARKS] FROM cw_accitems where ACCID is not null and ACCID<>'') UNION (SELECT [GID],FINANCESOFTCODE as [ACCID],BANKNAME as [ACCNAME],1 as [DETAILED],'借' as [DC],0 as [ISFCY],0 as [ISDEPTACC],0 as [ISEMPLACC],0 as [ISCORPACC],0 as [ISITEMACC],'' as [REMARKS] FROM sys_bank where FINANCESOFTCODE is not null and FINANCESOFTCODE<>'')) as a where 1=1"); strSql.Append("SELECT [GID],[ACCID],[ACCNAME],[DETAILED],[DC],[ISFCY],[ISDEPTACC],[ISEMPLACC],[ISCORPACC],[ISITEMACC],[REMARKS],ACCID+'_'+ACCNAME AS ACCIDNAME FROM cw_accitems where ACCID is not null and ACCID<>''"); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" and " + strCondition); } strSql.Append(" order by ACCID"); return SetCwAccitems(strSql); } private static List SetCwAccitems(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { CwAccitemsGlModel data = new CwAccitemsGlModel(); #region Set DB data to Object data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]).Trim()); data.ACCID = (reader["ACCID"] == null ? "" : Convert.ToString(reader["ACCID"]).Trim());//科目代码 data.ACCNAME = (reader["ACCNAME"] == null ? "" : Convert.ToString(reader["ACCNAME"]).Trim());//科目名称 data.DETAILED = (reader["DETAILED"] == null ? false : Convert.ToBoolean(reader["DETAILED"]));//是否末级科目(标志) data.DC = (reader["DC"] == null ? "" : Convert.ToString(reader["DC"]).Trim());//借贷方向 data.ISFCY = (reader["ISFCY"] == null ? false : Convert.ToBoolean(reader["ISFCY"]));//是否核算外币 data.ISDEPTACC = (reader["ISDEPTACC"] == null ? false : Convert.ToBoolean(reader["ISDEPTACC"]));//是否核算部门 data.ISEMPLACC = (reader["ISEMPLACC"] == null ? false : Convert.ToBoolean(reader["ISEMPLACC"]));//是否核算人员 data.ISCORPACC = (reader["ISCORPACC"] == null ? false : Convert.ToBoolean(reader["ISCORPACC"]));//是否算客户门 data.ISITEMACC = (reader["ISITEMACC"] == null ? false : Convert.ToBoolean(reader["ISITEMACC"]));//是否核算项目 data.REMARKS = (reader["REMARKS"] == null ? "" : Convert.ToString(reader["REMARKS"]).Trim());//备注 data.ACCIDNAME = (reader["ACCIDNAME"] == null ? "" : Convert.ToString(reader["ACCIDNAME"]).Trim()); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion // #region 获取指定表内,符合条件的列的数量,主要用于防止删除主表 static public int GetExist(string tablename, string condition) { var strSql = new StringBuilder(); strSql.Append("Select count(*) _count from " + tablename); if (!string.IsNullOrEmpty(condition)) { strSql.Append(" where " + condition); } var _count = 0; Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { _count = Convert.ToInt16(reader["_count"]); } reader.Close(); } return _count; } //fieldname相同 fieldname2不相同(通常用于判断 某单据号相同而GID号不同 以防止不同业务同单据号) static public int GetExist(string tablename, string fieldname, string value, string fieldname2, string value2) { var strSql = new StringBuilder(); var tvalue = value.Trim(); var condition = new StringBuilder(); if (tvalue == "null" || tvalue == "Null" || tvalue == "NULL") { condition.Append(" is null "); } else { condition.Append(fieldname + "='" + tvalue + "'"); } condition.Append(string.Format(" and {0}<>'{1}' ", fieldname2.Trim(), value2.Trim())); strSql.Append("Select count(*) _count from " + tablename); strSql.Append(" where " + condition.ToString()); var _count = 0; Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { _count = Convert.ToInt16(reader["_count"]); } reader.Close(); } return _count; } //返回 某表中 某字段=某值的列 的数量 static public int GetExist(string tablename, string fieldname, string value) { var strSql = new StringBuilder(); var tvalue = value.Trim(); var condition = new StringBuilder(); if (tvalue == "null" || tvalue == "Null" || tvalue == "NULL") { condition.Append(" is null "); } else { condition.Append(fieldname + "='" + tvalue + "'"); } strSql.Append("Select count(*) _count from " + tablename); strSql.Append(" where " + condition.ToString()); var _count = 0; Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { _count = Convert.ToInt16(reader["_count"]); } reader.Close(); } return _count; } //返回 某表中 某字段=某值 且 某字段=某值... 的列 的数量 static public int GetExist(string tablename, string keyname, string keyvalue, List fieldnamelist, List valuelist) { var strSql = new StringBuilder(); if (fieldnamelist.Count != valuelist.Count) return 999; var condition = new StringBuilder(); var _listcount = 0; foreach (var fieldname in fieldnamelist) { var value = valuelist[_listcount]; var tvalue = value.Trim(); if (condition.ToString() != "") condition.Append(" and "); if (tvalue == "null" || tvalue == "Null" || tvalue == "NULL") { condition.Append(fieldname + " is null "); } else { condition.Append(fieldname + "='" + tvalue + "'"); } _listcount++; } strSql.Append("Select count(*) _count from " + tablename); strSql.Append(" where " + keyname + "<>'" + keyvalue + "' and " + condition.ToString()); var _count = 0; Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { _count = Convert.ToInt16(reader["_count"]); } reader.Close(); } return _count; } static public bool HaveExist(string tablename, string fieldname, string value) { var _count = GetExist(tablename, fieldname, value); bool r = false; if (_count > 0) { r = true; } return r; } static public bool HaveExist(string tablename, string fieldname, string value, string fieldname2, decimal value2) { return HaveExist(tablename, fieldname, value, fieldname2, value2.ToString()); } /// /// fieldname相同 fieldname2不相同 /// /// /// /// /// /// /// static public bool HaveExist(string tablename, string fieldname, string value, string fieldname2, string value2) { var _count = GetExist(tablename, fieldname, value, fieldname2, value2); bool r = false; if (_count > 0) { r = true; } return r; } static public bool HaveExist(string tablename, string condition) { var _count = GetExist(tablename, condition); bool r = false; if (_count > 0) { r = true; } return r; } #endregion #region 获取 出纳摘要信息 static public List GetEXPLAN(string strCondition, string strUserID) { string strCtSTARTGID = BasicDataRefDAL.GetCtSTARTGID(strUserID); var strSql = new StringBuilder(); strSql.Append("SELECT *,MODIFIEDUSERNAME=(select top 1 SHOWNAME from [user] where gid=ct_explan_detail.MODIFIEDUSER) from ct_explan_detail where 1=1"); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" and LINKGID in (select GID from ct_explan where STARTGID='" + strCtSTARTGID + "' and " + strCondition + ")"); } strSql.Append(" order by EXPLAN"); return SetEXPLAN(strSql); } private static List SetEXPLAN(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { MsCtExplanDetail data = new MsCtExplanDetail(); #region Set DB data to Object data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]));//唯一编码 data.LINKGID = (reader["LINKGID"] == null ? "" : Convert.ToString(reader["LINKGID"]));//摘要GID data.EXPLAN = (reader["EXPLAN"] == null ? "" : Convert.ToString(reader["EXPLAN"]));//内容 data.MODIFIEDUSER = (reader["MODIFIEDUSER"] == null ? "" : Convert.ToString(reader["MODIFIEDUSER"]));//更改操作人gid if (data.MODIFIEDTIME != null) data.MODIFIEDTIME = Convert.ToDateTime(reader["MODIFIEDTIME"]);//更改操作时间 data.MODIFIEDUSERNAME = (reader["MODIFIEDUSERNAME"] == null ? "" : Convert.ToString(reader["MODIFIEDUSERNAME"]));//更改人 #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 通用查询方法 参数是查询语句,必须把GID和值as成GID和GValue static public List GeneralSelect(string strCondition) { var strSql = new StringBuilder(); strSql.Append(strCondition); return SetGeneralSelect(strSql); } static public List GeneralSelect(string tablename, string keyname, string valuename, string condition) {//keyname=GVALUE一般用于displayname var strSql = new StringBuilder(); strSql.Append(string.Format("select {1} as GID,{2} as GVALUE from {0}", tablename, keyname, valuename)); if (!string.IsNullOrEmpty(condition)) { strSql.Append(" where " + condition); } return SetGeneralSelect(strSql); } #region 将GVALUE的值集合成逗号隔开的 static public List GeneralSelect_commaList(string tablename, string valuename, string condition) { var strSql = new StringBuilder(); strSql.Append(string.Format("select distinct {1} as GVALUE from {0}", tablename, valuename)); if (!string.IsNullOrEmpty(condition)) { strSql.Append(" where " + condition); } return SetGeneralSelect2(strSql); } /// /// 获取指定表中,符合条件的字段值,返回一个用逗号隔开各个字段的string /// /// /// /// /// static public string GeneralSelect_commaString(string tablename, string valuename, string condition) { var itemlist = GeneralSelect_commaList(tablename, valuename, condition); var result = ""; if (itemlist.Count > 0) { foreach (var item in itemlist) { if (result != "") { result += ","; } result += "'" + item.GVALUE + "'"; } return result; } else return ""; } #endregion public static List GeneralGet(string tablename, string condition = "") { var _condition = condition; if (tablename == "company" || tablename == "sys_company") { if (!string.IsNullOrEmpty(_condition)) { _condition += " and ISDELETED=0 "; } else { _condition += " ISDELETED=0 "; } return GeneralSelect("company", "GID", "NAME", _condition); } else if (tablename == "client") { return GeneralSelect("info_client", "GID", "SHORTNAME", _condition); } else if (tablename == "client_airline") { return GeneralSelect("info_client", "CODENAME", "SHORTNAME", " ISAIRLINES=1 "); } return new List(); } public static string GeneralGet_String(string tablename, string condition = "") { var idlist = BasicDataRefDAL.GeneralGet(tablename, condition); var result = ""; if (idlist.Count > 0) { result = idlist[0].GVALUE.ToString(); } return result; } private static List SetGeneralSelect(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { GeneralModel data = new GeneralModel(); #region Set DB data to Object data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"])); data.GVALUE = (reader["GVALUE"] == null ? "" : Convert.ToString(reader["GVALUE"])); #endregion headList.Add(data); } reader.Close(); } return headList; } private static List SetGeneralSelect2(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { GeneralModel data = new GeneralModel(); #region Set DB data to Object data.GVALUE = (reader["GVALUE"] == null ? "" : Convert.ToString(reader["GVALUE"])); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion #region 将带逗号的内容拆成单个,并将出现频率最高的放置在最前。参数为(表名 列名 查询条件) /// /// 将带逗号的内容拆成单个,并将出现频率最高的放置在最前。参数为(表名 列名 查询条件) /// /// /// /// /// static public List GetCommaWord(string tablename, string columnname, string condition) { var strSql = new StringBuilder(); var column = " case isnull(" + columnname + ",'') when '' then '' else " + columnname + "+',' end "; strSql.Append(" WITH TB_2 AS ( "); strSql.Append(" SELECT " + column + " as " + columnname + " ,CHARINDEX(','," + column + ") STA,CHARINDEX(','," + column + ")-1 LENS FROM " + tablename + " where 1=1 "); if (!string.IsNullOrEmpty(condition)) { strSql.Append(" and " + condition); } strSql.Append(" UNION ALL "); strSql.Append(" SELECT " + columnname + " ,CHARINDEX(','," + columnname + ",STA+1) STA,CHARINDEX(','," + columnname + ",STA+1)-STA-1 LENS FROM TB_2 WHERE STA<>0) "); strSql.Append(" SELECT distinct SUBSTRING(" + columnname + ",STA-LENS,LENS) VALUE,count(SUBSTRING(" + columnname + ",STA-LENS,LENS)) count FROM TB_2 "); strSql.Append(" WHERE STA<>0 "); strSql.Append(" group by SUBSTRING(" + columnname + ",STA-LENS,LENS) "); strSql.Append(" order by count(SUBSTRING(" + columnname + ",STA-LENS,LENS)) DESC "); return SetCommaWord(strSql); } private static List SetCommaWord(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { DICModel data = new DICModel(); #region Set DB data to Object data.KEYFIELD = (reader["VALUE"] == null ? "" : Convert.ToString(reader["VALUE"]));//惟一值 data.VALUEFIELD = (reader["count"] == null ? "" : Convert.ToString(reader["count"]));//惟一值 #endregion headList.Add(data); } #region 空白项 DICModel data2 = new DICModel(); data2.KEYFIELD = "";//惟一值 data2.VALUEFIELD = "0";//惟一值 #endregion headList.Add(data2); reader.Close(); } return headList; } //符合条件的表、字段中,实际已存在的用逗号隔开的部分,是否包含指定文字; /// /// 符合条件的表、字段中,实际已存在的用逗号隔开的部分,是否包含指定文字; /// /// /// /// /// /// static public bool GetCommaWordExist(string tablename, string columnname, string ExistValue, string condition) { var _list = GetCommaWord(tablename, columnname, condition); if (_list.Count() == 0) { return false; } else { foreach (var item in _list) { if (item.KEYFIELD == ExistValue.Trim()) { return true; } } return false; } } #endregion // #region 判断字符串中是否包含中文 /// /// 判断字符串中是否包含中文 /// /// 需要判断的字符串 /// 判断结果 public static bool isHasChinese(string str) { return System.Text.RegularExpressions.Regex.IsMatch(str, @"[\u4e00-\u9fa5]"); } #endregion #region 直接DelCtnDetailList执行sql命令(小心使用) static public int ExecSql ( string StrSql) { Database db = DatabaseFactory.CreateDatabase(); var _count = db.ExecuteNonQuery(CommandType.Text, StrSql); return _count; } static public int ExecSql_DB(string StrSql,string DBNAME="") { Database db = DatabaseFactory.CreateDatabase(DBNAME); var _count = db.ExecuteNonQuery(CommandType.Text, StrSql); return _count; } static public int ExecSql(SqlCommand StrSqlComm) { Database db = DatabaseFactory.CreateDatabase(); var _count = db.ExecuteNonQuery(StrSqlComm); return _count; } #endregion #region 返回实体类的属性名与列表 public static List getProperties ( T t ) { var tStr = new List(); if (t == null) { return tStr; } System.Reflection.PropertyInfo[] properties = t.GetType().GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public); if (properties.Length <= 0) { return tStr; } foreach (System.Reflection.PropertyInfo item in properties) { string name = item.Name; object value = item.GetValue(t, null); if (item.PropertyType.IsValueType || item.PropertyType.Name.StartsWith("String")) { var _sl = new FieldModel(); _sl.FieldName = name; if (value != null) { _sl.FieldValue = value.ToString(); } tStr.Add(_sl); //tStr += string.Format("{0}:{1},", name, value); } else { //getProperties(value); } } return tStr; } #endregion #region 获取 InfoClass管理分类表 static public List GetMsInfoClass(string strCondition, string strUserID) { var strSql = new StringBuilder(); strSql.Append("select * from InfoClass where 1=1"); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" and " + strCondition); } strSql.Append(" order by sortID"); return SetMsInfoClass(strSql); } private static List SetMsInfoClass(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { MsInfoClassEntity data = new MsInfoClassEntity(); #region Set DB data to Object data.ID = (reader["ID"] == null ? 0 : Convert.ToInt32(reader["ID"])); data.PARENTID = (reader["PARENTID"] == null ? "" : Convert.ToString(reader["PARENTID"])); data.CLASSID = (reader["CLASSID"] == null ? "" : Convert.ToString(reader["CLASSID"])); data.CLASSNAMEENG = (reader["CLASSNAMEENG"] == null ? "" : Convert.ToString(reader["CLASSNAMEENG"])); data.CLASSNAME = (reader["CLASSNAME"] == null ? "" : Convert.ToString(reader["CLASSNAME"])); data.CLASSICON = (reader["CLASSICON"] == null ? "" : Convert.ToString(reader["CLASSICON"])); data.CLASSKEY = (reader["CLASSKEY"] == null ? "" : Convert.ToString(reader["CLASSKEY"])); data.CLASSLOCATION = (reader["CLASSLOCATION"] == null ? 0 : Convert.ToInt32(reader["CLASSLOCATION"])); data.CLASSATTRIB = (reader["CLASSATTRIB"] == null ? 0 : Convert.ToInt32(reader["CLASSATTRIB"])); data.HASCHILD = (reader["HASCHILD"] == null ? false : Convert.ToBoolean(reader["HASCHILD"])); data.ISUSED = (reader["ISUSED"] == null ? false : Convert.ToBoolean(reader["ISUSED"])); data.ISSORT = (reader["ISSORT"] == null ? false : Convert.ToBoolean(reader["ISSORT"])); data.SORTATTRIB = (reader["SORTATTRIB"] == null ? false : Convert.ToBoolean(reader["SORTATTRIB"])); data.SORTID = (reader["SORTID"] == null ? 0 : Convert.ToInt32(reader["SORTID"])); data.AUTHOR = (reader["AUTHOR"] == null ? "" : Convert.ToString(reader["AUTHOR"])); data.CREATEDATE = Convert.ToDateTime(reader["CREATEDATE"]); data.LASTMODIFYDATE = Convert.ToDateTime(reader["LASTMODIFYDATE"]); data.DEL_SIGN = (reader["DEL_SIGN"] == null ? false : Convert.ToBoolean(reader["DEL_SIGN"])); #endregion headList.Add(data); } #region 空白项 MsInfoClassEntity data2 = new MsInfoClassEntity(); data2.ID = 0; data2.PARENTID = ""; data2.CLASSID = ""; data2.CLASSNAMEENG = ""; data2.CLASSNAME = ""; data2.CLASSICON = ""; data2.CLASSKEY = ""; data2.CLASSLOCATION = 0; data2.CLASSATTRIB = 0; data2.HASCHILD = false; data2.ISUSED = false; data2.ISSORT = false; data2.SORTATTRIB = false; data2.SORTID = 0; data2.AUTHOR = ""; data2.CREATEDATE = DateTime.Now; data2.LASTMODIFYDATE = DateTime.Now; data2.DEL_SIGN = false; #endregion headList.Add(data2); reader.Close(); } return headList; } #endregion #region 获取 客户子项目 static public List GetMsInfoClientItem(string strCondition, string strUserID) { var strSql = new StringBuilder(); strSql.Append("select * from info_client_item where 1=1"); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" and " + strCondition); } return SetMsInfoClientItem(strSql); } private static List SetMsInfoClientItem(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { MsInfoClientItemEntity data = new MsInfoClientItemEntity(); #region Set DB data to Object data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]));//惟一值 data.LINKGID = (reader["LINKGID"] == null ? "" : Convert.ToString(reader["LINKGID"]));//客户GID data.ITEMNAME = (reader["ITEMNAME"] == null ? "" : Convert.ToString(reader["ITEMNAME"]));//项目名称 data.STARTTIME = Convert.ToDateTime(reader["STARTTIME"]);//起始时间 data.ENDTIME = Convert.ToDateTime(reader["ENDTIME"]);//结束时间 data.CREATEUSER = (reader["CREATEUSER"] == null ? "" : Convert.ToString(reader["CREATEUSER"]));//创建人gid data.CREATETIME = Convert.ToDateTime(reader["CREATETIME"]);//创建时间 data.MODIFIEDUSER = (reader["MODIFIEDUSER"] == null ? "" : Convert.ToString(reader["MODIFIEDUSER"]));//更改操作人gid data.MODIFIEDTIME = Convert.ToDateTime(reader["MODIFIEDTIME"]);//最后一次更改时间 #endregion headList.Add(data); } #region 空白项 MsInfoClientItemEntity data2 = new MsInfoClientItemEntity(); data2.GID = "";//惟一值 data2.LINKGID = "";//客户GID data2.ITEMNAME = "";//项目名称 data2.STARTTIME = DateTime.Now;//起始时间 data2.ENDTIME = DateTime.Now;//结束时间 data2.CREATEUSER = "";//创建人gid data2.CREATETIME = DateTime.Now;//创建时间 data2.MODIFIEDUSER = "";//更改操作人gid data2.MODIFIEDTIME = DateTime.Now;//最后一次更改时间 #endregion headList.Add(data2); reader.Close(); } return headList; } #endregion #region 良通捷运 目的地列表 static public List GetDetiNation_LTJY(string strCondition, string strUserID) { var strSql = new StringBuilder(); strSql.Append("select DISTINCT NAME,DISTANCE from PC_LTJY_Distance where 1=1 "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" and " + strCondition); } return SetDetiNation_LTJY(strSql); } private static List SetDetiNation_LTJY(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { DICModel data = new DICModel(); #region Set DB data to Object data.KEYFIELD = (reader["NAME"] == null ? "" : Convert.ToString(reader["NAME"]));//惟一值 data.VALUEFIELD = (reader["DISTANCE"] == null ? "" : Convert.ToString(reader["DISTANCE"]));//惟一值 #endregion headList.Add(data); } #region 空白项 DICModel data2 = new DICModel(); data2.KEYFIELD = "";//惟一值 data2.VALUEFIELD = "0";//惟一值 #endregion headList.Add(data2); reader.Close(); } return headList; } #endregion #region 国家 static public List GetCountryList(string strCondition) { var strSql = new StringBuilder(); strSql.Append("select distinct c_country_code+'-'+c_country_name as CodeAndName,c_country_code CountryCode,c_country_name CountryName,c_country_ename CountryNameEn from t_sys_country_code where 1=1"); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" and " + strCondition); } return SetCountryData(strSql.ToString()); } private static List SetCountryData(string sql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql)) { while (reader.Read()) { CangDanCountry data = new CangDanCountry(); #region Set DB data to Object data.CountryName = Convert.ToString(reader["CountryName"]); data.CountryNameEn = Convert.ToString(reader["CountryNameEn"]); data.CountryCode = Convert.ToString(reader["CountryCode"]); data.CodeAndName = Convert.ToString(reader["CodeAndName"]); #endregion headList.Add(data); } } return headList; } #endregion #region SaveLog public static ContentResult SaveLog ( List data, string USERID,string NAME,string LOGTYPE ) { var headData = new Sys_Logmd();//JsonConvert.Deserialize(data); headData.GID = System.Guid.NewGuid().ToString(); headData.NAME = NAME; headData.LOGTYPE = LOGTYPE; headData.LOGTIME = System.DateTime.Now.ToString(); headData.CREATEUSER = USERID; headData.LOGCONTENT = ""; foreach (var _F in data) { headData.LOGCONTENT += string.Format("{0}:{1},", _F.FieldName, _F.FieldValue); } headData.DbOperationType = DbOperationType.DbotIns; headData.ModelUIStatus = "I"; var result = new DBResult(); var modb = new ModelObjectRepository(); result = modb.Save(headData); //刷新父窗口上的父节点 var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public static ContentResult SaveLog ( T t, string USERID, string NAME, string LOGTYPE ) { var _FieldList = getProperties(t); return SaveLog(_FieldList, USERID, NAME, LOGTYPE); } public static ContentResult SaveLog(string data, string USERID, string NAME, string LOGTYPE) { var headData = new Sys_Logmd();//JsonConvert.Deserialize(data); headData.GID = System.Guid.NewGuid().ToString(); headData.NAME = NAME; headData.LOGTYPE = LOGTYPE; headData.LOGTIME = System.DateTime.Now.ToString(); headData.CREATEUSER = USERID; //headData.LOGCONTENT = ""; headData.LOGCONTENT = data; headData.DbOperationType = DbOperationType.DbotIns; headData.ModelUIStatus = "I"; var result = new DBResult(); var modb = new ModelObjectRepository(); result = modb.Save(headData); //刷新父窗口上的父节点 var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #endregion #region 读取指定文件 然后将其写入指定表的指定字段(image字段) public static DBResult SaveFileIntoDB(FileUrlModel FileInfo, string filename) { DBResult _r = new DBResult(); _r.Success = false; var _filename = HttpContext.Current.Server.MapPath(filename); if (File.Exists(_filename)) { //var file = File.Open(filename, FileMode.Open); byte[] bytes = File.ReadAllBytes(_filename); SqlCommand cmd = new SqlCommand(string.Format( "update {0} set {1} =@image where {2}='{3}'", FileInfo.TableName, FileInfo.ImgName ,FileInfo.KeyName,FileInfo.KeyValue)); cmd.Parameters.Add("@image", SqlDbType.Image).Value = bytes; var _c = ExecSql(cmd); if (_c > 0) { _r.Success = true; } else { } return _r; } else { _r.Message="不存在指定文件"; return _r; } } public static DBResult DelFileFromDB(FileUrlModel FileInfo) { DBResult _r = new DBResult(); _r.Success = false; byte[] bytes = new byte[0]; SqlCommand cmd = new SqlCommand(string.Format("update {0} set {1} =@image where {2}='{3}'", FileInfo.TableName, FileInfo.ImgName, FileInfo.KeyName, FileInfo.KeyValue)); cmd.Parameters.Add("@image", SqlDbType.Image).Value = bytes; var _c = ExecSql(cmd); if (_c > 0) { _r.Success = true; } else { } return _r; } #endregion #region 传入IDataReader 和字段名 和返回值类型 public static object getValue(IDataReader reader, string fieldname, string type) { reader.GetSchemaTable().DefaultView.RowFilter = "ColumnName= '"+ fieldname + "'"; if (reader.GetSchemaTable().DefaultView.Count > 0) { var _r = reader[fieldname]; if (_r != DBNull.Value) return _r; } return null; } #endregion public static DateTime Timestamp2Datetime(long timestamp) { System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));//当地时区 var time = startTime.AddMilliseconds(timestamp); return time; } public static ContentResult GetContentResult(DBResult dbresult) { var jsonRespose = new JsonResponse { Success = dbresult.Success, Message = dbresult.Message, Data = null }; if (dbresult.Data != null) jsonRespose.Data = dbresult.Data; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #region 通过USERID获取邮箱和QQ public static string GetPhoneWithUserId(string USERID,out string email, out string qq) { string sql = "select officephone,EMAIL1,QQ from user_baseinfo where userid = '" + USERID + "' "; Database db = DatabaseFactory.CreateDatabase(); string phone = ""; email = ""; qq = ""; using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql)) { while (reader.Read()) { phone = reader["officephone"].ToString(); email = reader["EMAIL1"].ToString(); qq = reader["QQ"].ToString(); } reader.Close(); } return phone; } #endregion } }