ImportExcel.cs 136 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424
  1. //using Microsoft.Office.Interop.Excel;
  2. using LYFZ.BLL;
  3. using LYFZ.Model;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Data;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. namespace LYFZ.Software.MainBusiness.Customers
  11. {
  12. public partial class ImportExcel : LYFZ.Software.UI.Customers.ImportExcel
  13. {
  14. public ImportExcel()
  15. {
  16. this.Shown += ImportExcel_Shown;
  17. this.btnAddExcel.Click += btnAddExcel_Click;
  18. this.btnAdd.Click += btnAdd_Click;
  19. this.btnClose.Click += btnClose_Click;
  20. //指定不再捕获对错误线程的调用
  21. Control.CheckForIllegalCrossThreadCalls = false;
  22. }
  23. /// <summary>
  24. /// 客户组编号集合
  25. /// </summary>
  26. List<string> Gmlist = new List<string>();
  27. /// <summary>
  28. /// 存放添加sql语句
  29. /// </summary>
  30. // List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
  31. BLL_ErpCustomer Cus_Bll = new BLL_ErpCustomer();
  32. BLL_ErpCustomerGroup GP_Bll = new BLL_ErpCustomerGroup();
  33. BLL_ErpCustomerGroupMembers GM_Bll = new BLL_ErpCustomerGroupMembers();
  34. LYFZ.BLL.BLL_ErpOrder orbll = new BLL_ErpOrder();
  35. // Model_ErpCustomer Cus_Model = null;
  36. // Model_ErpCustomerGroup GP_Model = null;
  37. // Model_ErpCustomerGroupMembers GM_Model = null;
  38. /// <summary>
  39. /// 客户类型 0 为其它客户(客户管理中的其他客户,只添加到用户表) 1 为老客户 2 为意向客户
  40. /// </summary>
  41. public int Type;
  42. /// <summary>
  43. /// 订单类型
  44. /// </summary>
  45. public int Leixing;
  46. Customer Cus = new Customer();
  47. string Url = "";
  48. System.Data.DataTable dt;
  49. System.Data.DataTable dtOK;
  50. System.Data.DataTable dtError;
  51. // DataGridViewEc dgvex;
  52. List<string> list = new List<string>();
  53. #region 关闭
  54. /// <summary>
  55. /// 关闭按钮
  56. /// </summary>
  57. void btnClose_Click( object sender, EventArgs e )
  58. {
  59. try
  60. {
  61. this.Close();
  62. }
  63. catch ( Exception ex )
  64. {
  65. MessageBoxCustom.Show( ex.Message );
  66. }
  67. }
  68. #endregion
  69. #region 打开Excel按钮
  70. /// <summary>
  71. /// 打开Excel按钮
  72. /// </summary>
  73. void btnAddExcel_Click( object sender, EventArgs e )
  74. {
  75. try
  76. {
  77. DialogResult dres = openFileDialog1.ShowDialog();
  78. if ( DialogResult.OK.Equals( dres ) )
  79. {
  80. dt = LYFZ.WinAPI.CustomPublicMethod.GetExcelDatatable( openFileDialog1.FileName ); //ExcelToDataTable(openFileDialog1.FileName, "Sheet1");
  81. Url = openFileDialog1.FileName;
  82. dtOK = dt.Copy();
  83. dtOK.Rows.Clear();
  84. dtError = dt.Copy();
  85. dtError.Rows.Clear();
  86. dtError.Columns.Add( "错误原因" );
  87. // dgvex = new DataGridViewEc();
  88. list = new List<string>();
  89. //其他客户
  90. if ( Type == 0 )
  91. {
  92. if ( dt.Columns.Count == 6 )
  93. {
  94. if ( dt.Columns[0].ToString().Trim() == "客户姓名" && dt.Columns[1].ToString().Trim() == "性别" && dt.Columns[2].ToString().Trim() == "电话"
  95. && dt.Columns[3].ToString().Trim() == "QQ" && dt.Columns[4].ToString().Trim() == "地址" && dt.Columns[5].ToString().Trim() == "生日" )
  96. {
  97. Checklistdata( "checkOther" );
  98. if ( dt.Rows.Count > 0 )
  99. {
  100. btnAdd.Enabled = true;
  101. }
  102. }
  103. else { MessageBoxCustom.Show( "请正确选择模板导入" ); btnAdd.Enabled = false; }
  104. }
  105. else { MessageBoxCustom.Show( "请正确选择模板导入!" ); }
  106. }
  107. //老客户
  108. if ( Type == 1 )
  109. {
  110. #region 检查数据
  111. switch ( Leixing )
  112. {
  113. //婚纱
  114. case 0:
  115. if ( dt.Columns.Count == 12 )
  116. {
  117. if ( dt.Columns[0].ToString().Trim() == "订单日期" && dt.Columns[1].ToString().Trim() == "先生名字" && dt.Columns[2].ToString().Trim() == "先生生日" && dt.Columns[3].ToString().Trim() == "先生QQ" &&
  118. dt.Columns[4].ToString().Trim() == "先生手机号" && dt.Columns[5].ToString().Trim() == "女士名字" && dt.Columns[6].ToString().Trim() == "女士生日" && dt.Columns[7].ToString().Trim() == "女士QQ" && dt.Columns[8].ToString().Trim() == "女士手机号"
  119. && dt.Columns[9].ToString().Trim() == "婚期" && dt.Columns[10].ToString().Trim() == "套系名称" && dt.Columns[11].ToString().Trim() == "套系价格" )
  120. {
  121. Checklistdata( "checkHS" );
  122. if ( dt.Rows.Count > 0 )
  123. {
  124. btnAdd.Enabled = true;
  125. }
  126. }
  127. else { MessageBoxCustom.Show( "请选择婚纱版模板" ); btnAdd.Enabled = false; }
  128. }
  129. else { MessageBoxCustom.Show( "请选择婚纱版模板!" ); btnAdd.Enabled = false; }
  130. break;
  131. //儿童
  132. case 1:
  133. if ( dt.Columns.Count == 9 )
  134. {
  135. if ( dt.Columns[0].ToString().Trim() == "订单日期" && dt.Columns[1].ToString().Trim() == "宝宝姓名" &&
  136. dt.Columns[2].ToString().Trim() == "家长姓名" && dt.Columns[3].ToString().Trim() == "手机号" &&
  137. dt.Columns[4].ToString().Trim() == "QQ" && dt.Columns[5].ToString().Trim() == "套系名称"
  138. && dt.Columns[6].ToString().Trim() == "套系价格" && dt.Columns[7].ToString().Trim() == "宝宝生日" && dt.Columns[8].ToString().Trim() == "宝宝性别" )
  139. {
  140. Checklistdata( "checkBaby" );
  141. if ( dtOK.Rows.Count > 0 )
  142. {
  143. btnAdd.Enabled = true;
  144. }
  145. }
  146. else { MessageBoxCustom.Show( "请选择儿童版模板" ); btnAdd.Enabled = false; }
  147. }
  148. else { MessageBoxCustom.Show( "请选择儿童版模板!" ); btnAdd.Enabled = false; }
  149. break;
  150. case 2:
  151. if ( dt.Columns.Count == 8 )
  152. {
  153. if ( dt.Columns[0].ToString().Trim() == "姓名" && dt.Columns[1].ToString().Trim() == "性别" &&
  154. dt.Columns[2].ToString().Trim() == "电话" && dt.Columns[3].ToString().Trim() == "QQ" &&
  155. dt.Columns[4].ToString().Trim() == "生日" && dt.Columns[5].ToString().Trim() == "套系名称"
  156. && dt.Columns[6].ToString().Trim() == "套系价格" && dt.Columns[7].ToString().Trim() == "订单日期" )
  157. {
  158. Checklistdata( "checkXZfw" );
  159. if ( dt.Rows.Count > 0 )
  160. {
  161. btnAdd.Enabled = true;
  162. }
  163. }
  164. else { MessageBoxCustom.Show( "请选择写真,服务版模板" ); btnAdd.Enabled = false; }
  165. }
  166. else { MessageBoxCustom.Show( "请选择写真,服务版模板!" ); btnAdd.Enabled = false; }
  167. break;
  168. case 3:
  169. if ( dt.Columns.Count == 8 )
  170. {
  171. if ( dt.Columns[0].ToString().Trim() == "姓名" && dt.Columns[1].ToString().Trim() == "性别" &&
  172. dt.Columns[2].ToString().Trim() == "电话" && dt.Columns[3].ToString().Trim() == "QQ" &&
  173. dt.Columns[4].ToString().Trim() == "生日" && dt.Columns[5].ToString().Trim() == "套系名称"
  174. && dt.Columns[6].ToString().Trim() == "套系价格" && dt.Columns[7].ToString().Trim() == "订单日期" )
  175. {
  176. Checklistdata( "checkXZfw" );
  177. if ( dt.Rows.Count > 0 )
  178. {
  179. btnAdd.Enabled = true;
  180. }
  181. }
  182. else { MessageBoxCustom.Show( "请选择写真,服务版模板" ); btnAdd.Enabled = false; }
  183. }
  184. else { MessageBoxCustom.Show( "请选择写真,服务版模板!" ); btnAdd.Enabled = false; }
  185. break;
  186. }
  187. #endregion
  188. }
  189. //意向客户
  190. if ( Type == 2 )
  191. {
  192. #region 检查数据
  193. if ( dt.Columns.Count >= 7 ) // >=7,兼容以前的模块;
  194. {
  195. if ( dt.Columns[0].ToString().Trim() == "客户姓名" && dt.Columns[1].ToString().Trim() == "性别" && dt.Columns[2].ToString().Trim() == "电话"
  196. && dt.Columns[3].ToString().Trim() == "QQ" && dt.Columns[4].ToString().Trim() == "地址" && dt.Columns[5].ToString().Trim() == "生日"
  197. && dt.Columns[6].ToString().Trim() == "订单类型" )
  198. {
  199. Checklistdata( "UYixiang" );
  200. if ( dt.Rows.Count > 0 )
  201. {
  202. btnAdd.Enabled = true;
  203. }
  204. }
  205. else { MessageBoxCustom.Show( "请正确选择模板导入" ); btnAdd.Enabled = false; }
  206. }
  207. else { MessageBoxCustom.Show( "请正确选择模板导入!" ); btnAdd.Enabled = false; }
  208. #endregion
  209. }
  210. if ( dt != null )
  211. {
  212. dgv.DataSource = dtOK;
  213. for ( int i = 0; i < this.dgv.Columns.Count; i++ )
  214. {
  215. this.dgv.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
  216. }
  217. }
  218. }
  219. }
  220. catch ( Exception ex )
  221. {
  222. MessageBoxCustom.Show( ex.Message );
  223. }
  224. }
  225. #endregion
  226. #region 保存
  227. /// <summary>
  228. /// 保存按钮
  229. /// </summary>
  230. void btnAdd_Click( object sender, EventArgs e )
  231. {
  232. bool upData = true;
  233. try
  234. {
  235. if ( dgv.Rows.Count > 0 )
  236. {
  237. // LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  238. // {
  239. if ( Type == 0 )
  240. {
  241. AddOther();
  242. }
  243. if ( Type == 1 )
  244. {
  245. switch ( Leixing )
  246. {
  247. case 0:
  248. OldHSNew();
  249. break;
  250. case 1:
  251. OldBabyNew();
  252. break;
  253. case 2:
  254. OldXZfwNew( 2 );
  255. break;
  256. case 3:
  257. OldXZfwNew(3);
  258. break;
  259. }
  260. }
  261. if ( Type == 2 )
  262. {
  263. upData=addYixiang();
  264. }
  265. if (upData)
  266. {
  267. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker)
  268. {
  269. backgroundWorker.ReportProgress(0, "正在更新客户资料...");
  270. LYFZ.DAL.DAL_ErpCustomer.UpdateAggregationCustomerAll();
  271. });
  272. MessageBoxCustom.Show("导入完成");
  273. this.DialogResult = System.Windows.Forms.DialogResult.Yes;
  274. }
  275. //});
  276. }
  277. }
  278. catch ( Exception ex )
  279. {
  280. MessageBoxCustom.Show( "导入出错:" + ex.Message );
  281. this.DialogResult = System.Windows.Forms.DialogResult.Yes;
  282. }
  283. this.DialogResult = System.Windows.Forms.DialogResult.Yes;
  284. }
  285. #endregion
  286. #region 加载
  287. void ImportExcel_Shown( object sender, EventArgs e )
  288. {
  289. if ( Type == 1 )
  290. {
  291. switch ( Leixing )
  292. {
  293. case 1:
  294. this.Text += " (儿童模板)";
  295. break;
  296. case 2:
  297. this.Text += " (写真模板)";
  298. break;
  299. case 3:
  300. this.Text += " (服务模板)";
  301. break;
  302. case 0:
  303. this.Text += " (婚纱模板)";
  304. break;
  305. }
  306. }
  307. }
  308. #endregion
  309. #region 判断数据
  310. /// <summary>
  311. /// 判断数据
  312. /// </summary>
  313. /// <param name="Svoid"></param>
  314. void Checklistdata( string Svoid )
  315. {
  316. LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod( delegate ( object obj, BackgroundWorker backgroundWorker )
  317. {
  318. System.Data.DataTable tblClient = new DataTable();
  319. switch ( Svoid )
  320. {
  321. //老客户宝宝
  322. case "checkBaby":
  323. tblClient = orbll.GetView_Custom( "tb_ErpCustomer", StrWhere: "Cus_Telephone in (" + StrDianhua( "手机号", dt ) + ")", ShowColumnName: "ID,Cus_Telephone" ).Tables[0];
  324. break;
  325. //老客户婚纱
  326. case "checkHS":
  327. string sj = StrDianhua( "女士手机号", dt ) + "," + StrDianhua( "先生手机号", dt );
  328. tblClient = orbll.GetView_Custom( "tb_ErpCustomer", StrWhere: "Cus_Telephone in (" + sj + ")", ShowColumnName: "ID,Cus_Telephone" ).Tables[0];
  329. break;
  330. //老客户写真服务
  331. case "checkXZfw":
  332. tblClient = orbll.GetView_Custom( "tb_ErpCustomer", StrWhere: "Cus_Telephone in (" + StrDianhua( "电话", dt ) + ")", ShowColumnName: "ID,Cus_Telephone" ).Tables[0];
  333. break;
  334. //意向客户
  335. case "UYixiang":
  336. tblClient = orbll.GetView_Custom( "tb_ErpCustomer", StrWhere: "Cus_Telephone in (" + StrDianhua( "电话", dt ) + ")", ShowColumnName: "ID,Cus_Telephone" ).Tables[0];
  337. break;
  338. //其他客户
  339. case "checkOther":
  340. tblClient = orbll.GetView_Custom( "tb_ErpCustomer", StrWhere: "Cus_Telephone in (" + StrDianhua( "电话", dt ) + ")", ShowColumnName: "ID,Cus_Telephone" ).Tables[0];
  341. break;
  342. }
  343. //总计数器
  344. float sumCount = dt.Rows.Count;
  345. //当前计数器
  346. int currentCount = 0;
  347. for ( int i = 0; i < sumCount; i++ )
  348. {
  349. currentCount++;
  350. switch ( Svoid )
  351. {
  352. //老客户宝宝
  353. case "checkBaby":
  354. string Cuowu = checkBaby( dt.Rows[i], tblClient ).ToString();
  355. if ( Cuowu == "" )
  356. {
  357. dtOK.Rows.Add( dt.Rows[i].ItemArray );
  358. }
  359. else
  360. {
  361. PuAdd( Cuowu, i );
  362. }
  363. break;
  364. //老客户婚纱
  365. case "checkHS":
  366. string Cuowu1 = checkHS( dt.Rows[i], tblClient ).ToString();
  367. if ( Cuowu1 == "" )
  368. {
  369. dtOK.Rows.Add( dt.Rows[i].ItemArray );
  370. }
  371. else
  372. {
  373. PuAdd( Cuowu1, i );
  374. }
  375. break;
  376. //老客户写真服务
  377. case "checkXZfw":
  378. string Cuowu2 = checkXZfw( dt.Rows[i], tblClient ).ToString();
  379. if ( Cuowu2 == "" )
  380. {
  381. dtOK.Rows.Add( dt.Rows[i].ItemArray );
  382. }
  383. else
  384. {
  385. PuAdd( Cuowu2, i );
  386. }
  387. break;
  388. //意向客户
  389. case "UYixiang":
  390. string Cuowu3 = UYixiang( dt.Rows[i], tblClient ).ToString();
  391. if ( Cuowu3 == "" )
  392. {
  393. dtOK.Rows.Add( dt.Rows[i].ItemArray );
  394. }
  395. else
  396. {
  397. PuAdd( Cuowu3, i );
  398. }
  399. break;
  400. //其他客户
  401. case "checkOther":
  402. string Cuowu4 = checkOther( dt.Rows[i], tblClient ).ToString();
  403. if ( Cuowu4 == "" )
  404. {
  405. dtOK.Rows.Add( dt.Rows[i].ItemArray );
  406. }
  407. else
  408. {
  409. PuAdd( Cuowu4, i );
  410. }
  411. break;
  412. }
  413. if ( backgroundWorker != null )
  414. {
  415. try
  416. {
  417. int currentProgres = Convert.ToInt32( 1000 / sumCount * currentCount );
  418. backgroundWorker.ReportProgress( currentProgres, "正在检查数据,共" + sumCount + "条,已验证" + currentCount.ToString() + "条..." );
  419. }
  420. catch { }
  421. }
  422. }
  423. }, width: 380 );
  424. if ( dtError.Rows.Count > 0 )
  425. {
  426. //this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
  427. //{
  428. // dgvex.DataSource(dtError);
  429. Cus.DataToExcel( dtError, "", Url );
  430. //}));
  431. }
  432. }
  433. #endregion
  434. #region 老客户添加操作
  435. BLL.BLL_OldOrderHistory bll_ooh = new BLL_OldOrderHistory();
  436. /// <summary>
  437. /// 儿童老客户
  438. /// </summary>
  439. [Obsolete]
  440. ///放弃已弃用
  441. void OldBaby()
  442. {
  443. try
  444. {
  445. if ( dgv.Rows.Count > 0 )
  446. {
  447. DateTime strTime = SDateTime.Now;
  448. // List<string> namelist = new List<string>();
  449. LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod( delegate ( object obj, BackgroundWorker backgroundWorker )
  450. {
  451. //总计数器
  452. float sumCount = dgv.Rows.Count;
  453. //当前计数器
  454. int currentCount = 0;
  455. for ( int i = 0; i < dgv.Rows.Count; i++ )
  456. {
  457. // 存放添加sql语句
  458. List<Helper.CommandInfo> sqllist = new List<Helper.CommandInfo>();
  459. //主联系人ID
  460. string ID = LYFZ.BLL.BLL_ErpCustomer.GetClientNumber();
  461. //客户关系组
  462. string GMID = LYFZ.BLL.BLL_ErpCustomer.GetNewClientGroupNumber();
  463. //宝宝
  464. Model_ErpCustomer Baby = new Model_ErpCustomer();
  465. Baby.Cus_CustomerNumber = ID;
  466. Baby.Cus_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  467. Baby.Cus_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter( dgv.Rows[i].Cells["宝宝姓名"].Value.ToString().Trim() );
  468. Baby.Cus_NamePinyin = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin( Baby.Cus_Name ).ToLower();
  469. Baby.Cus_Sex = dgv.Rows[i].Cells["宝宝性别"].Value.ToString().Trim() == "男" ? false : true;
  470. if ( dgv.Rows[i].Cells["宝宝生日"].Value.ToString().Trim() != "" )
  471. {
  472. Baby.Cus_Birthday = Convert.ToDateTime( dgv.Rows[i].Cells["宝宝生日"].Value.ToString().Trim() ).ToString( "yyyy-MM-dd" );
  473. }
  474. Baby.Cus_ServiceType = "Baby";
  475. Baby.Cus_Type = "儿童";
  476. Baby.Cus_CreateDateTime = strTime;
  477. Baby.Cus_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  478. sqllist.Add( Cus_Bll.GetAddCommandInfo( Baby ) );
  479. Model_ErpCustomerGroupMembers RT_GM_Model = new Model_ErpCustomerGroupMembers();
  480. RT_GM_Model.GM_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  481. RT_GM_Model.GM_CustomerGroupID = GMID;
  482. RT_GM_Model.GM_CustomerID = ID;
  483. RT_GM_Model.GM_Master = 0;
  484. RT_GM_Model.GM_ProtagonistCustomer = 1;
  485. RT_GM_Model.GM_RelatedPersonID = ID;
  486. RT_GM_Model.GM_Relation = "本人";
  487. RT_GM_Model.GM_IsOrder = dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim() != "" ? 1 : 0;
  488. RT_GM_Model.GM_IsOrderNumber = "";
  489. sqllist.Add( GM_Bll.GetAddCommandInfo( RT_GM_Model ) );
  490. //家长
  491. Model_ErpCustomer RT_Cus_Model = new Model_ErpCustomer();
  492. RT_Cus_Model.Cus_CustomerNumber = LYFZ.BLL.BLL_ErpCustomer.GetClientNumber(); //获取新编号
  493. RT_Cus_Model.Cus_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  494. RT_Cus_Model.Cus_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter( dgv.Rows[i].Cells["家长姓名"].Value.ToString().Trim() );
  495. if ( RT_Cus_Model.Cus_Name != "" )
  496. {
  497. RT_Cus_Model.Cus_NamePinyin = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin( RT_Cus_Model.Cus_Name ).ToLower();
  498. }
  499. RT_Cus_Model.Cus_Telephone = dgv.Rows[i].Cells["手机号"].Value.ToString().Trim();
  500. RT_Cus_Model.Cus_QQ = dgv.Rows[i].Cells["QQ"].Value.ToString().Trim();
  501. RT_Cus_Model.Cus_CreateDateTime = strTime;
  502. RT_Cus_Model.Cus_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  503. sqllist.Add( Cus_Bll.GetAddCommandInfo( RT_Cus_Model ) );
  504. //成员表
  505. RT_GM_Model = new Model_ErpCustomerGroupMembers();
  506. RT_GM_Model.GM_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  507. RT_GM_Model.GM_CustomerGroupID = GMID;
  508. RT_GM_Model.GM_CustomerID = RT_Cus_Model.Cus_CustomerNumber;
  509. RT_GM_Model.GM_Master = 1;
  510. RT_GM_Model.GM_ProtagonistCustomer = 0;
  511. RT_GM_Model.GM_RelatedPersonID = ID;
  512. RT_GM_Model.GM_Relation = "亲人";
  513. RT_GM_Model.GM_IsOrder = dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim() != "" ? 1 : 0;
  514. RT_GM_Model.GM_IsOrderNumber = "";
  515. sqllist.Add( GM_Bll.GetAddCommandInfo( RT_GM_Model ) );
  516. if ( dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim() != "" && dgv.Rows[i].Cells["套系价格"].Value.ToString().Trim() != "" )
  517. {
  518. Model.Model_OldOrderHistory model_ooh = new Model_OldOrderHistory();
  519. model_ooh.History_ID = GMID;
  520. model_ooh.History_Type = dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim();
  521. model_ooh.History_Money = Convert.ToInt32( dgv.Rows[i].Cells["套系价格"].Value.ToString().Trim() );
  522. if ( dgv.Rows[i].Cells["订单日期"].Value.ToString().Trim() != "" )
  523. {
  524. model_ooh.History_OrderTime = Convert.ToDateTime( dgv.Rows[i].Cells["订单日期"].Value.ToString().Trim() );
  525. }
  526. model_ooh.History_CurrentID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  527. model_ooh.History_CurrentTime = strTime;
  528. sqllist.Add( bll_ooh.GetAddCommandInfo( model_ooh ) );
  529. }
  530. //客户组表
  531. Model_ErpCustomerGroup RT_GP_Model = new Model_ErpCustomerGroup();
  532. RT_GP_Model.GP_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  533. RT_GP_Model.GP_CustomerGroupID = GMID;
  534. RT_GP_Model.GP_GroupType = Type;
  535. RT_GP_Model.GP_CustomerType = 1;
  536. RT_GP_Model.GP_CustomerStatus = "正常";
  537. RT_GP_Model.GP_CreateDatetime = strTime;
  538. RT_GP_Model.GP_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  539. RT_GP_Model.GP_CustomerSource = "";
  540. RT_GP_Model.GP_Remark = "";
  541. RT_GP_Model.GP_OrderNumber = "";
  542. RT_GP_Model.GP_LossReason = "";
  543. RT_GP_Model.GP_IntroducerCustomerID = "";
  544. RT_GP_Model.GP_DegreeOfIntent = "";
  545. RT_GP_Model.GP_BelongsPersonID = "";
  546. sqllist.Add( GP_Bll.GetAddCommandInfo( RT_GP_Model ) );
  547. // RT_Gmlist.Add(GMID);
  548. // namelist.Add("宝宝姓名:" + Baby.Cus_Name + ",家长姓名:" + RT_Cus_Model.Cus_Name);
  549. string item = "宝宝姓名:" + Baby.Cus_Name + ",家长姓名:" + RT_Cus_Model.Cus_Name;
  550. try
  551. {
  552. if ( LYFZ.BLL.BaseBllOperate.ExecuteSqlTran( sqllist ) > 0 )
  553. {
  554. //日志
  555. LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog( LYFZ.EnumPublic.SystemLogsType.添加客户资料, "添加联系人资料:" + item + ",时间:" + SDateTime.Now, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name );
  556. // DAL_ErpCustomer.UpdateAggregationCustomer(GMID);
  557. }
  558. }
  559. catch ( Exception ex )
  560. {
  561. MessageBoxCustom.Show( item + " 的客户导入失败:" + ex.Message, backgroundWorker: backgroundWorker );
  562. }
  563. currentCount++;
  564. if ( backgroundWorker != null )
  565. {
  566. try
  567. {
  568. int currentProgres = Convert.ToInt32( 1000 / sumCount * currentCount );
  569. backgroundWorker.ReportProgress( currentProgres, "共" + sumCount + "条,正在导入第" + currentCount.ToString() + "条..." );
  570. }
  571. catch { }
  572. }
  573. }
  574. }, width: 350 );
  575. /* if (clist.Count > 0)
  576. {
  577. LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  578. {
  579. if (backgroundWorker != null)
  580. {
  581. try
  582. {
  583. backgroundWorker.ReportProgress(0, "准备中...请稍后!");
  584. }
  585. catch { }
  586. }
  587. if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0)
  588. {
  589. foreach (string item in namelist)
  590. {
  591. //日志
  592. LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.添加客户资料, "添加联系人资料:" + item + ",时间:" + SDateTime.Now, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
  593. }
  594. //总计数器
  595. float sumCount = Gmlist.Count;
  596. //当前计数器
  597. int currentCount = 0;
  598. for (int i = 0; i < Gmlist.Count; i++)
  599. {
  600. currentCount++;
  601. DAL_ErpCustomer.UpdateAggregationCustomer(Gmlist[i].ToString().Trim());
  602. if (backgroundWorker != null)
  603. {
  604. try
  605. {
  606. int currentProgres = Convert.ToInt32(1000 / sumCount * currentCount);
  607. backgroundWorker.ReportProgress(currentProgres, "正在添加..,共" + sumCount + "条,正在添加第:" + currentCount.ToString() + "条...");
  608. }
  609. catch { }
  610. }
  611. }
  612. MessageBoxCustom.Show("添加成功!共导入:" + dgv.Rows.Count + "条");
  613. this.DialogResult = DialogResult.OK;
  614. }
  615. else { MessageBoxCustom.Show("添加失败!"); }
  616. }, width: 350);
  617. }*/
  618. }
  619. else { MessageBoxCustom.Show( "请导入Excel文档!" ); }
  620. }
  621. catch ( Exception ex )
  622. {
  623. MessageBoxCustom.Show( ex.Message );
  624. }
  625. }
  626. void OldBabyNew()
  627. {
  628. try
  629. {
  630. if (dgv.Rows.Count > 0)
  631. {
  632. DateTime strTime = SDateTime.Now;
  633. // List<string> namelist = new List<string>();
  634. LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker)
  635. {
  636. //总计数器
  637. float sumCount = dgv.Rows.Count;
  638. //当前计数器
  639. int currentCount = 0;
  640. DataTable erpCustomerDt = new DataTable();
  641. BindDataTableColumData(
  642. "Cus_CustomerNumber,Cus_DividedShop,Cus_Name,Cus_NamePinyin,Cus_Sex,Cus_Birthday,Cus_ServiceType,Cus_Type,Cus_CreateDateTime,Cus_CreateName"
  643. .Split(','),
  644. ref erpCustomerDt);
  645. DataTable erpCustomerGroupMembersDt = new DataTable();
  646. BindDataTableColumData(
  647. "GM_DividedShop,GM_CustomerGroupID,GM_CustomerID,GM_Master,GM_ProtagonistCustomer,GM_RelatedPersonID,GM_Relation,GM_IsOrder,GM_IsOrderNumber"
  648. .Split(','),
  649. ref erpCustomerGroupMembersDt);
  650. DataTable rtErpCustomerDt = new DataTable();
  651. BindDataTableColumData(
  652. "Cus_CustomerNumber,Cus_DividedShop,Cus_Name,Cus_NamePinyin,Cus_Telephone,Cus_QQ,Cus_CreateDateTime,Cus_CreateName"
  653. .Split(','),
  654. ref rtErpCustomerDt);
  655. DataTable rtErpCustomerGroupMembersDt = new DataTable();
  656. BindDataTableColumData(
  657. "GM_DividedShop,GM_CustomerGroupID,GM_CustomerID,GM_Master,GM_ProtagonistCustomer,GM_RelatedPersonID,GM_Relation,GM_IsOrder,GM_IsOrderNumber"
  658. .Split(','),
  659. ref rtErpCustomerGroupMembersDt);
  660. DataTable oldOrderHistoryDt = new DataTable();
  661. BindDataTableColumData(
  662. "History_ID,History_Type,History_Money,History_OrderTime,History_CurrentID,History_CurrentTime"
  663. .Split(','),
  664. ref oldOrderHistoryDt);
  665. DataTable erpCustomerGroupDt = new DataTable();
  666. BindDataTableColumData(
  667. "GP_DividedShop,GP_CustomerGroupID,GP_GroupType,GP_CustomerType,GP_CustomerStatus,GP_CreateDatetime,GP_CreateName,GP_CustomerSource,GP_Remark,GP_OrderNumber,GP_LossReason,GP_IntroducerCustomerID,GP_DegreeOfIntent,GP_BelongsPersonID"
  668. .Split(','),
  669. ref erpCustomerGroupDt);
  670. DataTable erpSystemLogsDt = new DataTable();
  671. BindDataTableColumData(
  672. "Slogs_DividedShop,Slogs_Content,Slogs_CreateDatetime,Slogs_CreateName,Slogs_UserName,Slogs_Type,Slogs_Topic,Slogs_IP"
  673. .Split(','),
  674. ref erpSystemLogsDt);
  675. for (int i = 0; i < dgv.Rows.Count; i++)
  676. {
  677. // 存放添加sql语句
  678. // List<Helper.CommandInfo> sqllist = new List<Helper.CommandInfo>();
  679. //主联系人ID
  680. string ID = LYFZ.BLL.BLL_ErpCustomer.GetClientNumber();
  681. //客户关系组
  682. string GMID = LYFZ.BLL.BLL_ErpCustomer.GetNewClientGroupNumber();
  683. string bbName = "";
  684. string jzName = "";
  685. //宝宝
  686. DataRow dr = erpCustomerDt.NewRow();
  687. dr["Cus_CustomerNumber"] = ID;
  688. dr["Cus_DividedShop"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  689. dr["Cus_Name"] = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(dgv.Rows[i].Cells["宝宝姓名"].Value.ToString().Trim());
  690. dr["Cus_NamePinyin"] = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin(dr["Cus_Name"].ToString_s()).ToLower();
  691. dr["Cus_Sex"] = dgv.Rows[i].Cells["宝宝性别"].Value.ToString().Trim() == "男" ? false : true;
  692. if (dgv.Rows[i].Cells["宝宝生日"].Value.ToString().Trim() != "")
  693. {
  694. dr["Cus_Birthday"] = Convert.ToDateTime(dgv.Rows[i].Cells["宝宝生日"].Value.ToString().Trim()).ToString("yyyy-MM-dd");
  695. }
  696. else
  697. {
  698. dr["Cus_Birthday"] = null;
  699. }
  700. dr["Cus_ServiceType"] = "Baby";
  701. dr["Cus_Type"] = "儿童";
  702. dr["Cus_CreateDateTime"] = strTime;
  703. dr["Cus_CreateName"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  704. bbName = dr["Cus_Name"].ToString_s();
  705. erpCustomerDt.Rows.Add(dr);
  706. ///关系
  707. dr = erpCustomerGroupMembersDt.NewRow();
  708. dr["GM_DividedShop"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  709. dr["GM_CustomerGroupID"] = GMID;
  710. dr["GM_CustomerID"] = ID;
  711. dr["GM_Master"] = "0";
  712. dr["GM_ProtagonistCustomer"] = "1";
  713. dr["GM_RelatedPersonID"] = ID;
  714. dr["GM_Relation"] = "本人";
  715. dr["GM_IsOrder"] = dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim() != "" ? 1 : 0;
  716. dr["GM_IsOrderNumber"] = "";
  717. erpCustomerGroupMembersDt.Rows.Add(dr);
  718. //家长
  719. DataRow rtdr = rtErpCustomerDt.NewRow();
  720. rtdr["Cus_CustomerNumber"] = LYFZ.BLL.BLL_ErpCustomer.GetClientNumber();
  721. rtdr["Cus_DividedShop"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  722. rtdr["Cus_Name"] = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(dgv.Rows[i].Cells["家长姓名"].Value.ToString().Trim());
  723. if (rtdr["Cus_Name"].ToString_s() != "")
  724. {
  725. rtdr["Cus_NamePinyin"] = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin(rtdr["Cus_Name"].ToString_s()).ToLower();
  726. //RT_Cus_Model.Cus_NamePinyin = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin(RT_Cus_Model.Cus_Name).ToLower();
  727. }
  728. rtdr["Cus_Telephone"] = dgv.Rows[i].Cells["手机号"].Value.ToString().Trim();
  729. rtdr["Cus_QQ"] = dgv.Rows[i].Cells["QQ"].Value.ToString().Trim();
  730. rtdr["Cus_CreateDateTime"] = strTime;
  731. rtdr["Cus_CreateName"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  732. jzName = rtdr["Cus_Name"].ToString_s();
  733. rtErpCustomerDt.Rows.Add(rtdr);
  734. //成员表
  735. dr = rtErpCustomerGroupMembersDt.NewRow();
  736. dr["GM_DividedShop"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  737. dr["GM_CustomerGroupID"] = GMID;
  738. dr["GM_CustomerID"] = rtdr["Cus_CustomerNumber"] ;
  739. dr["GM_Master"] = "1";
  740. dr["GM_ProtagonistCustomer"] = "0";
  741. dr["GM_RelatedPersonID"] = ID;
  742. dr["GM_Relation"] = "亲人";
  743. dr["GM_IsOrder"] = dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim() != "" ? 1 : 0; ;
  744. dr["GM_IsOrderNumber"] = "";
  745. rtErpCustomerGroupMembersDt.Rows.Add(dr);
  746. ///老订单历史数据
  747. if (dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim() != "" && dgv.Rows[i].Cells["套系价格"].Value.ToString().Trim() != "")
  748. {
  749. dr = oldOrderHistoryDt.NewRow();
  750. dr["History_ID"] = GMID;
  751. dr["History_Type"] = dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim();
  752. dr["History_Money"] = Convert.ToInt32(dgv.Rows[i].Cells["套系价格"].Value.ToString().Trim());
  753. if (dgv.Rows[i].Cells["订单日期"].Value.ToString().Trim() != "")
  754. {
  755. dr["History_OrderTime"] = Convert.ToDateTime(dgv.Rows[i].Cells["订单日期"].Value.ToString().Trim());
  756. }
  757. dr["History_CurrentID"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  758. dr["History_CurrentTime"] = strTime;
  759. oldOrderHistoryDt.Rows.Add(dr);
  760. }
  761. //客户组表
  762. dr = erpCustomerGroupDt.NewRow();
  763. dr["GP_DividedShop"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  764. dr["GP_CustomerGroupID"] = GMID;
  765. dr["GP_GroupType"] = Type;
  766. dr["GP_CustomerType"] = "1";
  767. dr["GP_CustomerStatus"] = "正常";
  768. dr["GP_CreateDatetime"] = strTime;
  769. dr["GP_CreateName"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  770. dr["GP_CustomerSource"] = "";
  771. dr["GP_Remark"] = "";
  772. dr["GP_OrderNumber"] = "";
  773. dr["GP_LossReason"] = "";
  774. dr["GP_IntroducerCustomerID"] = "";
  775. dr["GP_DegreeOfIntent"] = "";
  776. dr["GP_BelongsPersonID"] = "";
  777. erpCustomerGroupDt.Rows.Add(dr);
  778. // namelist.Add("宝宝姓名:" + Baby.Cus_Name + ",家长姓名:" + RT_Cus_Model.Cus_Name);
  779. string item = "宝宝姓名:" + bbName + ",家长姓名:" + jzName;
  780. dr = erpSystemLogsDt.NewRow();
  781. dr["Slogs_DividedShop"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  782. dr["Slogs_Content"] = "添加联系人资料:" + item + ",时间:" + SDateTime.Now + "[" + HPSocketCS.Extended.CommonLibrary.ClientMarkID + ":" + HPSocketCS.Extended.CommonLibrary.ClientMarkName + "]";
  783. dr["Slogs_CreateDatetime"] = SDateTime.Now;
  784. dr["Slogs_CreateName"] = LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID;
  785. dr["Slogs_UserName"] = LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name;
  786. dr["Slogs_Type"] = LYFZ.EnumPublic.SystemLogsType.添加客户资料;
  787. dr["Slogs_Topic"] = LYFZ.EnumPublic.SystemLogsType.添加客户资料;
  788. dr["Slogs_IP"] = "-";
  789. erpSystemLogsDt.Rows.Add(dr);
  790. }
  791. /*orbll.ExecuteSqlBulkCopyByDataTable("tb_ErpCustomer", erpCustomerDt, erpCustomerDt.Rows.Count);
  792. orbll.ExecuteSqlBulkCopyByDataTable("tb_ErpCustomerGroupMembers", erpCustomerGroupMembersDt, erpCustomerGroupMembersDt.Rows.Count);
  793. orbll.ExecuteSqlBulkCopyByDataTable("tb_ErpCustomer", rtErpCustomerDt, rtErpCustomerDt.Rows.Count);
  794. orbll.ExecuteSqlBulkCopyByDataTable("tb_ErpCustomerGroupMembers", rtErpCustomerGroupMembersDt, rtErpCustomerGroupMembersDt.Rows.Count);
  795. orbll.ExecuteSqlBulkCopyByDataTable("tb_OldOrderHistory", oldOrderHistoryDt, oldOrderHistoryDt.Rows.Count);
  796. orbll.ExecuteSqlBulkCopyByDataTable("tb_ErpCustomerGroup", erpCustomerGroupDt, erpCustomerGroupDt.Rows.Count);
  797. orbll.ExecuteSqlBulkCopyByDataTable("tb_ErpSystemLogs", erpSystemLogsDt, erpSystemLogsDt.Rows.Count);*/
  798. List<string> dataTableNames = new List<string>();
  799. List<DataTable> dataTables = new List<DataTable>();
  800. dataTableNames.Add("tb_ErpCustomer");
  801. dataTableNames.Add("tb_ErpCustomerGroupMembers");
  802. dataTableNames.Add("tb_ErpCustomer");
  803. dataTableNames.Add("tb_ErpCustomerGroupMembers");
  804. dataTableNames.Add("tb_OldOrderHistory");
  805. dataTableNames.Add("tb_ErpCustomerGroup");
  806. dataTableNames.Add("tb_ErpSystemLogs");
  807. dataTables.Add(erpCustomerDt);
  808. dataTables.Add(erpCustomerGroupMembersDt);
  809. dataTables.Add(rtErpCustomerDt);
  810. dataTables.Add(rtErpCustomerGroupMembersDt);
  811. dataTables.Add(oldOrderHistoryDt);
  812. dataTables.Add(erpCustomerGroupDt);
  813. dataTables.Add(erpSystemLogsDt);
  814. orbll.ExecuteSqlBulkCopyByDataTable(dataTableNames, dataTables);
  815. }, width: 350);
  816. }
  817. else { MessageBoxCustom.Show("请导入Excel文档!"); }
  818. }
  819. catch (Exception ex)
  820. {
  821. MessageBoxCustom.Show(ex.Message);
  822. }
  823. }
  824. void BindDataTableColumData(string[] cloums ,ref DataTable dt)
  825. {
  826. foreach(string colum in cloums)
  827. {
  828. dt.Columns.Add(colum);
  829. }
  830. }
  831. /// <summary>
  832. /// 婚纱老客户
  833. /// </summary>
  834. [Obsolete]
  835. void OldHS()
  836. {
  837. try
  838. {
  839. if ( dgv.Rows.Count > 0 )
  840. {
  841. // Gmlist = new List<string>();
  842. // List<string> namelist = new List<string>();
  843. LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod( delegate ( object obj, BackgroundWorker backgroundWorker )
  844. { //总计数器
  845. float sumCount = dgv.Rows.Count;
  846. //当前计数器
  847. int currentCount = 0;
  848. for ( int i = 0; i < dgv.Rows.Count; i++ )
  849. {
  850. // 存放添加sql语句
  851. List<Helper.CommandInfo> sqllist = new List<Helper.CommandInfo>();
  852. DateTime strTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
  853. //主联系人ID
  854. string ID = LYFZ.BLL.BLL_ErpCustomer.GetClientNumber();
  855. //客户关系组
  856. string GMID = LYFZ.BLL.BLL_ErpCustomer.GetNewClientGroupNumber();
  857. Model_ErpCustomer modelNan = new Model_ErpCustomer();
  858. Model_ErpCustomer modelNv = new Model_ErpCustomer();
  859. if ( dgv.Rows[i].Cells["女士名字"].Value.ToString().Trim() != "" )
  860. {
  861. //女
  862. modelNv = new Model_ErpCustomer();
  863. modelNv.Cus_CustomerNumber = LYFZ.BLL.BLL_ErpCustomer.GetClientNumber(); //获取新编号
  864. modelNv.Cus_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  865. modelNv.Cus_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter( dgv.Rows[i].Cells["女士名字"].Value.ToString().Trim() );
  866. if ( modelNv.Cus_Name != "" )
  867. {
  868. modelNv.Cus_NamePinyin = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin( modelNv.Cus_Name ).ToLower();
  869. }
  870. modelNv.Cus_Sex = true;
  871. if ( dgv.Rows[i].Cells["女士生日"].Value.ToString().Trim() != "" )
  872. {
  873. modelNv.Cus_Birthday = Convert.ToDateTime( dgv.Rows[i].Cells["女士生日"].Value.ToString().Trim() ).ToString( "yyyy-MM-dd" );
  874. }
  875. modelNv.Cus_Telephone = dgv.Rows[i].Cells["女士手机号"].Value.ToString().Trim();
  876. modelNv.Cus_QQ = dgv.Rows[i].Cells["女士QQ"].Value.ToString().Trim();
  877. if ( dgv.Rows[i].Cells["婚期"].Value.ToString().Trim() != "" )
  878. {
  879. modelNv.Cus_DayForMarriage = Convert.ToDateTime( dgv.Rows[i].Cells["婚期"].Value.ToString().Trim() ).ToString( "yyyy-MM-dd" );
  880. }
  881. modelNv.Cus_CreateDateTime = strTime;
  882. modelNv.Cus_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  883. sqllist.Add( Cus_Bll.GetAddCommandInfo( modelNv ) );
  884. //成员表
  885. Model_ErpCustomerGroupMembers GM_Modela = new Model_ErpCustomerGroupMembers();
  886. GM_Modela.GM_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  887. GM_Modela.GM_CustomerGroupID = GMID;
  888. GM_Modela.GM_CustomerID = modelNv.Cus_CustomerNumber;
  889. GM_Modela.GM_ProtagonistCustomer = 1;
  890. GM_Modela.GM_RelatedPersonID = ID;
  891. if ( dgv.Rows[i].Cells["女士手机号"].Value.ToString().Trim() != "" )
  892. {
  893. GM_Modela.GM_Master = 1; GM_Modela.GM_Relation = "本人";
  894. }
  895. else
  896. {
  897. GM_Modela.GM_Master = 0; GM_Modela.GM_Relation = "夫妻";
  898. }
  899. GM_Modela.GM_IsOrder = dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim() != "" ? 1 : 0;
  900. GM_Modela.GM_IsOrderNumber = "";
  901. sqllist.Add( GM_Bll.GetAddCommandInfo( GM_Modela ) );
  902. }
  903. if ( dgv.Rows[i].Cells["先生名字"].Value.ToString().Trim() != "" )
  904. {
  905. //男
  906. modelNan.Cus_CustomerNumber = ID;
  907. modelNan.Cus_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  908. modelNan.Cus_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter( dgv.Rows[i].Cells["先生名字"].Value.ToString().Trim() );
  909. modelNan.Cus_NamePinyin = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin( modelNan.Cus_Name ).ToLower();
  910. modelNan.Cus_Sex = false;
  911. if ( dgv.Rows[i].Cells["先生生日"].Value.ToString().Trim() != "" )
  912. {
  913. modelNan.Cus_Birthday = Convert.ToDateTime( dgv.Rows[i].Cells["先生生日"].Value.ToString().Trim() ).ToString( "yyyy-MM-dd" );
  914. }
  915. modelNan.Cus_Telephone = dgv.Rows[i].Cells["先生手机号"].Value.ToString().Trim();
  916. modelNan.Cus_QQ = dgv.Rows[i].Cells["先生QQ"].Value.ToString().Trim();
  917. if ( dgv.Rows[i].Cells["婚期"].Value.ToString().Trim() != "" )
  918. {
  919. modelNan.Cus_DayForMarriage = Convert.ToDateTime( dgv.Rows[i].Cells["婚期"].Value.ToString().Trim() ).ToString( "yyyy-MM-dd" );
  920. }
  921. modelNan.Cus_CreateDateTime = strTime;
  922. modelNan.Cus_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  923. sqllist.Add( Cus_Bll.GetAddCommandInfo( modelNan ) );
  924. Model_ErpCustomerGroupMembers GM_Modelb = new Model_ErpCustomerGroupMembers();
  925. GM_Modelb.GM_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  926. GM_Modelb.GM_CustomerGroupID = GMID;
  927. GM_Modelb.GM_CustomerID = ID;
  928. if ( dgv.Rows[i].Cells["女士手机号"].Value.ToString().Trim() != "" && dgv.Rows[i].Cells["女士名字"].Value.ToString().Trim() != "" )
  929. {
  930. GM_Modelb.GM_Master = 0;
  931. GM_Modelb.GM_Relation = "夫妻";
  932. }
  933. else { GM_Modelb.GM_Master = 1; GM_Modelb.GM_Relation = "本人"; }
  934. GM_Modelb.GM_ProtagonistCustomer = 1;
  935. GM_Modelb.GM_RelatedPersonID = ID;
  936. GM_Modelb.GM_IsOrder = dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim() != "" ? 1 : 0;
  937. GM_Modelb.GM_IsOrderNumber = "";
  938. sqllist.Add( GM_Bll.GetAddCommandInfo( GM_Modelb ) );
  939. }
  940. if ( dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim() != "" && dgv.Rows[i].Cells["套系价格"].Value.ToString().Trim() != "" )
  941. {
  942. BLL.BLL_OldOrderHistory bll_ooh = new BLL_OldOrderHistory();
  943. Model.Model_OldOrderHistory model_ooh = new Model_OldOrderHistory();
  944. model_ooh.History_ID = GMID;
  945. model_ooh.History_Type = dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim();
  946. model_ooh.History_Money = Convert.ToInt32( dgv.Rows[i].Cells["套系价格"].Value.ToString().Trim() );
  947. if ( dgv.Rows[i].Cells["订单日期"].Value.ToString().Trim() != "" )
  948. {
  949. try
  950. {
  951. model_ooh.History_OrderTime = Convert.ToDateTime( DDRQ( dgv.Rows[i].Cells["订单日期"].Value.ToString().Trim() ) );
  952. }
  953. catch { model_ooh.History_OrderTime = LYFZ.WinAPI.CustomPublicMethod.GetNullDateTime(); }
  954. }
  955. model_ooh.History_CurrentID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  956. model_ooh.History_CurrentTime = strTime;
  957. sqllist.Add( bll_ooh.GetAddCommandInfo( model_ooh ) );
  958. }
  959. //客户组表
  960. Model_ErpCustomerGroup GP_Model = new Model_ErpCustomerGroup();
  961. GP_Model.GP_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  962. GP_Model.GP_CustomerGroupID = GMID;
  963. GP_Model.GP_GroupType = Type;
  964. GP_Model.GP_CustomerType = 0;
  965. GP_Model.GP_CustomerStatus = "正常";
  966. GP_Model.GP_CreateDatetime = strTime;
  967. GP_Model.GP_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  968. GP_Model.GP_CustomerSource = "";
  969. GP_Model.GP_Remark = "";
  970. GP_Model.GP_OrderNumber = "";
  971. GP_Model.GP_LossReason = "";
  972. GP_Model.GP_IntroducerCustomerID = "";
  973. GP_Model.GP_DegreeOfIntent = "";
  974. GP_Model.GP_BelongsPersonID = "";
  975. sqllist.Add( GP_Bll.GetAddCommandInfo( GP_Model ) );
  976. // Gmlist.Add(GMID);
  977. string item = "先生姓名:" + modelNan.Cus_Name + ",女士姓名:" + modelNv.Cus_Name;
  978. try
  979. {
  980. if ( LYFZ.BLL.BaseBllOperate.ExecuteSqlTran( sqllist ) > 0 )
  981. {
  982. //日志
  983. LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog( LYFZ.EnumPublic.SystemLogsType.添加客户资料, "添加联系人资料:" + item + ",时间:" + SDateTime.Now, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name );
  984. // DAL_ErpCustomer.UpdateAggregationCustomer(GMID);
  985. }
  986. }
  987. catch ( Exception ex )
  988. {
  989. MessageBoxCustom.Show( item + " 的客户导入失败:" + ex.Message, backgroundWorker: backgroundWorker );
  990. }
  991. currentCount++;
  992. if ( backgroundWorker != null )
  993. {
  994. try
  995. {
  996. int currentProgres = Convert.ToInt32( 1000 / sumCount * currentCount );
  997. backgroundWorker.ReportProgress( currentProgres, "共" + sumCount + "条,正在导入第" + currentCount.ToString() + "条..." );
  998. }
  999. catch { }
  1000. }
  1001. }
  1002. }, width: 350 );
  1003. /* if (clist.Count > 0)
  1004. {
  1005. LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  1006. {
  1007. if (backgroundWorker != null)
  1008. {
  1009. try
  1010. {
  1011. backgroundWorker.ReportProgress(0, "准备中...请稍后!");
  1012. }
  1013. catch { }
  1014. }
  1015. if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0)
  1016. {
  1017. foreach (string item in namelist)
  1018. {
  1019. //日志
  1020. LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.添加客户资料, "添加联系人资料:" + item + ",时间:" + SDateTime.Now, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
  1021. }
  1022. //总计数器
  1023. float sumCount = Gmlist.Count;
  1024. //当前计数器
  1025. int currentCount = 0;
  1026. for (int i = 0; i < Gmlist.Count; i++)
  1027. {
  1028. currentCount++;
  1029. DAL_ErpCustomer.UpdateAggregationCustomer(Gmlist[i].ToString().Trim());
  1030. if (backgroundWorker != null)
  1031. {
  1032. try
  1033. {
  1034. int currentProgres = Convert.ToInt32(1000 / sumCount * currentCount);
  1035. backgroundWorker.ReportProgress(currentProgres, "正在添加..,共" + sumCount + "条,正在添加第:" + currentCount.ToString() + "条...");
  1036. }
  1037. catch { }
  1038. }
  1039. }
  1040. MessageBoxCustom.Show("添加成功!共导入:" + dgv.Rows.Count + "条");
  1041. this.DialogResult = DialogResult.OK;
  1042. }
  1043. else { MessageBoxCustom.Show("添加失败!"); }
  1044. }, width: 350);
  1045. }*/
  1046. }
  1047. else { MessageBoxCustom.Show( "请导入Excel文档!" ); }
  1048. }
  1049. catch ( Exception ex )
  1050. {
  1051. MessageBoxCustom.Show( ex.Message );
  1052. }
  1053. }
  1054. /// <summary>
  1055. /// 婚纱老客户
  1056. /// </summary>
  1057. void OldHSNew()
  1058. {
  1059. try
  1060. {
  1061. if (dgv.Rows.Count > 0)
  1062. {
  1063. // Gmlist = new List<string>();
  1064. // List<string> namelist = new List<string>();
  1065. LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker)
  1066. { //总计数器
  1067. float sumCount = dgv.Rows.Count;
  1068. //当前计数器
  1069. int currentCount = 0;
  1070. DataTable erpCustomerNvDt = new DataTable();
  1071. BindDataTableColumData(
  1072. "Cus_CustomerNumber,Cus_DividedShop,Cus_Name,Cus_NamePinyin,Cus_Sex,Cus_Birthday,Cus_Telephone,Cus_QQ,Cus_DayForMarriage,Cus_CreateDateTime,Cus_CreateName"
  1073. .Split(','),
  1074. ref erpCustomerNvDt);
  1075. DataTable erpCustomerGroupMembersNvDt = new DataTable();
  1076. BindDataTableColumData(
  1077. "GM_DividedShop,GM_CustomerGroupID,GM_CustomerID,GM_ProtagonistCustomer,GM_RelatedPersonID,GM_Master,GM_Relation,GM_IsOrder,GM_IsOrderNumber"
  1078. .Split(','),
  1079. ref erpCustomerGroupMembersNvDt);
  1080. DataTable erpCustomerNanDt = new DataTable();
  1081. BindDataTableColumData(
  1082. "Cus_CustomerNumber,Cus_DividedShop,Cus_Name,Cus_NamePinyin,Cus_Sex,Cus_Birthday,Cus_Telephone,Cus_QQ,Cus_DayForMarriage,Cus_CreateDateTime,Cus_CreateName"
  1083. .Split(','),
  1084. ref erpCustomerNanDt);
  1085. DataTable erpCustomerGroupMembersNanDt = new DataTable();
  1086. BindDataTableColumData(
  1087. "GM_DividedShop,GM_CustomerGroupID,GM_CustomerID,GM_Master,GM_Relation,GM_ProtagonistCustomer,GM_RelatedPersonID,GM_IsOrder,GM_IsOrderNumber"
  1088. .Split(','),
  1089. ref erpCustomerGroupMembersNanDt);
  1090. DataTable oldOrderHistoryDt = new DataTable();
  1091. BindDataTableColumData(
  1092. "History_ID,History_Type,History_Money,History_OrderTime,History_CurrentID,History_CurrentTime"
  1093. .Split(','),
  1094. ref oldOrderHistoryDt);
  1095. DataTable erpCustomerGroupDt = new DataTable();
  1096. BindDataTableColumData(
  1097. "GP_DividedShop,GP_CustomerGroupID,GP_GroupType,GP_CustomerType,GP_CustomerStatus,GP_CreateDatetime,GP_CreateName,GP_CustomerSource,GP_Remark,GP_OrderNumber,GP_LossReason,GP_IntroducerCustomerID,GP_DegreeOfIntent,GP_BelongsPersonID"
  1098. .Split(','),
  1099. ref erpCustomerGroupDt);
  1100. DataTable erpSystemLogsDt = new DataTable();
  1101. BindDataTableColumData(
  1102. "Slogs_DividedShop,Slogs_Content,Slogs_CreateDatetime,Slogs_CreateName,Slogs_UserName,Slogs_Type,Slogs_Topic,Slogs_IP"
  1103. .Split(','),
  1104. ref erpSystemLogsDt);
  1105. for (int i = 0; i < dgv.Rows.Count; i++)
  1106. {
  1107. // 存放添加sql语句
  1108. //List<Helper.CommandInfo> sqllist = new List<Helper.CommandInfo>();
  1109. DateTime strTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
  1110. //主联系人ID
  1111. string ID = LYFZ.BLL.BLL_ErpCustomer.GetClientNumber();
  1112. //客户关系组
  1113. string GMID = LYFZ.BLL.BLL_ErpCustomer.GetNewClientGroupNumber();
  1114. string nanName = "";
  1115. string nvName = "";
  1116. //宝宝
  1117. DataRow dr = null;
  1118. //Model_ErpCustomer modelNan = new Model_ErpCustomer();
  1119. //Model_ErpCustomer modelNv = new Model_ErpCustomer();
  1120. if (dgv.Rows[i].Cells["女士名字"].Value.ToString().Trim() != "")
  1121. {
  1122. //女
  1123. dr = erpCustomerNvDt.NewRow();
  1124. dr["Cus_CustomerNumber"] = LYFZ.BLL.BLL_ErpCustomer.GetClientNumber(); //获取新编号
  1125. dr["Cus_DividedShop"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  1126. dr["Cus_Name"] = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(dgv.Rows[i].Cells["女士名字"].Value.ToString().Trim());
  1127. if (dr["Cus_Name"].ToString_s() != "")
  1128. {
  1129. dr["Cus_NamePinyin"] = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin(dr["Cus_Name"].ToString_s()).ToLower();
  1130. }
  1131. dr["Cus_Sex"] = true; //获取新编号
  1132. if (dgv.Rows[i].Cells["女士生日"].Value.ToString().Trim() != "")
  1133. {
  1134. dr["Cus_Birthday"] = Convert.ToDateTime(dgv.Rows[i].Cells["女士生日"].Value.ToString().Trim()).ToString("yyyy-MM-dd");
  1135. }
  1136. dr["Cus_Telephone"] = dgv.Rows[i].Cells["女士手机号"].Value.ToString().Trim();
  1137. dr["Cus_QQ"] = dgv.Rows[i].Cells["女士QQ"].Value.ToString().Trim();
  1138. if (dgv.Rows[i].Cells["婚期"].Value.ToString().Trim() != "")
  1139. {
  1140. dr["Cus_DayForMarriage"] = Convert.ToDateTime(dgv.Rows[i].Cells["婚期"].Value.ToString().Trim()).ToString("yyyy-MM-dd");
  1141. }
  1142. dr["Cus_CreateDateTime"] = strTime;
  1143. dr["Cus_CreateName"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  1144. nvName = dr["Cus_Name"].ToString_s();
  1145. erpCustomerNvDt.Rows.Add(dr);
  1146. //成员表
  1147. DataRow gmDr = erpCustomerGroupMembersNvDt.NewRow();
  1148. gmDr["GM_DividedShop"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  1149. gmDr["GM_CustomerGroupID"] = GMID;
  1150. gmDr["GM_CustomerID"] = dr["Cus_CustomerNumber"];
  1151. gmDr["GM_ProtagonistCustomer"] = 1;
  1152. gmDr["GM_RelatedPersonID"] = ID;
  1153. if (dgv.Rows[i].Cells["女士手机号"].Value.ToString().Trim() != "")
  1154. {
  1155. gmDr["GM_Master"] = 1;
  1156. gmDr["GM_Relation"] = "本人";
  1157. }
  1158. else
  1159. {
  1160. gmDr["GM_Master"] = 0;
  1161. gmDr["GM_Relation"] = "夫妻";
  1162. }
  1163. gmDr["GM_IsOrder"] = dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim() != "" ? 1 : 0;
  1164. gmDr["GM_IsOrderNumber"] = "";
  1165. erpCustomerGroupMembersNvDt.Rows.Add(gmDr);
  1166. //sqllist.Add(GM_Bll.GetAddCommandInfo(GM_Modela));
  1167. }
  1168. if (dgv.Rows[i].Cells["先生名字"].Value.ToString().Trim() != "")
  1169. {
  1170. //男
  1171. dr = erpCustomerNanDt.NewRow();
  1172. dr["Cus_CustomerNumber"] = ID;
  1173. dr["Cus_DividedShop"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  1174. dr["Cus_Name"] = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(dgv.Rows[i].Cells["先生名字"].Value.ToString().Trim());
  1175. dr["Cus_NamePinyin"] = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin(dr["Cus_Name"].ToString_s()).ToLower();
  1176. dr["Cus_Sex"] = false;
  1177. if (dgv.Rows[i].Cells["先生生日"].Value.ToString().Trim() != "")
  1178. {
  1179. dr["Cus_Birthday"] = Convert.ToDateTime(dgv.Rows[i].Cells["先生生日"].Value.ToString().Trim()).ToString("yyyy-MM-dd");
  1180. }
  1181. dr["Cus_Telephone"] = dgv.Rows[i].Cells["先生手机号"].Value.ToString().Trim();
  1182. dr["Cus_QQ"] = dgv.Rows[i].Cells["先生QQ"].Value.ToString().Trim();
  1183. if (dgv.Rows[i].Cells["婚期"].Value.ToString().Trim() != "")
  1184. {
  1185. dr["Cus_DayForMarriage"] = Convert.ToDateTime(dgv.Rows[i].Cells["婚期"].Value.ToString().Trim()).ToString("yyyy-MM-dd");
  1186. }
  1187. dr["Cus_CreateDateTime"] = strTime;
  1188. dr["Cus_CreateName"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  1189. nanName = dr["Cus_Name"].ToString_s();
  1190. erpCustomerNanDt.Rows.Add(dr);
  1191. //sqllist.Add(Cus_Bll.GetAddCommandInfo(modelNan));
  1192. //Model_ErpCustomerGroupMembers GM_Modelb = new Model_ErpCustomerGroupMembers();
  1193. ///GM_DividedShop,GM_CustomerGroupID,GM_CustomerID,GM_Master,GM_Relation,GM_ProtagonistCustomer,GM_RelatedPersonID,GM_IsOrder,GM_IsOrderNumber
  1194. DataRow gmDr = erpCustomerGroupMembersNanDt.NewRow();
  1195. gmDr["GM_DividedShop"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  1196. gmDr["GM_CustomerGroupID"] = GMID;
  1197. gmDr["GM_CustomerID"] = ID;
  1198. if (dgv.Rows[i].Cells["女士手机号"].Value.ToString().Trim() != "" && dgv.Rows[i].Cells["女士名字"].Value.ToString().Trim() != "")
  1199. {
  1200. gmDr["GM_Master"] = 0;
  1201. gmDr["GM_Relation"] = "夫妻";
  1202. }
  1203. else { gmDr["GM_Master"] = 1; gmDr["GM_Relation"] = "本人"; }
  1204. gmDr["GM_ProtagonistCustomer"] = 1;
  1205. gmDr["GM_RelatedPersonID"] = ID;
  1206. gmDr["GM_IsOrder"] = dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim() != "" ? 1 : 0;
  1207. gmDr["GM_IsOrderNumber"] = "";
  1208. //sqllist.Add(GM_Bll.GetAddCommandInfo(GM_Modelb));
  1209. erpCustomerGroupMembersNanDt.Rows.Add(gmDr);
  1210. }
  1211. if (dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim() != "" && dgv.Rows[i].Cells["套系价格"].Value.ToString().Trim() != "")
  1212. {
  1213. dr = oldOrderHistoryDt.NewRow();
  1214. dr["History_ID"] = GMID;
  1215. dr["History_Type"] = dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim();
  1216. dr["History_Money"] = Convert.ToInt32(dgv.Rows[i].Cells["套系价格"].Value.ToString().Trim());
  1217. if (dgv.Rows[i].Cells["订单日期"].Value.ToString().Trim() != "")
  1218. {
  1219. dr["History_OrderTime"] = Convert.ToDateTime(dgv.Rows[i].Cells["订单日期"].Value.ToString().Trim());
  1220. }
  1221. dr["History_CurrentID"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  1222. dr["History_CurrentTime"] = strTime;
  1223. oldOrderHistoryDt.Rows.Add(dr);
  1224. }
  1225. //客户组表
  1226. dr = erpCustomerGroupDt.NewRow();
  1227. dr["GP_DividedShop"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  1228. dr["GP_CustomerGroupID"] = GMID;
  1229. dr["GP_GroupType"] = Type;
  1230. dr["GP_CustomerType"] = "0";
  1231. dr["GP_CustomerStatus"] = "正常";
  1232. dr["GP_CreateDatetime"] = strTime;
  1233. dr["GP_CreateName"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  1234. dr["GP_CustomerSource"] = "";
  1235. dr["GP_Remark"] = "";
  1236. dr["GP_OrderNumber"] = "";
  1237. dr["GP_LossReason"] = "";
  1238. dr["GP_IntroducerCustomerID"] = "";
  1239. dr["GP_DegreeOfIntent"] = "";
  1240. dr["GP_BelongsPersonID"] = "";
  1241. erpCustomerGroupDt.Rows.Add(dr);
  1242. // namelist.Add("宝宝姓名:" + Baby.Cus_Name + ",家长姓名:" + RT_Cus_Model.Cus_Name);
  1243. string item = "先生姓名:" + nanName + ",女士姓名:" + nvName;
  1244. dr = erpSystemLogsDt.NewRow();
  1245. dr["Slogs_DividedShop"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  1246. dr["Slogs_Content"] = "添加联系人资料:" + item + ",时间:" + SDateTime.Now + "[" + HPSocketCS.Extended.CommonLibrary.ClientMarkID + ":" + HPSocketCS.Extended.CommonLibrary.ClientMarkName + "]";
  1247. dr["Slogs_CreateDatetime"] = SDateTime.Now;
  1248. dr["Slogs_CreateName"] = LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID;
  1249. dr["Slogs_UserName"] = LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name;
  1250. dr["Slogs_Type"] = LYFZ.EnumPublic.SystemLogsType.添加客户资料;
  1251. dr["Slogs_Topic"] = LYFZ.EnumPublic.SystemLogsType.添加客户资料;
  1252. dr["Slogs_IP"] = "-";
  1253. erpSystemLogsDt.Rows.Add(dr);
  1254. }
  1255. List<string> dataTableNames = new List<string>();
  1256. List<DataTable> dataTables = new List<DataTable>();
  1257. dataTableNames.Add("tb_ErpCustomer");
  1258. dataTableNames.Add("tb_ErpCustomerGroupMembers");
  1259. dataTableNames.Add("tb_ErpCustomer");
  1260. dataTableNames.Add("tb_ErpCustomerGroupMembers");
  1261. dataTableNames.Add("tb_OldOrderHistory");
  1262. dataTableNames.Add("tb_ErpCustomerGroup");
  1263. dataTableNames.Add("tb_ErpSystemLogs");
  1264. dataTables.Add(erpCustomerNvDt);
  1265. dataTables.Add(erpCustomerGroupMembersNvDt);
  1266. dataTables.Add(erpCustomerNanDt);
  1267. dataTables.Add(erpCustomerGroupMembersNanDt);
  1268. dataTables.Add(oldOrderHistoryDt);
  1269. dataTables.Add(erpCustomerGroupDt);
  1270. dataTables.Add(erpSystemLogsDt);
  1271. orbll.ExecuteSqlBulkCopyByDataTable(dataTableNames, dataTables);
  1272. }, width: 350);
  1273. }
  1274. else { MessageBoxCustom.Show("请导入Excel文档!"); }
  1275. }
  1276. catch (Exception ex)
  1277. {
  1278. MessageBoxCustom.Show(ex.Message);
  1279. }
  1280. }
  1281. /// <summary>
  1282. /// 写真,服务
  1283. /// </summary>
  1284. /// <param name="objtype">2=写真,3=服务</param>
  1285. [Obsolete]
  1286. void OldXZfw( int objtype )
  1287. {
  1288. try
  1289. {
  1290. if ( dgv.Rows.Count > 0 )
  1291. {
  1292. // List<string> namelist = new List<string>();
  1293. // Gmlist = new List<string>();
  1294. LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod( delegate ( object obj, BackgroundWorker backgroundWorker )
  1295. {
  1296. //总计数器
  1297. float sumCount = dgv.Rows.Count;
  1298. //当前计数器
  1299. int currentCount = 0;
  1300. for ( int i = 0; i < dgv.Rows.Count; i++ )
  1301. {
  1302. // 存放添加sql语句
  1303. List<Helper.CommandInfo> sqllist = new List<Helper.CommandInfo>();
  1304. DateTime strTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
  1305. //主联系人ID
  1306. string ID = LYFZ.BLL.BLL_ErpCustomer.GetClientNumber();
  1307. //客户关系组
  1308. string GMID = LYFZ.BLL.BLL_ErpCustomer.GetNewClientGroupNumber();
  1309. Model_ErpCustomer modelNan = new Model_ErpCustomer();
  1310. modelNan.Cus_CustomerNumber = ID;
  1311. modelNan.Cus_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  1312. modelNan.Cus_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter( dgv.Rows[i].Cells["姓名"].Value.ToString().Trim() );
  1313. modelNan.Cus_NamePinyin = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin( modelNan.Cus_Name ).ToLower();
  1314. modelNan.Cus_Sex = dgv.Rows[i].Cells["性别"].Value.ToString().Trim() == "男" ? false : true;
  1315. if ( dgv.Rows[i].Cells["生日"].Value.ToString().Trim() != "" )
  1316. {
  1317. modelNan.Cus_Birthday = Convert.ToDateTime( dgv.Rows[i].Cells["生日"].Value.ToString().Trim() ).ToString( "yyyy-MM-dd" );
  1318. }
  1319. modelNan.Cus_Telephone = dgv.Rows[i].Cells["电话"].Value.ToString().Trim();
  1320. modelNan.Cus_QQ = dgv.Rows[i].Cells["QQ"].Value.ToString().Trim();
  1321. modelNan.Cus_CreateDateTime = strTime;
  1322. modelNan.Cus_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  1323. sqllist.Add( Cus_Bll.GetAddCommandInfo( modelNan ) );
  1324. Model_ErpCustomerGroupMembers GM_Model = new Model_ErpCustomerGroupMembers();
  1325. GM_Model.GM_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  1326. GM_Model.GM_CustomerGroupID = GMID;
  1327. GM_Model.GM_CustomerID = ID;
  1328. GM_Model.GM_Master = 1;
  1329. GM_Model.GM_ProtagonistCustomer = 1;
  1330. GM_Model.GM_RelatedPersonID = ID;
  1331. GM_Model.GM_Relation = "本人";
  1332. GM_Model.GM_IsOrder = dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim() != "" ? 1 : 0;
  1333. GM_Model.GM_IsOrderNumber = "";
  1334. sqllist.Add( GM_Bll.GetAddCommandInfo( GM_Model ) );
  1335. if ( dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim() != "" && dgv.Rows[i].Cells["套系价格"].Value.ToString().Trim() != "" )
  1336. {
  1337. BLL.BLL_OldOrderHistory bll_ooh = new BLL_OldOrderHistory();
  1338. Model.Model_OldOrderHistory model_ooh = new Model_OldOrderHistory();
  1339. model_ooh.History_ID = GMID;
  1340. model_ooh.History_Type = dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim();
  1341. model_ooh.History_Money = Convert.ToInt32( dgv.Rows[i].Cells["套系价格"].Value.ToString().Trim() );
  1342. if ( dgv.Rows[i].Cells["订单日期"].Value.ToString().Trim() != "" )
  1343. {
  1344. model_ooh.History_OrderTime = Convert.ToDateTime( dgv.Rows[i].Cells["订单日期"].Value.ToString().Trim() );
  1345. }
  1346. model_ooh.History_CurrentID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  1347. model_ooh.History_CurrentTime = strTime;
  1348. sqllist.Add( bll_ooh.GetAddCommandInfo( model_ooh ) );
  1349. }
  1350. //客户组表
  1351. Model_ErpCustomerGroup GP_Model = new Model_ErpCustomerGroup();
  1352. GP_Model.GP_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  1353. GP_Model.GP_CustomerGroupID = GMID;
  1354. GP_Model.GP_GroupType = Type;
  1355. GP_Model.GP_CustomerType = objtype;
  1356. GP_Model.GP_CustomerStatus = "正常";
  1357. GP_Model.GP_CreateDatetime = strTime;
  1358. GP_Model.GP_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  1359. GP_Model.GP_CustomerSource = "";
  1360. GP_Model.GP_Remark = "";
  1361. GP_Model.GP_OrderNumber = "";
  1362. GP_Model.GP_LossReason = "";
  1363. GP_Model.GP_IntroducerCustomerID = "";
  1364. GP_Model.GP_DegreeOfIntent = "";
  1365. GP_Model.GP_BelongsPersonID = "";
  1366. sqllist.Add( GP_Bll.GetAddCommandInfo( GP_Model ) );
  1367. Gmlist.Add( GMID );
  1368. // namelist.Add("客户姓名:" + modelNan.Cus_Name);
  1369. string item = "客户姓名:" + modelNan.Cus_Name;
  1370. try
  1371. {
  1372. if ( LYFZ.BLL.BaseBllOperate.ExecuteSqlTran( sqllist ) > 0 )
  1373. {
  1374. //日志
  1375. LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog( LYFZ.EnumPublic.SystemLogsType.添加客户资料, "添加联系人资料:" + item + ",时间:" + SDateTime.Now, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name );
  1376. // DAL_ErpCustomer.UpdateAggregationCustomer(GMID);
  1377. }
  1378. }
  1379. catch ( Exception ex )
  1380. {
  1381. MessageBoxCustom.Show( item + " 的客户导入失败:" + ex.Message, backgroundWorker: backgroundWorker );
  1382. }
  1383. currentCount++;
  1384. if ( backgroundWorker != null )
  1385. {
  1386. try
  1387. {
  1388. int currentProgres = Convert.ToInt32( 1000 / sumCount * currentCount );
  1389. backgroundWorker.ReportProgress( currentProgres, "共" + sumCount + "条,正在导入第" + currentCount.ToString() + "条..." );
  1390. }
  1391. catch { }
  1392. }
  1393. }
  1394. }, width: 350 );
  1395. /* if (clist.Count > 0)
  1396. {
  1397. LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  1398. {
  1399. if (backgroundWorker != null)
  1400. {
  1401. try
  1402. {
  1403. backgroundWorker.ReportProgress(0, "准备中...请稍后!");
  1404. }
  1405. catch { }
  1406. }
  1407. if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0)
  1408. {
  1409. foreach (string item in namelist)
  1410. {
  1411. //日志
  1412. LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.添加客户资料, "添加联系人资料:" + item, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
  1413. }
  1414. //总计数器
  1415. float sumCount = Gmlist.Count;
  1416. //当前计数器
  1417. int currentCount = 0;
  1418. for (int i = 0; i < Gmlist.Count; i++)
  1419. {
  1420. currentCount++;
  1421. DAL_ErpCustomer.UpdateAggregationCustomer(Gmlist[i].ToString().Trim());
  1422. if (backgroundWorker != null)
  1423. {
  1424. try
  1425. {
  1426. int currentProgres = Convert.ToInt32(1000 / sumCount * currentCount);
  1427. backgroundWorker.ReportProgress(currentProgres, "正在添加..,共" + sumCount + "条,正在添加第:" + currentCount.ToString() + "条...");
  1428. }
  1429. catch { }
  1430. }
  1431. }
  1432. MessageBoxCustom.Show("添加成功!共导入:" + dgv.Rows.Count + "条");
  1433. this.DialogResult = DialogResult.OK;
  1434. }
  1435. else { MessageBoxCustom.Show("添加失败!"); }
  1436. }, width: 350);
  1437. }*/
  1438. }
  1439. else { MessageBoxCustom.Show( "请导入Excel文档!" ); }
  1440. }
  1441. catch ( Exception ex )
  1442. {
  1443. MessageBoxCustom.Show( ex.Message );
  1444. }
  1445. }
  1446. void OldXZfwNew(int objtype)
  1447. {
  1448. try
  1449. {
  1450. if (dgv.Rows.Count > 0)
  1451. {
  1452. // List<string> namelist = new List<string>();
  1453. // Gmlist = new List<string>();
  1454. LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker)
  1455. {
  1456. //总计数器
  1457. float sumCount = dgv.Rows.Count;
  1458. //当前计数器
  1459. int currentCount = 0;
  1460. DataTable erpCustomerDt = new DataTable();
  1461. BindDataTableColumData(
  1462. "Cus_CustomerNumber,Cus_DividedShop,Cus_Name,Cus_NamePinyin,Cus_Sex,Cus_Birthday,Cus_Telephone,Cus_QQ,Cus_CreateDateTime,Cus_CreateName"
  1463. .Split(','),
  1464. ref erpCustomerDt);
  1465. DataTable erpCustomerGroupMembersDt = new DataTable();
  1466. BindDataTableColumData(
  1467. "GM_DividedShop,GM_CustomerGroupID,GM_CustomerID,GM_Master,GM_ProtagonistCustomer,GM_RelatedPersonID,GM_Relation,GM_IsOrder,GM_IsOrderNumber"
  1468. .Split(','),
  1469. ref erpCustomerGroupMembersDt);
  1470. DataTable oldOrderHistoryDt = new DataTable();
  1471. BindDataTableColumData(
  1472. "History_ID,History_Type,History_Money,History_OrderTime,History_CurrentID,History_CurrentTime"
  1473. .Split(','),
  1474. ref oldOrderHistoryDt);
  1475. DataTable erpCustomerGroupDt = new DataTable();
  1476. BindDataTableColumData(
  1477. "GP_DividedShop,GP_CustomerGroupID,GP_GroupType,GP_CustomerType,GP_CustomerStatus,GP_CreateDatetime,GP_CreateName,GP_CustomerSource,GP_Remark,GP_OrderNumber,GP_LossReason,GP_IntroducerCustomerID,GP_DegreeOfIntent,GP_BelongsPersonID"
  1478. .Split(','),
  1479. ref erpCustomerGroupDt);
  1480. DataTable erpSystemLogsDt = new DataTable();
  1481. BindDataTableColumData(
  1482. "Slogs_DividedShop,Slogs_Content,Slogs_CreateDatetime,Slogs_CreateName,Slogs_UserName,Slogs_Type,Slogs_Topic,Slogs_IP"
  1483. .Split(','),
  1484. ref erpSystemLogsDt);
  1485. for (int i = 0; i < dgv.Rows.Count; i++)
  1486. {
  1487. // 存放添加sql语句
  1488. //List<Helper.CommandInfo> sqllist = new List<Helper.CommandInfo>();
  1489. DateTime strTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
  1490. //主联系人ID
  1491. string ID = LYFZ.BLL.BLL_ErpCustomer.GetClientNumber();
  1492. //客户关系组
  1493. string GMID = LYFZ.BLL.BLL_ErpCustomer.GetNewClientGroupNumber();
  1494. string nanName = "";
  1495. //宝宝
  1496. DataRow dr = null;
  1497. //Cus_CustomerNumber,Cus_DividedShop,Cus_Name,Cus_NamePinyin,Cus_Sex,Cus_Birthday,Cus_Telephone,Cus_QQ,Cus_CreateDateTime,Cus_CreateName
  1498. dr = erpCustomerDt.NewRow();
  1499. dr["Cus_CustomerNumber"] = ID;
  1500. dr["Cus_DividedShop"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  1501. dr["Cus_Name"] = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(dgv.Rows[i].Cells["姓名"].Value.ToString().Trim());
  1502. dr["Cus_NamePinyin"] = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin(dr["Cus_Name"].ToString_s()).ToLower();
  1503. dr["Cus_Sex"] = dgv.Rows[i].Cells["性别"].Value.ToString().Trim() == "男" ? false : true;
  1504. if (dgv.Rows[i].Cells["生日"].Value.ToString().Trim() != "")
  1505. {
  1506. dr["Cus_Birthday"] = Convert.ToDateTime(dgv.Rows[i].Cells["生日"].Value.ToString().Trim()).ToString("yyyy-MM-dd");
  1507. }
  1508. dr["Cus_Telephone"] = dgv.Rows[i].Cells["电话"].Value.ToString().Trim();
  1509. dr["Cus_QQ"] = dgv.Rows[i].Cells["QQ"].Value.ToString().Trim();
  1510. dr["Cus_CreateDateTime"] = strTime;
  1511. dr["Cus_CreateName"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  1512. nanName = dr["Cus_Name"].ToString_s();
  1513. erpCustomerDt.Rows.Add(dr);
  1514. //sqllist.Add(Cus_Bll.GetAddCommandInfo(modelNan));
  1515. //Model_ErpCustomerGroupMembers GM_Model = new Model_ErpCustomerGroupMembers();
  1516. //GM_DividedShop,GM_CustomerGroupID,GM_CustomerID,GM_Master,GM_ProtagonistCustomer,GM_RelatedPersonID,GM_Relation,GM_IsOrder,GM_IsOrderNumber
  1517. dr = erpCustomerGroupMembersDt.NewRow();
  1518. dr["GM_DividedShop"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  1519. dr["GM_CustomerGroupID"] = GMID;
  1520. dr["GM_CustomerID"] = ID;
  1521. dr["GM_Master"] = 1;
  1522. dr["GM_ProtagonistCustomer"] = 1;
  1523. dr["GM_RelatedPersonID"] = ID;
  1524. dr["GM_Relation"] = "本人";
  1525. dr["GM_IsOrder"] = dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim() != "" ? 1 : 0;
  1526. dr["GM_IsOrderNumber"] = "";
  1527. erpCustomerGroupMembersDt.Rows.Add(dr);
  1528. if (dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim() != "" && dgv.Rows[i].Cells["套系价格"].Value.ToString().Trim() != "")
  1529. {
  1530. dr = oldOrderHistoryDt.NewRow();
  1531. dr["History_ID"] = GMID;
  1532. dr["History_Type"] = dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim();
  1533. dr["History_Money"] = Convert.ToInt32(dgv.Rows[i].Cells["套系价格"].Value.ToString().Trim());
  1534. if (dgv.Rows[i].Cells["订单日期"].Value.ToString().Trim() != "")
  1535. {
  1536. dr["History_OrderTime"] = Convert.ToDateTime(dgv.Rows[i].Cells["订单日期"].Value.ToString().Trim());
  1537. }
  1538. dr["History_CurrentID"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  1539. dr["History_CurrentTime"] = strTime;
  1540. oldOrderHistoryDt.Rows.Add(dr);
  1541. }
  1542. //客户组表
  1543. dr = erpCustomerGroupDt.NewRow();
  1544. dr["GP_DividedShop"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  1545. dr["GP_CustomerGroupID"] = GMID;
  1546. dr["GP_GroupType"] = Type;
  1547. dr["GP_CustomerType"] = objtype;
  1548. dr["GP_CustomerStatus"] = "正常";
  1549. dr["GP_CreateDatetime"] = strTime;
  1550. dr["GP_CreateName"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  1551. dr["GP_CustomerSource"] = "";
  1552. dr["GP_Remark"] = "";
  1553. dr["GP_OrderNumber"] = "";
  1554. dr["GP_LossReason"] = "";
  1555. dr["GP_IntroducerCustomerID"] = "";
  1556. dr["GP_DegreeOfIntent"] = "";
  1557. dr["GP_BelongsPersonID"] = "";
  1558. erpCustomerGroupDt.Rows.Add(dr);
  1559. // namelist.Add("客户姓名:" + modelNan.Cus_Name);
  1560. string item = "客户姓名:" + nanName;
  1561. dr = erpSystemLogsDt.NewRow();
  1562. dr["Slogs_DividedShop"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  1563. dr["Slogs_Content"] = "添加联系人资料:" + item + ",时间:" + SDateTime.Now + "[" + HPSocketCS.Extended.CommonLibrary.ClientMarkID + ":" + HPSocketCS.Extended.CommonLibrary.ClientMarkName + "]";
  1564. dr["Slogs_CreateDatetime"] = SDateTime.Now;
  1565. dr["Slogs_CreateName"] = LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID;
  1566. dr["Slogs_UserName"] = LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name;
  1567. dr["Slogs_Type"] = LYFZ.EnumPublic.SystemLogsType.添加客户资料;
  1568. dr["Slogs_Topic"] = LYFZ.EnumPublic.SystemLogsType.添加客户资料;
  1569. dr["Slogs_IP"] = "-";
  1570. erpSystemLogsDt.Rows.Add(dr);
  1571. }
  1572. List<string> dataTableNames = new List<string>();
  1573. List<DataTable> dataTables = new List<DataTable>();
  1574. dataTableNames.Add("tb_ErpCustomer");
  1575. dataTableNames.Add("tb_ErpCustomerGroupMembers");
  1576. dataTableNames.Add("tb_OldOrderHistory");
  1577. dataTableNames.Add("tb_ErpCustomerGroup");
  1578. dataTableNames.Add("tb_ErpSystemLogs");
  1579. dataTables.Add(erpCustomerDt);
  1580. dataTables.Add(erpCustomerGroupMembersDt);
  1581. dataTables.Add(oldOrderHistoryDt);
  1582. dataTables.Add(erpCustomerGroupDt);
  1583. dataTables.Add(erpSystemLogsDt);
  1584. orbll.ExecuteSqlBulkCopyByDataTable(dataTableNames, dataTables);
  1585. }, width: 350);
  1586. }
  1587. else { MessageBoxCustom.Show("请导入Excel文档!"); }
  1588. }
  1589. catch (Exception ex)
  1590. {
  1591. MessageBoxCustom.Show(ex.Message);
  1592. }
  1593. }
  1594. #endregion
  1595. #region 老客户检查操作
  1596. /// <summary>
  1597. /// 错误类型
  1598. /// </summary>
  1599. enum error
  1600. {
  1601. 手机号不能为空,
  1602. 手机号已存在,
  1603. 手机号必须是11位,
  1604. 家长姓名不能为空,
  1605. 宝宝生日错误,
  1606. 宝宝性别只能是男或女或不填,
  1607. 订单日期格式错误,
  1608. 套系价格只能输入数字,
  1609. 手机号在Excel中多次出现,
  1610. 生日错误,
  1611. 婚期错误,
  1612. 姓名不能为空,
  1613. 性别只能是男或女或不填,
  1614. ok
  1615. }
  1616. /// <summary>
  1617. /// 检查宝宝
  1618. /// </summary>
  1619. /// <returns></returns>
  1620. StringBuilder checkBaby( DataRow data, DataTable tblClient )
  1621. {
  1622. StringBuilder ok = new StringBuilder();
  1623. string list = "";
  1624. list = cheSJ( data["手机号"].ToString().Trim(), tblClient ).ToString();
  1625. ok.Append( list == error.ok.ToString() ? "" : list );
  1626. if ( data["家长姓名"].ToString().Trim() == "" )
  1627. {
  1628. ok.Append( error.家长姓名不能为空.ToString() );
  1629. }
  1630. if ( data["宝宝生日"].ToString().Trim() != "" )
  1631. {
  1632. if ( !cheSR( data["宝宝生日"].ToString().Trim() ) )
  1633. {
  1634. ok.Append( error.宝宝生日错误.ToString() );
  1635. }
  1636. }
  1637. if ( data["宝宝性别"].ToString().Trim() != "男" && data["宝宝性别"].ToString().Trim() != "女" && data["宝宝性别"].ToString().Trim() != "" )
  1638. {
  1639. ok.Append( error.宝宝性别只能是男或女或不填.ToString() );
  1640. }
  1641. if ( data["订单日期"].ToString().Trim() != "" )
  1642. {
  1643. if ( !cheDDRQ( data["订单日期"].ToString().Trim() ) )
  1644. {
  1645. ok.Append( error.订单日期格式错误.ToString() );
  1646. }
  1647. }
  1648. if ( data["套系价格"].ToString().Trim() != "" )
  1649. {
  1650. if ( !cheTXJG( data["套系价格"].ToString().Trim() ) )
  1651. {
  1652. ok.Append( error.套系价格只能输入数字.ToString() );
  1653. }
  1654. }
  1655. return ok;
  1656. }
  1657. /// <summary>
  1658. /// 检查婚纱版
  1659. /// </summary>
  1660. /// <returns></returns>
  1661. StringBuilder checkHS( DataRow data, DataTable tblClient )
  1662. {
  1663. StringBuilder ok = new StringBuilder();
  1664. if ( dt.Rows.Count > 0 )
  1665. {
  1666. if ( data["女士名字"].ToString().Trim() != "" )
  1667. {
  1668. if ( data["女士手机号"].ToString().Trim() != "" )
  1669. {
  1670. string list = "";
  1671. list = cheSJ( data["女士手机号"].ToString().Trim(), tblClient ).ToString();
  1672. ok.Append( list == error.ok.ToString() ? "" : list );
  1673. }
  1674. }
  1675. if ( data["先生名字"].ToString().Trim() != "" )
  1676. {
  1677. if ( data["先生手机号"].ToString().Trim() != "" )
  1678. {
  1679. string list = "";
  1680. list = cheSJ( data["先生手机号"].ToString().Trim(), tblClient ).ToString();
  1681. ok.Append( list == error.ok.ToString() ? "" : list );
  1682. }
  1683. }
  1684. if ( data["先生生日"].ToString().Trim() != "" )
  1685. {
  1686. if ( cheSR( data["先生生日"].ToString() ) == false )
  1687. {
  1688. ok.Append( error.生日错误.ToString() );
  1689. }
  1690. }
  1691. if ( data["女士生日"].ToString().Trim() != "" )
  1692. {
  1693. if ( cheSR( data["女士生日"].ToString() ) == false )
  1694. {
  1695. ok.Append( error.生日错误.ToString() );
  1696. }
  1697. }
  1698. if ( data["婚期"].ToString().Trim() != "" )
  1699. {
  1700. if ( cheSR( data["婚期"].ToString() ) == false )
  1701. {
  1702. ok.Append( error.生日错误.ToString() );
  1703. }
  1704. }
  1705. if ( data["套系价格"].ToString().Trim() != "" )
  1706. {
  1707. if ( cheTXJG( data["套系价格"].ToString() ) == false )
  1708. {
  1709. ok.Append( error.套系价格只能输入数字.ToString() );
  1710. }
  1711. }
  1712. if ( data["订单日期"].ToString().Trim() != "" )
  1713. {
  1714. if ( cheDDRQ( data["订单日期"].ToString() ) == false )
  1715. {
  1716. ok.Append( error.订单日期格式错误.ToString() );
  1717. }
  1718. }
  1719. }
  1720. return ok;
  1721. }
  1722. /// <summary>
  1723. /// 写真和服务
  1724. /// </summary>
  1725. /// <returns></returns>
  1726. StringBuilder checkXZfw( DataRow data, DataTable tblClient )
  1727. {
  1728. StringBuilder ok = new StringBuilder();
  1729. if ( dt.Rows.Count > 0 )
  1730. {
  1731. if ( data["姓名"].ToString().Trim() == "" )
  1732. {
  1733. ok.Append( error.姓名不能为空.ToString() );
  1734. }
  1735. if ( data["性别"].ToString().Trim() != "男" && data["性别"].ToString().Trim() != "女" )
  1736. {
  1737. ok.Append( error.性别只能是男或女或不填.ToString() );
  1738. }
  1739. string list = "";
  1740. list = cheSJ( data["电话"].ToString().Trim(), tblClient ).ToString();
  1741. ok.Append( list == error.ok.ToString() ? "" : list );
  1742. if ( data["生日"].ToString().Trim() != "" )
  1743. {
  1744. if ( !cheSR( data["生日"].ToString().Trim() ) )
  1745. {
  1746. ok.Append( error.生日错误.ToString() );
  1747. }
  1748. }
  1749. if ( data["套系价格"].ToString().Trim() != "" )
  1750. {
  1751. if ( !cheTXJG( data["套系价格"].ToString().Trim() ) )
  1752. {
  1753. ok.Append( error.套系价格只能输入数字.ToString() );
  1754. }
  1755. }
  1756. if ( data["订单日期"].ToString().Trim() != "" )
  1757. {
  1758. if ( cheDDRQ( data["订单日期"].ToString() ) == false )
  1759. {
  1760. ok.Append( error.订单日期格式错误.ToString() );
  1761. }
  1762. }
  1763. }
  1764. return ok;
  1765. }
  1766. #endregion
  1767. #region 意向客户添加操作
  1768. /// <summary>
  1769. /// 添加意向客户 婚纱 写真 服务
  1770. /// </summary>
  1771. bool addYixiang()
  1772. {
  1773. bool upData = true;
  1774. try
  1775. {
  1776. if ( dgv.Rows.Count > 0 )
  1777. {
  1778. // Gmlist = new List<string>();
  1779. // List<string> namelist = new List<string>();
  1780. LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod( delegate ( object obj, BackgroundWorker backgroundWorker )
  1781. {//总计数器
  1782. try
  1783. {
  1784. float sumCount = dgv.Rows.Count;
  1785. //当前计数器
  1786. int currentCount = 0;
  1787. for (int i = 0; i < dgv.Rows.Count; i++)
  1788. { // 存放添加sql语句
  1789. List<Helper.CommandInfo> sqllist = new List<Helper.CommandInfo>();
  1790. DateTime strTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
  1791. //主联系人ID
  1792. string ID = LYFZ.BLL.BLL_ErpCustomer.GetClientNumber();
  1793. //客户关系组
  1794. string GMID = LYFZ.BLL.BLL_ErpCustomer.GetNewClientGroupNumber();
  1795. Model_ErpCustomer model = new Model_ErpCustomer();
  1796. if (dgv.Rows[i].Cells["订单类型"].Value.ToString().Trim() == "儿童")
  1797. {
  1798. model.Cus_CustomerNumber = ID;
  1799. model.Cus_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  1800. model.Cus_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(dgv.Rows[i].Cells["客户姓名"].Value.ToString().Trim());
  1801. model.Cus_NamePinyin = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin(model.Cus_Name).ToLower();
  1802. model.Cus_Sex = dgv.Rows[i].Cells["性别"].Value.ToString().Trim() == "男" ? false : true;
  1803. if (dgv.Rows[i].Cells["生日"].Value.ToString().Trim() != "")
  1804. {
  1805. model.Cus_Birthday = Convert.ToDateTime(dgv.Rows[i].Cells["生日"].Value.ToString().Trim()).ToString("yyyy-MM-dd");
  1806. }
  1807. model.Cus_Telephone = dgv.Rows[i].Cells["电话"].Value.ToString().Trim();
  1808. model.Cus_QQ = dgv.Rows[i].Cells["QQ"].Value.ToString().Trim();
  1809. model.Cus_Address = dgv.Rows[i].Cells["地址"].Value.ToString().Trim();
  1810. model.Cus_CreateDateTime = strTime;
  1811. model.Cus_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  1812. model.Cus_CustomerSource = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(dgv.Rows[i].Cells["客户来源"].Value.ToString().Trim());
  1813. sqllist.Add(Cus_Bll.GetAddCommandInfo(model));
  1814. Model_ErpCustomerGroupMembers GM_Model = new Model_ErpCustomerGroupMembers();
  1815. GM_Model.GM_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  1816. GM_Model.GM_CustomerGroupID = GMID;
  1817. GM_Model.GM_CustomerID = ID;
  1818. GM_Model.GM_Master = 1;
  1819. GM_Model.GM_ProtagonistCustomer = 0;
  1820. GM_Model.GM_RelatedPersonID = ID;
  1821. GM_Model.GM_Relation = "亲人";
  1822. GM_Model.GM_IsOrder = 0;
  1823. GM_Model.GM_IsOrderNumber = "";
  1824. sqllist.Add(GM_Bll.GetAddCommandInfo(GM_Model));
  1825. //客户组表
  1826. Model_ErpCustomerGroup GP_Model = new Model_ErpCustomerGroup();
  1827. GP_Model.GP_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  1828. GP_Model.GP_CustomerGroupID = GMID;
  1829. GP_Model.GP_GroupType = Type;
  1830. GP_Model.GP_ISIntentionCustomer = 1;
  1831. GP_Model.GP_CustomerType = Lun(dgv.Rows[i].Cells["订单类型"].Value.ToString().Trim());
  1832. GP_Model.GP_CustomerStatus = "意向";
  1833. GP_Model.GP_CreateDatetime = strTime;
  1834. GP_Model.GP_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  1835. GP_Model.GP_CustomerSource = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(dgv.Rows[i].Cells["客户来源"].Value.ToString().Trim());
  1836. GP_Model.GP_Remark = "";
  1837. GP_Model.GP_OrderNumber = "";
  1838. GP_Model.GP_LossReason = "";
  1839. GP_Model.GP_IntroducerCustomerID = "";
  1840. GP_Model.GP_DegreeOfIntent = "";
  1841. GP_Model.GP_BelongsPersonID = "";
  1842. sqllist.Add(GP_Bll.GetAddCommandInfo(GP_Model));
  1843. Gmlist.Add(GMID);
  1844. }
  1845. else
  1846. {
  1847. // Model_ErpCustomer model = new Model_ErpCustomer();
  1848. model.Cus_CustomerNumber = ID;
  1849. model.Cus_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  1850. model.Cus_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(dgv.Rows[i].Cells["客户姓名"].Value.ToString().Trim());
  1851. model.Cus_NamePinyin = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin(model.Cus_Name).ToLower();
  1852. model.Cus_Sex = dgv.Rows[i].Cells["性别"].Value.ToString().Trim() == "男" ? false : true;
  1853. if (dgv.Rows[i].Cells["生日"].Value.ToString().Trim() != "")
  1854. {
  1855. model.Cus_Birthday = Convert.ToDateTime(dgv.Rows[i].Cells["生日"].Value.ToString().Trim()).ToString("yyyy-MM-dd");
  1856. }
  1857. model.Cus_Telephone = dgv.Rows[i].Cells["电话"].Value.ToString().Trim();
  1858. model.Cus_QQ = dgv.Rows[i].Cells["QQ"].Value.ToString().Trim();
  1859. model.Cus_Address = dgv.Rows[i].Cells["地址"].Value.ToString().Trim();
  1860. model.Cus_CreateDateTime = strTime;
  1861. model.Cus_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  1862. model.Cus_CustomerSource = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(dgv.Rows[i].Cells["客户来源"].Value.ToString().Trim());
  1863. sqllist.Add(Cus_Bll.GetAddCommandInfo(model));
  1864. Model_ErpCustomerGroupMembers GM_Model = new Model_ErpCustomerGroupMembers();
  1865. GM_Model.GM_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  1866. GM_Model.GM_CustomerGroupID = GMID;
  1867. GM_Model.GM_CustomerID = ID;
  1868. GM_Model.GM_Master = 1;
  1869. GM_Model.GM_ProtagonistCustomer = 1;
  1870. GM_Model.GM_RelatedPersonID = ID;
  1871. GM_Model.GM_Relation = "本人";
  1872. GM_Model.GM_IsOrder = 0;
  1873. GM_Model.GM_IsOrderNumber = "";
  1874. sqllist.Add(GM_Bll.GetAddCommandInfo(GM_Model));
  1875. //客户组表
  1876. Model_ErpCustomerGroup GP_Model = new Model_ErpCustomerGroup();
  1877. GP_Model.GP_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  1878. GP_Model.GP_CustomerGroupID = GMID;
  1879. GP_Model.GP_GroupType = Type;
  1880. GP_Model.GP_CustomerType = Lun(dgv.Rows[i].Cells["订单类型"].Value.ToString().Trim());
  1881. GP_Model.GP_CustomerStatus = "意向";
  1882. GP_Model.GP_CreateDatetime = strTime;
  1883. GP_Model.GP_ISIntentionCustomer = 1;
  1884. GP_Model.GP_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  1885. GP_Model.GP_CustomerSource = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(dgv.Rows[i].Cells["客户来源"].Value.ToString().Trim());
  1886. GP_Model.GP_Remark = "";
  1887. GP_Model.GP_OrderNumber = "";
  1888. GP_Model.GP_LossReason = "";
  1889. GP_Model.GP_IntroducerCustomerID = "";
  1890. GP_Model.GP_DegreeOfIntent = "";
  1891. GP_Model.GP_BelongsPersonID = "";
  1892. sqllist.Add(GP_Bll.GetAddCommandInfo(GP_Model));
  1893. Gmlist.Add(GMID);
  1894. }
  1895. // namelist.Add("客户姓名:" + model.Cus_Name);
  1896. string item = "客户姓名:" + model.Cus_Name;
  1897. try
  1898. {
  1899. if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(sqllist) > 0)
  1900. {
  1901. //日志
  1902. LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.添加客户资料, "添加联系人资料:" + item + ",时间:" + SDateTime.Now, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
  1903. // DAL_ErpCustomer.UpdateAggregationCustomer(GMID);
  1904. }
  1905. }
  1906. catch (Exception ex)
  1907. {
  1908. upData = false;
  1909. MessageBoxCustom.Show(item + " 的客户导入失败:" + ex.Message, backgroundWorker: backgroundWorker);
  1910. }
  1911. currentCount++;
  1912. if (backgroundWorker != null)
  1913. {
  1914. try
  1915. {
  1916. int currentProgres = Convert.ToInt32(1000 / sumCount * currentCount);
  1917. backgroundWorker.ReportProgress(currentProgres, "共" + sumCount + "条,正在导入第" + currentCount.ToString() + "条...");
  1918. }
  1919. catch { }
  1920. }
  1921. }
  1922. }
  1923. catch(Exception ex)
  1924. {
  1925. upData = false;
  1926. MessageBoxCustom.Show(ex.Message, "错误提示");
  1927. }
  1928. }, width: 350 );
  1929. /* if (clist.Count > 0)
  1930. {
  1931. LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  1932. {
  1933. if (backgroundWorker != null)
  1934. {
  1935. try
  1936. {
  1937. backgroundWorker.ReportProgress(0, "准备中...请稍后!");
  1938. }
  1939. catch { }
  1940. }
  1941. if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) >= 0)
  1942. {
  1943. foreach (string item in namelist)
  1944. {
  1945. //日志
  1946. LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.添加客户资料, "添加联系人资料:" + item, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
  1947. }
  1948. //总计数器
  1949. float sumCount = Gmlist.Count;
  1950. //当前计数器
  1951. int currentCount = 0;
  1952. for (int i = 0; i < Gmlist.Count; i++)
  1953. {
  1954. currentCount++;
  1955. DAL_ErpCustomer.UpdateAggregationCustomer(Gmlist[i].ToString().Trim());
  1956. if (backgroundWorker != null)
  1957. {
  1958. try
  1959. {
  1960. int currentProgres = Convert.ToInt32(1000 / sumCount * currentCount);
  1961. backgroundWorker.ReportProgress(currentProgres, "正在添加..,共" + sumCount + "条,正在添加第:" + currentCount.ToString() + "条...");
  1962. }
  1963. catch { }
  1964. }
  1965. }
  1966. MessageBoxCustom.Show("添加成功!共导入:" + dgv.Rows.Count + "条");
  1967. this.DialogResult = DialogResult.OK;
  1968. }
  1969. else { MessageBoxCustom.Show("添加失败!"); }
  1970. }, width: 350);
  1971. }*/
  1972. }
  1973. else {
  1974. upData = false;
  1975. MessageBoxCustom.Show( "请导入Excel文档!" );
  1976. }
  1977. }
  1978. catch ( Exception ex )
  1979. {
  1980. upData = false;
  1981. MessageBoxCustom.Show( ex.Message );
  1982. }
  1983. return upData;
  1984. }
  1985. #endregion
  1986. #region 意向客户检查操作
  1987. /// <summary>
  1988. /// 检测意向客户 婚纱 写真 服务 儿童
  1989. /// </summary>
  1990. /// <returns></returns>
  1991. StringBuilder UYixiang( DataRow data, DataTable tblClient )
  1992. {
  1993. StringBuilder ok = new StringBuilder();
  1994. if ( data["客户姓名"].ToString().Trim() == "" )
  1995. {
  1996. ok.Append( error.姓名不能为空.ToString() );
  1997. }
  1998. if ( data["性别"].ToString().Trim() != "男" && data["性别"].ToString().Trim() != "女" )
  1999. {
  2000. ok.Append( error.性别只能是男或女或不填.ToString() );
  2001. }
  2002. string list = "";
  2003. list = cheSJ( data["电话"].ToString().Trim(), tblClient ).ToString();
  2004. ok.Append( list == error.ok.ToString() ? "" : list );
  2005. if ( data["生日"].ToString().Trim() != "" )
  2006. {
  2007. if ( !cheSR( data["生日"].ToString().Trim() ) )
  2008. {
  2009. ok.Append( error.生日错误.ToString() );
  2010. }
  2011. }
  2012. string Dindanleixing = data["订单类型"].ToString().Trim();
  2013. if ( Dindanleixing == "" )
  2014. {
  2015. ok.Append( "类型不能为空," );
  2016. }
  2017. if ( Dindanleixing != "写真" && Dindanleixing != "服务" && Dindanleixing != "婚纱" && Dindanleixing != "儿童" )
  2018. {
  2019. ok.Append( "类型错误错误," );
  2020. }
  2021. return ok;
  2022. }
  2023. #endregion
  2024. #region 其他客户检查操作
  2025. StringBuilder checkOther( DataRow data, DataTable tblClient )
  2026. {
  2027. StringBuilder ok = new StringBuilder();
  2028. if ( dt.Rows.Count > 0 )
  2029. {
  2030. if ( data["客户姓名"].ToString().Trim() == "" )
  2031. {
  2032. ok.Append( error.姓名不能为空.ToString() );
  2033. }
  2034. if ( data["性别"].ToString().Trim() != "男" && data["性别"].ToString().Trim() != "女" )
  2035. {
  2036. ok.Append( error.性别只能是男或女或不填.ToString() );
  2037. }
  2038. string list = "";
  2039. list = cheSJ( data["电话"].ToString().Trim(), tblClient ).ToString();
  2040. ok.Append( list == error.ok.ToString() ? "" : list );
  2041. if ( data["生日"].ToString().Trim() != "" )
  2042. {
  2043. if ( !cheSR( data["生日"].ToString().Trim() ) )
  2044. {
  2045. ok.Append( error.生日错误.ToString() );
  2046. }
  2047. }
  2048. }
  2049. return ok;
  2050. }
  2051. #endregion
  2052. #region 其他客户添加操作
  2053. /// <summary>
  2054. /// 其他客户添加
  2055. /// </summary>
  2056. void AddOther()
  2057. {
  2058. // List<string> namelist = new List<string>();
  2059. LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod( delegate ( object obj, BackgroundWorker backgroundWorker )
  2060. {//总计数器
  2061. float sumCount = dgv.Rows.Count;
  2062. //当前计数器
  2063. int currentCount = 0;
  2064. for ( int i = 0; i < dgv.Rows.Count; i++ )
  2065. { // 存放添加sql语句
  2066. List<Helper.CommandInfo> sqllist = new List<Helper.CommandInfo>();
  2067. Model_ErpCustomer Cus_Model = new Model_ErpCustomer();
  2068. Cus_Model.Cus_CustomerNumber = LYFZ.BLL.BLL_ErpCustomer.GetClientNumber();
  2069. Cus_Model.Cus_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  2070. Cus_Model.Cus_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter( dgv.Rows[i].Cells["客户姓名"].Value.ToString().Trim() );
  2071. Cus_Model.Cus_NamePinyin = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin( Cus_Model.Cus_Name ).ToLower();
  2072. Cus_Model.Cus_Sex = dgv.Rows[i].Cells["性别"].Value.ToString().Trim() == "男" ? false : true;
  2073. if ( dgv.Rows[i].Cells["生日"].Value.ToString().Trim() != "" )
  2074. {
  2075. Cus_Model.Cus_Birthday = Convert.ToDateTime( dgv.Rows[i].Cells["生日"].Value.ToString().Trim() ).ToString( "yyyy-MM-dd" );
  2076. }
  2077. Cus_Model.Cus_Telephone = dgv.Rows[i].Cells["电话"].Value.ToString().Trim();
  2078. Cus_Model.Cus_QQ = dgv.Rows[i].Cells["QQ"].Value.ToString().Trim();
  2079. Cus_Model.Cus_Address = dgv.Rows[i].Cells["地址"].Value.ToString().Trim();
  2080. Cus_Model.Cus_CreateDateTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
  2081. Cus_Model.Cus_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  2082. sqllist.Add( Cus_Bll.GetAddCommandInfo( Cus_Model ) );
  2083. // namelist.Add("客户姓名:" + Cus_Model.Cus_Name);
  2084. string item = "客户姓名:" + Cus_Model.Cus_Name;
  2085. try
  2086. {
  2087. if ( LYFZ.BLL.BaseBllOperate.ExecuteSqlTran( sqllist ) > 0 )
  2088. {
  2089. //日志
  2090. LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog( LYFZ.EnumPublic.SystemLogsType.添加客户资料, "添加联系人资料:" + item + ",时间:" + SDateTime.Now, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name );
  2091. // DAL_ErpCustomer.UpdateAggregationCustomer(GMID);
  2092. }
  2093. }
  2094. catch ( Exception ex )
  2095. {
  2096. MessageBoxCustom.Show( item + " 的客户导入失败:" + ex.Message, backgroundWorker: backgroundWorker );
  2097. }
  2098. currentCount++;
  2099. if ( backgroundWorker != null )
  2100. {
  2101. try
  2102. {
  2103. int currentProgres = Convert.ToInt32( 1000 / sumCount * currentCount );
  2104. backgroundWorker.ReportProgress( currentProgres, "共" + sumCount + "条,正在导入第" + currentCount.ToString() + "条..." );
  2105. }
  2106. catch { }
  2107. }
  2108. }
  2109. /* if (clist.Count > 0)
  2110. {
  2111. if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) >= 0)
  2112. {
  2113. foreach (string item in namelist)
  2114. {
  2115. //日志
  2116. LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.添加客户资料, "添加联系人资料:" + item + ",时间:" + SDateTime.Now, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
  2117. }
  2118. MessageBoxCustom.Show("添加成功!共导入:" + dgv.Rows.Count + "条");
  2119. this.DialogResult = DialogResult.OK;
  2120. }
  2121. else { MessageBoxCustom.Show("添加失败!"); }
  2122. }*/
  2123. }, width: 350 );
  2124. }
  2125. #endregion
  2126. #region 判读公共方法
  2127. /// <summary>
  2128. /// 判断手机是否正确
  2129. /// </summary>
  2130. /// <returns></returns>
  2131. error cheSJ( string SJ, DataTable tblClient )
  2132. {
  2133. if ( SJ == "" )
  2134. {
  2135. return error.手机号不能为空;
  2136. }
  2137. if ( SJ.ToString().Trim().Length != 11 )
  2138. {
  2139. return error.手机号必须是11位;
  2140. }
  2141. DataRow[] sjrow = tblClient.Select( " Cus_Telephone='" + SJ + "'" );
  2142. if ( sjrow.Length > 0 )
  2143. {
  2144. return error.手机号已存在;
  2145. }
  2146. else if ( !check( SJ ) ) { return error.手机号在Excel中多次出现; } else { return error.ok; }
  2147. }
  2148. /// <summary>
  2149. /// 判断生日是否正确
  2150. /// </summary>
  2151. /// <returns></returns>
  2152. bool cheSR( string SR )
  2153. {
  2154. try
  2155. {
  2156. DateTime.Parse( SR );
  2157. return true;
  2158. }
  2159. catch { return false; }
  2160. }
  2161. /// <summary>
  2162. /// 判断套系价格
  2163. /// </summary>
  2164. /// <returns></returns>
  2165. bool cheTXJG( string GJ )
  2166. {
  2167. try
  2168. {
  2169. int o;
  2170. if ( !int.TryParse( GJ.Trim(), out o ) )
  2171. {
  2172. return false;
  2173. }
  2174. else { return true; }
  2175. }
  2176. catch { return false; }
  2177. }
  2178. /// <summary>
  2179. /// 检查订单日期
  2180. /// </summary>
  2181. /// <returns></returns>
  2182. bool cheDDRQ( string rq )
  2183. {
  2184. string sss = rq.Replace( "-", "" );
  2185. if ( (rq.Length - sss.Length) == 1 )
  2186. {
  2187. rq = rq.Split( '-' )[0].Insert( 4, "-" ).Insert( 7, "-" );
  2188. }
  2189. try
  2190. {
  2191. DateTime.Parse( rq );
  2192. return true;
  2193. }
  2194. catch { return true; }
  2195. }
  2196. #endregion
  2197. #region 判读公共数据方法
  2198. string DDRQ( string rq )
  2199. {
  2200. string sss = rq.Replace( "-", "" );
  2201. if ( (rq.Length - sss.Length) == 1 )
  2202. {
  2203. rq = rq.Split( '-' )[0].Insert( 4, "-" ).Insert( 7, "-" );
  2204. }
  2205. return rq;
  2206. }
  2207. /// <summary>
  2208. /// 遍历类型
  2209. /// </summary>
  2210. /// <param name="str"></param>
  2211. /// <returns></returns>
  2212. int Lun( string str )
  2213. {
  2214. int cLeixing = 0;
  2215. switch ( str )
  2216. {
  2217. case "婚纱":
  2218. cLeixing = 0;
  2219. break;
  2220. case "儿童":
  2221. cLeixing = 1;
  2222. break;
  2223. case "写真":
  2224. cLeixing = 2;
  2225. break;
  2226. case "服务":
  2227. cLeixing = 3;
  2228. break;
  2229. }
  2230. return cLeixing;
  2231. }
  2232. /// <summary>
  2233. /// 封装当前手机号
  2234. /// </summary>
  2235. /// <param name="lie"></param>
  2236. /// <returns></returns>
  2237. string StrDianhua( string lie, DataTable dt )
  2238. {
  2239. string str = "";
  2240. for ( int i = 0; i < dt.Rows.Count; i++ )
  2241. {
  2242. str += "'" + dt.Rows[i][lie].ToString().Trim() + "',";
  2243. }
  2244. str = str.Substring( 0, str.Length - 1 );
  2245. return str;
  2246. }
  2247. /// <summary>
  2248. /// 检查手机是存在 true 没有
  2249. /// </summary>
  2250. /// <param name="sj"></param>
  2251. /// <returns></returns>
  2252. public bool check( string sj )
  2253. {
  2254. if ( list.IndexOf( sj ) == -1 )
  2255. {
  2256. list.Add( sj );
  2257. return true;
  2258. }
  2259. else
  2260. {
  2261. return false;
  2262. }
  2263. }
  2264. /// <summary>
  2265. /// 减除错误数据
  2266. /// </summary>
  2267. /// <param name="dt"></param>
  2268. /// <param name="dgvNew"></param>
  2269. /// <param name="cuowu"></param>
  2270. public void PuAdd( string cuowu, int c )
  2271. {
  2272. DataRow row = dtError.NewRow();
  2273. if ( dt != null && dt.Rows.Count > 0 )
  2274. {
  2275. for ( int i = 0; i < dt.Columns.Count; i++ )
  2276. {
  2277. row[i] = dt.Rows[c][i];
  2278. }
  2279. row[dt.Columns.Count] = cuowu;
  2280. dtError.Rows.Add( row );
  2281. }
  2282. }
  2283. #endregion
  2284. }
  2285. }