You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
3128 lines
148 KiB
C#
3128 lines
148 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using DSWeb.MvcShipping.Models.MsInfoClient;
|
|
using DSWeb.MvcShipping.Models.MsInfoClientContact;
|
|
using DSWeb.MvcShipping.Models.MsInfoContract;
|
|
using DSWeb.MvcShipping.Models.MsInfoShipper;
|
|
using DSWeb.MvcShipping.Models.MsCompanysDept;
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
using DSWeb.Areas.CommMng.Models;
|
|
using HcUtility.Comm;
|
|
using DSWeb.TruckMng.Comm.Cookie;
|
|
using DSWeb.EntityDA;
|
|
using DSWeb.Areas.TruckMng.Models;
|
|
using System.Web;
|
|
using System.Data.SqlClient;
|
|
using System.IO;
|
|
using WebSqlHelper;
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
using System.Text.RegularExpressions;
|
|
using System.Linq;
|
|
using System.Data.Common;
|
|
using DSWeb.MvcShipping.DAL.MsSysParamSet;
|
|
using DSWeb.Common.DB;
|
|
using DSWeb.MvcShipping.Helper;
|
|
|
|
namespace DSWeb.MvcShipping.DAL.MsInfoClient
|
|
{
|
|
public class MsInfoClientDAL
|
|
{
|
|
#region BillNoSet
|
|
|
|
static public List<MsClient> GetDataList(int start, int limit, string strCondition, string userid, string usercode, string companyid, string sort = null)
|
|
{
|
|
var rangstr = GetRangDAStr("index", userid, usercode, companyid);
|
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
{
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strCondition = strCondition + " and " + rangstr;
|
|
}
|
|
else
|
|
{
|
|
strCondition = rangstr;
|
|
}
|
|
}
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append(@"SELECT * from (SELECT row_number() over (");
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
{
|
|
sortstring = sortstring.Replace("ACCREMARK", " (SELECT TOP 1 REMARK FROM Info_Client_ACCDATE WHERE LINKGID=info_client.GID order by BGNDATE DESC) ");
|
|
sortstring = sortstring.Replace("ACCTYPE", " (SELECT TOP 1 ACCTYPE FROM Info_Client_ACCDATE WHERE LINKGID=info_client.GID ORDER BY MODIFIEDTIME DESC) ");
|
|
sortstring = sortstring.Replace("ACCMONTH", " (SELECT TOP 1 ACCMONTH FROM Info_Client_ACCDATE WHERE LINKGID=info_client.GID ORDER BY MODIFIEDTIME DESC) ");
|
|
sortstring = sortstring.Replace("ALLOWAMOUNT", " (SELECT TOP 1 ALLOWAMOUNT FROM Info_Client_ACCDATE WHERE LINKGID=info_client.GID ORDER BY MODIFIEDTIME DESC) ");
|
|
|
|
sortstring = sortstring.Replace("BLSTATUSREF", " BLSTATUS ");
|
|
strSql.Append(" order by " + sortstring);
|
|
}
|
|
else
|
|
{
|
|
strSql.Append(" order by CODENAME desc");
|
|
}
|
|
strSql.Append(@") as num , ");
|
|
|
|
|
|
strSql.Append("[GID],[CODENAME],[SHORTNAME],[DESCRIPTION],[EnFullName],[STATUS],[ADDR],[EMAIL],[WEB]");
|
|
strSql.Append(",(SELECT TOP 1 ACCTYPE FROM Info_Client_ACCDATE WHERE ENDDATE>=GETDATE() AND LINKGID=info_client.GID ORDER BY MODIFIEDTIME DESC) ACCTYPE,(SELECT TOP 1 ACCDAYS FROM Info_Client_ACCDATE WHERE LINKGID=info_client.GID ORDER BY MODIFIEDTIME DESC) ACCDAYS");
|
|
strSql.Append(",[TEL],[FAX],[CHIEF],[SALE],[OP],[DOC],[ISCARRIER],[ISBOOKING],[ISYARD],[ISTRUCK],[ISCONTROLLER]");
|
|
strSql.Append(",[ISCUSTOM],[ISAGENT],[ISAGENTCN],[ISEXPRESS],[ISAIRLINES],[ISSHIPPER],[ISCONSIGNEE],[ISNOTIFYPARTY]");
|
|
strSql.Append(",[ISWAREHOUSE],[COUNTRY],[PROVINCE],[CITY],[CORPID],[BLCONTENT],[ISSTOP],[BillRises1],[BillRises2],INVBANK,INVADDRTEL");
|
|
strSql.Append(",[USDBillRises],[RMBBillRises],[USDMaxAmountCredit],[RMBMaxAmountCredit],[MaxAmountCredit],[STLNAME]");
|
|
strSql.Append(",[OPNAME],[OPTIME],[REMARK],[USDExchangeRate],[STLDATE],[STLFIRSTHALFDATE],[STLMIDDLEDATE],[STLDATEPJ]");
|
|
strSql.Append(",[LEVEL],[LOGINNAME],[LOGINPASSWORD],[QQ],[MSN],[MODIFIEDUSER],[MODIFIEDTIME],[ISWHARF],[ISSHIPPINGAGENT]");
|
|
strSql.Append(",[FARCODE],[FAPCODE],[ISINSURE],[ISLEASING],[ISTRADINGAGENCY],[ISOTHER],[OTHERS],[UNITPRICE],[REGISTRATIONNO]");
|
|
strSql.Append(",[ORDERNO],[ISENTERP],[TAXNO],[EDICODE],[EDICODE2],[EDICODE3],[ORGANIZATIONCODE],CODENAME + '-' + SHORTNAME AS CodeAndName");
|
|
strSql.Append(",PCORPNAME,InspectionNo,[ISSHIPAGENCY],ISSP,FEEFRT,BSSOURCE,BLSTATUS,SALECORPID,TICHENG,FENCHENG,TICHENGCANYU");
|
|
strSql.Append(",(select EnumValueName from tSysEnumValue where enumtypeid=99024 and enumvalueid=blstatus) BLSTATUSREF");
|
|
strSql.Append(",RCVMode,[CUSTTYPE],[CUSTGUIMO],[CUSTCLASS],[QUALIFICATION],[REGDATE],[CARGOL],[PRODUCT],[EXPREGION],[CARRIERLIST],[CTNTYPE],[CUSTNUM],[NATURE]");
|
|
strSql.Append(",(SELECT TOP 1 REMARK FROM Info_Client_ACCDATE WHERE ENDDATE>=GETDATE() AND LINKGID=info_client.GID order by BGNDATE DESC) ACCREMARK");
|
|
strSql.Append(",(SELECT TOP 1 ACCMONTH FROM Info_Client_ACCDATE WHERE ENDDATE>=GETDATE() AND LINKGID=info_client.GID ORDER BY MODIFIEDTIME DESC) ACCMONTH");
|
|
strSql.Append(",(SELECT TOP 1 ALLOWAMOUNT FROM Info_Client_ACCDATE WHERE ENDDATE>=GETDATE() AND LINKGID=info_client.GID ORDER BY MODIFIEDTIME DESC) ALLOWAMOUNT");
|
|
strSql.Append(",case WHEN BLSTATUS=0 THEN '合作客户' else '潜在客户' end CUSTPROP");
|
|
strSql.Append(",(select showname from [user] where gid=info_client.MODIFIEDUSER) MODIFIEDUSERREF ");
|
|
|
|
strSql.Append(" from info_client where 1=1 ");
|
|
|
|
|
|
var InfoClintBlstatus = MsSysParamSetDAL.GetData("PARAMNAME='InfoClintBlstatus'");
|
|
if (InfoClintBlstatus.PARAMVALUE != "")
|
|
{
|
|
if (InfoClintBlstatus.PARAMVALUE == "1")
|
|
{
|
|
var modCrmClientVisible = MsBaseInfoDAL.MsBaseInfoDAL.GetUserModuleEnable("modCrmClientVisible", userid);
|
|
if (modCrmClientVisible)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
strSql.Append(" and (OPNAME='" + usercode + "' or (ISNULL(BLSTATUS,1)=0)) ");
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" and " + strCondition);
|
|
}
|
|
|
|
strSql.Append(@")as t ");
|
|
strSql.Append(string.Format("where t.num>{0} and t.num<={1} order by t.num ", start, start + limit)); //
|
|
|
|
|
|
return SetData(strSql, userid);
|
|
}
|
|
|
|
static public List<MsClient> GetDataListAll(string strCondition, string userid, string usercode, string companyid, string sort = null)
|
|
{
|
|
var rangstr = GetRangDAStr("index", userid, usercode, companyid);
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
{
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strCondition = strCondition + " and " + rangstr;
|
|
}
|
|
else
|
|
{
|
|
strCondition = rangstr;
|
|
}
|
|
}
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT [GID],[CODENAME],[SHORTNAME],[DESCRIPTION],[EnFullName],[STATUS],[ADDR],[EMAIL],[WEB],(SELECT TOP 1 ACCTYPE FROM Info_Client_ACCDATE WHERE LINKGID=info_client.GID ORDER BY MODIFIEDTIME DESC) ACCTYPE,(SELECT TOP 1 ACCDAYS FROM Info_Client_ACCDATE WHERE LINKGID=info_client.GID ORDER BY MODIFIEDTIME DESC) ACCDAYS");
|
|
strSql.Append(",[TEL],[FAX],[CHIEF],[SALE],[OP],[DOC],[ISCARRIER],[ISBOOKING],[ISYARD],[ISTRUCK],[ISCONTROLLER]");
|
|
strSql.Append(",[ISCUSTOM],[ISAGENT],[ISAGENTCN],[ISEXPRESS],[ISAIRLINES],[ISSHIPPER],[ISCONSIGNEE],[ISNOTIFYPARTY]");
|
|
strSql.Append(",[ISWAREHOUSE],[COUNTRY],[PROVINCE],[CITY],[CORPID],[BLCONTENT],[ISSTOP],[BillRises1],[BillRises2],INVBANK,INVADDRTEL");
|
|
strSql.Append(",[USDBillRises],[RMBBillRises],[USDMaxAmountCredit],[RMBMaxAmountCredit],[MaxAmountCredit],[STLNAME]");
|
|
strSql.Append(",[OPNAME],[OPTIME],[REMARK],[USDExchangeRate],[STLDATE],[STLFIRSTHALFDATE],[STLMIDDLEDATE],[STLDATEPJ]");
|
|
strSql.Append(",[LEVEL],[LOGINNAME],[LOGINPASSWORD],[QQ],[MSN],[MODIFIEDUSER],[MODIFIEDTIME],[ISWHARF],[ISSHIPPINGAGENT]");
|
|
strSql.Append(",[FARCODE],[FAPCODE],[ISINSURE],[ISLEASING],[ISTRADINGAGENCY],[ISOTHER],[OTHERS],[UNITPRICE],[REGISTRATIONNO]");
|
|
strSql.Append(",[ORDERNO],[ISENTERP],[TAXNO],[EDICODE],[EDICODE2],[EDICODE3],[ORGANIZATIONCODE],CODENAME + '-' + SHORTNAME AS CodeAndName");
|
|
strSql.Append(",PCORPNAME,InspectionNo,[ISSHIPAGENCY],ISSP,FEEFRT,BSSOURCE,BLSTATUS,SALECORPID,TICHENG,FENCHENG,TICHENGCANYU");
|
|
strSql.Append(",(select EnumValueName from tSysEnumValue where enumtypeid=99024 and enumvalueid=blstatus) BLSTATUSREF");
|
|
strSql.Append(",RCVMode,[CUSTTYPE],[CUSTGUIMO],[CUSTCLASS],[QUALIFICATION],[REGDATE],[CARGOL],[PRODUCT],[EXPREGION],[CARRIERLIST],[CTNTYPE],[CUSTNUM],[NATURE]");
|
|
strSql.Append(",(SELECT TOP 1 REMARK FROM Info_Client_ACCDATE WHERE LINKGID=info_client.GID order by BGNDATE DESC) ACCREMARK");
|
|
strSql.Append(",(SELECT TOP 1 ACCMONTH FROM Info_Client_ACCDATE WHERE LINKGID=info_client.GID ORDER BY MODIFIEDTIME DESC) ACCMONTH");
|
|
strSql.Append(",(SELECT TOP 1 ALLOWAMOUNT FROM Info_Client_ACCDATE WHERE LINKGID=info_client.GID ORDER BY MODIFIEDTIME DESC) ALLOWAMOUNT");
|
|
strSql.Append(",case WHEN BLSTATUS=0 THEN '合作客户' else '潜在客户' end CUSTPROP");
|
|
strSql.Append(",(select showname from [user] where gid=info_client.MODIFIEDUSER) MODIFIEDUSERREF ");
|
|
|
|
strSql.Append(" from info_client where 1=1 ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" and " + strCondition);
|
|
}
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
{
|
|
strSql.Append(" order by " + sortstring);
|
|
}
|
|
else
|
|
{
|
|
strSql.Append(" order by CODENAME desc");
|
|
}
|
|
|
|
return SetData(strSql);
|
|
}
|
|
|
|
|
|
|
|
public static int getTotalCount(string strCondition, string userid, string usercode, string companyid)
|
|
{
|
|
var rangstr = GetRangDAStr("index", userid, usercode, companyid);
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
{
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strCondition = strCondition + " and " + rangstr;
|
|
}
|
|
else
|
|
{
|
|
strCondition = rangstr;
|
|
}
|
|
}
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("select count(*) ");
|
|
strSql.Append(" from info_client where 1=1 ");
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" and " + strCondition);
|
|
}
|
|
int cnt = 0;
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
cnt = Convert.ToInt32(reader[0]);
|
|
}
|
|
}
|
|
return cnt;
|
|
}
|
|
|
|
|
|
static public string GetDataListStr(string strCondition, string userid, string usercode, string companyid, string sort = null)
|
|
{
|
|
|
|
var rangstr = GetRangDAStr("index", userid, usercode, companyid);
|
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
{
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strCondition = strCondition + " and " + rangstr;
|
|
}
|
|
else
|
|
{
|
|
strCondition = rangstr;
|
|
}
|
|
}
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT [GID],[CODENAME],[SHORTNAME],[DESCRIPTION],[EnFullName],[STATUS],[ADDR],[EMAIL],[WEB],(SELECT TOP 1 ACCTYPE FROM Info_Client_ACCDATE WHERE LINKGID=info_client.GID ORDER BY MODIFIEDTIME DESC) ACCTYPE,(SELECT TOP 1 ACCDAYS FROM Info_Client_ACCDATE WHERE LINKGID=info_client.GID ORDER BY MODIFIEDTIME DESC) ACCDAYS");
|
|
strSql.Append(",[TEL],[FAX],[CHIEF],[SALE],[OP],[DOC],[ISCARRIER],[ISBOOKING],[ISYARD],[ISTRUCK],[ISCONTROLLER]");
|
|
strSql.Append(",[ISCUSTOM],[ISAGENT],[ISAGENTCN],[ISEXPRESS],[ISAIRLINES],[ISSHIPPER],[ISCONSIGNEE],[ISNOTIFYPARTY]");
|
|
strSql.Append(",[ISWAREHOUSE],[COUNTRY],[PROVINCE],[CITY],[CORPID],[BLCONTENT],[ISSTOP],[BillRises1],[BillRises2],INVBANK,INVADDRTEL");
|
|
strSql.Append(",[USDBillRises],[RMBBillRises],[USDMaxAmountCredit],[RMBMaxAmountCredit],[MaxAmountCredit],[STLNAME]");
|
|
strSql.Append(",[OPNAME],[OPTIME],[REMARK],[USDExchangeRate],[STLDATE],[STLFIRSTHALFDATE],[STLMIDDLEDATE],[STLDATEPJ]");
|
|
strSql.Append(",[LEVEL],[LOGINNAME],[LOGINPASSWORD],[QQ],[MSN],[MODIFIEDUSER],[MODIFIEDTIME],[ISWHARF],[ISSHIPPINGAGENT]");
|
|
strSql.Append(",[FARCODE],[FAPCODE],[ISINSURE],[ISLEASING],[ISTRADINGAGENCY],[ISOTHER],[OTHERS],[UNITPRICE],[REGISTRATIONNO]");
|
|
strSql.Append(",[ORDERNO],[ISENTERP],[TAXNO],[EDICODE],[EDICODE2],[EDICODE3],[ORGANIZATIONCODE],CODENAME + '-' + SHORTNAME AS CodeAndName");
|
|
strSql.Append(",PCORPNAME,InspectionNo,[ISSHIPAGENCY],ISSP,FEEFRT,BSSOURCE,BLSTATUS,SALECORPID,TICHENG,FENCHENG,TICHENGCANYU");
|
|
strSql.Append(",(select EnumValueName from tSysEnumValue where enumtypeid=99024 and enumvalueid=blstatus) BLSTATUSREF");
|
|
strSql.Append(",RCVMode,[CUSTTYPE],[CUSTGUIMO],[CUSTCLASS],[QUALIFICATION],[REGDATE],[CARGOL],[PRODUCT],[EXPREGION],[CARRIERLIST],[CTNTYPE],[CUSTNUM],[NATURE]");
|
|
strSql.Append(",(SELECT TOP 1 REMARK FROM Info_Client_ACCDATE WHERE LINKGID=info_client.GID order by BGNDATE DESC) ACCREMARK");
|
|
strSql.Append(",(SELECT TOP 1 ACCMONTH FROM Info_Client_ACCDATE WHERE LINKGID=info_client.GID ORDER BY MODIFIEDTIME DESC) ACCMONTH");
|
|
strSql.Append(",(SELECT TOP 1 ALLOWAMOUNT FROM Info_Client_ACCDATE WHERE LINKGID=info_client.GID ORDER BY MODIFIEDTIME DESC) ALLOWAMOUNT");
|
|
strSql.Append(",case WHEN BLSTATUS=0 THEN '合作客户' else '潜在客户' end CUSTPROP");
|
|
strSql.Append(",(select showname from [user] where gid=info_client.MODIFIEDUSER) MODIFIEDUSERREF ");
|
|
|
|
strSql.Append(" from info_client where 1=1 ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" and " + strCondition);
|
|
}
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
{
|
|
strSql.Append(" order by " + sortstring);
|
|
}
|
|
else
|
|
{
|
|
strSql.Append(" order by CODENAME ");
|
|
|
|
}
|
|
|
|
return strSql.ToString();
|
|
}
|
|
|
|
static public MsClient GetData(string condition)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT [GID],[CODENAME],[SHORTNAME],[DESCRIPTION],[EnFullName],[STATUS],[ADDR],[EMAIL],[WEB]");
|
|
strSql.Append(",[TEL],[FAX],[CHIEF],[SALE],[OP],[DOC],[ISCARRIER],[ISBOOKING],[ISYARD],[ISTRUCK],[ISCONTROLLER]");
|
|
strSql.Append(",[ISCUSTOM],[ISAGENT],[ISAGENTCN],[ISEXPRESS],[ISAIRLINES],[ISSHIPPER],[ISCONSIGNEE],[ISNOTIFYPARTY]");
|
|
strSql.Append(",[ISWAREHOUSE],[COUNTRY],[PROVINCE],[CITY],[CORPID],[BLCONTENT],[ISSTOP],[BillRises1],[BillRises2],INVBANK,INVADDRTEL");
|
|
strSql.Append(",[USDBillRises],[RMBBillRises],[USDMaxAmountCredit],[RMBMaxAmountCredit],[MaxAmountCredit],[STLNAME]");
|
|
strSql.Append(",[OPNAME],[OPTIME],[REMARK],[USDExchangeRate],[STLDATE],[STLFIRSTHALFDATE],[STLMIDDLEDATE],[STLDATEPJ]");
|
|
strSql.Append(",[LEVEL],[LOGINNAME],[LOGINPASSWORD],[QQ],[MSN],[MODIFIEDUSER],[MODIFIEDTIME],[ISWHARF],[ISSHIPPINGAGENT]");
|
|
strSql.Append(",[FARCODE],[FAPCODE],[ISINSURE],[ISLEASING],[ISTRADINGAGENCY],[ISOTHER],[OTHERS],[UNITPRICE],[REGISTRATIONNO]");
|
|
strSql.Append(",[ORDERNO],[ISENTERP],[TAXNO],[EDICODE],[EDICODE2],[EDICODE3],[ORGANIZATIONCODE],CODENAME + '-' + SHORTNAME AS CodeAndName");
|
|
strSql.Append(",PCORPNAME,InspectionNo,ISSHIPAGENCY,ISSP,FEEFRT,BSSOURCE,BLSTATUS,SALECORPID,TICHENG,FENCHENG,TICHENGCANYU");
|
|
strSql.Append(",(select EnumValueName from tSysEnumValue where enumtypeid=99024 and enumvalueid=blstatus) BLSTATUSREF");
|
|
strSql.Append(",RCVMode,'' ACCREMARK,'' ACCMONTH,'' ALLOWAMOUNT");
|
|
strSql.Append(",[CUSTTYPE],[CUSTGUIMO],[CUSTCLASS],[QUALIFICATION],[REGDATE],[CARGOL],[PRODUCT],[EXPREGION],[CARRIERLIST],[CTNTYPE],[CUSTNUM],[NATURE]");
|
|
strSql.Append(",case WHEN BLSTATUS=0 THEN '合作客户' else '潜在客户' end CUSTPROP");
|
|
strSql.Append(",(select showname from [user] where gid=info_client.MODIFIEDUSER) MODIFIEDUSERREF ");
|
|
|
|
strSql.Append(" from info_client where 1=1 ");
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
{
|
|
strSql.Append(" and " + condition);
|
|
}
|
|
var list = SetData(strSql);
|
|
if (list.Count > 0)
|
|
return list[0];
|
|
return new MsClient();
|
|
}
|
|
|
|
|
|
private static List<MsClient> SetData(StringBuilder strSql,string USERID="")
|
|
{
|
|
var headList = new List<MsClient>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
var contractrangstr = "";
|
|
var ContractList = GetContractDataList("", null, USERID);
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
MsClient data = new MsClient();
|
|
#region Set DB data to Object
|
|
reader.GetSchemaTable().DefaultView.RowFilter = "ColumnName= 'ACCTYPE'";
|
|
if (reader.GetSchemaTable().DefaultView.Count > 0)
|
|
{
|
|
data.ACCTYPE = Convert.ToString(reader["ACCTYPE"]);
|
|
data.ACCDAYS = Convert.ToString(reader["ACCDAYS"]);
|
|
data.ACCMONTH = Convert.ToString(reader["ACCMONTH"]);
|
|
if (data.ACCTYPE == "") data.ACCTYPE = "现结买单";
|
|
data.ALLOWAMOUNT = Convert.ToString(reader["ALLOWAMOUNT"]);
|
|
|
|
}
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
data.PCORPNAME = Convert.ToString(reader["PCORPNAME"]);
|
|
data.CODENAME = Convert.ToString(reader["CODENAME"]);
|
|
data.SHORTNAME = Convert.ToString(reader["SHORTNAME"]);
|
|
data.CodeAndName = Convert.ToString(reader["CodeAndName"]);
|
|
data.DESCRIPTION = Convert.ToString(reader["DESCRIPTION"]);
|
|
data.ENFULLNAME = Convert.ToString(reader["ENFULLNAME"]);
|
|
data.STATUS = Convert.ToInt16(reader["STATUS"]);
|
|
data.ADDR = Convert.ToString(reader["ADDR"]);
|
|
data.EMAIL = Convert.ToString(reader["EMAIL"]);
|
|
data.WEB = Convert.ToString(reader["WEB"]);
|
|
data.TEL = Convert.ToString(reader["TEL"]);
|
|
data.FAX = Convert.ToString(reader["FAX"]);
|
|
data.CHIEF = Convert.ToString(reader["CHIEF"]);
|
|
data.OP = Convert.ToString(reader["OP"]);
|
|
data.DOC = Convert.ToString(reader["DOC"]);
|
|
data.SALE = Convert.ToString(reader["SALE"]);
|
|
data.OPNAME = Convert.ToString(reader["OPNAME"]);
|
|
data.OPTIME = Convert.ToString(reader["OPTIME"]);
|
|
data.CORPID = Convert.ToString(reader["CORPID"]);
|
|
data.SALECORPID = Convert.ToString(reader["SALECORPID"]);
|
|
data.OTHERS = Convert.ToString(reader["OTHERS"]);
|
|
if (reader["STATUS"] != DBNull.Value)
|
|
data.STATUS = Convert.ToInt16(reader["STATUS"]);//状态1
|
|
data.COUNTRY = Convert.ToString(reader["COUNTRY"]);
|
|
data.PROVINCE = Convert.ToString(reader["PROVINCE"]);
|
|
data.CITY = Convert.ToString(reader["CITY"]);
|
|
data.BLCONTENT = Convert.ToString(reader["BLCONTENT"]);
|
|
data.BILLRISES1 = Convert.ToString(reader["BILLRISES1"]);
|
|
data.BILLRISES2 = Convert.ToString(reader["BILLRISES2"]);
|
|
data.INVBANK = Convert.ToString(reader["INVBANK"]);
|
|
data.INVADDRTEL = Convert.ToString(reader["INVADDRTEL"]);
|
|
data.RMBBILLRISES = Convert.ToString(reader["RMBBILLRISES"]);
|
|
data.USDBILLRISES = Convert.ToString(reader["USDBILLRISES"]);
|
|
if (reader["USDMAXAMOUNTCREDIT"] != DBNull.Value)
|
|
data.USDMAXAMOUNTCREDIT = Convert.ToDecimal(reader["USDMAXAMOUNTCREDIT"]);//状态1
|
|
if (reader["RMBMAXAMOUNTCREDIT"] != DBNull.Value)
|
|
data.RMBMAXAMOUNTCREDIT = Convert.ToDecimal(reader["RMBMAXAMOUNTCREDIT"]);//状态1
|
|
if (reader["MAXAMOUNTCREDIT"] != DBNull.Value)
|
|
data.MAXAMOUNTCREDIT = Convert.ToDecimal(reader["MAXAMOUNTCREDIT"]);//状态1
|
|
data.STLNAME = Convert.ToString(reader["STLNAME"]);
|
|
data.REMARK = Convert.ToString(reader["REMARK"]);
|
|
data.ACCREMARK = Convert.ToString(reader["ACCREMARK"]);
|
|
data.STLDATE = Convert.ToString(reader["STLDATE"]);
|
|
if (reader["USDEXCHANGERATE"] != DBNull.Value)
|
|
data.USDEXCHANGERATE = Convert.ToDecimal(reader["USDEXCHANGERATE"]);//状态1
|
|
data.STLFIRSTHALFDATE = Convert.ToString(reader["STLFIRSTHALFDATE"]);
|
|
data.STLMIDDLEDATE = Convert.ToString(reader["STLMIDDLEDATE"]);
|
|
data.STLDATEPJ = Convert.ToString(reader["STLDATEPJ"]);
|
|
data.LEVEL = Convert.ToString(reader["LEVEL"]);
|
|
data.LOGINNAME = Convert.ToString(reader["LOGINNAME"]);
|
|
data.LOGINPASSWORD = Convert.ToString(reader["LOGINPASSWORD"]);
|
|
data.QQ = Convert.ToString(reader["QQ"]);
|
|
data.MSN = Convert.ToString(reader["MSN"]);
|
|
data.FARCODE = Convert.ToString(reader["FARCODE"]);
|
|
data.FAPCODE = Convert.ToString(reader["FAPCODE"]);
|
|
data.UNITPRICE = Convert.ToString(reader["UNITPRICE"]);
|
|
data.REGISTRATIONNO = Convert.ToString(reader["REGISTRATIONNO"]);
|
|
data.TAXNO = Convert.ToString(reader["TAXNO"]);
|
|
data.InspectionNo = Convert.ToString(reader["InspectionNo"]);
|
|
data.EDICODE = Convert.ToString(reader["EDICODE"]);
|
|
data.EDICODE2 = Convert.ToString(reader["EDICODE2"]);
|
|
data.EDICODE3 = Convert.ToString(reader["EDICODE3"]);
|
|
data.ORGANIZATIONCODE = Convert.ToString(reader["ORGANIZATIONCODE"]);
|
|
data.ORDERNO = Convert.ToString(reader["ORDERNO"]);
|
|
if (reader["ISCARRIER"] != DBNull.Value)
|
|
data.ISCARRIER = Convert.ToBoolean(reader["ISCARRIER"]);//状态
|
|
if (reader["ISBOOKING"] != DBNull.Value)
|
|
data.ISBOOKING = Convert.ToBoolean(reader["ISBOOKING"]);//状态
|
|
if (reader["ISYARD"] != DBNull.Value)
|
|
data.ISYARD = Convert.ToBoolean(reader["ISYARD"]);//状态
|
|
if (reader["ISTRUCK"] != DBNull.Value)
|
|
data.ISTRUCK = Convert.ToBoolean(reader["ISTRUCK"]);//状态
|
|
if (reader["ISCONTROLLER"] != DBNull.Value)
|
|
data.ISCONTROLLER = Convert.ToBoolean(reader["ISCONTROLLER"]);//状态
|
|
if (reader["ISCUSTOM"] != DBNull.Value)
|
|
data.ISCUSTOM = Convert.ToBoolean(reader["ISCUSTOM"]);//状态
|
|
if (reader["ISAGENT"] != DBNull.Value)
|
|
data.ISAGENT = Convert.ToBoolean(reader["ISAGENT"]);//状态
|
|
if (reader["ISAGENTCN"] != DBNull.Value)
|
|
data.ISAGENTCN = Convert.ToBoolean(reader["ISAGENTCN"]);//状态
|
|
if (reader["ISEXPRESS"] != DBNull.Value)
|
|
data.ISEXPRESS = Convert.ToBoolean(reader["ISEXPRESS"]);//状态
|
|
if (reader["ISAIRLINES"] != DBNull.Value)
|
|
data.ISAIRLINES = Convert.ToBoolean(reader["ISAIRLINES"]);//状态
|
|
if (reader["ISSHIPPER"] != DBNull.Value)
|
|
data.ISSHIPPER = Convert.ToBoolean(reader["ISSHIPPER"]);//状态
|
|
if (reader["ISCONSIGNEE"] != DBNull.Value)
|
|
data.ISCONSIGNEE = Convert.ToBoolean(reader["ISCONSIGNEE"]);//状态
|
|
if (reader["ISNOTIFYPARTY"] != DBNull.Value)
|
|
data.ISNOTIFYPARTY = Convert.ToBoolean(reader["ISNOTIFYPARTY"]);//状态
|
|
if (reader["ISWAREHOUSE"] != DBNull.Value)
|
|
data.ISWAREHOUSE = Convert.ToBoolean(reader["ISWAREHOUSE"]);//状态
|
|
if (reader["ISINSURE"] != DBNull.Value)
|
|
data.ISINSURE = Convert.ToBoolean(reader["ISINSURE"]);//状态
|
|
if (reader["ISLEASING"] != DBNull.Value)
|
|
data.ISLEASING = Convert.ToBoolean(reader["ISLEASING"]);//状态
|
|
if (reader["ISTRADINGAGENCY"] != DBNull.Value)
|
|
data.ISTRADINGAGENCY = Convert.ToBoolean(reader["ISTRADINGAGENCY"]);//状
|
|
if (reader["ISOTHER"] != DBNull.Value)
|
|
data.ISOTHER = Convert.ToBoolean(reader["ISOTHER"]);//状
|
|
if (reader["ISENTERP"] != DBNull.Value)
|
|
data.ISENTERP = Convert.ToBoolean(reader["ISENTERP"]);//状
|
|
if (reader["ISSTOP"] != DBNull.Value)
|
|
data.ISSTOP = Convert.ToBoolean(reader["ISSTOP"]);//状态1
|
|
if (reader["ISSHIPAGENCY"] != DBNull.Value)
|
|
data.ISSHIPAGENCY = Convert.ToBoolean(reader["ISSHIPAGENCY"]);//状
|
|
|
|
data.BLSTATUSREF = Convert.ToString(reader["BLSTATUSREF"]);
|
|
if (reader["ISSP"] != DBNull.Value)
|
|
data.ISSP = Convert.ToBoolean(reader["ISSP"]);//状
|
|
data.FEEFRT = Convert.ToString(reader["FEEFRT"]);
|
|
data.RCVMode = Convert.ToString(reader["RCVMode"]);
|
|
data.BSSOURCE = Convert.ToString(reader["BSSOURCE"]);
|
|
if (reader["TICHENG"] != DBNull.Value)
|
|
data.TICHENG = Convert.ToString(reader["TICHENG"]);//提成
|
|
if (reader["FENCHENG"] != DBNull.Value)
|
|
data.FENCHENG = Convert.ToString(reader["FENCHENG"]);//分成
|
|
data.TICHENGCANYU = Convert.ToString(reader["TICHENGCANYU"]);//分成
|
|
data.CUSTTYPE = Convert.ToString(reader["CUSTTYPE"]);//分成
|
|
data.CUSTGUIMO = Convert.ToString(reader["CUSTGUIMO"]);//分成
|
|
data.CUSTCLASS = Convert.ToString(reader["CUSTCLASS"]);//分成
|
|
data.QUALIFICATION = Convert.ToString(reader["QUALIFICATION"]);//分成
|
|
data.REGDATE = Convert.ToString(reader["REGDATE"]);//分成
|
|
data.CARGOL = Convert.ToString(reader["CARGOL"]);//分成
|
|
data.PRODUCT = Convert.ToString(reader["PRODUCT"]);//分成
|
|
data.EXPREGION = Convert.ToString(reader["EXPREGION"]);//分成
|
|
data.CARRIERLIST = Convert.ToString(reader["CARRIERLIST"]);//分成
|
|
data.CTNTYPE = Convert.ToString(reader["CTNTYPE"]);//分成
|
|
data.CUSTNUM = Convert.ToString(reader["CUSTNUM"]);//分成
|
|
data.NATURE = Convert.ToString(reader["NATURE"]);//分成
|
|
data.CUSTPROP = Convert.ToString(reader["CUSTPROP"]);//客户属性
|
|
data.MODIFIEDUSERREF = Convert.ToString(reader["MODIFIEDUSERREF"]);
|
|
if (reader["MODIFIEDTIME"] != DBNull.Value)
|
|
data.MODIFIEDTIME = Convert.ToDateTime(reader["MODIFIEDTIME"]).ToString("yyyy-MM-dd HH:mm:ss");
|
|
#endregion
|
|
|
|
|
|
data.SetContractStatus(ContractList);
|
|
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
#endregion
|
|
|
|
#region 联系人
|
|
|
|
static public List<MsClientContact> GetContactDataList(string strCondition,string sort = null,string USERID="1")
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT [GID],[LINKID],[CODENAME],[SHOWNAME],[ADDR],[EMAIL],[TEL],QQ,[FAX],[MOBILE]");
|
|
strSql.Append(",[ISFINANCIALSTAFF],[ISOPERATOR],[ISSALEMAN],[ISOTHER],[ISINSURANCE],[CREATEUSER],[CREATETIME]");
|
|
strSql.Append(" ,[ISSTOP],[ISDELETED],[REMARK],[ANNIVERSARY2],[AREMARK2],[BIRTHDAY],[ANNIVERSARY1] ");
|
|
strSql.Append(" ,[AREMARK1],[ISBIRTHDAY],[ISANNIVERSARY1],[ISANNIVERSARY2],[BIRTHDAYDAY],[ANNIVERSARYDAY1]");
|
|
strSql.Append(" ,[ANNIVERSARYDAY2],[JOB],[SEX],[AGE],[MARRY],[CHILDREN],[HOBBIES],ISDUI");
|
|
strSql.Append(",(select filename from info_files where pid=info_client_contact.gid) PICURL");
|
|
strSql.Append(" from info_client_contact where 1=1 ");
|
|
|
|
|
|
var rangstr = "";
|
|
|
|
if (USERID == "1") rangstr = "1=2";
|
|
else
|
|
{
|
|
rangstr=BasicDataRefDAL.GetVisableRange("modInfoClinet_info", USERID, "", "CREATEUSER");
|
|
}
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
{
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strCondition = strCondition + " and " + rangstr;
|
|
}
|
|
else
|
|
{
|
|
strCondition = rangstr;
|
|
}
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" and " + strCondition);
|
|
}
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
{
|
|
strSql.Append(" order by " + sortstring);
|
|
}
|
|
else
|
|
{
|
|
strSql.Append(" order by CODENAME");
|
|
|
|
}
|
|
return SetContactData(strSql);
|
|
}
|
|
|
|
static public MsClientContact GetContactData(string condition,string userid)
|
|
{
|
|
MsClientContact data = null;
|
|
var list = GetContactDataList(condition,"", userid);
|
|
if (list.Count > 0)
|
|
data = list[0];
|
|
|
|
if (data == null)
|
|
{
|
|
data = new MsClientContact();
|
|
}
|
|
|
|
return data;
|
|
}
|
|
|
|
|
|
private static List<MsClientContact> SetContactData(StringBuilder strSql)
|
|
{
|
|
var headList = new List<MsClientContact>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
MsClientContact data = new MsClientContact();
|
|
#region Set DB data to Object
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
data.LINKID = Convert.ToString(reader["LINKID"]);
|
|
data.CODENAME = Convert.ToString(reader["CODENAME"]);
|
|
data.SHOWNAME = Convert.ToString(reader["SHOWNAME"]);
|
|
data.ADDR = Convert.ToString(reader["ADDR"]);
|
|
data.EMAIL = Convert.ToString(reader["EMAIL"]);
|
|
data.MOBILE = Convert.ToString(reader["MOBILE"]);
|
|
data.TEL = Convert.ToString(reader["TEL"]);
|
|
data.QQ = Convert.ToString(reader["QQ"]);
|
|
data.FAX = Convert.ToString(reader["FAX"]);
|
|
data.JOB = Convert.ToString(reader["JOB"]);
|
|
data.SEX = Convert.ToString(reader["SEX"]);
|
|
data.AGE = Convert.ToString(reader["AGE"]);
|
|
data.MARRY = Convert.ToString(reader["MARRY"]);
|
|
data.CHILDREN = Convert.ToString(reader["CHILDREN"]);
|
|
data.HOBBIES = Convert.ToString(reader["HOBBIES"]);
|
|
if (reader["ISFINANCIALSTAFF"] != DBNull.Value)
|
|
data.ISFINANCIALSTAFF = Convert.ToBoolean(reader["ISFINANCIALSTAFF"]);//状态1
|
|
if (reader["ISOPERATOR"] != DBNull.Value)
|
|
data.ISOPERATOR = Convert.ToBoolean(reader["ISOPERATOR"]);//状态1
|
|
if (reader["ISSALEMAN"] != DBNull.Value)
|
|
data.ISSALEMAN = Convert.ToBoolean(reader["ISSALEMAN"]);//状态1
|
|
if (reader["ISSTOP"] != DBNull.Value)
|
|
data.ISSTOP = Convert.ToBoolean(reader["ISSTOP"]);//状态1
|
|
if (reader["ISINSURANCE"] != DBNull.Value)
|
|
data.ISINSURANCE = Convert.ToBoolean(reader["ISINSURANCE"]);//状态1
|
|
if (reader["ISDUI"] != DBNull.Value)
|
|
data.ISDUI = Convert.ToBoolean(reader["ISDUI"]);//状态1
|
|
data.REMARK = Convert.ToString(reader["REMARK"]);
|
|
data.BIRTHDAY = Convert.ToString(reader["BIRTHDAY"]);
|
|
if (reader["ISBIRTHDAY"] != DBNull.Value)
|
|
data.ISBIRTHDAY = Convert.ToBoolean(reader["ISBIRTHDAY"]);//状态1
|
|
if (reader["BIRTHDAYDAY"] != DBNull.Value)
|
|
data.BIRTHDAYDAY = Convert.ToInt16(reader["BIRTHDAYDAY"]);//状态1
|
|
data.ANNIVERSARY1 = Convert.ToString(reader["ANNIVERSARY1"]);
|
|
if (reader["ISANNIVERSARY1"] != DBNull.Value)
|
|
data.ISANNIVERSARY1 = Convert.ToBoolean(reader["ISANNIVERSARY1"]);//状态1
|
|
if (reader["ANNIVERSARYDAY1"] != DBNull.Value)
|
|
data.ANNIVERSARYDAY1 = Convert.ToInt16(reader["ANNIVERSARYDAY1"]);//状态1
|
|
data.ANNIVERSARY2 = Convert.ToString(reader["ANNIVERSARY2"]);
|
|
if (reader["ISANNIVERSARY2"] != DBNull.Value)
|
|
data.ISANNIVERSARY2 = Convert.ToBoolean(reader["ISANNIVERSARY2"]);//状态1
|
|
if (reader["ANNIVERSARYDAY2"] != DBNull.Value)
|
|
data.ANNIVERSARYDAY2 = Convert.ToInt16(reader["ANNIVERSARYDAY2"]);//状态1
|
|
|
|
data.PICURL = Convert.ToString(reader["PICURL"]);
|
|
data.CREATEUSER = Convert.ToString(reader["CREATEUSER"]);
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
|
|
public static DBResult SaveContactDetail(string linkid,List<MsClientContact> bodyList, string userid,string companyid)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
var cmdInsert =
|
|
db.GetSqlStringCommand(
|
|
@"insert into info_client_contact ([GID],[LINKID],[CODENAME],[SHOWNAME],[ADDR],[EMAIL],[TEL],QQ,[FAX],[MOBILE]
|
|
,[ISFINANCIALSTAFF],[ISOPERATOR],[ISSALEMAN],[ISOTHER],[CREATEUSER],[CREATETIME],[ISSTOP],[REMARK],[ANNIVERSARY2],
|
|
[AREMARK2],[BIRTHDAY],[ANNIVERSARY1],[AREMARK1],[ISBIRTHDAY],[ISANNIVERSARY1],[ISANNIVERSARY2],[BIRTHDAYDAY],[ANNIVERSARYDAY1]
|
|
,[ANNIVERSARYDAY2],[JOB],[SEX],[AGE],[MARRY],[CHILDREN],[HOBBIES])
|
|
values (@GID,@LINKID,@CODENAME,@SHOWNAME,@ADDR,@EMAIL,@TEL,@QQ,@FAX,@MOBILE
|
|
,@ISFINANCIALSTAFF,@ISOPERATOR,@ISSALEMAN,@ISOTHER,@CREATEUSER,@CREATETIME,@ISSTOP,@REMARK,@ANNIVERSARY2,
|
|
@AREMARK2,@BIRTHDAY,@ANNIVERSARY1,@AREMARK1,@ISBIRTHDAY,@ISANNIVERSARY1,@ISANNIVERSARY2,@BIRTHDAYDAY,@ANNIVERSARYDAY1
|
|
,@ANNIVERSARYDAY2,@JOB,@SEX,@AGE,@MARRY,@CHILDREN,@HOBBIES) ");
|
|
|
|
var cmdUpdate =
|
|
db.GetSqlStringCommand(
|
|
@"update info_client_contact set LINKID=@LINKID,CODENAME=@CODENAME,SHOWNAME=@SHOWNAME,ADDR=@ADDR,EMAIL=@EMAIL,TEL=@TEL,QQ=@QQ,FAX=@FAX,MOBILE=@MOBILE
|
|
,ISFINANCIALSTAFF=@ISFINANCIALSTAFF,ISOPERATOR=@ISOPERATOR,ISSALEMAN=@ISSALEMAN,ISOTHER=@ISOTHER,CREATEUSER=@CREATEUSER,CREATETIME=@CREATETIME
|
|
,ISSTOP@ISSTOP,REMARK=@REMARK,ANNIVERSARY2=@ANNIVERSARY2,AREMARK2=@AREMARK2,BIRTHDAY=@BIRTHDAY,ANNIVERSARY1=@ANNIVERSARY1
|
|
,AREMARK1=@AREMARK1,ISBIRTHDAY=@ISBIRTHDAY,ISANNIVERSARY1=@ISANNIVERSARY1,ISANNIVERSARY2=@ISANNIVERSARY2,BIRTHDAYDAY=@BIRTHDAYDAY,
|
|
ANNIVERSARYDAY1=@ANNIVERSARYDAY1,ANNIVERSARYDAY2=@ANNIVERSARYDAY2,JOB=@JOB,SEX=@SEX,AGE=@AGE,MARRY=@MARRY,CHILDREN=@CHILDREN,HOBBIES=@HOBBIES
|
|
where GID=@GID ");
|
|
|
|
if (bodyList != null)
|
|
{
|
|
foreach (var enumValue in bodyList)
|
|
{
|
|
|
|
if (enumValue.GID == "*" || enumValue.GID == "")
|
|
{
|
|
cmdInsert.Parameters.Clear();
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
db.AddInParameter(cmdInsert, "@LINKID", DbType.String, linkid);
|
|
db.AddInParameter(cmdInsert, "@CODENAME", DbType.String, enumValue.CODENAME);
|
|
db.AddInParameter(cmdInsert, "@SHOWNAME", DbType.String, enumValue.SHOWNAME);
|
|
db.AddInParameter(cmdInsert, "@ADDR", DbType.String, enumValue.ADDR);
|
|
db.AddInParameter(cmdInsert, "@EMAIL", DbType.String, enumValue.EMAIL);
|
|
db.AddInParameter(cmdInsert, "@TEL", DbType.String, enumValue.TEL);
|
|
db.AddInParameter(cmdInsert, "@QQ", DbType.String, enumValue.QQ);
|
|
db.AddInParameter(cmdInsert, "@FAX", DbType.String, enumValue.FAX);
|
|
db.AddInParameter(cmdInsert, "@MOBILE", DbType.String, enumValue.MOBILE);
|
|
db.AddInParameter(cmdInsert, "@ISFINANCIALSTAFF", DbType.Boolean, enumValue.ISFINANCIALSTAFF);
|
|
db.AddInParameter(cmdInsert, "@ISOPERATOR", DbType.Boolean, enumValue.ISOPERATOR);
|
|
db.AddInParameter(cmdInsert, "@ISSALEMAN", DbType.Boolean, enumValue.ISSALEMAN);
|
|
db.AddInParameter(cmdInsert, "@ISOTHER", DbType.Boolean, enumValue.ISOTHER);
|
|
db.AddInParameter(cmdInsert, "@CREATEUSER", DbType.String, userid);
|
|
db.AddInParameter(cmdInsert, "@CREATETIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd"));
|
|
db.AddInParameter(cmdInsert, "@ISSTOP", DbType.Boolean, enumValue.ISSTOP);
|
|
db.AddInParameter(cmdInsert, "@REMARK", DbType.String, enumValue.REMARK);
|
|
db.AddInParameter(cmdInsert, "@ANNIVERSARY2", DbType.String, enumValue.ANNIVERSARY2);
|
|
db.AddInParameter(cmdInsert, "@AREMARK2", DbType.String, enumValue.AREMARK2);
|
|
db.AddInParameter(cmdInsert, "@BIRTHDAY", DbType.String, enumValue.BIRTHDAY);
|
|
db.AddInParameter(cmdInsert, "@ANNIVERSARY1", DbType.String, enumValue.ANNIVERSARY1);
|
|
db.AddInParameter(cmdInsert, "@AREMARK1", DbType.String, enumValue.AREMARK1);
|
|
db.AddInParameter(cmdInsert, "@ISBIRTHDAY", DbType.Boolean, enumValue.ISBIRTHDAY);
|
|
db.AddInParameter(cmdInsert, "@ISANNIVERSARY1", DbType.Boolean, enumValue.ISANNIVERSARY1);
|
|
db.AddInParameter(cmdInsert, "@ISANNIVERSARY2", DbType.Boolean, enumValue.ISANNIVERSARY2);
|
|
db.AddInParameter(cmdInsert, "@BIRTHDAYDAY", DbType.Int16, enumValue.BIRTHDAYDAY);
|
|
db.AddInParameter(cmdInsert, "@ANNIVERSARYDAY1", DbType.Int16, enumValue.ANNIVERSARYDAY1);
|
|
db.AddInParameter(cmdInsert, "@ANNIVERSARYDAY2", DbType.Int16, enumValue.ANNIVERSARYDAY2);
|
|
db.AddInParameter(cmdInsert, "@JOB", DbType.String, enumValue.JOB);
|
|
db.AddInParameter(cmdInsert, "@SEX", DbType.String, enumValue.SEX);
|
|
db.AddInParameter(cmdInsert, "@AGE", DbType.String, enumValue.AGE);
|
|
db.AddInParameter(cmdInsert, "@MARRY", DbType.String, enumValue.MARRY);
|
|
db.AddInParameter(cmdInsert, "@CHILDREN", DbType.String, enumValue.CHILDREN);
|
|
db.AddInParameter(cmdInsert, "@HOBBIES", DbType.String, enumValue.HOBBIES);
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
}
|
|
else
|
|
{
|
|
|
|
cmdUpdate.Parameters.Clear();
|
|
db.AddInParameter(cmdUpdate, "@GID", DbType.String, enumValue.GID);
|
|
db.AddInParameter(cmdUpdate, "@LINKID", DbType.String, enumValue.LINKID);
|
|
db.AddInParameter(cmdUpdate, "@CODENAME", DbType.String, enumValue.CODENAME);
|
|
db.AddInParameter(cmdUpdate, "@SHOWNAME", DbType.String, enumValue.SHOWNAME);
|
|
db.AddInParameter(cmdUpdate, "@ADDR", DbType.String, enumValue.ADDR);
|
|
db.AddInParameter(cmdUpdate, "@EMAIL", DbType.String, enumValue.EMAIL);
|
|
db.AddInParameter(cmdUpdate, "@TEL", DbType.String, enumValue.TEL);
|
|
db.AddInParameter(cmdUpdate, "@QQ", DbType.String, enumValue.QQ);
|
|
db.AddInParameter(cmdUpdate, "@FAX", DbType.String, enumValue.FAX);
|
|
db.AddInParameter(cmdUpdate, "@MOBILE", DbType.String, enumValue.MOBILE);
|
|
db.AddInParameter(cmdUpdate, "@ISFINANCIALSTAFF", DbType.Boolean, enumValue.ISFINANCIALSTAFF);
|
|
db.AddInParameter(cmdUpdate, "@ISOPERATOR", DbType.Boolean, enumValue.ISOPERATOR);
|
|
db.AddInParameter(cmdUpdate, "@ISSALEMAN", DbType.Boolean, enumValue.ISSALEMAN);
|
|
db.AddInParameter(cmdUpdate, "@ISOTHER", DbType.Boolean, enumValue.ISOTHER);
|
|
db.AddInParameter(cmdUpdate, "@CREATEUSER", DbType.String, userid);
|
|
db.AddInParameter(cmdUpdate, "@CREATETIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd"));
|
|
db.AddInParameter(cmdUpdate, "@ISSTOP", DbType.Boolean, enumValue.ISSTOP);
|
|
db.AddInParameter(cmdUpdate, "@REMARK", DbType.String, enumValue.REMARK);
|
|
db.AddInParameter(cmdUpdate, "@ANNIVERSARY2", DbType.String, enumValue.ANNIVERSARY2);
|
|
db.AddInParameter(cmdUpdate, "@AREMARK2", DbType.String, enumValue.AREMARK2);
|
|
db.AddInParameter(cmdUpdate, "@BIRTHDAY", DbType.String, enumValue.BIRTHDAY);
|
|
db.AddInParameter(cmdUpdate, "@ANNIVERSARY1", DbType.String, enumValue.ANNIVERSARY1);
|
|
db.AddInParameter(cmdUpdate, "@AREMARK1", DbType.String, enumValue.AREMARK1);
|
|
db.AddInParameter(cmdUpdate, "@ISBIRTHDAY", DbType.Boolean, enumValue.ISBIRTHDAY);
|
|
db.AddInParameter(cmdUpdate, "@ISANNIVERSARY1", DbType.Boolean, enumValue.ISANNIVERSARY1);
|
|
db.AddInParameter(cmdUpdate, "@ISANNIVERSARY2", DbType.Boolean, enumValue.ISANNIVERSARY2);
|
|
db.AddInParameter(cmdUpdate, "@BIRTHDAYDAY", DbType.Int16, enumValue.BIRTHDAYDAY);
|
|
db.AddInParameter(cmdUpdate, "@ANNIVERSARYDAY1", DbType.Int16, enumValue.ANNIVERSARYDAY1);
|
|
db.AddInParameter(cmdUpdate, "@ANNIVERSARYDAY2", DbType.Int16, enumValue.ANNIVERSARYDAY2);
|
|
db.AddInParameter(cmdUpdate, "@JOB", DbType.String, enumValue.JOB);
|
|
db.AddInParameter(cmdUpdate, "@SEX", DbType.String, enumValue.SEX);
|
|
db.AddInParameter(cmdUpdate, "@AGE", DbType.String, enumValue.AGE);
|
|
db.AddInParameter(cmdUpdate, "@MARRY", DbType.String, enumValue.MARRY);
|
|
db.AddInParameter(cmdUpdate, "@CHILDREN", DbType.String, enumValue.HOBBIES);
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "保存出现错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "保存成功" + result.Message;
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region 合同
|
|
|
|
static public List<MsInfoContract> GetContractDataList(string strCondition, string sort = null,string USERID="1")
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT [GID],LINKID,[CONTRACTNO],CONTRACTNAME,[SIGNINGDATE],[STARTDATE],");
|
|
strSql.Append("[CANCELDATE],[CHIEF],[REMARK],[CORPID],[CREATEUSER],[CREATETIME],[DEPTGID]");
|
|
strSql.Append(",(select ShowName from [user] where GID=info_client_contract.CREATEUSER) as CREATEUSERREF");
|
|
strSql.Append(",(select SHORTNAME from info_client where GID=info_client_contract.LINKID) as CUSTNAME");
|
|
strSql.Append(" from info_client_contract where 1=1 ");
|
|
|
|
var rangstr = "";
|
|
|
|
if (USERID == "1") rangstr = "1=2";
|
|
else
|
|
{
|
|
rangstr = BasicDataRefDAL.GetVisableRange("modInfoClinet_info", USERID, "", "CREATEUSER","DEPTGID");
|
|
}
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
{
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strCondition = strCondition + " and " + rangstr;
|
|
}
|
|
else
|
|
{
|
|
strCondition = rangstr;
|
|
}
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" and " + strCondition);
|
|
}
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
{
|
|
strSql.Append(" order by " + sortstring);
|
|
}
|
|
else
|
|
{
|
|
strSql.Append(" order by SIGNINGDATE DESC");
|
|
|
|
}
|
|
return SetContractData(strSql);
|
|
}
|
|
|
|
static public MsInfoContract GetContractData(string condition,string userid)
|
|
{
|
|
MsInfoContract data = null;
|
|
var list = GetContractDataList(condition,"",userid);
|
|
if (list.Count > 0)
|
|
data = list[0];
|
|
|
|
if (data == null)
|
|
{
|
|
data = new MsInfoContract();
|
|
}
|
|
|
|
return data;
|
|
}
|
|
|
|
|
|
private static List<MsInfoContract> SetContractData(StringBuilder strSql)
|
|
{
|
|
var headList = new List<MsInfoContract>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
MsInfoContract data = new MsInfoContract();
|
|
#region Set DB data to Object
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
data.LINKID = Convert.ToString(reader["LINKID"]);
|
|
data.CONTRACTNO = Convert.ToString(reader["CONTRACTNO"]);
|
|
data.CONTRACTNAME = Convert.ToString(reader["CONTRACTNAME"]);
|
|
data.CUSTNAME = Convert.ToString(reader["CUSTNAME"]);
|
|
|
|
if (reader["SIGNINGDATE"] != DBNull.Value)
|
|
data.SIGNINGDATE = Convert.ToDateTime(reader["SIGNINGDATE"]).ToString("yyyy-MM-dd");//预抵日期
|
|
if (reader["STARTDATE"] != DBNull.Value)
|
|
data.STARTDATE = Convert.ToDateTime(reader["STARTDATE"]).ToString("yyyy-MM-dd");//预抵日期
|
|
if (reader["CANCELDATE"] != DBNull.Value)
|
|
data.CANCELDATE = Convert.ToDateTime(reader["CANCELDATE"]).ToString("yyyy-MM-dd");//预抵日期
|
|
|
|
data.CHIEF = Convert.ToString(reader["CHIEF"]);
|
|
data.REMARK = Convert.ToString(reader["REMARK"]);
|
|
data.CORPID = Convert.ToString(reader["CORPID"]);
|
|
data.DEPTGID = Convert.ToString(reader["DEPTGID"]);
|
|
data.CREATETIME = Convert.ToString(reader["CREATETIME"]);
|
|
data.CREATEUSER = Convert.ToString(reader["CREATEUSER"]);
|
|
data.CREATEUSERREF = Convert.ToString(reader["CREATEUSERREF"]);
|
|
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
public static DBResult SaveCustFee(MsClient headData, List<Info_Client_GDFYWHmb> bodyList, string userid)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
|
|
var cmdDelete = db.GetSqlStringCommand("delete from cust_fee_templatedetail where CUSTOMERNAME='" + headData.SHORTNAME + "'");
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
|
|
var cmdInsert =
|
|
db.GetSqlStringCommand(
|
|
@"insert into cust_fee_templatedetail (GID,FEENAME,CUSTOMERNAME,UNIT,CURRENCY,UNITPRICE,REMARK,CREATEUSER,CREATETIME,EXCHANGERATE,ISCTN,ISINVOICE,ISADVANCEDPAY,FEEFRT,TAXRATE,TAX)
|
|
values (@GID,@FEENAME,@CUSTOMERNAME,@UNIT,@CURRENCY,@UNITPRICE,@REMARK,@CREATEUSER,@CREATETIME,@EXCHANGERATE,@ISCTN,@ISINVOICE,@ISADVANCEDPAY,@FEEFRT,@TAXRATE,@TAX) ");
|
|
|
|
if (bodyList != null)
|
|
{
|
|
foreach (var enumValue in bodyList)
|
|
{
|
|
cmdInsert.Parameters.Clear();
|
|
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
db.AddInParameter(cmdInsert, "@FEENAME", DbType.String, enumValue.FEENAME);
|
|
db.AddInParameter(cmdInsert, "@CUSTOMERNAME", DbType.String, headData.SHORTNAME);
|
|
db.AddInParameter(cmdInsert, "@UNIT", DbType.String, enumValue.UNIT);
|
|
db.AddInParameter(cmdInsert, "@CURRENCY", DbType.String, enumValue.CURRENCY);
|
|
db.AddInParameter(cmdInsert, "@UNITPRICE", DbType.Decimal, enumValue.UNITPRICE);
|
|
db.AddInParameter(cmdInsert, "@REMARK", DbType.String, enumValue.REMARK);
|
|
db.AddInParameter(cmdInsert, "@CREATEUSER", DbType.String, userid);
|
|
db.AddInParameter(cmdInsert, "@CREATETIME", DbType.String, DateTime.Now.ToString());
|
|
db.AddInParameter(cmdInsert, "@EXCHANGERATE", DbType.Decimal, enumValue.EXCHANGERATE);
|
|
db.AddInParameter(cmdInsert, "@ISCTN", DbType.Boolean, enumValue.ISCTN);
|
|
db.AddInParameter(cmdInsert, "@ISINVOICE", DbType.Boolean, enumValue.ISINVOICE);
|
|
db.AddInParameter(cmdInsert, "@ISADVANCEDPAY", DbType.Boolean, enumValue.ISADVANCEDPAY);
|
|
db.AddInParameter(cmdInsert, "@FEEFRT", DbType.String, enumValue.FEEFRT);
|
|
db.AddInParameter(cmdInsert, "@TAXRATE", DbType.Decimal, enumValue.TAXRATE);
|
|
db.AddInParameter(cmdInsert, "@TAX", DbType.Decimal, enumValue.TAX);
|
|
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
}
|
|
}
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "保存出现错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "保存成功";
|
|
|
|
return result;
|
|
}
|
|
|
|
static public DBResult CreateHangXinCust(string filename)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
var cmdDelete = db.GetSqlStringCommand("delete from tmp_hangxincust ");
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
|
|
try
|
|
{
|
|
|
|
FileStream fs = new FileStream(filename, FileMode.Open);
|
|
StreamReader sr = new StreamReader(fs, System.Text.Encoding.GetEncoding("gb2312"));
|
|
string line;
|
|
int linecount = 0;
|
|
while ((line = sr.ReadLine()) != null)
|
|
{
|
|
if (linecount < 3)
|
|
{
|
|
linecount++;
|
|
continue;
|
|
}
|
|
linecount++;
|
|
string[] custlist = Regex.Split(line, "~~", RegexOptions.IgnoreCase);
|
|
if (custlist.Length > 5)
|
|
{
|
|
var cmdInsert =
|
|
db.GetSqlStringCommand(
|
|
@"insert into tmp_hangxincust (NO,CUSTNAME,TAXNO,ADDRTEL,BANK,SORT)
|
|
values (@NO,@CUSTNAME,@TAXNO,@ADDRTEL,@BANK,@SORT) ");
|
|
|
|
|
|
cmdInsert.Parameters.Clear();
|
|
|
|
db.AddInParameter(cmdInsert, "@NO", DbType.String, custlist[0]);
|
|
db.AddInParameter(cmdInsert, "@CUSTNAME", DbType.String, custlist[1]);
|
|
db.AddInParameter(cmdInsert, "@TAXNO", DbType.String, custlist[3]);
|
|
db.AddInParameter(cmdInsert, "@ADDRTEL", DbType.String, custlist[4]);
|
|
db.AddInParameter(cmdInsert, "@BANK", DbType.String, custlist[5]);
|
|
db.AddInParameter(cmdInsert, "@SORT", DbType.Int32, linecount);
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
}
|
|
|
|
}
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "保存出现错误,请重试或联系系统管理员"+e.Message;
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "保存成功";
|
|
|
|
return result;
|
|
}
|
|
|
|
public static DBResult SaveHangXinCust(List<MsHangXinCust> boday, String USERID)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
|
|
if (boday != null)
|
|
{
|
|
|
|
var cmdUpdate =
|
|
db.GetSqlStringCommand(
|
|
@"update tmp_hangxincust set SHORTNAME=@SHORTNAME WHERE GID=@GID ");
|
|
|
|
foreach (var enumValue in boday)
|
|
{
|
|
|
|
cmdUpdate.Parameters.Clear();
|
|
db.AddInParameter(cmdUpdate, "@SHORTNAME", DbType.String, enumValue.SHORTNAME);
|
|
db.AddInParameter(cmdUpdate, "@GID", DbType.String, enumValue.GID);
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
|
|
}
|
|
}
|
|
|
|
result = new DBResult();
|
|
result.Success = true;
|
|
result.Message = "设置完成";
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "设置出现错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "设置完成";
|
|
|
|
return result;
|
|
}
|
|
|
|
public static DBResult UpdateHangXinCust(List<MsHangXinCust> boday, String USERID)
|
|
{
|
|
var result = new DBResult();
|
|
var errostr = "";
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
var shortname = "";
|
|
|
|
try
|
|
{
|
|
|
|
|
|
if (boday != null)
|
|
{
|
|
|
|
var cmdUpdate =
|
|
db.GetSqlStringCommand(
|
|
@"update info_client set BILLRISES1=@BILLRISES1,INVADDRTEL=@INVADDRTEL,TAXNO=@TAXNO WHERE SHORTNAME=@SHORTNAME ");
|
|
|
|
var cmdInsert =
|
|
db.GetSqlStringCommand(
|
|
@"insert into info_client_bank (GID,LINKID,CODENAME,CURRENCY,BANKNAME,ACCOUNT,[REMARK],FINANCESOFTCODE,CREATEUSER,CREATETIME,ACCOUNTNAME)
|
|
SELECT NEWID(),GID,'','RMB',@BANKNAME,@ACCOUNT,'','',@CREATEUSER,GETDATE(),@ACCOUNTNAME FROM INFO_CLIENT WHERE SHORTNAME=@SHORTNAME ");
|
|
|
|
foreach (var enumValue in boday)
|
|
{
|
|
if (enumValue.SHORTNAME != "")
|
|
{
|
|
shortname = enumValue.SHORTNAME;
|
|
cmdUpdate.Parameters.Clear();
|
|
db.AddInParameter(cmdUpdate, "@BILLRISES1", DbType.String, enumValue.CUSTNAME);
|
|
db.AddInParameter(cmdUpdate, "@INVADDRTEL", DbType.String, enumValue.ADDRTEL);
|
|
db.AddInParameter(cmdUpdate, "@TAXNO", DbType.String, enumValue.TAXNO);
|
|
db.AddInParameter(cmdUpdate, "@SHORTNAME", DbType.String, enumValue.SHORTNAME);
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
var BANKSTR = enumValue.BANK;
|
|
if (BANKSTR != "") {
|
|
BANKSTR = BANKSTR.Replace(" ", "");
|
|
BANKSTR = BANKSTR.Replace("-", "");
|
|
Regex r = new Regex(@"\d+");
|
|
try
|
|
{
|
|
var ms = r.Matches(BANKSTR);
|
|
var bankaccount = ms.OfType<Match>().Last().ToString();
|
|
var bankname = BANKSTR.Replace(bankaccount, "").Trim();
|
|
var banklist = GetBankList(" LINKID in (select GID FROM INFO_CLIENT WHERE SHORTNAME='" + enumValue.SHORTNAME + "') and BANKNAME='" + bankname + "' and ACCOUNT='" + bankaccount + "'", "1", "BANKNAME", tran);
|
|
if (banklist.Count == 0)
|
|
{
|
|
|
|
cmdInsert.Parameters.Clear();
|
|
db.AddInParameter(cmdInsert, "@BANKNAME", DbType.String, bankname);
|
|
db.AddInParameter(cmdInsert, "@ACCOUNT", DbType.String, bankaccount);
|
|
db.AddInParameter(cmdInsert, "@CREATEUSER", DbType.String, USERID);
|
|
db.AddInParameter(cmdInsert, "@ACCOUNTNAME", DbType.String, enumValue.CUSTNAME);
|
|
db.AddInParameter(cmdInsert, "@SHORTNAME", DbType.String, enumValue.SHORTNAME);
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
errostr = errostr + e.Message;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
result = new DBResult();
|
|
result.Success = true;
|
|
result.Message = "设置完成";
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "设置出现错误,请重试或联系系统管理员 "+ shortname + e.Message;
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "设置完成"+ errostr;
|
|
|
|
return result;
|
|
}
|
|
|
|
public static string GetBankNo(string str)
|
|
{
|
|
string resultstr = "";
|
|
str = str.Replace(" ", "");
|
|
str = str.Replace("-", "");
|
|
Regex r = new Regex(@"\d+");
|
|
var ms = r.Matches(str);
|
|
resultstr = ms.OfType<Match>().Last().ToString();
|
|
|
|
return resultstr;
|
|
|
|
}
|
|
|
|
|
|
#region 客户部门
|
|
static public List<MsCompanysDept> GetDeptList(string strCondition, string sort = null)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT * from info_client_dept where 1=1");
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" and " + strCondition);
|
|
}
|
|
//
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
{
|
|
strSql.Append(" order by " + sortstring);
|
|
}
|
|
else
|
|
{
|
|
strSql.Append(" order by DEPTNO,MODIFIEDTIME");
|
|
}
|
|
return SetDeptData(strSql);
|
|
}
|
|
|
|
static public MsCompanysDept GetDeptData(string condition)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT * from info_client_dept where 1=1");
|
|
if (!string.IsNullOrEmpty(condition))
|
|
{
|
|
strSql.Append(" and " + condition);
|
|
}
|
|
var list = SetDeptData(strSql);
|
|
if (list.Count > 0)
|
|
return list[0];
|
|
return new MsCompanysDept();
|
|
}
|
|
|
|
private static List<MsCompanysDept> SetDeptData(StringBuilder strSql)
|
|
{
|
|
var headList = new List<MsCompanysDept>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
MsCompanysDept data = new MsCompanysDept();
|
|
#region Set DB data to Object
|
|
data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]));//惟一编号
|
|
data.LINKID = (reader["LINKID"] == null ? "" : Convert.ToString(reader["LINKID"]));//公司关联id
|
|
data.DEPTNO = (reader["DEPTNO"] == null ? "" : Convert.ToString(reader["DEPTNO"]));//代码
|
|
data.DEPTNAME = (reader["DEPTNAME"] == null ? "" : Convert.ToString(reader["DEPTNAME"]));//名称
|
|
data.FINANCESOFTCODE = (reader["FINANCESOFTCODE"] == null ? "" : Convert.ToString(reader["FINANCESOFTCODE"]));//FINANCESOFTCODE
|
|
data.MANAGE1 = (reader["MANAGE1"] == null ? "" : Convert.ToString(reader["MANAGE1"]));//经理
|
|
data.MANAGE2 = (reader["MANAGE2"] == null ? "" : Convert.ToString(reader["MANAGE2"]));//副经理
|
|
data.REMARK = (reader["REMARK"] == null ? "" : Convert.ToString(reader["REMARK"]));//备注
|
|
data.CREATEUSER = (reader["CREATEUSER"] == null ? "" : Convert.ToString(reader["CREATEUSER"]));//CREATEUSER
|
|
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"]);//更改操作时间
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
#endregion
|
|
|
|
#region 银行信息
|
|
static public List<MsClientAccount> GetBankList(string strCondition,string isedit="0", string sort = null,DbTransaction tran=null)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT * ,(SELECT SHORTNAME FROM info_client where GID=info_client_bank.LINKID) CUSTNAME");
|
|
strSql.Append(",BANKNAME + '-' + ACCOUNTNAME AS ACCOUNTNAMEREF");
|
|
strSql.Append(",BANKNAME + ' ' + ACCOUNT AS BANKACCOUNT");
|
|
strSql.Append(",(select country from code_country where countryid=info_client_bank.countryid) country");
|
|
strSql.Append(",ISINVDEF,(CASE WHEN ISINVDEF='1' THEN '是' ELSE '否' END) ISINVDEFREF");
|
|
strSql.Append(" from info_client_bank where 1=1");
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" and " + strCondition);
|
|
}
|
|
//
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
{
|
|
strSql.Append(" order by " + sortstring);
|
|
}
|
|
else
|
|
{
|
|
strSql.Append(" order by CODENAME");
|
|
}
|
|
return SetBankData(strSql,isedit, tran);
|
|
}
|
|
|
|
static public MsClientAccount GetBankData(string condition)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT * ,(SELECT SHORTNAME FROM info_client where GID=info_client_bank.LINKID) CUSTNAME");
|
|
strSql.Append(",BANKNAME + '-' + ACCOUNTNAME AS ACCOUNTNAMEREF");
|
|
strSql.Append(",BANKNAME + ' ' + ACCOUNT AS BANKACCOUNT");
|
|
strSql.Append(",(select country from code_country where countryid=info_client_bank.countryid) country");
|
|
strSql.Append(",ISINVDEF,(CASE WHEN ISINVDEF='1' THEN '是' ELSE '否' END) ISINVDEFREF");
|
|
|
|
//strSql.Append(",(select country from code_country where countryid=info_client_bank.countryid),0,(charindex('(',(select country from code_country where countryid=info_client_bank.countryid))) ) country");
|
|
strSql.Append(" from info_client_bank where 1=1");
|
|
if (!string.IsNullOrEmpty(condition))
|
|
{
|
|
strSql.Append(" and " + condition);
|
|
}
|
|
var list = SetBankData(strSql,"1");
|
|
if (list.Count > 0)
|
|
return list[0];
|
|
return new MsClientAccount();
|
|
}
|
|
|
|
private static List<MsClientAccount> SetBankData(StringBuilder strSql,string isedit, DbTransaction tran = null)
|
|
{
|
|
var headList = new List<MsClientAccount>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
if (tran == null)
|
|
{
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
MsClientAccount data = new MsClientAccount();
|
|
#region Set DB data to Object
|
|
data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]));//GID
|
|
data.LINKID = (reader["LINKID"] == null ? "" : Convert.ToString(reader["LINKID"]));//公司关联id
|
|
data.CODENAME = (reader["CODENAME"] == null ? "" : Convert.ToString(reader["CODENAME"]));//CODENAME
|
|
data.CURRENCY = (reader["CURRENCY"] == null ? "" : Convert.ToString(reader["CURRENCY"]));//CURRENCY
|
|
data.BANKNAME = (reader["BANKNAME"] == null ? "" : Convert.ToString(reader["BANKNAME"]));//BANKNAME
|
|
data.ACCOUNT = (reader["ACCOUNT"] == null ? "" : Convert.ToString(reader["ACCOUNT"]));//ACCOUNT
|
|
data.ACCOUNTNAME = (reader["ACCOUNTNAME"] == null ? "" : Convert.ToString(reader["ACCOUNTNAME"]));//ACCOUNT
|
|
data.SUBJECTCODE = (reader["SUBJECTCODE"] == null ? "" : Convert.ToString(reader["SUBJECTCODE"]));//银行账户
|
|
data.REMARK = (reader["REMARK"] == null ? "" : Convert.ToString(reader["REMARK"]));//REMARK
|
|
data.FINANCESOFTCODE = (reader["FINANCESOFTCODE"] == null ? "" : Convert.ToString(reader["FINANCESOFTCODE"]));//FINANCESOFTCODE
|
|
data.CREATEUSER = (reader["CREATEUSER"] == null ? "" : Convert.ToString(reader["CREATEUSER"]));//CREATEUSER
|
|
if (reader["CREATETIME"] != DBNull.Value)
|
|
data.CREATETIME = Convert.ToString(reader["CREATETIME"]);//创建时间
|
|
data.CUSTNAME = Convert.ToString(reader["CUSTNAME"]);//创建时间
|
|
data.ACCOUNTNAMEREF = Convert.ToString(reader["ACCOUNTNAMEREF"]);//创建时间
|
|
data.SWIFT = Convert.ToString(reader["SWIFT"]);
|
|
data.BANKAGENTNAME = Convert.ToString(reader["BANKAGENTNAME"]);
|
|
data.BANKADDR = Convert.ToString(reader["BANKADDR"]);
|
|
data.BANKACNO = Convert.ToString(reader["BANKACNO"]);
|
|
|
|
data.COUNTRYID = Convert.ToString(reader["COUNTRYID"]);
|
|
data.COUNTRY = Convert.ToString(reader["COUNTRY"]);
|
|
data.BANKNAME_ACCOUNT = Convert.ToString(reader["BANKACCOUNT"]);
|
|
data.ISINVDEF = Convert.ToString(reader["ISINVDEF"]);
|
|
data.ISINVDEFREF = Convert.ToString(reader["ISINVDEFREF"]);
|
|
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
}
|
|
else {
|
|
using (IDataReader reader = db.ExecuteReader(tran,CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
MsClientAccount data = new MsClientAccount();
|
|
#region Set DB data to Object
|
|
data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]));//GID
|
|
data.LINKID = (reader["LINKID"] == null ? "" : Convert.ToString(reader["LINKID"]));//公司关联id
|
|
data.CODENAME = (reader["CODENAME"] == null ? "" : Convert.ToString(reader["CODENAME"]));//CODENAME
|
|
data.CURRENCY = (reader["CURRENCY"] == null ? "" : Convert.ToString(reader["CURRENCY"]));//CURRENCY
|
|
data.BANKNAME = (reader["BANKNAME"] == null ? "" : Convert.ToString(reader["BANKNAME"]));//BANKNAME
|
|
data.ACCOUNT = (reader["ACCOUNT"] == null ? "" : Convert.ToString(reader["ACCOUNT"]));//ACCOUNT
|
|
data.ACCOUNTNAME = (reader["ACCOUNTNAME"] == null ? "" : Convert.ToString(reader["ACCOUNTNAME"]));//ACCOUNT
|
|
data.SUBJECTCODE = (reader["SUBJECTCODE"] == null ? "" : Convert.ToString(reader["SUBJECTCODE"]));//银行账户
|
|
data.REMARK = (reader["REMARK"] == null ? "" : Convert.ToString(reader["REMARK"]));//REMARK
|
|
data.FINANCESOFTCODE = (reader["FINANCESOFTCODE"] == null ? "" : Convert.ToString(reader["FINANCESOFTCODE"]));//FINANCESOFTCODE
|
|
data.CREATEUSER = (reader["CREATEUSER"] == null ? "" : Convert.ToString(reader["CREATEUSER"]));//CREATEUSER
|
|
if (reader["CREATETIME"] != DBNull.Value)
|
|
data.CREATETIME = Convert.ToString(reader["CREATETIME"]);//创建时间
|
|
data.CUSTNAME = Convert.ToString(reader["CUSTNAME"]);//创建时间
|
|
data.ACCOUNTNAMEREF = Convert.ToString(reader["ACCOUNTNAMEREF"]);//创建时间
|
|
data.SWIFT = Convert.ToString(reader["SWIFT"]);
|
|
data.BANKAGENTNAME = Convert.ToString(reader["BANKAGENTNAME"]);
|
|
data.BANKADDR = Convert.ToString(reader["BANKADDR"]);
|
|
data.BANKACNO = Convert.ToString(reader["BANKACNO"]);
|
|
|
|
data.COUNTRYID = Convert.ToString(reader["COUNTRYID"]);
|
|
data.COUNTRY = Convert.ToString(reader["COUNTRY"]);
|
|
data.BANKNAME_ACCOUNT = Convert.ToString(reader["BANKACCOUNT"]);
|
|
data.ISINVDEF = Convert.ToString(reader["ISINVDEF"]);
|
|
data.ISINVDEFREF = Convert.ToString(reader["ISINVDEFREF"]);
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
if (isedit != "1")
|
|
{
|
|
MsClientAccount adata = new MsClientAccount();
|
|
#region Set DB data to Object
|
|
adata.GID = "";//GID
|
|
adata.LINKID = "";//公司关联id
|
|
adata.CODENAME = "";//CODENAME
|
|
adata.CURRENCY = "";//CURRENCY
|
|
adata.BANKNAME = "";//BANKNAME
|
|
adata.ACCOUNT = "";//ACCOUNT
|
|
adata.ACCOUNTNAME = "";//ACCOUNT
|
|
adata.SUBJECTCODE = "";//银行账户
|
|
adata.REMARK = "";//REMARK
|
|
adata.FINANCESOFTCODE = "";//FINANCESOFTCODE
|
|
adata.CREATEUSER = "";//CREATEUSER
|
|
adata.CUSTNAME = "";//创建时间
|
|
adata.ACCOUNTNAMEREF = "";//创建时间
|
|
adata.BANKNAME_ACCOUNT = "";
|
|
adata.ISINVDEF ="0";
|
|
adata.ISINVDEFREF ="否";
|
|
#endregion
|
|
headList.Add(adata);
|
|
}
|
|
|
|
return headList;
|
|
}
|
|
|
|
public static DBResult SaveBank(string GID, List<MsClientAccount> bodyList, string userid)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
var cmdInsert =
|
|
db.GetSqlStringCommand(
|
|
@"insert into info_client_bank (GID,LINKID,CODENAME,CURRENCY,BANKNAME,ACCOUNT,[REMARK],FINANCESOFTCODE,CREATEUSER,CREATETIME,ACCOUNTNAME,ISINVDEF)
|
|
values (@GID,@LINKID,@CODENAME,@CURRENCY,@BANKNAME,@ACCOUNT,@REMARK,@FINANCESOFTCODE,@CREATEUSER,@CREATETIME,@ACCOUNTNAME,@ISINVDEF) ");
|
|
|
|
var cmdUpdate =
|
|
db.GetSqlStringCommand(
|
|
@"update info_client_bank set CODENAME=@CODENAME,CURRENCY=@CURRENCY,BANKNAME=@BANKNAME,ACCOUNT=@ACCOUNT,REMARK=@REMARK,FINANCESOFTCODE=@FINANCESOFTCODE
|
|
,ACCOUNTNAME=@ACCOUNTNAME,ISINVDEF=@ISINVDEF where GID=@GID ");
|
|
|
|
if (bodyList != null)
|
|
{
|
|
foreach (var enumValue in bodyList)
|
|
{
|
|
|
|
if (enumValue.LINKID == "*" || enumValue.LINKID == "")
|
|
{
|
|
cmdInsert.Parameters.Clear();
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, enumValue.GID);
|
|
db.AddInParameter(cmdInsert, "@LINKID", DbType.String,GID);
|
|
db.AddInParameter(cmdInsert, "@CODENAME", DbType.String, enumValue.CODENAME);
|
|
db.AddInParameter(cmdInsert, "@CURRENCY", DbType.String, enumValue.CURRENCY);
|
|
db.AddInParameter(cmdInsert, "@BANKNAME", DbType.String, enumValue.BANKNAME);
|
|
db.AddInParameter(cmdInsert, "@ACCOUNT", DbType.String, enumValue.ACCOUNT);
|
|
db.AddInParameter(cmdInsert, "@REMARK", DbType.String, enumValue.REMARK);
|
|
db.AddInParameter(cmdInsert, "@FINANCESOFTCODE", DbType.String, enumValue.FINANCESOFTCODE);
|
|
db.AddInParameter(cmdInsert, "@CREATEUSER", DbType.String, userid);
|
|
db.AddInParameter(cmdInsert, "@CREATETIME", DbType.String, DateTime.Now.ToString());
|
|
db.AddInParameter(cmdInsert, "@ACCOUNTNAME", DbType.String, enumValue.ACCOUNTNAME);
|
|
db.AddInParameter(cmdInsert, "@ISINVDEF", DbType.String, enumValue.ISINVDEF);
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
}
|
|
else
|
|
{
|
|
|
|
cmdUpdate.Parameters.Clear();
|
|
db.AddInParameter(cmdUpdate, "@GID", DbType.String, enumValue.GID);
|
|
db.AddInParameter(cmdUpdate, "@CODENAME", DbType.String, enumValue.CODENAME);
|
|
db.AddInParameter(cmdUpdate, "@CURRENCY", DbType.String, enumValue.CURRENCY);
|
|
db.AddInParameter(cmdUpdate, "@BANKNAME", DbType.String, enumValue.BANKNAME);
|
|
db.AddInParameter(cmdUpdate, "@ACCOUNT", DbType.String, enumValue.ACCOUNT);
|
|
db.AddInParameter(cmdUpdate, "@REMARK", DbType.String, enumValue.REMARK);
|
|
db.AddInParameter(cmdUpdate, "@FINANCESOFTCODE", DbType.String, enumValue.FINANCESOFTCODE);
|
|
db.AddInParameter(cmdUpdate, "@ACCOUNTNAME", DbType.String, enumValue.ACCOUNTNAME);
|
|
db.AddInParameter(cmdUpdate, "@ISINVDEF", DbType.String, enumValue.ISINVDEF);
|
|
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "保存出现错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "保存成功" + result.Message;
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 收发货人信息
|
|
|
|
static public List<MsInfoShipper> GetShipperDataList(string strCondition)
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT shipperID,[codename],[SHORTNAME],[shipperdetail]");
|
|
strSql.Append(",[shippertype],[LOADADDRESS],[DELIVERADDRESS] ,[ISPUBLIC],SERVICECONTRACTNO,COUNTRY,ATTN,TEL,EMAIL,CORPID ");
|
|
strSql.Append(",(select SHORTNAME from info_client where CODENAME=info_shipper.codename) AS CUSTOMERNAME ");
|
|
strSql.Append(" from info_shipper where 1=1 ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" and " + strCondition);
|
|
}
|
|
strSql.Append(" order by shipperID");
|
|
|
|
|
|
return SetShipperData(strSql);
|
|
}
|
|
|
|
static public MsInfoShipper GetShipperData(string condition)
|
|
{
|
|
MsInfoShipper data = null;
|
|
var list = GetShipperDataList(condition);
|
|
if (list.Count > 0)
|
|
data = list[0];
|
|
|
|
if (data == null)
|
|
{
|
|
data = new MsInfoShipper();
|
|
}
|
|
|
|
return data;
|
|
}
|
|
|
|
|
|
private static List<MsInfoShipper> SetShipperData(StringBuilder strSql)
|
|
{
|
|
var headList = new List<MsInfoShipper>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
MsInfoShipper data = new MsInfoShipper();
|
|
#region Set DB data to Object
|
|
data.SHIPPERID = Convert.ToString(reader["SHIPPERID"]);
|
|
data.CODENAME = Convert.ToString(reader["CODENAME"]);
|
|
data.SHORTNAME = Convert.ToString(reader["SHORTNAME"]);
|
|
data.SHIPPERDETAIL = Convert.ToString(reader["SHIPPERDETAIL"]);
|
|
if (reader["SHIPPERTYPE"] != DBNull.Value)
|
|
data.SHIPPERTYPE = Convert.ToInt16(reader["SHIPPERTYPE"]);
|
|
if (reader["ISPUBLIC"] != DBNull.Value)
|
|
data.ISPUBLIC = Convert.ToBoolean(reader["ISPUBLIC"]);
|
|
data.SHIPPERDETAIL = Convert.ToString(reader["SHIPPERDETAIL"]);
|
|
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
|
|
if (reader["SERVICECONTRACTNO"] != DBNull.Value)
|
|
data.SERVICECONTRACTNO = Convert.ToString(reader["SERVICECONTRACTNO"]);
|
|
data.CORPID = Convert.ToString(reader["CORPID"]);
|
|
data.COUNTRY = Convert.ToString(reader["COUNTRY"]);
|
|
data.ATTN = Convert.ToString(reader["ATTN"]);
|
|
data.TEL = Convert.ToString(reader["TEL"]);
|
|
data.EMAIL = Convert.ToString(reader["EMAIL"]);
|
|
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
#region 权限范围
|
|
public static string GetRangDAStr(string tb, string userid, string username, string companyid)
|
|
{
|
|
string str = "";
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append(" VISIBLERANGE,OPERATERANGE ");
|
|
strSql.Append(" from VW_User_Authority ");
|
|
strSql.Append(" where [NAME]='modExchangesUnit' and USERID='" + userid + "' and ISDELETE=0");
|
|
|
|
string visiblerange = "4";
|
|
string operaterange = "4";
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
|
|
while (reader.Read())
|
|
{
|
|
visiblerange = Convert.ToString(reader["VISIBLERANGE"]);
|
|
operaterange = Convert.ToString(reader["OPERATERANGE"]);
|
|
break;
|
|
}
|
|
reader.Close();
|
|
}
|
|
if (visiblerange == "4")
|
|
{
|
|
str = "1=2";
|
|
}
|
|
else if (visiblerange == "3")
|
|
{
|
|
|
|
str = " OPNAME='" + username + "' or SALE='" + username + "' or DOC='" + username + "'or OP='" + username + "' ";
|
|
|
|
}
|
|
else if (visiblerange == "2")
|
|
{
|
|
if (tb == "index")
|
|
{
|
|
var rangeDa = new RangeDA();
|
|
var deptname = rangeDa.GetDEPTNAME(userid);
|
|
var userstr = new StringBuilder();
|
|
userstr.Append(" select SHOWNAME from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')");
|
|
Database userdb = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
|
|
{
|
|
str = "";
|
|
while (reader.Read())
|
|
{
|
|
if (str == "")
|
|
{
|
|
str = " OPNAME='" + Convert.ToString(reader["SHOWNAME"]) + "' or SALE='" + Convert.ToString(reader["SHOWNAME"]) + "' or DOC='" + Convert.ToString(reader["SHOWNAME"]) + "' or OP='" + Convert.ToString(reader["SHOWNAME"]) + "' ";
|
|
}
|
|
else
|
|
{
|
|
str = str + " or OPNAME='" + Convert.ToString(reader["SHOWNAME"]) + "' or SALE='" + Convert.ToString(reader["SHOWNAME"]) + "' or DOC='" + Convert.ToString(reader["SHOWNAME"]) + "' or OP='" + Convert.ToString(reader["SHOWNAME"]) + "' ";
|
|
};
|
|
}
|
|
reader.Close();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
str = " UPPER(Corpid)='" + companyid + "'";
|
|
}
|
|
|
|
}
|
|
else if (visiblerange == "1")
|
|
{
|
|
str = " UPPER(Corpid)='" + companyid + "'";
|
|
}
|
|
|
|
|
|
//20220823 增加对 info_client.TANGETYPE 的查询支持
|
|
//info_client.TANGETYPE='集团' 则都可以查看
|
|
|
|
if (str != "")
|
|
{
|
|
str = "((" + str + ") or RANGETYPE='集团')";
|
|
}
|
|
|
|
|
|
|
|
return str;
|
|
}
|
|
#endregion
|
|
|
|
#region 客户权限范围
|
|
public static DBResult InsertClientRange(List<MsClient> bodyList, string op,string seltype,string userid)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
if (bodyList != null)
|
|
{
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
foreach (var enumValue in bodyList)
|
|
{
|
|
if (seltype == "2")
|
|
{
|
|
var cmddeletefeedo = db.GetSqlStringCommand("insert into info_client_range select newid(),'" + enumValue.SHORTNAME + "',u.userid,'" + userid + "',GETDATE() from VW_user u where USERID IN (" + op + ") AND USERID NOT IN (SELECT USERID FROM info_client_range WHERE SHORTNAME='" + enumValue.SHORTNAME + "') ");
|
|
db.ExecuteNonQuery(cmddeletefeedo, tran);
|
|
}
|
|
else if (seltype == "1")
|
|
{
|
|
var cmddeletefeedo = db.GetSqlStringCommand("insert into info_client_range select newid(),'" + enumValue.SHORTNAME + "',u.userid,'" + userid + "',GETDATE() from VW_user u where deptgid IN (" + op + ") AND USERID NOT IN (SELECT USERID FROM info_client_range WHERE SHORTNAME='" + enumValue.SHORTNAME + "') ");
|
|
db.ExecuteNonQuery(cmddeletefeedo, tran);
|
|
}
|
|
else if (seltype == "0")
|
|
{
|
|
var cmddeletefeedo = db.GetSqlStringCommand("insert into info_client_range select newid(),'" + enumValue.SHORTNAME + "',u.userid,'" + userid + "',GETDATE() from VW_user u where COMPANYID IN (" + op + ") AND USERID NOT IN (SELECT USERID FROM info_client_range WHERE SHORTNAME='" + enumValue.SHORTNAME + "') ");
|
|
db.ExecuteNonQuery(cmddeletefeedo, tran);
|
|
}
|
|
|
|
}
|
|
result = new DBResult();
|
|
result.Success = true;
|
|
result.Message = "成功";
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "删除出现错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
public static DBResult DelClientRange(List<MsClient> bodyList, string op, string seltype, string userid)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
if (bodyList != null)
|
|
{
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
foreach (var enumValue in bodyList)
|
|
{
|
|
if (seltype == "2")
|
|
{
|
|
var cmddeletefeedo = db.GetSqlStringCommand("delete from info_client_range where USERID IN (" + op + ") and SHORTNAME='"+enumValue.SHORTNAME+"' ");
|
|
db.ExecuteNonQuery(cmddeletefeedo, tran);
|
|
}
|
|
else if (seltype == "1")
|
|
{
|
|
var cmddeletefeedo = db.GetSqlStringCommand("delete from info_client_range where userid in (select userid from VW_user where deptgid IN (" + op + ")) and SHORTNAME='" + enumValue.SHORTNAME + "' ");
|
|
db.ExecuteNonQuery(cmddeletefeedo, tran);
|
|
}
|
|
else if (seltype == "0")
|
|
{
|
|
var cmddeletefeedo = db.GetSqlStringCommand("delete from info_client_range where userid in (select userid from VW_user where companyid IN (" + op + ")) and SHORTNAME='" + enumValue.SHORTNAME + "' ");
|
|
db.ExecuteNonQuery(cmddeletefeedo, tran);
|
|
}
|
|
else if (seltype == "3")
|
|
{
|
|
var cmddeletefeedo = db.GetSqlStringCommand("delete from info_client_range where SHORTNAME='" + enumValue.SHORTNAME + "' ");
|
|
db.ExecuteNonQuery(cmddeletefeedo, tran);
|
|
}
|
|
}
|
|
result = new DBResult();
|
|
result.Success = true;
|
|
result.Message = "成功";
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "删除出现错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
static public int GetRdCount(string strCondition)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT Count(GID) AS CT from info_client (NOLOCK) ");
|
|
if (strCondition.Trim() != String.Empty)
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
var ct = 0;
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
ct = Convert.ToInt16(reader["CT"]);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return ct;
|
|
}
|
|
|
|
static public string GetMaxNum()
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("select ISNULL(max(cast(CUSTNUM as int)),0) as maxxh from info_client(NOLOCK) ");
|
|
var ct = 0;
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
ct = Convert.ToInt16(reader["maxxh"]);
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
ct = ct + 1;
|
|
var custnum = ct.ToString();
|
|
if (custnum.Length < 7) {
|
|
while (custnum.Length < 7) {
|
|
custnum = "0" + custnum;
|
|
}
|
|
}
|
|
|
|
return custnum;
|
|
}
|
|
|
|
static public int GetShipperRdCount(string strCondition)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT Count(info_shipper) AS CT from info_shipper (NOLOCK) ");
|
|
if (strCondition.Trim() != String.Empty)
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
var ct = 0;
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
ct = Convert.ToInt16(reader["CT"]);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return ct;
|
|
}
|
|
|
|
static public int GetFeeTemplateCount(string strCondition)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT Count(GID) AS CT from Cust_Truck_feetemplate (NOLOCK) ");
|
|
if (strCondition.Trim() != String.Empty)
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
var ct = 0;
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
ct = Convert.ToInt16(reader["CT"]);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return ct;
|
|
}
|
|
|
|
static public bool ISCUSTUSE(string CUSTNAME)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT Count(CUSTNAME) AS CT from v_all_client (NOLOCK) where CUSTNAME='" + CUSTNAME + "'");
|
|
var ct = 0;
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
ct = Convert.ToInt16(reader["CT"]);
|
|
}
|
|
reader.Close();
|
|
}
|
|
if (ct > 0)
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
|
|
public static DBResult UpdateEmail(string userid, string email)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase("SHIPPINGBOX");
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
var cmdUpdate =
|
|
db.GetSqlStringCommand(
|
|
@" Update UserInfo set email=@Email where mobile=@Mobile ");
|
|
|
|
cmdUpdate.Parameters.Clear();
|
|
db.AddInParameter(cmdUpdate, "@Email", DbType.String, email);
|
|
db.AddInParameter(cmdUpdate, "@Mobile", DbType.String, userid);
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "保存出现错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "保存成功" + result.Message;
|
|
|
|
return result;
|
|
}
|
|
public static DBResult UpdateCust(string gid, string shortname,string codename)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
var cmdUpdate =
|
|
db.GetSqlStringCommand(
|
|
@" Update info_client set CODENAME=@CODENAME,SHORTNAME=@SHORTNAME where GID=@GID ");
|
|
|
|
cmdUpdate.Parameters.Clear();
|
|
db.AddInParameter(cmdUpdate, "@CODENAME", DbType.String, codename);
|
|
db.AddInParameter(cmdUpdate, "@SHORTNAME", DbType.String, shortname);
|
|
db.AddInParameter(cmdUpdate, "@GID", DbType.String, gid);
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "保存出现错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "保存成功" + result.Message;
|
|
|
|
return result;
|
|
}
|
|
|
|
#region BillNoSet
|
|
|
|
static public List<MsInfoClentGroup> GetClientGroupList(string strCondition)
|
|
{
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT [CODENAME],[SHORTNAME],CODENAME + '-' + SHORTNAME AS CodeAndName,PCORPNAME");
|
|
strSql.Append(" from info_client where 1=1 ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" and " + strCondition);
|
|
}
|
|
return SetClientGroupData(strSql);
|
|
}
|
|
|
|
static public MsInfoClentGroup GetClientGroupData(string condition)
|
|
{
|
|
MsInfoClentGroup data = null;
|
|
var list = GetClientGroupList(condition);
|
|
if (list.Count > 0)
|
|
data = list[0];
|
|
|
|
if (data == null)
|
|
{
|
|
data = new MsInfoClentGroup();
|
|
}
|
|
|
|
return data;
|
|
}
|
|
|
|
|
|
private static List<MsInfoClentGroup> SetClientGroupData(StringBuilder strSql)
|
|
{
|
|
var headList = new List<MsInfoClentGroup>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
MsInfoClentGroup data = new MsInfoClentGroup();
|
|
#region Set DB data to Object
|
|
data.PCORPNAME = Convert.ToString(reader["PCORPNAME"]);
|
|
data.CODENAME = Convert.ToString(reader["CODENAME"]);
|
|
data.SHORTNAME = Convert.ToString(reader["SHORTNAME"]);
|
|
data.CodeAndName = Convert.ToString(reader["CodeAndName"]);
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
#endregion
|
|
|
|
#region 账期列表
|
|
|
|
public static DBResult SaveAccDateDetail(MsInfoContract headData, List<Info_Client_ACCDATEmb> bodyList, string userid)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
|
|
var cmdInsert =
|
|
db.GetSqlStringCommand(
|
|
@"insert into Info_Client_ACCDATE (GID,LINKGID,CONTRACTGID,BGNDATE,ENDDATE,OPLBNAME,SALE,ACCTYPE,ACCSTARTDATE,ACCMONTH,ACCDAYS,ALLOWAMOUNT,REMARK,MODIFIEDUSER,MODIFIEDTIME,BSSOURCE,COMMISSIONRATE)
|
|
values (@GID,@LINKGID,@CONTRACTGID,@BGNDATE,@ENDDATE,@OPLBNAME,@SALE,@ACCTYPE,@ACCSTARTDATE,@ACCMONTH,@ACCDAYS,@ALLOWAMOUNT,@REMARK,@MODIFIEDUSER,@MODIFIEDTIME,@BSSOURCE,@COMMISSIONRATE) ");
|
|
|
|
var cmdUpdate =
|
|
db.GetSqlStringCommand(
|
|
@"update Info_Client_ACCDATE set BGNDATE=@BGNDATE,ENDDATE=@ENDDATE,OPLBNAME=@OPLBNAME,SALE=@SALE,ACCTYPE=@ACCTYPE,ACCSTARTDATE=@ACCSTARTDATE,ACCMONTH=@ACCMONTH,ACCDAYS=@ACCDAYS,ALLOWAMOUNT=@ALLOWAMOUNT,REMARK=@REMARK,MODIFIEDUSER=@MODIFIEDUSER,MODIFIEDTIME=@MODIFIEDTIME,BSSOURCE=@BSSOURCE,COMMISSIONRATE=@COMMISSIONRATE where GID=@GID ");
|
|
if (bodyList != null)
|
|
{
|
|
foreach (var enumValue in bodyList)
|
|
{
|
|
if (enumValue.COMMISSIONRATE == "" || enumValue.COMMISSIONRATE == null) enumValue.COMMISSIONRATE = "0";
|
|
|
|
if (enumValue.CONTRACTGID == "*" || enumValue.CONTRACTGID == "")
|
|
{
|
|
cmdInsert.Parameters.Clear();
|
|
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
db.AddInParameter(cmdInsert, "@CONTRACTGID", DbType.String, headData.GID);
|
|
db.AddInParameter(cmdInsert, "@LINKGID", DbType.String, headData.LINKID);
|
|
db.AddInParameter(cmdInsert, "@BGNDATE", DbType.String, enumValue.BGNDATE);
|
|
db.AddInParameter(cmdInsert, "@ENDDATE", DbType.String, enumValue.ENDDATE);
|
|
db.AddInParameter(cmdInsert, "@OPLBNAME", DbType.String, enumValue.OPLBNAME);
|
|
db.AddInParameter(cmdInsert, "@SALE", DbType.String, enumValue.SALE);
|
|
db.AddInParameter(cmdInsert, "@BSSOURCE", DbType.String, enumValue.BSSOURCE);
|
|
db.AddInParameter(cmdInsert, "@COMMISSIONRATE", DbType.Decimal,Convert.ToDecimal(enumValue.COMMISSIONRATE));
|
|
db.AddInParameter(cmdInsert, "@ACCTYPE", DbType.String, enumValue.ACCTYPE);
|
|
db.AddInParameter(cmdInsert, "@ACCSTARTDATE", DbType.String, enumValue.ACCSTARTDATE);
|
|
db.AddInParameter(cmdInsert, "@ACCMONTH", DbType.String, enumValue.ACCMONTH);
|
|
db.AddInParameter(cmdInsert, "@ACCDAYS", DbType.String, enumValue.ACCDAYS);
|
|
db.AddInParameter(cmdInsert, "@ALLOWAMOUNT", DbType.String, enumValue.ALLOWAMOUNT);
|
|
db.AddInParameter(cmdInsert, "@REMARK", DbType.String, enumValue.REMARK);
|
|
db.AddInParameter(cmdInsert, "@MODIFIEDUSER", DbType.String, userid);
|
|
db.AddInParameter(cmdInsert, "@MODIFIEDTIME", DbType.String, DateTime.Now.ToString());
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
}
|
|
else
|
|
{
|
|
|
|
cmdUpdate.Parameters.Clear();
|
|
db.AddInParameter(cmdUpdate, "@GID", DbType.String, enumValue.GID);
|
|
db.AddInParameter(cmdInsert, "@LINKGID", DbType.String, headData.LINKID);
|
|
db.AddInParameter(cmdUpdate, "@BGNDATE", DbType.String, enumValue.BGNDATE);
|
|
db.AddInParameter(cmdUpdate, "@ENDDATE", DbType.String, enumValue.ENDDATE);
|
|
db.AddInParameter(cmdUpdate, "@OPLBNAME", DbType.String, enumValue.OPLBNAME);
|
|
db.AddInParameter(cmdUpdate, "@SALE", DbType.String, enumValue.SALE);
|
|
db.AddInParameter(cmdUpdate, "@BSSOURCE", DbType.String, enumValue.BSSOURCE);
|
|
db.AddInParameter(cmdUpdate, "@COMMISSIONRATE", DbType.Decimal, Convert.ToDecimal(enumValue.COMMISSIONRATE));
|
|
db.AddInParameter(cmdUpdate, "@ACCTYPE", DbType.String, enumValue.ACCTYPE);
|
|
db.AddInParameter(cmdUpdate, "@ACCSTARTDATE", DbType.String, enumValue.ACCSTARTDATE);
|
|
db.AddInParameter(cmdUpdate, "@ACCMONTH", DbType.String, enumValue.ACCMONTH);
|
|
db.AddInParameter(cmdUpdate, "@ACCDAYS", DbType.String, enumValue.ACCDAYS);
|
|
db.AddInParameter(cmdUpdate, "@ALLOWAMOUNT", DbType.String, enumValue.ALLOWAMOUNT);
|
|
db.AddInParameter(cmdUpdate, "@REMARK", DbType.String, enumValue.REMARK);
|
|
db.AddInParameter(cmdUpdate, "@MODIFIEDUSER", DbType.String, userid);
|
|
db.AddInParameter(cmdUpdate, "@MODIFIEDTIME", DbType.String, DateTime.Now.ToString());
|
|
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
}
|
|
}
|
|
}
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "保存出现错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "保存成功";
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
|
|
static public List<Info_Client_ACCDATEmb> GetACCDATEList ( string strCondition )
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append(" SELECT GID,LINKGID,dbo.trimdate(BGNDATE) BGNDATE,dbo.trimdate(ENDDATE) ENDDATE,OPLBNAME ");
|
|
strSql.Append(" ,SALE,ACCTYPE,ACCSTARTDATE,ACCMONTH,ACCDAYS,ALLOWAMOUNT,MODIFIEDUSER,MODIFIEDUSER,dbo.GetUSER(MODIFIEDUSER) MODIFIEDUSERREF,MODIFIEDTIME,REMARK,CONTRACTGID,BSSOURCE,COMMISSIONRATE ");
|
|
strSql.Append(" from Info_Client_ACCDATE ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
|
|
return SetACCDATEData(strSql);
|
|
}
|
|
private static List<Info_Client_ACCDATEmb> SetACCDATEData ( StringBuilder strSql )
|
|
{
|
|
var headList = new List<Info_Client_ACCDATEmb>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
Info_Client_ACCDATEmb data = new Info_Client_ACCDATEmb();
|
|
#region Set DB data to Object
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
data.LINKGID = Convert.ToString(reader["LINKGID"]);
|
|
data.CONTRACTGID = Convert.ToString(reader["CONTRACTGID"]);
|
|
data.BGNDATE = Convert.ToString(reader["BGNDATE"]);
|
|
data.ENDDATE = Convert.ToString(reader["ENDDATE"]);
|
|
data.OPLBNAME = Convert.ToString(reader["OPLBNAME"]);
|
|
data.SALE = Convert.ToString(reader["SALE"]);
|
|
data.BSSOURCE = Convert.ToString(reader["BSSOURCE"]);
|
|
if (reader["COMMISSIONRATE"] != DBNull.Value)
|
|
data.COMMISSIONRATE = Convert.ToString(reader["COMMISSIONRATE"]);//状态1
|
|
|
|
data.ACCTYPE = Convert.ToString(reader["ACCTYPE"]);
|
|
data.ACCSTARTDATE = Convert.ToString(reader["ACCSTARTDATE"]);
|
|
data.ACCMONTH = Convert.ToString(reader["ACCMONTH"]);
|
|
data.ACCDAYS = Convert.ToString(reader["ACCDAYS"]);
|
|
data.ALLOWAMOUNT = Convert.ToString(reader["ALLOWAMOUNT"]);
|
|
data.MODIFIEDUSER = Convert.ToString(reader["MODIFIEDUSER"]);
|
|
data.MODIFIEDUSERREF = Convert.ToString(reader["MODIFIEDUSERREF"]);
|
|
data.MODIFIEDTIME = Convert.ToString(reader["MODIFIEDTIME"]);
|
|
data.REMARK = Convert.ToString(reader["REMARK"]);
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
#endregion
|
|
|
|
#region 固定费用维护
|
|
static public List<Info_Client_GDFYWHmb> GetGDFYWHList(string strCondition, string sort = null)
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append("GID,FEENAME,CUSTOMERNAME,UNIT");
|
|
strSql.Append(",CURRENCY,UNITPRICE,REMARK,CREATEUSER,CREATETIME,EXCHANGERATE,ISCTN,TAXRATE,TAX");
|
|
strSql.Append(",(case ISCTN when 1 then '是' else '否' end) as ISCTNREF,ISINVOICE,ISADVANCEDPAY,FEEFRT ");
|
|
strSql.Append(" from cust_fee_templatedetail ");
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
{
|
|
strSql.Append(" order by " + sortstring);
|
|
}
|
|
|
|
return SetBodyData(strSql);
|
|
}
|
|
|
|
private static List<Info_Client_GDFYWHmb> SetBodyData(StringBuilder strSql)
|
|
{
|
|
var bodyList = new List<Info_Client_GDFYWHmb>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
Info_Client_GDFYWHmb data = new Info_Client_GDFYWHmb();
|
|
#region Set DB data to Object
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
if (reader["UNITPRICE"] != DBNull.Value)
|
|
data.UNITPRICE = Convert.ToDecimal(reader["UNITPRICE"]);
|
|
if (reader["EXCHANGERATE"] != DBNull.Value)
|
|
data.EXCHANGERATE = Convert.ToDecimal(reader["EXCHANGERATE"]);
|
|
if (reader["TAXRATE"] != DBNull.Value)
|
|
data.TAXRATE = Convert.ToDecimal(reader["TAXRATE"]);
|
|
if (reader["TAX"] != DBNull.Value)
|
|
data.TAX = Convert.ToDecimal(reader["TAX"]);
|
|
data.FEENAME = Convert.ToString(reader["FEENAME"]);
|
|
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
|
|
data.UNIT = Convert.ToString(reader["UNIT"]);
|
|
data.CURRENCY = Convert.ToString(reader["CURRENCY"]);
|
|
data.REMARK = Convert.ToString(reader["REMARK"]);
|
|
data.FEEFRT = Convert.ToString(reader["FEEFRT"]);
|
|
data.CREATEUSER = Convert.ToString(reader["CREATEUSER"]);
|
|
data.CREATETIME = Convert.ToString(reader["CREATETIME"]);
|
|
if (reader["ISCTN"] != DBNull.Value)
|
|
data.ISCTN = Convert.ToBoolean(reader["ISCTN"]);
|
|
data.ISCTNREF = Convert.ToString(reader["ISCTNREF"]);
|
|
if (reader["ISINVOICE"] != DBNull.Value)
|
|
data.ISINVOICE = Convert.ToBoolean(reader["ISINVOICE"]);
|
|
if (reader["ISADVANCEDPAY"] != DBNull.Value)
|
|
data.ISADVANCEDPAY = Convert.ToBoolean(reader["ISADVANCEDPAY"]);
|
|
#endregion
|
|
|
|
bodyList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
return bodyList;
|
|
}
|
|
#endregion
|
|
|
|
#region 获得结算日期
|
|
static public STLDATEmb GetSTLDATE ( string CUSTOMERNAME,string OPLBNAME,string BUSDATE,string SALE )
|
|
{
|
|
var strcondition=new StringBuilder();
|
|
strcondition.Append(" LINKGID=(SELECT GID from info_client where Shortname='" + CUSTOMERNAME
|
|
+ "') and Convert(datetime,'" + BUSDATE + "') between BGNDATE and ENDDATE and (OPLBNAME='" + OPLBNAME + "' or ISNULL(OPLBNAME,'')='') ");
|
|
|
|
if (!string.IsNullOrEmpty(SALE))
|
|
{
|
|
strcondition.Append(" and (isnull(SALE,'')='" + SALE + "' or isnull(SALE,'')='') ");
|
|
}
|
|
else {
|
|
strcondition.Append(" and isnull(SALE,'')='' ");
|
|
}
|
|
strcondition.Append(" order by SALE desc,BGNDATE ASC ");
|
|
|
|
var ClientACCDATEList = GetACCDATEList(strcondition.ToString());
|
|
if (ClientACCDATEList.Count==0){
|
|
var _r=new STLDATEmb();
|
|
_r.STLDATE=BUSDATE;
|
|
_r.STLNAME = "";
|
|
_r.BSSOURCE = "";
|
|
return _r;
|
|
}else{
|
|
var CA = ClientACCDATEList[0];
|
|
|
|
var _r = new STLDATEmb();
|
|
_r.STLNAME = CA.ACCTYPE;
|
|
_r.BSSOURCE = CA.BSSOURCE;
|
|
|
|
if (CA.ACCTYPE == "月结") {
|
|
//延迟月份 指定日
|
|
var Date_0=Convert.ToDateTime(BUSDATE);
|
|
var year_0 =Date_0.Year;
|
|
var month_0=Date_0.Month;
|
|
var day_0 = Date_0.Day;
|
|
|
|
var month = Convert.ToInt32(CA.ACCMONTH);
|
|
if (month<=0) month=1;
|
|
//var tmonth = Convert.ToInt32((Math.Ceiling(Convert.ToDecimal(month_0 / month)) + 1) * month );
|
|
//if (tmonth > 12) {
|
|
// var years = Convert.ToDouble(tmonth / 12);
|
|
// tmonth = tmonth % 12;
|
|
// year_0=year_0+Convert.ToInt32( Math.Floor(years));
|
|
//}
|
|
|
|
var day = Convert.ToInt32(CA.ACCDAYS);
|
|
|
|
//var d = new DateTime();
|
|
var d = Date_0.AddMonths(month);
|
|
|
|
if (day > 28) {
|
|
d = new DateTime(d.Year, d.Month, 1).AddMonths(1).AddDays(-1);
|
|
// d = Convert.ToDateTime(d).AddMonths(1).AddDays(-1);
|
|
}else{
|
|
if (day == 0) {
|
|
d = Date_0.AddMonths(month);
|
|
}else
|
|
d = new DateTime(d.Year, d.Month, day);
|
|
}
|
|
|
|
|
|
_r.STLDATE = d.ToShortDateString();
|
|
return _r;
|
|
}else
|
|
if (CA.ACCTYPE == "约定天数")// CA.ACCTYPE == "固定期限"||
|
|
{
|
|
var month = Convert.ToInt32(CA.ACCMONTH);
|
|
var Date = Convert.ToDateTime(BUSDATE);//.AddMonths(month);
|
|
Date = Date.AddDays(Convert.ToInt32(CA.ACCDAYS));
|
|
|
|
_r.STLDATE = Date.ToShortDateString();
|
|
return _r;
|
|
}
|
|
else
|
|
if (CA.ACCTYPE == "旬结")// CA.ACCTYPE == "固定期限"||
|
|
{
|
|
var month = Convert.ToInt32(CA.ACCMONTH);
|
|
var Date = Convert.ToDateTime(BUSDATE);//.AddMonths(month);
|
|
Date = Date.AddDays(Convert.ToInt32(10));
|
|
|
|
_r.STLDATE = Date.ToShortDateString();
|
|
return _r;
|
|
}
|
|
else
|
|
if (CA.ACCTYPE == "半月结")
|
|
{
|
|
var _busdate = Convert.ToDateTime(BUSDATE);
|
|
var Date = Convert.ToDateTime(BUSDATE);
|
|
|
|
if (_busdate.Day < 16)
|
|
{
|
|
var TMPDAYS =Convert.ToInt32(CA.ACCDAYS);
|
|
if (Convert.ToInt32(CA.ACCDAYS) > 28) {
|
|
var tmpdate= new DateTime(_busdate.Year, _busdate.Month,1);
|
|
tmpdate = tmpdate.AddMonths(1).AddDays(-1);
|
|
if (tmpdate.Day < Convert.ToInt32(CA.ACCDAYS)) TMPDAYS = tmpdate.Day;
|
|
}
|
|
|
|
Date = new DateTime(_busdate.Year, _busdate.Month, TMPDAYS);
|
|
}
|
|
else
|
|
{
|
|
var TMPDAYS = Convert.ToInt32(CA.ACCMONTH);
|
|
if (Convert.ToInt32(CA.ACCDAYS) > 28)
|
|
{
|
|
var tmpdate = new DateTime(_busdate.Year, _busdate.Month, 1);
|
|
tmpdate = tmpdate.AddMonths(2).AddDays(-1);
|
|
if (tmpdate.Day < Convert.ToInt32(CA.ACCMONTH)) TMPDAYS = tmpdate.Day;
|
|
}
|
|
Date = new DateTime(_busdate.Year, _busdate.Month, TMPDAYS);
|
|
Date = Date.AddMonths(1);
|
|
}
|
|
|
|
_r.STLDATE = Date.ToShortDateString();
|
|
return _r;
|
|
}
|
|
else
|
|
if (CA.ACCTYPE == "季结")
|
|
{
|
|
var _busdate = Convert.ToDateTime(BUSDATE);
|
|
var Date = _busdate.AddDays(Convert.ToInt32(Convert.ToInt16(CA.ACCMONTH)*90));
|
|
|
|
_r.STLDATE = Date.ToShortDateString();
|
|
return _r;
|
|
}
|
|
else
|
|
{
|
|
_r.STLDATE = BUSDATE;
|
|
return _r;
|
|
}
|
|
/*if (CA.ACCTYPE == "约定天数")
|
|
{
|
|
|
|
}*/
|
|
}
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 获得账期天数
|
|
static public STLDATEmb GetSTLDAYS ( string CUSTOMERNAME, string OPLBNAME, string BUSDATE, string SALE )
|
|
{
|
|
var strcondition = new StringBuilder();
|
|
strcondition.Append(" LINKGID=(SELECT GID from info_client where Shortname='" + CUSTOMERNAME
|
|
+ "') and Convert(datetime,(dbo.trimdate(BGNDATE)+' 00:00:00'))<=Convert(datetime,'" + BUSDATE + "') "
|
|
+ " and Convert(datetime,(dbo.trimdate(ENDDATE)+' 23:59:59'))>=Convert(datetime,'" + BUSDATE + "') and OPLBNAME='" + OPLBNAME + "' ");
|
|
|
|
if (!string.IsNullOrEmpty(SALE))
|
|
{
|
|
strcondition.Append(" and SALE='" + SALE + "' ");
|
|
}
|
|
strcondition.Append(" order by BGNDATE ");
|
|
|
|
var ClientACCDATEList = GetACCDATEList(strcondition.ToString());
|
|
if (ClientACCDATEList.Count == 0)
|
|
{
|
|
var _r = new STLDATEmb();
|
|
_r.STLDATE = BUSDATE;
|
|
_r.STLNAME = "";
|
|
return _r;
|
|
}
|
|
else
|
|
{
|
|
var CA = ClientACCDATEList[0];
|
|
|
|
var _r = new STLDATEmb();
|
|
_r.STLNAME = CA.ACCTYPE;
|
|
|
|
if (CA.ACCTYPE == "月结")
|
|
{
|
|
//延迟月份 指定日
|
|
var Date_0 = Convert.ToDateTime(BUSDATE);
|
|
var year_0 = Date_0.Year;
|
|
var month_0 = Date_0.Month;
|
|
|
|
var month = Convert.ToInt32(CA.ACCMONTH);
|
|
if (month <= 0) month = 1;
|
|
var tmonth = Convert.ToInt32((Math.Ceiling(Convert.ToDecimal(month_0 / month)) + 1) * month);
|
|
if (tmonth > 12)
|
|
{
|
|
tmonth = tmonth % 12;
|
|
var years = Convert.ToDouble(year_0 / 12);
|
|
year_0 = year_0 + Convert.ToInt32(Math.Floor(years));
|
|
}
|
|
|
|
var day = Convert.ToInt32(CA.ACCDAYS);
|
|
|
|
var d = new DateTime();
|
|
|
|
if (day > 28)
|
|
{
|
|
var Date = new DateTime(year_0, tmonth, 1);
|
|
d = Convert.ToDateTime(Date).AddMonths(1).AddDays(-1);
|
|
}
|
|
else
|
|
{
|
|
d = new DateTime(year_0, tmonth, day);
|
|
}
|
|
|
|
|
|
DateTime d1 = Convert.ToDateTime(BUSDATE);
|
|
DateTime d2 = Convert.ToDateTime(d.ToShortDateString());
|
|
|
|
TimeSpan d3 = d2.Subtract(d1);
|
|
|
|
_r.STLDAYS = d3.Days.ToString();
|
|
return _r;
|
|
}
|
|
else
|
|
if (CA.ACCTYPE == "约定天数")// CA.ACCTYPE == "固定期限"||
|
|
{
|
|
var month = Convert.ToInt32(CA.ACCMONTH);
|
|
var Date = Convert.ToDateTime(BUSDATE);//.AddMonths(month);
|
|
Date = Date.AddDays(Convert.ToInt32(CA.ACCDAYS));
|
|
|
|
_r.STLDATE = Date.ToShortDateString();
|
|
DateTime d1 = Convert.ToDateTime(BUSDATE);
|
|
DateTime d2 = Convert.ToDateTime(Date.ToShortDateString());
|
|
|
|
TimeSpan d3 = d2.Subtract(d1);
|
|
|
|
_r.STLDAYS = d3.Days.ToString();
|
|
return _r;
|
|
}
|
|
else
|
|
if (CA.ACCTYPE == "半月结")
|
|
{
|
|
var _busdate = Convert.ToDateTime(BUSDATE);
|
|
var Date = Convert.ToDateTime(BUSDATE);
|
|
|
|
if (_busdate.Day < 16)
|
|
{
|
|
Date = new DateTime(_busdate.Year, _busdate.Month, Convert.ToInt32(CA.ACCDAYS));
|
|
}
|
|
else
|
|
{
|
|
Date = new DateTime(_busdate.Year, _busdate.Month, Convert.ToInt32(CA.ACCMONTH));
|
|
Date = Date.AddMonths(1);
|
|
}
|
|
|
|
_r.STLDATE = Date.ToShortDateString();
|
|
|
|
DateTime d1 = Convert.ToDateTime(BUSDATE);
|
|
DateTime d2 = Convert.ToDateTime(Date.ToShortDateString());
|
|
|
|
TimeSpan d3 = d2.Subtract(d1);
|
|
|
|
_r.STLDAYS = d3.Days.ToString();
|
|
return _r;
|
|
}
|
|
else
|
|
{
|
|
_r.STLDATE = BUSDATE;
|
|
return _r;
|
|
}
|
|
/*if (CA.ACCTYPE == "约定天数")
|
|
{
|
|
|
|
}*/
|
|
}
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 往来单位审核
|
|
public static DBResult IC_Start ( List<MsClient> _List, string USERID ) //申请签入
|
|
{
|
|
var WorkFlowName = "MsInfoClient_Audit";
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
var result = new DBResult();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
foreach (var _bill in _List)
|
|
{
|
|
Resultmb WorkResult = WorkFlowDAL.WorkFlowStart(WorkFlowName, _bill.GID, USERID,_bill.SHORTNAME, _bill.GID,"");
|
|
|
|
if (WorkResult.Success == true)
|
|
{
|
|
if (WorkResult.islast != true)
|
|
{
|
|
var cmdupdate = db.GetSqlStringCommand("update Info_client set BLSTATUS=2 where GID=@GID and BLSTATUS in(1,6) ");
|
|
cmdupdate.Parameters.Clear();
|
|
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
}
|
|
else {
|
|
var cmdupdate = db.GetSqlStringCommand("update Info_client set BLSTATUS=0 where GID=@GID and BLSTATUS in(1,6) ");
|
|
cmdupdate.Parameters.Clear();
|
|
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
result.Success = false;
|
|
result.Message = "提交错误!";
|
|
}
|
|
}
|
|
|
|
result = new DBResult();
|
|
result.Success = true;
|
|
result.Message = "提交成功";
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "提交错误,请重试或联系系统管理员";
|
|
|
|
//return result;
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
public static DBResult IC_back ( List<MsClient> _List, string USERID ) //申请签入_撤回
|
|
{
|
|
var WorkFlowName = "MsInfoClient_Audit";
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
var result = new DBResult();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
foreach (var _bill in _List)
|
|
{
|
|
|
|
Resultmb WorkResult = WorkFlowDAL.WorkFlowReset(WorkFlowName, _bill.GID, USERID);
|
|
|
|
if (WorkResult.Success == true)
|
|
{
|
|
var cmdupdate = db.GetSqlStringCommand("update Info_Client set BLSTATUS=1 where GID=@GID and BLSTATUS=2 ");
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
}
|
|
else
|
|
{
|
|
result.Success = false;
|
|
result.Message = "提交错误!";
|
|
}
|
|
}
|
|
|
|
result = new DBResult();
|
|
result.Success = true;
|
|
result.Message = "提交成功";
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "提交错误,请重试或联系系统管理员";
|
|
|
|
//return result;
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
public static DBResult IC_Auditback ( List<MsClient> _List, string USERID ) //申请签入_驳回
|
|
{
|
|
var WorkFlowName = "MsInfoClient_Audit";
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
var result = new DBResult();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
foreach (var _bill in _List)
|
|
{
|
|
|
|
Resultmb WorkResult = WorkFlowDAL.DeleteWorkFlowDo(WorkFlowName, _bill.GID, USERID, "");
|
|
|
|
if (WorkResult.Success == true)
|
|
{
|
|
var cmdupdate = db.GetSqlStringCommand("update Info_client set BLSTATUS=6 where GID=@GID and BLSTATUS in (2,0) ");
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
}
|
|
else
|
|
{
|
|
result.Success = false;
|
|
result.Message = "提交错误!";
|
|
}
|
|
}
|
|
|
|
result = new DBResult();
|
|
result.Success = true;
|
|
result.Message = "提交成功";
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "提交错误,请重试或联系系统管理员";
|
|
|
|
//return result;
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
public static DBResult IC_Audit ( List<MsClient> _List, string USERID ) //申请签入_驳回
|
|
{
|
|
var WorkFlowName = "MsInfoClient_Audit";
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
var result = new DBResult();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
foreach (var _bill in _List)
|
|
{
|
|
|
|
Resultmb WorkResult = WorkFlowDAL.InsertWorkFlowDo(WorkFlowName, _bill.GID, USERID,_bill.SHORTNAME);
|
|
|
|
if (WorkResult.Success == true)
|
|
{
|
|
if (WorkResult.islast == true)
|
|
{
|
|
var cmdupdate = db.GetSqlStringCommand("update Info_Client set BLSTATUS=0 where GID=@GID and BLSTATUS =2 ");
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
//db.AddInParameter(cmdupdate, "@AUDITDATE", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, _bill.GID);
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
result.Success = false;
|
|
result.Message = "提交错误!";
|
|
}
|
|
}
|
|
|
|
result = new DBResult();
|
|
result.Success = true;
|
|
result.Message = "提交成功";
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "提交错误,请重试或联系系统管理员";
|
|
|
|
//return result;
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 往来单位图片
|
|
|
|
static public List<MsInfoClientImgmb> GetImgList(string strCondition, string sort = null,string USERID="1")
|
|
{
|
|
var strSql = new StringBuilder();
|
|
|
|
var rangstr = "";
|
|
|
|
if (USERID == "1") rangstr = "1=2";
|
|
else
|
|
{
|
|
rangstr = BasicDataRefDAL.GetVisableRange("modInfoClinet_info", USERID, "", "CREATEUSER");
|
|
}
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
{
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strCondition = strCondition + " and " + rangstr;
|
|
}
|
|
else
|
|
{
|
|
strCondition = rangstr;
|
|
}
|
|
}
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" and " + strCondition);
|
|
}
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
{
|
|
strSql.Append(" order by " + sortstring);
|
|
}
|
|
else
|
|
{
|
|
strSql.Append(" order by NAME ");
|
|
}
|
|
return SetImgData(strSql);
|
|
}
|
|
|
|
private static List<MsInfoClientImgmb> SetImgData(StringBuilder strSql)//, List<HcUtility.Core.Fieldmb> fieldlist
|
|
{
|
|
var headList = new List<MsInfoClientImgmb>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
string sql = MsInfoClientImgmb.getSQL() + strSql;
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
|
|
////根据字段名设定同名属性值
|
|
MsInfoClientImgmb data = new MsInfoClientImgmb();
|
|
data.SetExtendValue(reader);
|
|
|
|
data.SetValue("INDATABASE_OLD", data.GetValue("INDATABASE"));
|
|
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
return headList;
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region 独立版本功能 设定往来单位权限
|
|
public static DBResult SetRange(string RANGETYPE, string data,string USERID)
|
|
|
|
{
|
|
//1集团 2分公司 3个人
|
|
//1集团 即清空所有往来单位人员权限
|
|
//2分公司 效果为选中所有该往来单位录入人的本公司人员
|
|
//3个人 效果为选中录入人本人 和他所在公司的操作部、财务
|
|
|
|
var dataList = JsonConvert.Deserialize<List<MsClient>>(data);
|
|
var result = new DBResult();
|
|
|
|
//op为一串用逗号隔开的带单引号userid 形如 'aaaaa','bbbbb'
|
|
var op = "";
|
|
var seltype = "2";
|
|
var cdc = new CommonDataContext();
|
|
|
|
if (RANGETYPE == "1")
|
|
{
|
|
result = MsInfoClientDAL.DelClientRange(dataList, op, "3", USERID);
|
|
|
|
SetInfoclientLogic_range(dataList, RANGETYPE);
|
|
}
|
|
if (RANGETYPE == "2")
|
|
{
|
|
result = MsInfoClientDAL.DelClientRange(dataList, op, "3", USERID);
|
|
//获取本公司的所有人gid
|
|
var 本公司人员 = new List<VW_user_md>();
|
|
foreach (var item in dataList)
|
|
{
|
|
本公司人员 = cdc.VW_user.Where(x => x.COMPANYID == item.CORPID).ToList();
|
|
op = GetUseridStr(本公司人员);
|
|
|
|
var templist = dataList.Where(x => x.GID == item.GID).ToList();
|
|
|
|
result = MsInfoClientDAL.InsertClientRange(templist, op, seltype, USERID);
|
|
|
|
if (!result.Success) return result;
|
|
}
|
|
SetInfoclientLogic_range(dataList, RANGETYPE);
|
|
}
|
|
if (RANGETYPE == "3")
|
|
{
|
|
result = MsInfoClientDAL.DelClientRange(dataList, op, "3", USERID);
|
|
|
|
//获取本公司非销售人员
|
|
//user_userattribute.userid属于本公司 且attri 3C91140E-6FB6-4B5A-B5AB-30E59E3CBBED
|
|
//var 本公司人员 = new List<VW_user_md>();
|
|
foreach (var item in dataList)
|
|
{
|
|
//本公司人员 = cdc.VW_user.Where(x => x.COMPANYID == item.CORPID).ToList();
|
|
var 本人 = cdc.VW_user.FirstOrDefault(x => x.SHOWNAME == item.OPNAME);
|
|
|
|
var 全部人员 = cdc.VW_user.Where(x => x.USERID!= 本人.USERID).ToList();
|
|
op = 获取非销售人员str(全部人员);
|
|
|
|
|
|
|
|
if (op != "") op += ",";
|
|
op += $"'{本人.USERID}'";
|
|
result = MsInfoClientDAL.InsertClientRange(dataList, op, seltype, USERID);
|
|
if (!result.Success) return result;
|
|
}
|
|
SetInfoclientLogic_range(dataList, RANGETYPE);
|
|
}
|
|
return result;
|
|
|
|
}
|
|
|
|
private static string GetUseridStr(List<VW_user_md> vwuserlist)
|
|
{
|
|
var result = "";
|
|
foreach (var user in vwuserlist)
|
|
{
|
|
if (result != "") result += ",";
|
|
result += $"'{user.USERID}'";
|
|
}
|
|
return result;
|
|
}
|
|
|
|
private static string 获取非销售人员str(List<VW_user_md> vwuserlist)
|
|
{
|
|
var cdc = new CommonDataContext();
|
|
|
|
var useridlist = vwuserlist.Select(s => s.USERID).ToList();
|
|
|
|
var 非销售List = cdc.user_userattribute.Where(x => useridlist.Contains(x.USERID) && x.ATTRIBUTEID == "3C91140E-6FB6-4B5A-B5AB-30E59E3CBBED" && x.VALUE == "false").ToList();
|
|
|
|
var 非销售UseridList = 非销售List.Select(s => s.USERID).ToList();
|
|
|
|
var result = "";
|
|
foreach (var userid in 非销售UseridList)
|
|
{
|
|
if (result != "") result += ",";
|
|
result += $"'{userid}'";
|
|
}
|
|
return result;
|
|
}
|
|
|
|
private static void SetInfoclientLogic_range(List<MsClient> MsClients, string RANGETYPE) {
|
|
foreach (var client in MsClients) {
|
|
var logicinfo= new Dictionary<string, string>();
|
|
logicinfo.Add("权限范围", RANGETYPE);
|
|
BasicDataRefDAL.SaveLogicInfo(client.GID, "权限范围", logicinfo);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 参照部分
|
|
|
|
#region FileList
|
|
static public List<MsUpLoadFile> GetUpLoadFileList ( string strCondition )
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append("GID,PID,FILENAME,FILETYPE,IMGFILE,UPLOADEMPLY,UPLOADDATE,FILEPATH");
|
|
strSql.Append(" from info_files ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
return SetUpLoadFileData(strSql);
|
|
}
|
|
|
|
|
|
private static List<MsUpLoadFile> SetUpLoadFileData ( StringBuilder strSql )
|
|
{
|
|
var headList = new List<MsUpLoadFile>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
MsUpLoadFile data = new MsUpLoadFile();
|
|
#region Set DB data to Object
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
data.PID = Convert.ToString(reader["PID"]);
|
|
data.UPLOADEMPLY = Convert.ToString(reader["UPLOADEMPLY"]);
|
|
data.UPLOADDATE = Convert.ToString(reader["UPLOADDATE"]);
|
|
data.FILETYPE = Convert.ToString(reader["FILETYPE"]);
|
|
data.FILENAME = Convert.ToString(reader["FILENAME"]);
|
|
data.FILEPATH = Convert.ToString(reader["FILEPATH"]);
|
|
|
|
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
public static bool UpdateFileData ( HttpRequestBase request, string filename,string Path, string GID, out string msg )
|
|
{
|
|
var isSucess = false;
|
|
msg = "";
|
|
|
|
Stream stream = new FileStream(filename, FileMode.Open);
|
|
|
|
byte[] data = new byte[stream.Length];
|
|
stream.Read(data, 0, data.Length);
|
|
stream.Close();
|
|
|
|
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
|
|
{
|
|
try
|
|
{
|
|
|
|
const string insertSql = @" delete from info_files where PID=@PID0 "+
|
|
" insert info_files (GID,PID,UPLOADEMPLY,UPLOADDATE,FILENAME,FILETYPE,IMGFILE) "+
|
|
" VALUES(@GID,@PID,@UPLOADEMPLY,@UPLOADDATE,@FILENAME,@FILETYPE,@Image) ";
|
|
|
|
|
|
SqlParameter[] insertParms = new SqlParameter[] {
|
|
new SqlParameter("@GID",SqlDbType.VarChar),
|
|
new SqlParameter("@PID",SqlDbType.VarChar),
|
|
new SqlParameter("@UPLOADEMPLY",SqlDbType.VarChar),
|
|
new SqlParameter("@UPLOADDATE",SqlDbType.VarChar),
|
|
new SqlParameter("@FILENAME",SqlDbType.VarChar),
|
|
new SqlParameter("@FILETYPE",SqlDbType.VarChar),
|
|
new SqlParameter("@PID0",SqlDbType.VarChar),
|
|
new SqlParameter("@Image",SqlDbType.Image)
|
|
};
|
|
|
|
insertParms[0].Value = Guid.NewGuid().ToString();
|
|
insertParms[1].Value = GID;
|
|
insertParms[2].Value = CookieConfig.GetCookie_UserName(request);
|
|
insertParms[3].Value = DateTime.Now.ToString();
|
|
insertParms[4].Value = Path;
|
|
insertParms[5].Value = "结算单位联系人签名";
|
|
insertParms[6].Value = GID;
|
|
insertParms[7].Value = data;
|
|
|
|
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, insertSql, insertParms);
|
|
|
|
sqlTran.Commit();
|
|
|
|
isSucess = true;//状态为1表示插入成功
|
|
}
|
|
catch (Exception execError)
|
|
{
|
|
isSucess = false;//有异常,插入失败
|
|
sqlTran.Rollback();
|
|
msg = execError.Message;
|
|
}
|
|
finally
|
|
{
|
|
SqlHelper.CloseConnection();
|
|
}
|
|
}
|
|
return isSucess;
|
|
}
|
|
|
|
static public int SaveFileList ( IList<MsUpLoadFile> tempFileEntities, string tempBSNO )
|
|
{
|
|
int iResult = 0;
|
|
const string SQL_INSERT = @"insert info_files (GID,PID,UPLOADEMPLY,UPLOADDATE,FILENAME,FILETYPE) VALUES(@GID,@PID,@UPLOADEMPLY,@UPLOADDATE,@FILENAME,@FILETYPE) ";
|
|
const string SQL_UPDATE = @"update info_files SET FILENAME=@FILENAME where GID=@GID";
|
|
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
|
|
{
|
|
try
|
|
{
|
|
|
|
foreach (MsUpLoadFile fileEntity in tempFileEntities)
|
|
{
|
|
if (fileEntity.PID == "*" || fileEntity.PID == "")
|
|
{
|
|
SqlParameter[] insertParms = new SqlParameter[] {
|
|
new SqlParameter("@GID",SqlDbType.VarChar),
|
|
new SqlParameter("@PID",SqlDbType.VarChar),
|
|
new SqlParameter("@UPLOADEMPLY",SqlDbType.VarChar),
|
|
new SqlParameter("@UPLOADDATE",SqlDbType.VarChar),
|
|
new SqlParameter("@FILENAME",SqlDbType.VarChar),
|
|
new SqlParameter("@FILETYPE",SqlDbType.VarChar)
|
|
|
|
};
|
|
|
|
insertParms[0].Value = fileEntity.GID;
|
|
insertParms[1].Value = tempBSNO;
|
|
insertParms[2].Value = fileEntity.UPLOADEMPLY;
|
|
insertParms[3].Value = fileEntity.UPLOADDATE;
|
|
insertParms[4].Value = fileEntity.FILENAME;
|
|
insertParms[5].Value = fileEntity.FILETYPE;
|
|
|
|
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_INSERT, insertParms);
|
|
}
|
|
else
|
|
{
|
|
SqlParameter[] updateParms = new SqlParameter[] {
|
|
new SqlParameter("@FILENAME",SqlDbType.VarChar)
|
|
|
|
};
|
|
|
|
updateParms[0].Value = fileEntity.GID;
|
|
updateParms[1].Value = tempBSNO;
|
|
updateParms[2].Value = fileEntity.UPLOADEMPLY;
|
|
updateParms[3].Value = fileEntity.UPLOADDATE;
|
|
updateParms[4].Value = fileEntity.FILENAME;
|
|
|
|
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_UPDATE, updateParms);
|
|
}
|
|
}
|
|
sqlTran.Commit();
|
|
|
|
iResult = 1;//状态为1表示插入成功
|
|
}
|
|
catch (Exception execError)
|
|
{
|
|
iResult = -1;//有异常,插入失败
|
|
sqlTran.Rollback();
|
|
iResult = -2;//插入异常,事务已回滚成功
|
|
throw execError;
|
|
}
|
|
finally
|
|
{
|
|
SqlHelper.CloseConnection();
|
|
}
|
|
}
|
|
|
|
return iResult;
|
|
}
|
|
|
|
static public int DeleteUploadFile ( string tempGId )
|
|
{
|
|
int iResult = 0;
|
|
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
|
|
{
|
|
try
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("Delete from info_files where ");
|
|
strSql.Append(" GId in (" + tempGId + ")");
|
|
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, strSql.ToString());
|
|
sqlTran.Commit();
|
|
|
|
iResult = 1;//状态为1表示插入成功
|
|
}
|
|
catch (Exception execError)
|
|
{
|
|
iResult = -1;//有异常,插入失败
|
|
sqlTran.Rollback();
|
|
iResult = -2;//插入异常,事务已回滚成功
|
|
throw execError;
|
|
}
|
|
finally
|
|
{
|
|
SqlHelper.CloseConnection();
|
|
}
|
|
}
|
|
|
|
return iResult;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|