三元财务API

T_Cus_CustomerBase.cs 56KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117
  1. using CallCenterApi.DB;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Data.SqlClient;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace CallCenterApi.DAL
  10. {
  11. /// <summary>
  12. /// 数据访问类:T_Cus_CustomerBase
  13. /// </summary>
  14. public partial class T_Cus_CustomerBase
  15. {
  16. public T_Cus_CustomerBase()
  17. { }
  18. #region BasicMethod
  19. /// <summary>
  20. /// 得到最大ID
  21. /// </summary>
  22. public int GetMaxId()
  23. {
  24. return DbHelperSQL.GetMaxID("F_CustomerId", "T_Cus_CustomerBase");
  25. }
  26. /// <summary>
  27. /// 是否存在该记录
  28. /// </summary>
  29. public bool Exists(int F_CustomerId)
  30. {
  31. StringBuilder strSql = new StringBuilder();
  32. strSql.Append("select count(1) from T_Cus_CustomerBase");
  33. strSql.Append(" where F_CustomerId=@F_CustomerId");
  34. SqlParameter[] parameters = {
  35. new SqlParameter("@F_CustomerId", SqlDbType.Int,4)
  36. };
  37. parameters[0].Value = F_CustomerId;
  38. return DbHelperSQL.Exists(strSql.ToString(), parameters);
  39. }
  40. /// <summary>
  41. /// 增加一条数据
  42. /// </summary>
  43. public int Add(CallCenterApi.Model.T_Cus_CustomerBase model)
  44. {
  45. StringBuilder strSql = new StringBuilder();
  46. strSql.Append("insert into T_Cus_CustomerBase(");
  47. strSql.Append("F_CustomerName,F_CustomerCode,F_CustomerEName,F_CustomerPym,F_Layer,F_CustomerLayer,F_CategoryId,F_TradeId,F_RegionId,F_IndustryId,F_Address,F_Url,F_Telephone,F_Mobile,F_Fax,F_Email,F_Website,F_PostCode,F_ScaleResume,F_BusinessProfile,F_BusinessLicenseID,F_TaxID,F_OpeningBank,F_BankAccount,F_LegalRepresentative,F_LegalRepresentativeCardID,F_Nature,F_Kind,F_CustomerType,F_MainProduct,F_CustomerFrom,F_TrackInfo,F_TrackState,F_ImportDegree,F_IntentProduct,F_CreateBy,F_CreatedOn,F_ModifyBy,F_ModifiedOn,F_DeleteFlag,F_StatusCode,F_ServiceDept,F_ChargeName,F_ChargeTelephone,F_Province,F_ProductLine,F_ChargeDept,F_AfterSaleName,F_CustomerNature,F_CustomerClass,F_CustomerIndustry,F_RelationShipClass,F_CurrentVersion,F_SystemStartTime,F_QualityGuaranteeEndTime,F_AfterSaleTelephone,F_Notes,F_SystemType,F_City,F_CustomerStatus,F_DeviceCount,F_MaintenanceType,F_ERPCustomerCode,F_ServiceDeptID,F_ProductLineID,F_AfterSaleNameID,F_CustomerNatureID,F_CustomerClassID,F_RelationShipClassID,F_CityID,F_WxOpenId,F_Password)");
  48. strSql.Append(" values (");
  49. strSql.Append("@F_CustomerName,@F_CustomerCode,@F_CustomerEName,@F_CustomerPym,@F_Layer,@F_CustomerLayer,@F_CategoryId,@F_TradeId,@F_RegionId,@F_IndustryId,@F_Address,@F_Url,@F_Telephone,@F_Mobile,@F_Fax,@F_Email,@F_Website,@F_PostCode,@F_ScaleResume,@F_BusinessProfile,@F_BusinessLicenseID,@F_TaxID,@F_OpeningBank,@F_BankAccount,@F_LegalRepresentative,@F_LegalRepresentativeCardID,@F_Nature,@F_Kind,@F_CustomerType,@F_MainProduct,@F_CustomerFrom,@F_TrackInfo,@F_TrackState,@F_ImportDegree,@F_IntentProduct,@F_CreateBy,@F_CreatedOn,@F_ModifyBy,@F_ModifiedOn,@F_DeleteFlag,@F_StatusCode,@F_ServiceDept,@F_ChargeName,@F_ChargeTelephone,@F_Province,@F_ProductLine,@F_ChargeDept,@F_AfterSaleName,@F_CustomerNature,@F_CustomerClass,@F_CustomerIndustry,@F_RelationShipClass,@F_CurrentVersion,@F_SystemStartTime,@F_QualityGuaranteeEndTime,@F_AfterSaleTelephone,@F_Notes,@F_SystemType,@F_City,@F_CustomerStatus,@F_DeviceCount,@F_MaintenanceType,@F_ERPCustomerCode,@F_ServiceDeptID,@F_ProductLineID,@F_AfterSaleNameID,@F_CustomerNatureID,@F_CustomerClassID,@F_RelationShipClassID,@F_CityID,@F_WxOpenId,@F_Password)");
  50. strSql.Append(";select @@IDENTITY");
  51. SqlParameter[] parameters = {
  52. new SqlParameter("@F_CustomerName", SqlDbType.NVarChar,200),
  53. new SqlParameter("@F_CustomerCode", SqlDbType.VarChar,100),
  54. new SqlParameter("@F_CustomerEName", SqlDbType.NVarChar,800),
  55. new SqlParameter("@F_CustomerPym", SqlDbType.NVarChar,50),
  56. new SqlParameter("@F_Layer", SqlDbType.SmallInt,2),
  57. new SqlParameter("@F_CustomerLayer", SqlDbType.NVarChar,50),
  58. new SqlParameter("@F_CategoryId", SqlDbType.Int,4),
  59. new SqlParameter("@F_TradeId", SqlDbType.Int,4),
  60. new SqlParameter("@F_RegionId", SqlDbType.Int,4),
  61. new SqlParameter("@F_IndustryId", SqlDbType.Int,4),
  62. new SqlParameter("@F_Address", SqlDbType.NVarChar,300),
  63. new SqlParameter("@F_Url", SqlDbType.NVarChar,200),
  64. new SqlParameter("@F_Telephone", SqlDbType.NVarChar,200),
  65. new SqlParameter("@F_Mobile", SqlDbType.NVarChar,200),
  66. new SqlParameter("@F_Fax", SqlDbType.NVarChar,200),
  67. new SqlParameter("@F_Email", SqlDbType.VarChar,200),
  68. new SqlParameter("@F_Website", SqlDbType.VarChar,200),
  69. new SqlParameter("@F_PostCode", SqlDbType.NVarChar,50),
  70. new SqlParameter("@F_ScaleResume", SqlDbType.NVarChar,2000),
  71. new SqlParameter("@F_BusinessProfile", SqlDbType.NVarChar,2000),
  72. new SqlParameter("@F_BusinessLicenseID", SqlDbType.VarChar,80),
  73. new SqlParameter("@F_TaxID", SqlDbType.VarChar,80),
  74. new SqlParameter("@F_OpeningBank", SqlDbType.NVarChar,100),
  75. new SqlParameter("@F_BankAccount", SqlDbType.VarChar,80),
  76. new SqlParameter("@F_LegalRepresentative", SqlDbType.VarChar,50),
  77. new SqlParameter("@F_LegalRepresentativeCardID", SqlDbType.VarChar,30),
  78. new SqlParameter("@F_Nature", SqlDbType.NVarChar,80),
  79. new SqlParameter("@F_Kind", SqlDbType.NVarChar,80),
  80. new SqlParameter("@F_CustomerType", SqlDbType.Int,4),
  81. new SqlParameter("@F_MainProduct", SqlDbType.Text),
  82. new SqlParameter("@F_CustomerFrom", SqlDbType.NVarChar,200),
  83. new SqlParameter("@F_TrackInfo", SqlDbType.NVarChar,200),
  84. new SqlParameter("@F_TrackState", SqlDbType.NVarChar,50),
  85. new SqlParameter("@F_ImportDegree", SqlDbType.NVarChar,50),
  86. new SqlParameter("@F_IntentProduct", SqlDbType.Text),
  87. new SqlParameter("@F_CreateBy", SqlDbType.Int,4),
  88. new SqlParameter("@F_CreatedOn", SqlDbType.DateTime),
  89. new SqlParameter("@F_ModifyBy", SqlDbType.Int,4),
  90. new SqlParameter("@F_ModifiedOn", SqlDbType.DateTime),
  91. new SqlParameter("@F_DeleteFlag", SqlDbType.SmallInt,2),
  92. new SqlParameter("@F_StatusCode", SqlDbType.SmallInt,2),
  93. new SqlParameter("@F_ServiceDept", SqlDbType.NVarChar,20),
  94. new SqlParameter("@F_ChargeName", SqlDbType.NVarChar,20),
  95. new SqlParameter("@F_ChargeTelephone", SqlDbType.VarChar,15),
  96. new SqlParameter("@F_Province", SqlDbType.NVarChar,20),
  97. new SqlParameter("@F_ProductLine", SqlDbType.NVarChar,50),
  98. new SqlParameter("@F_ChargeDept", SqlDbType.NVarChar,20),
  99. new SqlParameter("@F_AfterSaleName", SqlDbType.NVarChar,20),
  100. new SqlParameter("@F_CustomerNature", SqlDbType.NVarChar,20),
  101. new SqlParameter("@F_CustomerClass", SqlDbType.NVarChar,10),
  102. new SqlParameter("@F_CustomerIndustry", SqlDbType.NVarChar,10),
  103. new SqlParameter("@F_RelationShipClass", SqlDbType.NVarChar,10),
  104. new SqlParameter("@F_CurrentVersion", SqlDbType.VarChar,100),
  105. new SqlParameter("@F_SystemStartTime", SqlDbType.DateTime),
  106. new SqlParameter("@F_QualityGuaranteeEndTime", SqlDbType.DateTime),
  107. new SqlParameter("@F_AfterSaleTelephone", SqlDbType.VarChar,15),
  108. new SqlParameter("@F_Notes", SqlDbType.NVarChar,500),
  109. new SqlParameter("@F_SystemType", SqlDbType.NVarChar,100),
  110. new SqlParameter("@F_City", SqlDbType.NVarChar,10),
  111. new SqlParameter("@F_CustomerStatus", SqlDbType.NVarChar,10),
  112. new SqlParameter("@F_DeviceCount", SqlDbType.Int,4),
  113. new SqlParameter("@F_MaintenanceType", SqlDbType.NVarChar,30),
  114. new SqlParameter("@F_ERPCustomerCode", SqlDbType.VarChar,100),
  115. new SqlParameter("@F_ServiceDeptID", SqlDbType.Int,4),
  116. new SqlParameter("@F_ProductLineID", SqlDbType.Int,4),
  117. new SqlParameter("@F_AfterSaleNameID", SqlDbType.Int,4),
  118. new SqlParameter("@F_CustomerNatureID", SqlDbType.Int,4),
  119. new SqlParameter("@F_CustomerClassID", SqlDbType.Int,4),
  120. new SqlParameter("@F_RelationShipClassID", SqlDbType.Int,4),
  121. new SqlParameter("@F_CityID", SqlDbType.Int,4),
  122. new SqlParameter("@F_WxOpenId", SqlDbType.VarChar,300),
  123. new SqlParameter("@F_Password", SqlDbType.VarChar,100)};
  124. parameters[0].Value = model.F_CustomerName;
  125. parameters[1].Value = model.F_CustomerCode;
  126. parameters[2].Value = model.F_CustomerEName;
  127. parameters[3].Value = model.F_CustomerPym;
  128. parameters[4].Value = model.F_Layer;
  129. parameters[5].Value = model.F_CustomerLayer;
  130. parameters[6].Value = model.F_CategoryId;
  131. parameters[7].Value = model.F_TradeId;
  132. parameters[8].Value = model.F_RegionId;
  133. parameters[9].Value = model.F_IndustryId;
  134. parameters[10].Value = model.F_Address;
  135. parameters[11].Value = model.F_Url;
  136. parameters[12].Value = model.F_Telephone;
  137. parameters[13].Value = model.F_Mobile;
  138. parameters[14].Value = model.F_Fax;
  139. parameters[15].Value = model.F_Email;
  140. parameters[16].Value = model.F_Website;
  141. parameters[17].Value = model.F_PostCode;
  142. parameters[18].Value = model.F_ScaleResume;
  143. parameters[19].Value = model.F_BusinessProfile;
  144. parameters[20].Value = model.F_BusinessLicenseID;
  145. parameters[21].Value = model.F_TaxID;
  146. parameters[22].Value = model.F_OpeningBank;
  147. parameters[23].Value = model.F_BankAccount;
  148. parameters[24].Value = model.F_LegalRepresentative;
  149. parameters[25].Value = model.F_LegalRepresentativeCardID;
  150. parameters[26].Value = model.F_Nature;
  151. parameters[27].Value = model.F_Kind;
  152. parameters[28].Value = model.F_CustomerType;
  153. parameters[29].Value = model.F_MainProduct;
  154. parameters[30].Value = model.F_CustomerFrom;
  155. parameters[31].Value = model.F_TrackInfo;
  156. parameters[32].Value = model.F_TrackState;
  157. parameters[33].Value = model.F_ImportDegree;
  158. parameters[34].Value = model.F_IntentProduct;
  159. parameters[35].Value = model.F_CreateBy;
  160. parameters[36].Value = model.F_CreatedOn;
  161. parameters[37].Value = model.F_ModifyBy;
  162. parameters[38].Value = model.F_ModifiedOn;
  163. parameters[39].Value = model.F_DeleteFlag;
  164. parameters[40].Value = model.F_StatusCode;
  165. parameters[41].Value = model.F_ServiceDept;
  166. parameters[42].Value = model.F_ChargeName;
  167. parameters[43].Value = model.F_ChargeTelephone;
  168. parameters[44].Value = model.F_Province;
  169. parameters[45].Value = model.F_ProductLine;
  170. parameters[46].Value = model.F_ChargeDept;
  171. parameters[47].Value = model.F_AfterSaleName;
  172. parameters[48].Value = model.F_CustomerNature;
  173. parameters[49].Value = model.F_CustomerClass;
  174. parameters[50].Value = model.F_CustomerIndustry;
  175. parameters[51].Value = model.F_RelationShipClass;
  176. parameters[52].Value = model.F_CurrentVersion;
  177. parameters[53].Value = model.F_SystemStartTime;
  178. parameters[54].Value = model.F_QualityGuaranteeEndTime;
  179. parameters[55].Value = model.F_AfterSaleTelephone;
  180. parameters[56].Value = model.F_Notes;
  181. parameters[57].Value = model.F_SystemType;
  182. parameters[58].Value = model.F_City;
  183. parameters[59].Value = model.F_CustomerStatus;
  184. parameters[60].Value = model.F_DeviceCount;
  185. parameters[61].Value = model.F_MaintenanceType;
  186. parameters[62].Value = model.F_ERPCustomerCode;
  187. parameters[63].Value = model.F_ServiceDeptID;
  188. parameters[64].Value = model.F_ProductLineID;
  189. parameters[65].Value = model.F_AfterSaleNameID;
  190. parameters[66].Value = model.F_CustomerNatureID;
  191. parameters[67].Value = model.F_CustomerClassID;
  192. parameters[68].Value = model.F_RelationShipClassID;
  193. parameters[69].Value = model.F_CityID;
  194. parameters[70].Value = model.F_WxOpenId;
  195. parameters[71].Value = model.F_Password;
  196. object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
  197. if (obj == null)
  198. {
  199. return 0;
  200. }
  201. else
  202. {
  203. return Convert.ToInt32(obj);
  204. }
  205. }
  206. /// <summary>
  207. /// 判断来电单位是否存在
  208. /// </summary>
  209. /// <returns></returns>
  210. public bool LDdepExist(string lddep)
  211. {
  212. bool lddepexists = false;
  213. List<string> dep = null;
  214. string str = "select distinct F_CustomerIndustry from T_Cus_CustomerBase";
  215. DataSet ds = DbHelperSQL.Query(str);
  216. if (ds != null && ds.Tables[0].Rows.Count > 0)
  217. {
  218. foreach (DataRow dr in ds.Tables[0].Rows)
  219. {
  220. if (!string.IsNullOrEmpty(dr[0].ToString()))
  221. {
  222. dep.Add(dr[0].ToString());
  223. }
  224. }
  225. if (dep.Contains(lddep))
  226. lddepexists = true;
  227. }
  228. return lddepexists;
  229. }
  230. /// <summary>
  231. /// 获取来电单位
  232. /// </summary>
  233. /// <returns></returns>
  234. public List<string> GetLDdep()
  235. {
  236. List<string> lddep = new List<string>();
  237. string str = "select distinct F_CustomerIndustry,F_RelationShipClass from T_Cus_CustomerBase where F_DeleteFlag=0 and ((F_CustomerIndustry <> '') or (F_RelationShipClass <> ''))";
  238. DataSet ds = DbHelperSQL.Query(str);
  239. if (ds != null && ds.Tables[0].Rows.Count > 0)
  240. {
  241. foreach (DataRow dr in ds.Tables[0].Rows)
  242. {
  243. for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
  244. {
  245. string ldname = dr[i].ToString();
  246. if (!string.IsNullOrEmpty(ldname) && !lddep.Contains(ldname))
  247. {
  248. lddep.Add(ldname);
  249. }
  250. }
  251. }
  252. }
  253. return lddep;
  254. }
  255. /// <summary>
  256. /// 更新一条数据
  257. /// </summary>
  258. public bool Update(CallCenterApi.Model.T_Cus_CustomerBase model)
  259. {
  260. StringBuilder strSql = new StringBuilder();
  261. strSql.Append("update T_Cus_CustomerBase set ");
  262. strSql.Append("F_CustomerName=@F_CustomerName,");
  263. strSql.Append("F_CustomerCode=@F_CustomerCode,");
  264. strSql.Append("F_CustomerEName=@F_CustomerEName,");
  265. strSql.Append("F_CustomerPym=@F_CustomerPym,");
  266. strSql.Append("F_Layer=@F_Layer,");
  267. strSql.Append("F_CustomerLayer=@F_CustomerLayer,");
  268. strSql.Append("F_CategoryId=@F_CategoryId,");
  269. strSql.Append("F_TradeId=@F_TradeId,");
  270. strSql.Append("F_RegionId=@F_RegionId,");
  271. strSql.Append("F_IndustryId=@F_IndustryId,");
  272. strSql.Append("F_Address=@F_Address,");
  273. strSql.Append("F_Url=@F_Url,");
  274. strSql.Append("F_Telephone=@F_Telephone,");
  275. strSql.Append("F_Mobile=@F_Mobile,");
  276. strSql.Append("F_Fax=@F_Fax,");
  277. strSql.Append("F_Email=@F_Email,");
  278. strSql.Append("F_Website=@F_Website,");
  279. strSql.Append("F_PostCode=@F_PostCode,");
  280. strSql.Append("F_ScaleResume=@F_ScaleResume,");
  281. strSql.Append("F_BusinessProfile=@F_BusinessProfile,");
  282. strSql.Append("F_BusinessLicenseID=@F_BusinessLicenseID,");
  283. strSql.Append("F_TaxID=@F_TaxID,");
  284. strSql.Append("F_OpeningBank=@F_OpeningBank,");
  285. strSql.Append("F_BankAccount=@F_BankAccount,");
  286. strSql.Append("F_LegalRepresentative=@F_LegalRepresentative,");
  287. strSql.Append("F_LegalRepresentativeCardID=@F_LegalRepresentativeCardID,");
  288. strSql.Append("F_Nature=@F_Nature,");
  289. strSql.Append("F_Kind=@F_Kind,");
  290. strSql.Append("F_CustomerType=@F_CustomerType,");
  291. strSql.Append("F_MainProduct=@F_MainProduct,");
  292. strSql.Append("F_CustomerFrom=@F_CustomerFrom,");
  293. strSql.Append("F_TrackInfo=@F_TrackInfo,");
  294. strSql.Append("F_TrackState=@F_TrackState,");
  295. strSql.Append("F_ImportDegree=@F_ImportDegree,");
  296. strSql.Append("F_IntentProduct=@F_IntentProduct,");
  297. strSql.Append("F_CreateBy=@F_CreateBy,");
  298. strSql.Append("F_CreatedOn=@F_CreatedOn,");
  299. strSql.Append("F_ModifyBy=@F_ModifyBy,");
  300. strSql.Append("F_ModifiedOn=@F_ModifiedOn,");
  301. strSql.Append("F_DeleteFlag=@F_DeleteFlag,");
  302. strSql.Append("F_StatusCode=@F_StatusCode,");
  303. strSql.Append("F_ServiceDept=@F_ServiceDept,");
  304. strSql.Append("F_ChargeName=@F_ChargeName,");
  305. strSql.Append("F_ChargeTelephone=@F_ChargeTelephone,");
  306. strSql.Append("F_Province=@F_Province,");
  307. strSql.Append("F_ProductLine=@F_ProductLine,");
  308. strSql.Append("F_ChargeDept=@F_ChargeDept,");
  309. strSql.Append("F_AfterSaleName=@F_AfterSaleName,");
  310. strSql.Append("F_CustomerNature=@F_CustomerNature,");
  311. strSql.Append("F_CustomerClass=@F_CustomerClass,");
  312. strSql.Append("F_CustomerIndustry=@F_CustomerIndustry,");
  313. strSql.Append("F_RelationShipClass=@F_RelationShipClass,");
  314. strSql.Append("F_CurrentVersion=@F_CurrentVersion,");
  315. strSql.Append("F_SystemStartTime=@F_SystemStartTime,");
  316. strSql.Append("F_QualityGuaranteeEndTime=@F_QualityGuaranteeEndTime,");
  317. strSql.Append("F_AfterSaleTelephone=@F_AfterSaleTelephone,");
  318. strSql.Append("F_Notes=@F_Notes,");
  319. strSql.Append("F_SystemType=@F_SystemType,");
  320. strSql.Append("F_City=@F_City,");
  321. strSql.Append("F_CustomerStatus=@F_CustomerStatus,");
  322. strSql.Append("F_DeviceCount=@F_DeviceCount,");
  323. strSql.Append("F_MaintenanceType=@F_MaintenanceType,");
  324. strSql.Append("F_ERPCustomerCode=@F_ERPCustomerCode,");
  325. strSql.Append("F_ServiceDeptID=@F_ServiceDeptID,");
  326. strSql.Append("F_ProductLineID=@F_ProductLineID,");
  327. strSql.Append("F_AfterSaleNameID=@F_AfterSaleNameID,");
  328. strSql.Append("F_CustomerNatureID=@F_CustomerNatureID,");
  329. strSql.Append("F_CustomerClassID=@F_CustomerClassID,");
  330. strSql.Append("F_RelationShipClassID=@F_RelationShipClassID,");
  331. strSql.Append("F_CityID=@F_CityID,");
  332. strSql.Append("F_WxOpenId=@F_WxOpenId,");
  333. strSql.Append("F_Password=@F_Password");
  334. strSql.Append(" where F_CustomerId=@F_CustomerId");
  335. SqlParameter[] parameters = {
  336. new SqlParameter("@F_CustomerName", SqlDbType.NVarChar,200),
  337. new SqlParameter("@F_CustomerCode", SqlDbType.VarChar,100),
  338. new SqlParameter("@F_CustomerEName", SqlDbType.NVarChar,800),
  339. new SqlParameter("@F_CustomerPym", SqlDbType.NVarChar,50),
  340. new SqlParameter("@F_Layer", SqlDbType.SmallInt,2),
  341. new SqlParameter("@F_CustomerLayer", SqlDbType.NVarChar,50),
  342. new SqlParameter("@F_CategoryId", SqlDbType.Int,4),
  343. new SqlParameter("@F_TradeId", SqlDbType.Int,4),
  344. new SqlParameter("@F_RegionId", SqlDbType.Int,4),
  345. new SqlParameter("@F_IndustryId", SqlDbType.Int,4),
  346. new SqlParameter("@F_Address", SqlDbType.NVarChar,300),
  347. new SqlParameter("@F_Url", SqlDbType.NVarChar,200),
  348. new SqlParameter("@F_Telephone", SqlDbType.NVarChar,200),
  349. new SqlParameter("@F_Mobile", SqlDbType.NVarChar,200),
  350. new SqlParameter("@F_Fax", SqlDbType.NVarChar,200),
  351. new SqlParameter("@F_Email", SqlDbType.VarChar,200),
  352. new SqlParameter("@F_Website", SqlDbType.VarChar,200),
  353. new SqlParameter("@F_PostCode", SqlDbType.NVarChar,50),
  354. new SqlParameter("@F_ScaleResume", SqlDbType.NVarChar,2000),
  355. new SqlParameter("@F_BusinessProfile", SqlDbType.NVarChar,2000),
  356. new SqlParameter("@F_BusinessLicenseID", SqlDbType.VarChar,80),
  357. new SqlParameter("@F_TaxID", SqlDbType.VarChar,80),
  358. new SqlParameter("@F_OpeningBank", SqlDbType.NVarChar,100),
  359. new SqlParameter("@F_BankAccount", SqlDbType.VarChar,80),
  360. new SqlParameter("@F_LegalRepresentative", SqlDbType.VarChar,50),
  361. new SqlParameter("@F_LegalRepresentativeCardID", SqlDbType.VarChar,30),
  362. new SqlParameter("@F_Nature", SqlDbType.NVarChar,80),
  363. new SqlParameter("@F_Kind", SqlDbType.NVarChar,80),
  364. new SqlParameter("@F_CustomerType", SqlDbType.Int,4),
  365. new SqlParameter("@F_MainProduct", SqlDbType.Text),
  366. new SqlParameter("@F_CustomerFrom", SqlDbType.NVarChar,200),
  367. new SqlParameter("@F_TrackInfo", SqlDbType.NVarChar,200),
  368. new SqlParameter("@F_TrackState", SqlDbType.NVarChar,50),
  369. new SqlParameter("@F_ImportDegree", SqlDbType.NVarChar,50),
  370. new SqlParameter("@F_IntentProduct", SqlDbType.Text),
  371. new SqlParameter("@F_CreateBy", SqlDbType.Int,4),
  372. new SqlParameter("@F_CreatedOn", SqlDbType.DateTime),
  373. new SqlParameter("@F_ModifyBy", SqlDbType.Int,4),
  374. new SqlParameter("@F_ModifiedOn", SqlDbType.DateTime),
  375. new SqlParameter("@F_DeleteFlag", SqlDbType.SmallInt,2),
  376. new SqlParameter("@F_StatusCode", SqlDbType.SmallInt,2),
  377. new SqlParameter("@F_ServiceDept", SqlDbType.NVarChar,20),
  378. new SqlParameter("@F_ChargeName", SqlDbType.NVarChar,20),
  379. new SqlParameter("@F_ChargeTelephone", SqlDbType.VarChar,15),
  380. new SqlParameter("@F_Province", SqlDbType.NVarChar,20),
  381. new SqlParameter("@F_ProductLine", SqlDbType.NVarChar,50),
  382. new SqlParameter("@F_ChargeDept", SqlDbType.NVarChar,20),
  383. new SqlParameter("@F_AfterSaleName", SqlDbType.NVarChar,20),
  384. new SqlParameter("@F_CustomerNature", SqlDbType.NVarChar,20),
  385. new SqlParameter("@F_CustomerClass", SqlDbType.NVarChar,10),
  386. new SqlParameter("@F_CustomerIndustry", SqlDbType.NVarChar,10),
  387. new SqlParameter("@F_RelationShipClass", SqlDbType.NVarChar,10),
  388. new SqlParameter("@F_CurrentVersion", SqlDbType.VarChar,100),
  389. new SqlParameter("@F_SystemStartTime", SqlDbType.DateTime),
  390. new SqlParameter("@F_QualityGuaranteeEndTime", SqlDbType.DateTime),
  391. new SqlParameter("@F_AfterSaleTelephone", SqlDbType.VarChar,15),
  392. new SqlParameter("@F_Notes", SqlDbType.NVarChar,500),
  393. new SqlParameter("@F_SystemType", SqlDbType.NVarChar,100),
  394. new SqlParameter("@F_City", SqlDbType.NVarChar,10),
  395. new SqlParameter("@F_CustomerStatus", SqlDbType.NVarChar,10),
  396. new SqlParameter("@F_DeviceCount", SqlDbType.Int,4),
  397. new SqlParameter("@F_MaintenanceType", SqlDbType.NVarChar,30),
  398. new SqlParameter("@F_ERPCustomerCode", SqlDbType.VarChar,100),
  399. new SqlParameter("@F_ServiceDeptID", SqlDbType.Int,4),
  400. new SqlParameter("@F_ProductLineID", SqlDbType.Int,4),
  401. new SqlParameter("@F_AfterSaleNameID", SqlDbType.Int,4),
  402. new SqlParameter("@F_CustomerNatureID", SqlDbType.Int,4),
  403. new SqlParameter("@F_CustomerClassID", SqlDbType.Int,4),
  404. new SqlParameter("@F_RelationShipClassID", SqlDbType.Int,4),
  405. new SqlParameter("@F_CityID", SqlDbType.Int,4),
  406. new SqlParameter("@F_WxOpenId", SqlDbType.NVarChar,300),
  407. new SqlParameter("@F_Password", SqlDbType.VarChar,100),
  408. new SqlParameter("@F_CustomerId", SqlDbType.Int,4)};
  409. parameters[0].Value = model.F_CustomerName;
  410. parameters[1].Value = model.F_CustomerCode;
  411. parameters[2].Value = model.F_CustomerEName;
  412. parameters[3].Value = model.F_CustomerPym;
  413. parameters[4].Value = model.F_Layer;
  414. parameters[5].Value = model.F_CustomerLayer;
  415. parameters[6].Value = model.F_CategoryId;
  416. parameters[7].Value = model.F_TradeId;
  417. parameters[8].Value = model.F_RegionId;
  418. parameters[9].Value = model.F_IndustryId;
  419. parameters[10].Value = model.F_Address;
  420. parameters[11].Value = model.F_Url;
  421. parameters[12].Value = model.F_Telephone;
  422. parameters[13].Value = model.F_Mobile;
  423. parameters[14].Value = model.F_Fax;
  424. parameters[15].Value = model.F_Email;
  425. parameters[16].Value = model.F_Website;
  426. parameters[17].Value = model.F_PostCode;
  427. parameters[18].Value = model.F_ScaleResume;
  428. parameters[19].Value = model.F_BusinessProfile;
  429. parameters[20].Value = model.F_BusinessLicenseID;
  430. parameters[21].Value = model.F_TaxID;
  431. parameters[22].Value = model.F_OpeningBank;
  432. parameters[23].Value = model.F_BankAccount;
  433. parameters[24].Value = model.F_LegalRepresentative;
  434. parameters[25].Value = model.F_LegalRepresentativeCardID;
  435. parameters[26].Value = model.F_Nature;
  436. parameters[27].Value = model.F_Kind;
  437. parameters[28].Value = model.F_CustomerType;
  438. parameters[29].Value = model.F_MainProduct;
  439. parameters[30].Value = model.F_CustomerFrom;
  440. parameters[31].Value = model.F_TrackInfo;
  441. parameters[32].Value = model.F_TrackState;
  442. parameters[33].Value = model.F_ImportDegree;
  443. parameters[34].Value = model.F_IntentProduct;
  444. parameters[35].Value = model.F_CreateBy;
  445. parameters[36].Value = model.F_CreatedOn;
  446. parameters[37].Value = model.F_ModifyBy;
  447. parameters[38].Value = model.F_ModifiedOn;
  448. parameters[39].Value = model.F_DeleteFlag;
  449. parameters[40].Value = model.F_StatusCode;
  450. parameters[41].Value = model.F_ServiceDept;
  451. parameters[42].Value = model.F_ChargeName;
  452. parameters[43].Value = model.F_ChargeTelephone;
  453. parameters[44].Value = model.F_Province;
  454. parameters[45].Value = model.F_ProductLine;
  455. parameters[46].Value = model.F_ChargeDept;
  456. parameters[47].Value = model.F_AfterSaleName;
  457. parameters[48].Value = model.F_CustomerNature;
  458. parameters[49].Value = model.F_CustomerClass;
  459. parameters[50].Value = model.F_CustomerIndustry;
  460. parameters[51].Value = model.F_RelationShipClass;
  461. parameters[52].Value = model.F_CurrentVersion;
  462. parameters[53].Value = model.F_SystemStartTime;
  463. parameters[54].Value = model.F_QualityGuaranteeEndTime;
  464. parameters[55].Value = model.F_AfterSaleTelephone;
  465. parameters[56].Value = model.F_Notes;
  466. parameters[57].Value = model.F_SystemType;
  467. parameters[58].Value = model.F_City;
  468. parameters[59].Value = model.F_CustomerStatus;
  469. parameters[60].Value = model.F_DeviceCount;
  470. parameters[61].Value = model.F_MaintenanceType;
  471. parameters[62].Value = model.F_ERPCustomerCode;
  472. parameters[63].Value = model.F_ServiceDeptID;
  473. parameters[64].Value = model.F_ProductLineID;
  474. parameters[65].Value = model.F_AfterSaleNameID;
  475. parameters[66].Value = model.F_CustomerNatureID;
  476. parameters[67].Value = model.F_CustomerClassID;
  477. parameters[68].Value = model.F_RelationShipClassID;
  478. parameters[69].Value = model.F_CityID;
  479. parameters[70].Value = model.F_WxOpenId;
  480. parameters[71].Value = model.F_Password;
  481. parameters[72].Value = model.F_CustomerId;
  482. int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
  483. if (rows > 0)
  484. {
  485. return true;
  486. }
  487. else
  488. {
  489. return false;
  490. }
  491. }
  492. /// <summary>
  493. /// 删除一条数据
  494. /// </summary>
  495. public bool Delete(int F_CustomerId)
  496. {
  497. StringBuilder strSql = new StringBuilder();
  498. //strSql.Append("delete from T_Cus_CustomerBase ");
  499. strSql.Append("update T_Cus_CustomerBase set F_DeleteFlag=1");
  500. strSql.Append(" where F_CustomerId=@F_CustomerId");
  501. SqlParameter[] parameters = {
  502. new SqlParameter("@F_CustomerId", SqlDbType.Int,4)
  503. };
  504. parameters[0].Value = F_CustomerId;
  505. int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
  506. if (rows > 0)
  507. {
  508. return true;
  509. }
  510. else
  511. {
  512. return false;
  513. }
  514. }
  515. /// <summary>
  516. /// 批量删除数据
  517. /// </summary>
  518. public bool DeleteList(string F_CustomerIdlist)
  519. {
  520. StringBuilder strSql = new StringBuilder();
  521. //strSql.Append("delete from T_Cus_CustomerBase ");
  522. strSql.Append("update T_Cus_CustomerBase set F_DeleteFlag=1");
  523. strSql.Append(" where F_CustomerId in (" + F_CustomerIdlist + ") ");
  524. int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
  525. if (rows > 0)
  526. {
  527. return true;
  528. }
  529. else
  530. {
  531. return false;
  532. }
  533. }
  534. /// <summary>
  535. /// 得到一个对象实体
  536. /// </summary>
  537. public CallCenterApi.Model.T_Cus_CustomerBase GetModel(int F_CustomerId)
  538. {
  539. StringBuilder strSql = new StringBuilder();
  540. strSql.Append("select top 1 F_CustomerId,F_CustomerName,F_CustomerCode,F_CustomerEName,F_CustomerPym,F_Layer,F_CustomerLayer,F_CategoryId,F_TradeId,F_RegionId,F_IndustryId,F_Address,F_Url,F_Telephone,F_Mobile,F_Fax,F_Email,F_Website,F_PostCode,F_ScaleResume,F_BusinessProfile,F_BusinessLicenseID,F_TaxID,F_OpeningBank,F_BankAccount,F_LegalRepresentative,F_LegalRepresentativeCardID,F_Nature,F_Kind,F_CustomerType,F_MainProduct,F_CustomerFrom,F_TrackInfo,F_TrackState,F_ImportDegree,F_IntentProduct,F_CreateBy,F_CreatedOn,F_ModifyBy,F_ModifiedOn,F_DeleteFlag,F_StatusCode,F_ServiceDept,F_ChargeName,F_ChargeTelephone,F_Province,F_ProductLine,F_ChargeDept,F_AfterSaleName,F_CustomerNature,F_CustomerClass,F_CustomerIndustry,F_RelationShipClass,F_CurrentVersion,F_SystemStartTime,F_QualityGuaranteeEndTime,F_AfterSaleTelephone,F_Notes,F_SystemType,F_City,F_CustomerStatus,F_DeviceCount,F_MaintenanceType,F_ERPCustomerCode,F_ServiceDeptID,F_ProductLineID,F_AfterSaleNameID,F_CustomerNatureID,F_CustomerClassID,F_RelationShipClassID,F_CityID,F_WxOpenId,F_Password from T_Cus_CustomerBase ");
  541. strSql.Append(" where F_CustomerId=@F_CustomerId");
  542. SqlParameter[] parameters = {
  543. new SqlParameter("@F_CustomerId", SqlDbType.Int,4)
  544. };
  545. parameters[0].Value = F_CustomerId;
  546. CallCenterApi.Model.T_Cus_CustomerBase model = new CallCenterApi.Model.T_Cus_CustomerBase();
  547. DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
  548. if (ds.Tables[0].Rows.Count > 0)
  549. {
  550. return DataRowToModel(ds.Tables[0].Rows[0]);
  551. }
  552. else
  553. {
  554. return null;
  555. }
  556. }
  557. /// <summary>
  558. /// 根据Openid 获取用户
  559. /// </summary>
  560. public CallCenterApi.Model.T_Cus_CustomerBase GetModelByOpenid(string openid)
  561. {
  562. StringBuilder strSql = new StringBuilder();
  563. strSql.Append("select top 1 * from T_Cus_CustomerBase ");
  564. strSql.Append(" where F_WxOpenId=@F_WxOpenId");
  565. SqlParameter[] parameters = {
  566. new SqlParameter("@F_WxOpenId", SqlDbType.NVarChar,200)
  567. };
  568. parameters[0].Value = openid;
  569. CallCenterApi.Model.T_Cus_CustomerBase model = new CallCenterApi.Model.T_Cus_CustomerBase();
  570. DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
  571. if (ds.Tables[0].Rows.Count > 0)
  572. {
  573. return DataRowToModel(ds.Tables[0].Rows[0]);
  574. }
  575. else
  576. {
  577. return null;
  578. }
  579. }
  580. /// <summary>
  581. /// 通过电话获得客户实体
  582. /// </summary>
  583. /// <param name="F_Mobile">电话号码</param>
  584. /// <returns></returns>
  585. public CallCenterApi.Model.T_Cus_CustomerBase GetModel(string F_Mobile)
  586. {
  587. StringBuilder strSql = new StringBuilder();
  588. strSql.Append("select top 1 * from T_Cus_CustomerBase ");
  589. strSql.Append(" where F_Mobile=@F_Mobile");
  590. SqlParameter[] parameters = {
  591. new SqlParameter("@F_Mobile", SqlDbType.NVarChar,200)
  592. };
  593. parameters[0].Value = F_Mobile;
  594. CallCenterApi.Model.T_Cus_CustomerBase model = new CallCenterApi.Model.T_Cus_CustomerBase();
  595. DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
  596. if (ds.Tables[0].Rows.Count > 0)
  597. {
  598. return DataRowToModel(ds.Tables[0].Rows[0]);
  599. }
  600. else
  601. {
  602. return null;
  603. }
  604. }
  605. /// <summary>
  606. /// 得到一个对象实体
  607. /// </summary>
  608. public CallCenterApi.Model.T_Cus_CustomerBase DataRowToModel(DataRow row)
  609. {
  610. CallCenterApi.Model.T_Cus_CustomerBase model = new CallCenterApi.Model.T_Cus_CustomerBase();
  611. if (row != null)
  612. {
  613. if (row["F_CustomerId"] != null && row["F_CustomerId"].ToString() != "")
  614. {
  615. model.F_CustomerId = int.Parse(row["F_CustomerId"].ToString());
  616. }
  617. if (row["F_CustomerName"] != null)
  618. {
  619. model.F_CustomerName = row["F_CustomerName"].ToString();
  620. }
  621. if (row["F_CustomerCode"] != null)
  622. {
  623. model.F_CustomerCode = row["F_CustomerCode"].ToString();
  624. }
  625. if (row["F_CustomerEName"] != null)
  626. {
  627. model.F_CustomerEName = row["F_CustomerEName"].ToString();
  628. }
  629. if (row["F_CustomerPym"] != null)
  630. {
  631. model.F_CustomerPym = row["F_CustomerPym"].ToString();
  632. }
  633. if (row["F_Layer"] != null && row["F_Layer"].ToString() != "")
  634. {
  635. model.F_Layer = int.Parse(row["F_Layer"].ToString());
  636. }
  637. if (row["F_CustomerLayer"] != null)
  638. {
  639. model.F_CustomerLayer = row["F_CustomerLayer"].ToString();
  640. }
  641. if (row["F_CategoryId"] != null && row["F_CategoryId"].ToString() != "")
  642. {
  643. model.F_CategoryId = int.Parse(row["F_CategoryId"].ToString());
  644. }
  645. if (row["F_TradeId"] != null && row["F_TradeId"].ToString() != "")
  646. {
  647. model.F_TradeId = int.Parse(row["F_TradeId"].ToString());
  648. }
  649. if (row["F_RegionId"] != null && row["F_RegionId"].ToString() != "")
  650. {
  651. model.F_RegionId = int.Parse(row["F_RegionId"].ToString());
  652. }
  653. if (row["F_IndustryId"] != null && row["F_IndustryId"].ToString() != "")
  654. {
  655. model.F_IndustryId = int.Parse(row["F_IndustryId"].ToString());
  656. }
  657. if (row["F_Address"] != null)
  658. {
  659. model.F_Address = row["F_Address"].ToString();
  660. }
  661. if (row["F_Url"] != null)
  662. {
  663. model.F_Url = row["F_Url"].ToString();
  664. }
  665. if (row["F_Telephone"] != null)
  666. {
  667. model.F_Telephone = row["F_Telephone"].ToString();
  668. }
  669. if (row["F_Mobile"] != null)
  670. {
  671. model.F_Mobile = row["F_Mobile"].ToString();
  672. }
  673. if (row["F_Fax"] != null)
  674. {
  675. model.F_Fax = row["F_Fax"].ToString();
  676. }
  677. if (row["F_Email"] != null)
  678. {
  679. model.F_Email = row["F_Email"].ToString();
  680. }
  681. if (row["F_Website"] != null)
  682. {
  683. model.F_Website = row["F_Website"].ToString();
  684. }
  685. if (row["F_PostCode"] != null)
  686. {
  687. model.F_PostCode = row["F_PostCode"].ToString();
  688. }
  689. if (row["F_ScaleResume"] != null)
  690. {
  691. model.F_ScaleResume = row["F_ScaleResume"].ToString();
  692. }
  693. if (row["F_BusinessProfile"] != null)
  694. {
  695. model.F_BusinessProfile = row["F_BusinessProfile"].ToString();
  696. }
  697. if (row["F_BusinessLicenseID"] != null)
  698. {
  699. model.F_BusinessLicenseID = row["F_BusinessLicenseID"].ToString();
  700. }
  701. if (row["F_TaxID"] != null)
  702. {
  703. model.F_TaxID = row["F_TaxID"].ToString();
  704. }
  705. if (row["F_OpeningBank"] != null)
  706. {
  707. model.F_OpeningBank = row["F_OpeningBank"].ToString();
  708. }
  709. if (row["F_BankAccount"] != null)
  710. {
  711. model.F_BankAccount = row["F_BankAccount"].ToString();
  712. }
  713. if (row["F_LegalRepresentative"] != null)
  714. {
  715. model.F_LegalRepresentative = row["F_LegalRepresentative"].ToString();
  716. }
  717. if (row["F_LegalRepresentativeCardID"] != null)
  718. {
  719. model.F_LegalRepresentativeCardID = row["F_LegalRepresentativeCardID"].ToString();
  720. }
  721. if (row["F_Nature"] != null)
  722. {
  723. model.F_Nature = row["F_Nature"].ToString();
  724. }
  725. if (row["F_Kind"] != null)
  726. {
  727. model.F_Kind = row["F_Kind"].ToString();
  728. }
  729. if (row["F_CustomerType"] != null && row["F_CustomerType"].ToString() != "")
  730. {
  731. model.F_CustomerType = int.Parse(row["F_CustomerType"].ToString());
  732. }
  733. if (row["F_MainProduct"] != null)
  734. {
  735. model.F_MainProduct = row["F_MainProduct"].ToString();
  736. }
  737. if (row["F_CustomerFrom"] != null)
  738. {
  739. model.F_CustomerFrom = row["F_CustomerFrom"].ToString();
  740. }
  741. if (row["F_TrackInfo"] != null)
  742. {
  743. model.F_TrackInfo = row["F_TrackInfo"].ToString();
  744. }
  745. if (row["F_TrackState"] != null)
  746. {
  747. model.F_TrackState = row["F_TrackState"].ToString();
  748. }
  749. if (row["F_ImportDegree"] != null)
  750. {
  751. model.F_ImportDegree = row["F_ImportDegree"].ToString();
  752. }
  753. if (row["F_IntentProduct"] != null)
  754. {
  755. model.F_IntentProduct = row["F_IntentProduct"].ToString();
  756. }
  757. if (row["F_CreateBy"] != null && row["F_CreateBy"].ToString() != "")
  758. {
  759. model.F_CreateBy = int.Parse(row["F_CreateBy"].ToString());
  760. }
  761. if (row["F_CreatedOn"] != null && row["F_CreatedOn"].ToString() != "")
  762. {
  763. model.F_CreatedOn = DateTime.Parse(row["F_CreatedOn"].ToString());
  764. }
  765. if (row["F_ModifyBy"] != null && row["F_ModifyBy"].ToString() != "")
  766. {
  767. model.F_ModifyBy = int.Parse(row["F_ModifyBy"].ToString());
  768. }
  769. if (row["F_ModifiedOn"] != null && row["F_ModifiedOn"].ToString() != "")
  770. {
  771. model.F_ModifiedOn = DateTime.Parse(row["F_ModifiedOn"].ToString());
  772. }
  773. if (row["F_DeleteFlag"] != null && row["F_DeleteFlag"].ToString() != "")
  774. {
  775. model.F_DeleteFlag = int.Parse(row["F_DeleteFlag"].ToString());
  776. }
  777. if (row["F_StatusCode"] != null && row["F_StatusCode"].ToString() != "")
  778. {
  779. model.F_StatusCode = int.Parse(row["F_StatusCode"].ToString());
  780. }
  781. if (row["F_ServiceDept"] != null)
  782. {
  783. model.F_ServiceDept = row["F_ServiceDept"].ToString();
  784. }
  785. if (row["F_ChargeName"] != null)
  786. {
  787. model.F_ChargeName = row["F_ChargeName"].ToString();
  788. }
  789. if (row["F_ChargeTelephone"] != null)
  790. {
  791. model.F_ChargeTelephone = row["F_ChargeTelephone"].ToString();
  792. }
  793. if (row["F_Province"] != null)
  794. {
  795. model.F_Province = row["F_Province"].ToString();
  796. }
  797. if (row["F_ProductLine"] != null)
  798. {
  799. model.F_ProductLine = row["F_ProductLine"].ToString();
  800. }
  801. if (row["F_ChargeDept"] != null)
  802. {
  803. model.F_ChargeDept = row["F_ChargeDept"].ToString();
  804. }
  805. if (row["F_AfterSaleName"] != null)
  806. {
  807. model.F_AfterSaleName = row["F_AfterSaleName"].ToString();
  808. }
  809. if (row["F_CustomerNature"] != null)
  810. {
  811. model.F_CustomerNature = row["F_CustomerNature"].ToString();
  812. }
  813. if (row["F_CustomerClass"] != null)
  814. {
  815. model.F_CustomerClass = row["F_CustomerClass"].ToString();
  816. }
  817. if (row["F_CustomerIndustry"] != null)
  818. {
  819. model.F_CustomerIndustry = row["F_CustomerIndustry"].ToString();
  820. }
  821. if (row["F_RelationShipClass"] != null)
  822. {
  823. model.F_RelationShipClass = row["F_RelationShipClass"].ToString();
  824. }
  825. if (row["F_CurrentVersion"] != null)
  826. {
  827. model.F_CurrentVersion = row["F_CurrentVersion"].ToString();
  828. }
  829. if (row["F_SystemStartTime"] != null && row["F_SystemStartTime"].ToString() != "")
  830. {
  831. model.F_SystemStartTime = DateTime.Parse(row["F_SystemStartTime"].ToString());
  832. }
  833. if (row["F_QualityGuaranteeEndTime"] != null && row["F_QualityGuaranteeEndTime"].ToString() != "")
  834. {
  835. model.F_QualityGuaranteeEndTime = DateTime.Parse(row["F_QualityGuaranteeEndTime"].ToString());
  836. }
  837. if (row["F_AfterSaleTelephone"] != null)
  838. {
  839. model.F_AfterSaleTelephone = row["F_AfterSaleTelephone"].ToString();
  840. }
  841. if (row["F_Notes"] != null)
  842. {
  843. model.F_Notes = row["F_Notes"].ToString();
  844. }
  845. if (row["F_SystemType"] != null)
  846. {
  847. model.F_SystemType = row["F_SystemType"].ToString();
  848. }
  849. if (row["F_City"] != null)
  850. {
  851. model.F_City = row["F_City"].ToString();
  852. }
  853. if (row["F_CustomerStatus"] != null)
  854. {
  855. model.F_CustomerStatus = row["F_CustomerStatus"].ToString();
  856. }
  857. if (row["F_DeviceCount"] != null && row["F_DeviceCount"].ToString() != "")
  858. {
  859. model.F_DeviceCount = int.Parse(row["F_DeviceCount"].ToString());
  860. }
  861. if (row["F_MaintenanceType"] != null)
  862. {
  863. model.F_MaintenanceType = row["F_MaintenanceType"].ToString();
  864. }
  865. if (row["F_ERPCustomerCode"] != null)
  866. {
  867. model.F_ERPCustomerCode = row["F_ERPCustomerCode"].ToString();
  868. }
  869. if (row["F_ServiceDeptID"] != null && row["F_ServiceDeptID"].ToString() != "")
  870. {
  871. model.F_ServiceDeptID = int.Parse(row["F_ServiceDeptID"].ToString());
  872. }
  873. if (row["F_ProductLineID"] != null && row["F_ProductLineID"].ToString() != "")
  874. {
  875. model.F_ProductLineID = int.Parse(row["F_ProductLineID"].ToString());
  876. }
  877. if (row["F_AfterSaleNameID"] != null && row["F_AfterSaleNameID"].ToString() != "")
  878. {
  879. model.F_AfterSaleNameID = int.Parse(row["F_AfterSaleNameID"].ToString());
  880. }
  881. if (row["F_CustomerNatureID"] != null && row["F_CustomerNatureID"].ToString() != "")
  882. {
  883. model.F_CustomerNatureID = int.Parse(row["F_CustomerNatureID"].ToString());
  884. }
  885. if (row["F_CustomerClassID"] != null && row["F_CustomerClassID"].ToString() != "")
  886. {
  887. model.F_CustomerClassID = int.Parse(row["F_CustomerClassID"].ToString());
  888. }
  889. if (row["F_RelationShipClassID"] != null && row["F_RelationShipClassID"].ToString() != "")
  890. {
  891. model.F_RelationShipClassID = int.Parse(row["F_RelationShipClassID"].ToString());
  892. }
  893. if (row["F_CityID"] != null && row["F_CityID"].ToString() != "")
  894. {
  895. model.F_CityID = int.Parse(row["F_CityID"].ToString());
  896. }
  897. if (row["F_WxOpenId"] != null && row["F_WxOpenId"].ToString() != "")
  898. {
  899. model.F_WxOpenId = row["F_WxOpenId"].ToString();
  900. }
  901. if (row["F_Password"] != null && row["F_Password"].ToString() != "")
  902. {
  903. model.F_Password = row["F_Password"].ToString();
  904. }
  905. }
  906. return model;
  907. }
  908. /// <summary>
  909. /// 获得数据列表
  910. /// </summary>
  911. public DataSet GetList(string strWhere)
  912. {
  913. StringBuilder strSql = new StringBuilder();
  914. strSql.Append("select F_CustomerId,F_CustomerName,F_CustomerCode,F_CustomerEName,F_CustomerPym,F_Layer,F_CustomerLayer,F_CategoryId,F_TradeId,F_RegionId,F_IndustryId,F_Address,F_Url,F_Telephone,F_Mobile,F_Fax,F_Email,F_Website,F_PostCode,F_ScaleResume,F_BusinessProfile,F_BusinessLicenseID,F_TaxID,F_OpeningBank,F_BankAccount,F_LegalRepresentative,F_LegalRepresentativeCardID,F_Nature,F_Kind,F_CustomerType,F_MainProduct,F_CustomerFrom,F_TrackInfo,F_TrackState,F_ImportDegree,F_IntentProduct,F_CreateBy,F_CreatedOn,F_ModifyBy,F_ModifiedOn,F_DeleteFlag,F_StatusCode,F_ServiceDept,F_ChargeName,F_ChargeTelephone,F_Province,F_ProductLine,F_ChargeDept,F_AfterSaleName,F_CustomerNature,F_CustomerClass,F_CustomerIndustry,F_RelationShipClass,F_CurrentVersion,F_SystemStartTime,F_QualityGuaranteeEndTime,F_AfterSaleTelephone,F_Notes,F_SystemType,F_City,F_CustomerStatus,F_DeviceCount,F_MaintenanceType,F_ERPCustomerCode,F_ServiceDeptID,F_ProductLineID,F_AfterSaleNameID,F_CustomerNatureID,F_CustomerClassID,F_RelationShipClassID,F_CityID,F_WxOpenId,F_Password ");
  915. strSql.Append(" FROM T_Cus_CustomerBase ");
  916. if (strWhere.Trim() != "")
  917. {
  918. strSql.Append(" where " + strWhere);
  919. }
  920. return DbHelperSQL.Query(strSql.ToString());
  921. }
  922. /// <summary>
  923. /// 获得前几行数据
  924. /// </summary>
  925. public DataSet GetList(int Top, string strWhere, string filedOrder)
  926. {
  927. StringBuilder strSql = new StringBuilder();
  928. strSql.Append("select ");
  929. if (Top > 0)
  930. {
  931. strSql.Append(" top " + Top.ToString());
  932. }
  933. strSql.Append(" F_CustomerId,F_CustomerName,F_CustomerCode,F_CustomerEName,F_CustomerPym,F_Layer,F_CustomerLayer,F_CategoryId,F_TradeId,F_RegionId,F_IndustryId,F_Address,F_Url,F_Telephone,F_Mobile,F_Fax,F_Email,F_Website,F_PostCode,F_ScaleResume,F_BusinessProfile,F_BusinessLicenseID,F_TaxID,F_OpeningBank,F_BankAccount,F_LegalRepresentative,F_LegalRepresentativeCardID,F_Nature,F_Kind,F_CustomerType,F_MainProduct,F_CustomerFrom,F_TrackInfo,F_TrackState,F_ImportDegree,F_IntentProduct,F_CreateBy,F_CreatedOn,F_ModifyBy,F_ModifiedOn,F_DeleteFlag,F_StatusCode,F_ServiceDept,F_ChargeName,F_ChargeTelephone,F_Province,F_ProductLine,F_ChargeDept,F_AfterSaleName,F_CustomerNature,F_CustomerClass,F_CustomerIndustry,F_RelationShipClass,F_CurrentVersion,F_SystemStartTime,F_QualityGuaranteeEndTime,F_AfterSaleTelephone,F_Notes,F_SystemType,F_City,F_CustomerStatus,F_DeviceCount,F_MaintenanceType,F_ERPCustomerCode,F_ServiceDeptID,F_ProductLineID,F_AfterSaleNameID,F_CustomerNatureID,F_CustomerClassID,F_RelationShipClassID,F_CityID,F_WxOpenId,F_Password ");
  934. strSql.Append(" FROM T_Cus_CustomerBase ");
  935. if (strWhere.Trim() != "")
  936. {
  937. strSql.Append(" where " + strWhere);
  938. }
  939. strSql.Append(" order by " + filedOrder);
  940. return DbHelperSQL.Query(strSql.ToString());
  941. }
  942. /// <summary>
  943. /// 获取记录总数
  944. /// </summary>
  945. public int GetRecordCount(string strWhere)
  946. {
  947. StringBuilder strSql = new StringBuilder();
  948. strSql.Append("select count(1) FROM T_Cus_CustomerBase ");
  949. if (strWhere.Trim() != "")
  950. {
  951. strSql.Append(" where " + strWhere);
  952. }
  953. object obj = DbHelperSQL.GetSingle(strSql.ToString());
  954. if (obj == null)
  955. {
  956. return 0;
  957. }
  958. else
  959. {
  960. return Convert.ToInt32(obj);
  961. }
  962. }
  963. /// <summary>
  964. /// 分页获取数据列表
  965. /// </summary>
  966. public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
  967. {
  968. StringBuilder strSql = new StringBuilder();
  969. strSql.Append("SELECT * FROM ( ");
  970. strSql.Append(" SELECT ROW_NUMBER() OVER (");
  971. if (!string.IsNullOrEmpty(orderby.Trim()))
  972. {
  973. strSql.Append("order by T." + orderby);
  974. }
  975. else
  976. {
  977. strSql.Append("order by T.F_CustomerId desc");
  978. }
  979. strSql.Append(")AS Row, T.* from T_Cus_CustomerBase T ");
  980. if (!string.IsNullOrEmpty(strWhere.Trim()))
  981. {
  982. strSql.Append(" WHERE " + strWhere);
  983. }
  984. strSql.Append(" ) TT");
  985. strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
  986. return DbHelperSQL.Query(strSql.ToString());
  987. }
  988. /*
  989. /// <summary>
  990. /// 分页获取数据列表
  991. /// </summary>
  992. public DataSet GetList(int PageSize,int PageIndex,string strWhere)
  993. {
  994. SqlParameter[] parameters = {
  995. new SqlParameter("@tblName", SqlDbType.VarChar, 255),
  996. new SqlParameter("@fldName", SqlDbType.VarChar, 255),
  997. new SqlParameter("@PageSize", SqlDbType.Int),
  998. new SqlParameter("@PageIndex", SqlDbType.Int),
  999. new SqlParameter("@IsReCount", SqlDbType.Bit),
  1000. new SqlParameter("@OrderType", SqlDbType.Bit),
  1001. new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
  1002. };
  1003. parameters[0].Value = "T_Cus_CustomerBase";
  1004. parameters[1].Value = "F_CustomerId";
  1005. parameters[2].Value = PageSize;
  1006. parameters[3].Value = PageIndex;
  1007. parameters[4].Value = 0;
  1008. parameters[5].Value = 0;
  1009. parameters[6].Value = strWhere;
  1010. return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
  1011. }*/
  1012. //2017-11-2
  1013. /// <summary>
  1014. /// 是否存在该记录
  1015. /// </summary>
  1016. public bool PhoneExists(string F_Mobile)
  1017. {
  1018. StringBuilder strSql = new StringBuilder();
  1019. strSql.Append("select count(1) from T_Cus_CustomerBase");
  1020. strSql.Append(" where F_Mobile=@F_Mobile and F_DeleteFlag=0");
  1021. SqlParameter[] parameters = {
  1022. new SqlParameter("@F_Mobile", SqlDbType.NVarChar,100)
  1023. };
  1024. parameters[0].Value = F_Mobile;
  1025. return DbHelperSQL.Exists(strSql.ToString(), parameters);
  1026. }
  1027. /// <summary>
  1028. /// 根据号码获取客户信息
  1029. /// </summary>
  1030. /// <param name="F_Mobile"></param>
  1031. /// <returns></returns>
  1032. public CallCenterApi.Model.T_Cus_CustomerBase GetModelByPhone(string F_Mobile)
  1033. {
  1034. StringBuilder strSql = new StringBuilder();
  1035. strSql.Append("select * from T_Cus_CustomerBase ");
  1036. strSql.Append(" where F_Mobile=@F_Mobile and F_DeleteFlag=0");
  1037. SqlParameter[] parameters = {
  1038. new SqlParameter("@F_Mobile", SqlDbType.NVarChar,100)
  1039. };
  1040. parameters[0].Value = F_Mobile;
  1041. CallCenterApi.Model.T_Cus_CustomerBase model = new CallCenterApi.Model.T_Cus_CustomerBase();
  1042. DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
  1043. if (ds.Tables[0].Rows.Count > 0)
  1044. {
  1045. return DataRowToModel(ds.Tables[0].Rows[0]);
  1046. }
  1047. else
  1048. {
  1049. return null;
  1050. }
  1051. }
  1052. /// <summary>
  1053. /// 根据手机号删除一条数据
  1054. /// </summary>
  1055. public bool PhoneDelete(string F_Mobile)
  1056. {
  1057. StringBuilder strSql = new StringBuilder();
  1058. //strSql.Append("delete from T_Cus_CustomerBase ");
  1059. strSql.Append("update T_Cus_CustomerBase set F_DeleteFlag=1");
  1060. strSql.Append(" where F_Mobile=@F_Mobile");
  1061. SqlParameter[] parameters = {
  1062. new SqlParameter("@F_Mobile", SqlDbType.NVarChar,100)
  1063. };
  1064. parameters[0].Value = F_Mobile;
  1065. int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
  1066. if (rows > 0)
  1067. {
  1068. return true;
  1069. }
  1070. else
  1071. {
  1072. return false;
  1073. }
  1074. }
  1075. #endregion BasicMethod
  1076. #region ExtensionMethod
  1077. #endregion ExtensionMethod
  1078. }
  1079. }