|
|
|
|
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.MvcShipping.Comm.Cookie;
|
|
|
|
|
using DSWeb.EntityDA;
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
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("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],(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");
|
|
|
|
|
strSql.Append(",(select EnumValueName from tSysEnumValue where enumtypeid=99024 and enumvalueid=blstatus) BLSTATUSREF");
|
|
|
|
|
strSql.Append(",RCVMode");
|
|
|
|
|
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(" from info_client where 1=1 ");
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
strSql.Append(",(select EnumValueName from tSysEnumValue where enumtypeid=99024 and enumvalueid=blstatus) BLSTATUSREF");
|
|
|
|
|
strSql.Append(",RCVMode");
|
|
|
|
|
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(" 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]");
|
|
|
|
|
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,FEEFRT,BSSOURCE,BLSTATUS,SALECORPID,TICHENG,FENCHENG");
|
|
|
|
|
strSql.Append(",(select EnumValueName from tSysEnumValue where enumtypeid=99024 and enumvalueid=blstatus) BLSTATUSREF");
|
|
|
|
|
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(" 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");
|
|
|
|
|
strSql.Append(",(select EnumValueName from tSysEnumValue where enumtypeid=99024 and enumvalueid=blstatus) BLSTATUSREF");
|
|
|
|
|
strSql.Append(",RCVMode,'' ACCREMARK,'' ACCMONTH,'' ALLOWAMOUNT");
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
var headList = new List<MsClient>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
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"]);//分成
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
headList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
return headList;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 联系人
|
|
|
|
|
|
|
|
|
|
static public List<MsClientContact> GetContactDataList(string strCondition,string sort = null)
|
|
|
|
|
{
|
|
|
|
|
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]");
|
|
|
|
|
strSql.Append(",(select filename from info_files where pid=info_client_contact.gid) PICURL");
|
|
|
|
|
strSql.Append(" from info_client_contact 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 SetContactData(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static public MsClientContact GetContactData(string condition)
|
|
|
|
|
{
|
|
|
|
|
MsClientContact data = null;
|
|
|
|
|
var list = GetContactDataList(condition);
|
|
|
|
|
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
|
|
|
|
|
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"]);
|
|
|
|
|
|
|
|
|
|
#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)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
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 ");
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
MsInfoContract data = null;
|
|
|
|
|
var list = GetContractDataList(condition);
|
|
|
|
|
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 < 4)
|
|
|
|
|
{
|
|
|
|
|
linecount++;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
linecount++;
|
|
|
|
|
string[] custlist = Regex.Split(line, "~~", RegexOptions.IgnoreCase);
|
|
|
|
|
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(" 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(",(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"]);
|
|
|
|
|
|
|
|
|
|
#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"]);
|
|
|
|
|
|
|
|
|
|
#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 = "";
|
|
|
|
|
|
|
|
|
|
#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)
|
|
|
|
|
values (@GID,@LINKID,@CODENAME,@CURRENCY,@BANKNAME,@ACCOUNT,@REMARK,@FINANCESOFTCODE,@CREATEUSER,@CREATETIME,@ACCOUNTNAME) ");
|
|
|
|
|
|
|
|
|
|
var cmdUpdate =
|
|
|
|
|
db.GetSqlStringCommand(
|
|
|
|
|
@"update info_client_bank set CODENAME=@CODENAME,CURRENCY=@CURRENCY,BANKNAME=@BANKNAME,ACCOUNT=@ACCOUNT,REMARK=@REMARK,FINANCESOFTCODE=@FINANCESOFTCODE
|
|
|
|
|
,ACCOUNTNAME=@ACCOUNTNAME 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.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.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")
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
str = " UPPER(Corpid)='" + companyid + "'";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (visiblerange == "1")
|
|
|
|
|
{
|
|
|
|
|
str = " UPPER(Corpid)='" + companyid + "'";
|
|
|
|
|
}
|
|
|
|
|
if (str != "")
|
|
|
|
|
{
|
|
|
|
|
str = "(" + str + ")";
|
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#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,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.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 == "半月结")
|
|
|
|
|
{
|
|
|
|
|
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();
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
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 参照部分
|
|
|
|
|
|
|
|
|
|
#region FileList
|
|
|
|
|
|
|
|
|
|
#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[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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|