封丘民调

T_Cus_CustomerBase.cs 51KB

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