Brak opisu

T_Cus_CustomerBase.cs 52KB

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