Aucune description

T_Cus_CustomerBase.cs 55KB

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