123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424 |
- //using Microsoft.Office.Interop.Excel;
- using LYFZ.BLL;
- using LYFZ.Model;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Text;
- using System.Windows.Forms;
- namespace LYFZ.Software.MainBusiness.Customers
- {
- public partial class ImportExcel : LYFZ.Software.UI.Customers.ImportExcel
- {
- public ImportExcel()
- {
- this.Shown += ImportExcel_Shown;
- this.btnAddExcel.Click += btnAddExcel_Click;
- this.btnAdd.Click += btnAdd_Click;
- this.btnClose.Click += btnClose_Click;
- //指定不再捕获对错误线程的调用
- Control.CheckForIllegalCrossThreadCalls = false;
- }
- /// <summary>
- /// 客户组编号集合
- /// </summary>
- List<string> Gmlist = new List<string>();
- /// <summary>
- /// 存放添加sql语句
- /// </summary>
- // List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
- BLL_ErpCustomer Cus_Bll = new BLL_ErpCustomer();
- BLL_ErpCustomerGroup GP_Bll = new BLL_ErpCustomerGroup();
- BLL_ErpCustomerGroupMembers GM_Bll = new BLL_ErpCustomerGroupMembers();
- LYFZ.BLL.BLL_ErpOrder orbll = new BLL_ErpOrder();
- // Model_ErpCustomer Cus_Model = null;
- // Model_ErpCustomerGroup GP_Model = null;
- // Model_ErpCustomerGroupMembers GM_Model = null;
- /// <summary>
- /// 客户类型 0 为其它客户(客户管理中的其他客户,只添加到用户表) 1 为老客户 2 为意向客户
- /// </summary>
- public int Type;
- /// <summary>
- /// 订单类型
- /// </summary>
- public int Leixing;
- Customer Cus = new Customer();
- string Url = "";
- System.Data.DataTable dt;
- System.Data.DataTable dtOK;
- System.Data.DataTable dtError;
- // DataGridViewEc dgvex;
- List<string> list = new List<string>();
- #region 关闭
- /// <summary>
- /// 关闭按钮
- /// </summary>
- void btnClose_Click( object sender, EventArgs e )
- {
- try
- {
- this.Close();
- }
- catch ( Exception ex )
- {
- MessageBoxCustom.Show( ex.Message );
- }
- }
- #endregion
- #region 打开Excel按钮
- /// <summary>
- /// 打开Excel按钮
- /// </summary>
- void btnAddExcel_Click( object sender, EventArgs e )
- {
- try
- {
- DialogResult dres = openFileDialog1.ShowDialog();
- if ( DialogResult.OK.Equals( dres ) )
- {
- dt = LYFZ.WinAPI.CustomPublicMethod.GetExcelDatatable( openFileDialog1.FileName ); //ExcelToDataTable(openFileDialog1.FileName, "Sheet1");
- Url = openFileDialog1.FileName;
- dtOK = dt.Copy();
- dtOK.Rows.Clear();
- dtError = dt.Copy();
- dtError.Rows.Clear();
- dtError.Columns.Add( "错误原因" );
- // dgvex = new DataGridViewEc();
- list = new List<string>();
- //其他客户
- if ( Type == 0 )
- {
- if ( dt.Columns.Count == 6 )
- {
- if ( dt.Columns[0].ToString().Trim() == "客户姓名" && dt.Columns[1].ToString().Trim() == "性别" && dt.Columns[2].ToString().Trim() == "电话"
- && dt.Columns[3].ToString().Trim() == "QQ" && dt.Columns[4].ToString().Trim() == "地址" && dt.Columns[5].ToString().Trim() == "生日" )
- {
- Checklistdata( "checkOther" );
- if ( dt.Rows.Count > 0 )
- {
- btnAdd.Enabled = true;
- }
- }
- else { MessageBoxCustom.Show( "请正确选择模板导入" ); btnAdd.Enabled = false; }
- }
- else { MessageBoxCustom.Show( "请正确选择模板导入!" ); }
- }
- //老客户
- if ( Type == 1 )
- {
- #region 检查数据
- switch ( Leixing )
- {
- //婚纱
- case 0:
- if ( dt.Columns.Count == 12 )
- {
- if ( dt.Columns[0].ToString().Trim() == "订单日期" && dt.Columns[1].ToString().Trim() == "先生名字" && dt.Columns[2].ToString().Trim() == "先生生日" && dt.Columns[3].ToString().Trim() == "先生QQ" &&
- 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() == "女士手机号"
- && dt.Columns[9].ToString().Trim() == "婚期" && dt.Columns[10].ToString().Trim() == "套系名称" && dt.Columns[11].ToString().Trim() == "套系价格" )
- {
- Checklistdata( "checkHS" );
- if ( dt.Rows.Count > 0 )
- {
- btnAdd.Enabled = true;
- }
- }
- else { MessageBoxCustom.Show( "请选择婚纱版模板" ); btnAdd.Enabled = false; }
- }
- else { MessageBoxCustom.Show( "请选择婚纱版模板!" ); btnAdd.Enabled = false; }
- break;
- //儿童
- case 1:
- if ( dt.Columns.Count == 9 )
- {
- if ( dt.Columns[0].ToString().Trim() == "订单日期" && dt.Columns[1].ToString().Trim() == "宝宝姓名" &&
- dt.Columns[2].ToString().Trim() == "家长姓名" && dt.Columns[3].ToString().Trim() == "手机号" &&
- dt.Columns[4].ToString().Trim() == "QQ" && dt.Columns[5].ToString().Trim() == "套系名称"
- && dt.Columns[6].ToString().Trim() == "套系价格" && dt.Columns[7].ToString().Trim() == "宝宝生日" && dt.Columns[8].ToString().Trim() == "宝宝性别" )
- {
- Checklistdata( "checkBaby" );
- if ( dtOK.Rows.Count > 0 )
- {
- btnAdd.Enabled = true;
- }
- }
- else { MessageBoxCustom.Show( "请选择儿童版模板" ); btnAdd.Enabled = false; }
- }
- else { MessageBoxCustom.Show( "请选择儿童版模板!" ); btnAdd.Enabled = false; }
- break;
- case 2:
- if ( dt.Columns.Count == 8 )
- {
- if ( dt.Columns[0].ToString().Trim() == "姓名" && dt.Columns[1].ToString().Trim() == "性别" &&
- dt.Columns[2].ToString().Trim() == "电话" && dt.Columns[3].ToString().Trim() == "QQ" &&
- dt.Columns[4].ToString().Trim() == "生日" && dt.Columns[5].ToString().Trim() == "套系名称"
- && dt.Columns[6].ToString().Trim() == "套系价格" && dt.Columns[7].ToString().Trim() == "订单日期" )
- {
- Checklistdata( "checkXZfw" );
- if ( dt.Rows.Count > 0 )
- {
- btnAdd.Enabled = true;
- }
- }
- else { MessageBoxCustom.Show( "请选择写真,服务版模板" ); btnAdd.Enabled = false; }
- }
- else { MessageBoxCustom.Show( "请选择写真,服务版模板!" ); btnAdd.Enabled = false; }
- break;
- case 3:
- if ( dt.Columns.Count == 8 )
- {
- if ( dt.Columns[0].ToString().Trim() == "姓名" && dt.Columns[1].ToString().Trim() == "性别" &&
- dt.Columns[2].ToString().Trim() == "电话" && dt.Columns[3].ToString().Trim() == "QQ" &&
- dt.Columns[4].ToString().Trim() == "生日" && dt.Columns[5].ToString().Trim() == "套系名称"
- && dt.Columns[6].ToString().Trim() == "套系价格" && dt.Columns[7].ToString().Trim() == "订单日期" )
- {
- Checklistdata( "checkXZfw" );
- if ( dt.Rows.Count > 0 )
- {
- btnAdd.Enabled = true;
- }
- }
- else { MessageBoxCustom.Show( "请选择写真,服务版模板" ); btnAdd.Enabled = false; }
- }
- else { MessageBoxCustom.Show( "请选择写真,服务版模板!" ); btnAdd.Enabled = false; }
- break;
- }
- #endregion
- }
- //意向客户
- if ( Type == 2 )
- {
- #region 检查数据
- if ( dt.Columns.Count >= 7 ) // >=7,兼容以前的模块;
- {
- if ( dt.Columns[0].ToString().Trim() == "客户姓名" && dt.Columns[1].ToString().Trim() == "性别" && dt.Columns[2].ToString().Trim() == "电话"
- && dt.Columns[3].ToString().Trim() == "QQ" && dt.Columns[4].ToString().Trim() == "地址" && dt.Columns[5].ToString().Trim() == "生日"
- && dt.Columns[6].ToString().Trim() == "订单类型" )
- {
- Checklistdata( "UYixiang" );
- if ( dt.Rows.Count > 0 )
- {
- btnAdd.Enabled = true;
- }
- }
- else { MessageBoxCustom.Show( "请正确选择模板导入" ); btnAdd.Enabled = false; }
- }
- else { MessageBoxCustom.Show( "请正确选择模板导入!" ); btnAdd.Enabled = false; }
- #endregion
- }
- if ( dt != null )
- {
- dgv.DataSource = dtOK;
- for ( int i = 0; i < this.dgv.Columns.Count; i++ )
- {
- this.dgv.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
- }
- }
- }
- }
- catch ( Exception ex )
- {
- MessageBoxCustom.Show( ex.Message );
- }
- }
- #endregion
- #region 保存
- /// <summary>
- /// 保存按钮
- /// </summary>
- void btnAdd_Click( object sender, EventArgs e )
- {
- bool upData = true;
- try
- {
- if ( dgv.Rows.Count > 0 )
- {
- // LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- // {
- if ( Type == 0 )
- {
- AddOther();
- }
- if ( Type == 1 )
- {
- switch ( Leixing )
- {
- case 0:
- OldHSNew();
- break;
- case 1:
- OldBabyNew();
- break;
- case 2:
- OldXZfwNew( 2 );
- break;
- case 3:
- OldXZfwNew(3);
- break;
- }
- }
- if ( Type == 2 )
- {
- upData=addYixiang();
- }
- if (upData)
- {
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker)
- {
- backgroundWorker.ReportProgress(0, "正在更新客户资料...");
- LYFZ.DAL.DAL_ErpCustomer.UpdateAggregationCustomerAll();
- });
- MessageBoxCustom.Show("导入完成");
- this.DialogResult = System.Windows.Forms.DialogResult.Yes;
- }
- //});
- }
- }
- catch ( Exception ex )
- {
- MessageBoxCustom.Show( "导入出错:" + ex.Message );
- this.DialogResult = System.Windows.Forms.DialogResult.Yes;
- }
- this.DialogResult = System.Windows.Forms.DialogResult.Yes;
- }
- #endregion
- #region 加载
- void ImportExcel_Shown( object sender, EventArgs e )
- {
- if ( Type == 1 )
- {
- switch ( Leixing )
- {
- case 1:
- this.Text += " (儿童模板)";
- break;
- case 2:
- this.Text += " (写真模板)";
- break;
- case 3:
- this.Text += " (服务模板)";
- break;
- case 0:
- this.Text += " (婚纱模板)";
- break;
- }
- }
- }
- #endregion
- #region 判断数据
- /// <summary>
- /// 判断数据
- /// </summary>
- /// <param name="Svoid"></param>
- void Checklistdata( string Svoid )
- {
- LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod( delegate ( object obj, BackgroundWorker backgroundWorker )
- {
- System.Data.DataTable tblClient = new DataTable();
- switch ( Svoid )
- {
- //老客户宝宝
- case "checkBaby":
- tblClient = orbll.GetView_Custom( "tb_ErpCustomer", StrWhere: "Cus_Telephone in (" + StrDianhua( "手机号", dt ) + ")", ShowColumnName: "ID,Cus_Telephone" ).Tables[0];
- break;
- //老客户婚纱
- case "checkHS":
- string sj = StrDianhua( "女士手机号", dt ) + "," + StrDianhua( "先生手机号", dt );
- tblClient = orbll.GetView_Custom( "tb_ErpCustomer", StrWhere: "Cus_Telephone in (" + sj + ")", ShowColumnName: "ID,Cus_Telephone" ).Tables[0];
- break;
- //老客户写真服务
- case "checkXZfw":
- tblClient = orbll.GetView_Custom( "tb_ErpCustomer", StrWhere: "Cus_Telephone in (" + StrDianhua( "电话", dt ) + ")", ShowColumnName: "ID,Cus_Telephone" ).Tables[0];
- break;
- //意向客户
- case "UYixiang":
- tblClient = orbll.GetView_Custom( "tb_ErpCustomer", StrWhere: "Cus_Telephone in (" + StrDianhua( "电话", dt ) + ")", ShowColumnName: "ID,Cus_Telephone" ).Tables[0];
- break;
- //其他客户
- case "checkOther":
- tblClient = orbll.GetView_Custom( "tb_ErpCustomer", StrWhere: "Cus_Telephone in (" + StrDianhua( "电话", dt ) + ")", ShowColumnName: "ID,Cus_Telephone" ).Tables[0];
- break;
- }
- //总计数器
- float sumCount = dt.Rows.Count;
- //当前计数器
- int currentCount = 0;
- for ( int i = 0; i < sumCount; i++ )
- {
- currentCount++;
- switch ( Svoid )
- {
- //老客户宝宝
- case "checkBaby":
- string Cuowu = checkBaby( dt.Rows[i], tblClient ).ToString();
- if ( Cuowu == "" )
- {
- dtOK.Rows.Add( dt.Rows[i].ItemArray );
- }
- else
- {
- PuAdd( Cuowu, i );
- }
- break;
- //老客户婚纱
- case "checkHS":
- string Cuowu1 = checkHS( dt.Rows[i], tblClient ).ToString();
- if ( Cuowu1 == "" )
- {
- dtOK.Rows.Add( dt.Rows[i].ItemArray );
- }
- else
- {
- PuAdd( Cuowu1, i );
- }
- break;
- //老客户写真服务
- case "checkXZfw":
- string Cuowu2 = checkXZfw( dt.Rows[i], tblClient ).ToString();
- if ( Cuowu2 == "" )
- {
- dtOK.Rows.Add( dt.Rows[i].ItemArray );
- }
- else
- {
- PuAdd( Cuowu2, i );
- }
- break;
- //意向客户
- case "UYixiang":
- string Cuowu3 = UYixiang( dt.Rows[i], tblClient ).ToString();
- if ( Cuowu3 == "" )
- {
- dtOK.Rows.Add( dt.Rows[i].ItemArray );
- }
- else
- {
- PuAdd( Cuowu3, i );
- }
- break;
- //其他客户
- case "checkOther":
- string Cuowu4 = checkOther( dt.Rows[i], tblClient ).ToString();
- if ( Cuowu4 == "" )
- {
- dtOK.Rows.Add( dt.Rows[i].ItemArray );
- }
- else
- {
- PuAdd( Cuowu4, i );
- }
- break;
- }
- if ( backgroundWorker != null )
- {
- try
- {
- int currentProgres = Convert.ToInt32( 1000 / sumCount * currentCount );
- backgroundWorker.ReportProgress( currentProgres, "正在检查数据,共" + sumCount + "条,已验证" + currentCount.ToString() + "条..." );
- }
- catch { }
- }
- }
- }, width: 380 );
- if ( dtError.Rows.Count > 0 )
- {
- //this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
- //{
- // dgvex.DataSource(dtError);
- Cus.DataToExcel( dtError, "", Url );
- //}));
- }
- }
- #endregion
- #region 老客户添加操作
- BLL.BLL_OldOrderHistory bll_ooh = new BLL_OldOrderHistory();
- /// <summary>
- /// 儿童老客户
- /// </summary>
- [Obsolete]
- ///放弃已弃用
- void OldBaby()
- {
- try
- {
- if ( dgv.Rows.Count > 0 )
- {
- DateTime strTime = SDateTime.Now;
- // List<string> namelist = new List<string>();
- LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod( delegate ( object obj, BackgroundWorker backgroundWorker )
- {
- //总计数器
- float sumCount = dgv.Rows.Count;
- //当前计数器
- int currentCount = 0;
- for ( int i = 0; i < dgv.Rows.Count; i++ )
- {
- // 存放添加sql语句
- List<Helper.CommandInfo> sqllist = new List<Helper.CommandInfo>();
- //主联系人ID
- string ID = LYFZ.BLL.BLL_ErpCustomer.GetClientNumber();
- //客户关系组
- string GMID = LYFZ.BLL.BLL_ErpCustomer.GetNewClientGroupNumber();
- //宝宝
- Model_ErpCustomer Baby = new Model_ErpCustomer();
- Baby.Cus_CustomerNumber = ID;
- Baby.Cus_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- Baby.Cus_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter( dgv.Rows[i].Cells["宝宝姓名"].Value.ToString().Trim() );
- Baby.Cus_NamePinyin = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin( Baby.Cus_Name ).ToLower();
- Baby.Cus_Sex = dgv.Rows[i].Cells["宝宝性别"].Value.ToString().Trim() == "男" ? false : true;
- if ( dgv.Rows[i].Cells["宝宝生日"].Value.ToString().Trim() != "" )
- {
- Baby.Cus_Birthday = Convert.ToDateTime( dgv.Rows[i].Cells["宝宝生日"].Value.ToString().Trim() ).ToString( "yyyy-MM-dd" );
- }
- Baby.Cus_ServiceType = "Baby";
- Baby.Cus_Type = "儿童";
- Baby.Cus_CreateDateTime = strTime;
- Baby.Cus_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- sqllist.Add( Cus_Bll.GetAddCommandInfo( Baby ) );
- Model_ErpCustomerGroupMembers RT_GM_Model = new Model_ErpCustomerGroupMembers();
- RT_GM_Model.GM_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- RT_GM_Model.GM_CustomerGroupID = GMID;
- RT_GM_Model.GM_CustomerID = ID;
- RT_GM_Model.GM_Master = 0;
- RT_GM_Model.GM_ProtagonistCustomer = 1;
- RT_GM_Model.GM_RelatedPersonID = ID;
- RT_GM_Model.GM_Relation = "本人";
- RT_GM_Model.GM_IsOrder = dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim() != "" ? 1 : 0;
- RT_GM_Model.GM_IsOrderNumber = "";
- sqllist.Add( GM_Bll.GetAddCommandInfo( RT_GM_Model ) );
- //家长
- Model_ErpCustomer RT_Cus_Model = new Model_ErpCustomer();
- RT_Cus_Model.Cus_CustomerNumber = LYFZ.BLL.BLL_ErpCustomer.GetClientNumber(); //获取新编号
- RT_Cus_Model.Cus_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- RT_Cus_Model.Cus_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter( dgv.Rows[i].Cells["家长姓名"].Value.ToString().Trim() );
- if ( RT_Cus_Model.Cus_Name != "" )
- {
- RT_Cus_Model.Cus_NamePinyin = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin( RT_Cus_Model.Cus_Name ).ToLower();
- }
- RT_Cus_Model.Cus_Telephone = dgv.Rows[i].Cells["手机号"].Value.ToString().Trim();
- RT_Cus_Model.Cus_QQ = dgv.Rows[i].Cells["QQ"].Value.ToString().Trim();
- RT_Cus_Model.Cus_CreateDateTime = strTime;
- RT_Cus_Model.Cus_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- sqllist.Add( Cus_Bll.GetAddCommandInfo( RT_Cus_Model ) );
- //成员表
- RT_GM_Model = new Model_ErpCustomerGroupMembers();
- RT_GM_Model.GM_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- RT_GM_Model.GM_CustomerGroupID = GMID;
- RT_GM_Model.GM_CustomerID = RT_Cus_Model.Cus_CustomerNumber;
- RT_GM_Model.GM_Master = 1;
- RT_GM_Model.GM_ProtagonistCustomer = 0;
- RT_GM_Model.GM_RelatedPersonID = ID;
- RT_GM_Model.GM_Relation = "亲人";
- RT_GM_Model.GM_IsOrder = dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim() != "" ? 1 : 0;
- RT_GM_Model.GM_IsOrderNumber = "";
- sqllist.Add( GM_Bll.GetAddCommandInfo( RT_GM_Model ) );
- if ( dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim() != "" && dgv.Rows[i].Cells["套系价格"].Value.ToString().Trim() != "" )
- {
- Model.Model_OldOrderHistory model_ooh = new Model_OldOrderHistory();
- model_ooh.History_ID = GMID;
- model_ooh.History_Type = dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim();
- model_ooh.History_Money = Convert.ToInt32( dgv.Rows[i].Cells["套系价格"].Value.ToString().Trim() );
- if ( dgv.Rows[i].Cells["订单日期"].Value.ToString().Trim() != "" )
- {
- model_ooh.History_OrderTime = Convert.ToDateTime( dgv.Rows[i].Cells["订单日期"].Value.ToString().Trim() );
- }
- model_ooh.History_CurrentID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- model_ooh.History_CurrentTime = strTime;
- sqllist.Add( bll_ooh.GetAddCommandInfo( model_ooh ) );
- }
- //客户组表
- Model_ErpCustomerGroup RT_GP_Model = new Model_ErpCustomerGroup();
- RT_GP_Model.GP_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- RT_GP_Model.GP_CustomerGroupID = GMID;
- RT_GP_Model.GP_GroupType = Type;
- RT_GP_Model.GP_CustomerType = 1;
- RT_GP_Model.GP_CustomerStatus = "正常";
- RT_GP_Model.GP_CreateDatetime = strTime;
- RT_GP_Model.GP_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- RT_GP_Model.GP_CustomerSource = "";
- RT_GP_Model.GP_Remark = "";
- RT_GP_Model.GP_OrderNumber = "";
- RT_GP_Model.GP_LossReason = "";
- RT_GP_Model.GP_IntroducerCustomerID = "";
- RT_GP_Model.GP_DegreeOfIntent = "";
- RT_GP_Model.GP_BelongsPersonID = "";
- sqllist.Add( GP_Bll.GetAddCommandInfo( RT_GP_Model ) );
- // RT_Gmlist.Add(GMID);
- // namelist.Add("宝宝姓名:" + Baby.Cus_Name + ",家长姓名:" + RT_Cus_Model.Cus_Name);
- string item = "宝宝姓名:" + Baby.Cus_Name + ",家长姓名:" + RT_Cus_Model.Cus_Name;
- try
- {
- if ( LYFZ.BLL.BaseBllOperate.ExecuteSqlTran( sqllist ) > 0 )
- {
- //日志
- 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 );
- // DAL_ErpCustomer.UpdateAggregationCustomer(GMID);
- }
- }
- catch ( Exception ex )
- {
- MessageBoxCustom.Show( item + " 的客户导入失败:" + ex.Message, backgroundWorker: backgroundWorker );
- }
- currentCount++;
- if ( backgroundWorker != null )
- {
- try
- {
- int currentProgres = Convert.ToInt32( 1000 / sumCount * currentCount );
- backgroundWorker.ReportProgress( currentProgres, "共" + sumCount + "条,正在导入第" + currentCount.ToString() + "条..." );
- }
- catch { }
- }
- }
- }, width: 350 );
- /* if (clist.Count > 0)
- {
- LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- if (backgroundWorker != null)
- {
- try
- {
- backgroundWorker.ReportProgress(0, "准备中...请稍后!");
- }
- catch { }
- }
- if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0)
- {
- foreach (string item in namelist)
- {
- //日志
- 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);
- }
- //总计数器
- float sumCount = Gmlist.Count;
- //当前计数器
- int currentCount = 0;
- for (int i = 0; i < Gmlist.Count; i++)
- {
- currentCount++;
- DAL_ErpCustomer.UpdateAggregationCustomer(Gmlist[i].ToString().Trim());
- if (backgroundWorker != null)
- {
- try
- {
- int currentProgres = Convert.ToInt32(1000 / sumCount * currentCount);
- backgroundWorker.ReportProgress(currentProgres, "正在添加..,共" + sumCount + "条,正在添加第:" + currentCount.ToString() + "条...");
- }
- catch { }
- }
- }
- MessageBoxCustom.Show("添加成功!共导入:" + dgv.Rows.Count + "条");
- this.DialogResult = DialogResult.OK;
- }
- else { MessageBoxCustom.Show("添加失败!"); }
- }, width: 350);
- }*/
- }
- else { MessageBoxCustom.Show( "请导入Excel文档!" ); }
- }
- catch ( Exception ex )
- {
- MessageBoxCustom.Show( ex.Message );
- }
- }
- void OldBabyNew()
- {
- try
- {
- if (dgv.Rows.Count > 0)
- {
- DateTime strTime = SDateTime.Now;
- // List<string> namelist = new List<string>();
- LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker)
- {
- //总计数器
- float sumCount = dgv.Rows.Count;
- //当前计数器
- int currentCount = 0;
- DataTable erpCustomerDt = new DataTable();
- BindDataTableColumData(
- "Cus_CustomerNumber,Cus_DividedShop,Cus_Name,Cus_NamePinyin,Cus_Sex,Cus_Birthday,Cus_ServiceType,Cus_Type,Cus_CreateDateTime,Cus_CreateName"
- .Split(','),
- ref erpCustomerDt);
- DataTable erpCustomerGroupMembersDt = new DataTable();
- BindDataTableColumData(
- "GM_DividedShop,GM_CustomerGroupID,GM_CustomerID,GM_Master,GM_ProtagonistCustomer,GM_RelatedPersonID,GM_Relation,GM_IsOrder,GM_IsOrderNumber"
- .Split(','),
- ref erpCustomerGroupMembersDt);
- DataTable rtErpCustomerDt = new DataTable();
- BindDataTableColumData(
- "Cus_CustomerNumber,Cus_DividedShop,Cus_Name,Cus_NamePinyin,Cus_Telephone,Cus_QQ,Cus_CreateDateTime,Cus_CreateName"
- .Split(','),
- ref rtErpCustomerDt);
- DataTable rtErpCustomerGroupMembersDt = new DataTable();
- BindDataTableColumData(
- "GM_DividedShop,GM_CustomerGroupID,GM_CustomerID,GM_Master,GM_ProtagonistCustomer,GM_RelatedPersonID,GM_Relation,GM_IsOrder,GM_IsOrderNumber"
- .Split(','),
- ref rtErpCustomerGroupMembersDt);
- DataTable oldOrderHistoryDt = new DataTable();
- BindDataTableColumData(
- "History_ID,History_Type,History_Money,History_OrderTime,History_CurrentID,History_CurrentTime"
- .Split(','),
- ref oldOrderHistoryDt);
- DataTable erpCustomerGroupDt = new DataTable();
- BindDataTableColumData(
- "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"
- .Split(','),
- ref erpCustomerGroupDt);
- DataTable erpSystemLogsDt = new DataTable();
- BindDataTableColumData(
- "Slogs_DividedShop,Slogs_Content,Slogs_CreateDatetime,Slogs_CreateName,Slogs_UserName,Slogs_Type,Slogs_Topic,Slogs_IP"
- .Split(','),
- ref erpSystemLogsDt);
- for (int i = 0; i < dgv.Rows.Count; i++)
- {
- // 存放添加sql语句
- // List<Helper.CommandInfo> sqllist = new List<Helper.CommandInfo>();
- //主联系人ID
- string ID = LYFZ.BLL.BLL_ErpCustomer.GetClientNumber();
- //客户关系组
- string GMID = LYFZ.BLL.BLL_ErpCustomer.GetNewClientGroupNumber();
- string bbName = "";
- string jzName = "";
- //宝宝
- DataRow dr = erpCustomerDt.NewRow();
- dr["Cus_CustomerNumber"] = ID;
- dr["Cus_DividedShop"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- dr["Cus_Name"] = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(dgv.Rows[i].Cells["宝宝姓名"].Value.ToString().Trim());
- dr["Cus_NamePinyin"] = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin(dr["Cus_Name"].ToString_s()).ToLower();
- dr["Cus_Sex"] = dgv.Rows[i].Cells["宝宝性别"].Value.ToString().Trim() == "男" ? false : true;
- if (dgv.Rows[i].Cells["宝宝生日"].Value.ToString().Trim() != "")
- {
- dr["Cus_Birthday"] = Convert.ToDateTime(dgv.Rows[i].Cells["宝宝生日"].Value.ToString().Trim()).ToString("yyyy-MM-dd");
- }
- else
- {
- dr["Cus_Birthday"] = null;
- }
- dr["Cus_ServiceType"] = "Baby";
- dr["Cus_Type"] = "儿童";
- dr["Cus_CreateDateTime"] = strTime;
- dr["Cus_CreateName"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- bbName = dr["Cus_Name"].ToString_s();
- erpCustomerDt.Rows.Add(dr);
- ///关系
- dr = erpCustomerGroupMembersDt.NewRow();
- dr["GM_DividedShop"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- dr["GM_CustomerGroupID"] = GMID;
- dr["GM_CustomerID"] = ID;
- dr["GM_Master"] = "0";
- dr["GM_ProtagonistCustomer"] = "1";
- dr["GM_RelatedPersonID"] = ID;
- dr["GM_Relation"] = "本人";
- dr["GM_IsOrder"] = dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim() != "" ? 1 : 0;
- dr["GM_IsOrderNumber"] = "";
- erpCustomerGroupMembersDt.Rows.Add(dr);
- //家长
- DataRow rtdr = rtErpCustomerDt.NewRow();
- rtdr["Cus_CustomerNumber"] = LYFZ.BLL.BLL_ErpCustomer.GetClientNumber();
- rtdr["Cus_DividedShop"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- rtdr["Cus_Name"] = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(dgv.Rows[i].Cells["家长姓名"].Value.ToString().Trim());
- if (rtdr["Cus_Name"].ToString_s() != "")
- {
- rtdr["Cus_NamePinyin"] = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin(rtdr["Cus_Name"].ToString_s()).ToLower();
- //RT_Cus_Model.Cus_NamePinyin = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin(RT_Cus_Model.Cus_Name).ToLower();
- }
- rtdr["Cus_Telephone"] = dgv.Rows[i].Cells["手机号"].Value.ToString().Trim();
- rtdr["Cus_QQ"] = dgv.Rows[i].Cells["QQ"].Value.ToString().Trim();
- rtdr["Cus_CreateDateTime"] = strTime;
- rtdr["Cus_CreateName"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- jzName = rtdr["Cus_Name"].ToString_s();
- rtErpCustomerDt.Rows.Add(rtdr);
- //成员表
- dr = rtErpCustomerGroupMembersDt.NewRow();
- dr["GM_DividedShop"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- dr["GM_CustomerGroupID"] = GMID;
- dr["GM_CustomerID"] = rtdr["Cus_CustomerNumber"] ;
- dr["GM_Master"] = "1";
- dr["GM_ProtagonistCustomer"] = "0";
- dr["GM_RelatedPersonID"] = ID;
- dr["GM_Relation"] = "亲人";
- dr["GM_IsOrder"] = dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim() != "" ? 1 : 0; ;
- dr["GM_IsOrderNumber"] = "";
- rtErpCustomerGroupMembersDt.Rows.Add(dr);
- ///老订单历史数据
- if (dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim() != "" && dgv.Rows[i].Cells["套系价格"].Value.ToString().Trim() != "")
- {
- dr = oldOrderHistoryDt.NewRow();
- dr["History_ID"] = GMID;
- dr["History_Type"] = dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim();
- dr["History_Money"] = Convert.ToInt32(dgv.Rows[i].Cells["套系价格"].Value.ToString().Trim());
- if (dgv.Rows[i].Cells["订单日期"].Value.ToString().Trim() != "")
- {
- dr["History_OrderTime"] = Convert.ToDateTime(dgv.Rows[i].Cells["订单日期"].Value.ToString().Trim());
- }
- dr["History_CurrentID"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- dr["History_CurrentTime"] = strTime;
- oldOrderHistoryDt.Rows.Add(dr);
- }
- //客户组表
- dr = erpCustomerGroupDt.NewRow();
- dr["GP_DividedShop"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- dr["GP_CustomerGroupID"] = GMID;
- dr["GP_GroupType"] = Type;
- dr["GP_CustomerType"] = "1";
- dr["GP_CustomerStatus"] = "正常";
- dr["GP_CreateDatetime"] = strTime;
- dr["GP_CreateName"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- dr["GP_CustomerSource"] = "";
- dr["GP_Remark"] = "";
- dr["GP_OrderNumber"] = "";
- dr["GP_LossReason"] = "";
- dr["GP_IntroducerCustomerID"] = "";
- dr["GP_DegreeOfIntent"] = "";
- dr["GP_BelongsPersonID"] = "";
- erpCustomerGroupDt.Rows.Add(dr);
-
- // namelist.Add("宝宝姓名:" + Baby.Cus_Name + ",家长姓名:" + RT_Cus_Model.Cus_Name);
- string item = "宝宝姓名:" + bbName + ",家长姓名:" + jzName;
- dr = erpSystemLogsDt.NewRow();
- dr["Slogs_DividedShop"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- dr["Slogs_Content"] = "添加联系人资料:" + item + ",时间:" + SDateTime.Now + "[" + HPSocketCS.Extended.CommonLibrary.ClientMarkID + ":" + HPSocketCS.Extended.CommonLibrary.ClientMarkName + "]";
- dr["Slogs_CreateDatetime"] = SDateTime.Now;
- dr["Slogs_CreateName"] = LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID;
- dr["Slogs_UserName"] = LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name;
- dr["Slogs_Type"] = LYFZ.EnumPublic.SystemLogsType.添加客户资料;
- dr["Slogs_Topic"] = LYFZ.EnumPublic.SystemLogsType.添加客户资料;
- dr["Slogs_IP"] = "-";
- erpSystemLogsDt.Rows.Add(dr);
- }
- /*orbll.ExecuteSqlBulkCopyByDataTable("tb_ErpCustomer", erpCustomerDt, erpCustomerDt.Rows.Count);
- orbll.ExecuteSqlBulkCopyByDataTable("tb_ErpCustomerGroupMembers", erpCustomerGroupMembersDt, erpCustomerGroupMembersDt.Rows.Count);
- orbll.ExecuteSqlBulkCopyByDataTable("tb_ErpCustomer", rtErpCustomerDt, rtErpCustomerDt.Rows.Count);
- orbll.ExecuteSqlBulkCopyByDataTable("tb_ErpCustomerGroupMembers", rtErpCustomerGroupMembersDt, rtErpCustomerGroupMembersDt.Rows.Count);
- orbll.ExecuteSqlBulkCopyByDataTable("tb_OldOrderHistory", oldOrderHistoryDt, oldOrderHistoryDt.Rows.Count);
- orbll.ExecuteSqlBulkCopyByDataTable("tb_ErpCustomerGroup", erpCustomerGroupDt, erpCustomerGroupDt.Rows.Count);
- orbll.ExecuteSqlBulkCopyByDataTable("tb_ErpSystemLogs", erpSystemLogsDt, erpSystemLogsDt.Rows.Count);*/
-
- List<string> dataTableNames = new List<string>();
- List<DataTable> dataTables = new List<DataTable>();
- dataTableNames.Add("tb_ErpCustomer");
- dataTableNames.Add("tb_ErpCustomerGroupMembers");
- dataTableNames.Add("tb_ErpCustomer");
- dataTableNames.Add("tb_ErpCustomerGroupMembers");
- dataTableNames.Add("tb_OldOrderHistory");
- dataTableNames.Add("tb_ErpCustomerGroup");
- dataTableNames.Add("tb_ErpSystemLogs");
- dataTables.Add(erpCustomerDt);
- dataTables.Add(erpCustomerGroupMembersDt);
- dataTables.Add(rtErpCustomerDt);
- dataTables.Add(rtErpCustomerGroupMembersDt);
- dataTables.Add(oldOrderHistoryDt);
- dataTables.Add(erpCustomerGroupDt);
- dataTables.Add(erpSystemLogsDt);
- orbll.ExecuteSqlBulkCopyByDataTable(dataTableNames, dataTables);
- }, width: 350);
-
- }
- else { MessageBoxCustom.Show("请导入Excel文档!"); }
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show(ex.Message);
- }
- }
- void BindDataTableColumData(string[] cloums ,ref DataTable dt)
- {
- foreach(string colum in cloums)
- {
- dt.Columns.Add(colum);
- }
- }
- /// <summary>
- /// 婚纱老客户
- /// </summary>
- [Obsolete]
- void OldHS()
- {
- try
- {
- if ( dgv.Rows.Count > 0 )
- {
- // Gmlist = new List<string>();
- // List<string> namelist = new List<string>();
- LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod( delegate ( object obj, BackgroundWorker backgroundWorker )
- { //总计数器
- float sumCount = dgv.Rows.Count;
- //当前计数器
- int currentCount = 0;
- for ( int i = 0; i < dgv.Rows.Count; i++ )
- {
- // 存放添加sql语句
- List<Helper.CommandInfo> sqllist = new List<Helper.CommandInfo>();
- DateTime strTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
- //主联系人ID
- string ID = LYFZ.BLL.BLL_ErpCustomer.GetClientNumber();
- //客户关系组
- string GMID = LYFZ.BLL.BLL_ErpCustomer.GetNewClientGroupNumber();
- Model_ErpCustomer modelNan = new Model_ErpCustomer();
- Model_ErpCustomer modelNv = new Model_ErpCustomer();
- if ( dgv.Rows[i].Cells["女士名字"].Value.ToString().Trim() != "" )
- {
- //女
- modelNv = new Model_ErpCustomer();
- modelNv.Cus_CustomerNumber = LYFZ.BLL.BLL_ErpCustomer.GetClientNumber(); //获取新编号
- modelNv.Cus_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- modelNv.Cus_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter( dgv.Rows[i].Cells["女士名字"].Value.ToString().Trim() );
- if ( modelNv.Cus_Name != "" )
- {
- modelNv.Cus_NamePinyin = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin( modelNv.Cus_Name ).ToLower();
- }
- modelNv.Cus_Sex = true;
- if ( dgv.Rows[i].Cells["女士生日"].Value.ToString().Trim() != "" )
- {
- modelNv.Cus_Birthday = Convert.ToDateTime( dgv.Rows[i].Cells["女士生日"].Value.ToString().Trim() ).ToString( "yyyy-MM-dd" );
- }
- modelNv.Cus_Telephone = dgv.Rows[i].Cells["女士手机号"].Value.ToString().Trim();
- modelNv.Cus_QQ = dgv.Rows[i].Cells["女士QQ"].Value.ToString().Trim();
- if ( dgv.Rows[i].Cells["婚期"].Value.ToString().Trim() != "" )
- {
- modelNv.Cus_DayForMarriage = Convert.ToDateTime( dgv.Rows[i].Cells["婚期"].Value.ToString().Trim() ).ToString( "yyyy-MM-dd" );
- }
- modelNv.Cus_CreateDateTime = strTime;
- modelNv.Cus_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- sqllist.Add( Cus_Bll.GetAddCommandInfo( modelNv ) );
- //成员表
- Model_ErpCustomerGroupMembers GM_Modela = new Model_ErpCustomerGroupMembers();
- GM_Modela.GM_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- GM_Modela.GM_CustomerGroupID = GMID;
- GM_Modela.GM_CustomerID = modelNv.Cus_CustomerNumber;
- GM_Modela.GM_ProtagonistCustomer = 1;
- GM_Modela.GM_RelatedPersonID = ID;
- if ( dgv.Rows[i].Cells["女士手机号"].Value.ToString().Trim() != "" )
- {
- GM_Modela.GM_Master = 1; GM_Modela.GM_Relation = "本人";
- }
- else
- {
- GM_Modela.GM_Master = 0; GM_Modela.GM_Relation = "夫妻";
- }
- GM_Modela.GM_IsOrder = dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim() != "" ? 1 : 0;
- GM_Modela.GM_IsOrderNumber = "";
- sqllist.Add( GM_Bll.GetAddCommandInfo( GM_Modela ) );
- }
- if ( dgv.Rows[i].Cells["先生名字"].Value.ToString().Trim() != "" )
- {
- //男
- modelNan.Cus_CustomerNumber = ID;
- modelNan.Cus_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- modelNan.Cus_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter( dgv.Rows[i].Cells["先生名字"].Value.ToString().Trim() );
- modelNan.Cus_NamePinyin = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin( modelNan.Cus_Name ).ToLower();
- modelNan.Cus_Sex = false;
- if ( dgv.Rows[i].Cells["先生生日"].Value.ToString().Trim() != "" )
- {
- modelNan.Cus_Birthday = Convert.ToDateTime( dgv.Rows[i].Cells["先生生日"].Value.ToString().Trim() ).ToString( "yyyy-MM-dd" );
- }
- modelNan.Cus_Telephone = dgv.Rows[i].Cells["先生手机号"].Value.ToString().Trim();
- modelNan.Cus_QQ = dgv.Rows[i].Cells["先生QQ"].Value.ToString().Trim();
- if ( dgv.Rows[i].Cells["婚期"].Value.ToString().Trim() != "" )
- {
- modelNan.Cus_DayForMarriage = Convert.ToDateTime( dgv.Rows[i].Cells["婚期"].Value.ToString().Trim() ).ToString( "yyyy-MM-dd" );
- }
- modelNan.Cus_CreateDateTime = strTime;
- modelNan.Cus_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- sqllist.Add( Cus_Bll.GetAddCommandInfo( modelNan ) );
- Model_ErpCustomerGroupMembers GM_Modelb = new Model_ErpCustomerGroupMembers();
- GM_Modelb.GM_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- GM_Modelb.GM_CustomerGroupID = GMID;
- GM_Modelb.GM_CustomerID = ID;
- if ( dgv.Rows[i].Cells["女士手机号"].Value.ToString().Trim() != "" && dgv.Rows[i].Cells["女士名字"].Value.ToString().Trim() != "" )
- {
- GM_Modelb.GM_Master = 0;
- GM_Modelb.GM_Relation = "夫妻";
- }
- else { GM_Modelb.GM_Master = 1; GM_Modelb.GM_Relation = "本人"; }
- GM_Modelb.GM_ProtagonistCustomer = 1;
- GM_Modelb.GM_RelatedPersonID = ID;
- GM_Modelb.GM_IsOrder = dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim() != "" ? 1 : 0;
- GM_Modelb.GM_IsOrderNumber = "";
- sqllist.Add( GM_Bll.GetAddCommandInfo( GM_Modelb ) );
- }
- if ( dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim() != "" && dgv.Rows[i].Cells["套系价格"].Value.ToString().Trim() != "" )
- {
- BLL.BLL_OldOrderHistory bll_ooh = new BLL_OldOrderHistory();
- Model.Model_OldOrderHistory model_ooh = new Model_OldOrderHistory();
- model_ooh.History_ID = GMID;
- model_ooh.History_Type = dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim();
- model_ooh.History_Money = Convert.ToInt32( dgv.Rows[i].Cells["套系价格"].Value.ToString().Trim() );
- if ( dgv.Rows[i].Cells["订单日期"].Value.ToString().Trim() != "" )
- {
- try
- {
- model_ooh.History_OrderTime = Convert.ToDateTime( DDRQ( dgv.Rows[i].Cells["订单日期"].Value.ToString().Trim() ) );
- }
- catch { model_ooh.History_OrderTime = LYFZ.WinAPI.CustomPublicMethod.GetNullDateTime(); }
- }
- model_ooh.History_CurrentID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- model_ooh.History_CurrentTime = strTime;
- sqllist.Add( bll_ooh.GetAddCommandInfo( model_ooh ) );
- }
- //客户组表
- Model_ErpCustomerGroup GP_Model = new Model_ErpCustomerGroup();
- GP_Model.GP_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- GP_Model.GP_CustomerGroupID = GMID;
- GP_Model.GP_GroupType = Type;
- GP_Model.GP_CustomerType = 0;
- GP_Model.GP_CustomerStatus = "正常";
- GP_Model.GP_CreateDatetime = strTime;
- GP_Model.GP_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- GP_Model.GP_CustomerSource = "";
- GP_Model.GP_Remark = "";
- GP_Model.GP_OrderNumber = "";
- GP_Model.GP_LossReason = "";
- GP_Model.GP_IntroducerCustomerID = "";
- GP_Model.GP_DegreeOfIntent = "";
- GP_Model.GP_BelongsPersonID = "";
- sqllist.Add( GP_Bll.GetAddCommandInfo( GP_Model ) );
- // Gmlist.Add(GMID);
- string item = "先生姓名:" + modelNan.Cus_Name + ",女士姓名:" + modelNv.Cus_Name;
- try
- {
- if ( LYFZ.BLL.BaseBllOperate.ExecuteSqlTran( sqllist ) > 0 )
- {
- //日志
- 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 );
- // DAL_ErpCustomer.UpdateAggregationCustomer(GMID);
- }
- }
- catch ( Exception ex )
- {
- MessageBoxCustom.Show( item + " 的客户导入失败:" + ex.Message, backgroundWorker: backgroundWorker );
- }
- currentCount++;
- if ( backgroundWorker != null )
- {
- try
- {
- int currentProgres = Convert.ToInt32( 1000 / sumCount * currentCount );
- backgroundWorker.ReportProgress( currentProgres, "共" + sumCount + "条,正在导入第" + currentCount.ToString() + "条..." );
- }
- catch { }
- }
- }
- }, width: 350 );
- /* if (clist.Count > 0)
- {
- LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- if (backgroundWorker != null)
- {
- try
- {
- backgroundWorker.ReportProgress(0, "准备中...请稍后!");
- }
- catch { }
- }
- if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0)
- {
- foreach (string item in namelist)
- {
- //日志
- 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);
- }
- //总计数器
- float sumCount = Gmlist.Count;
- //当前计数器
- int currentCount = 0;
- for (int i = 0; i < Gmlist.Count; i++)
- {
- currentCount++;
- DAL_ErpCustomer.UpdateAggregationCustomer(Gmlist[i].ToString().Trim());
- if (backgroundWorker != null)
- {
- try
- {
- int currentProgres = Convert.ToInt32(1000 / sumCount * currentCount);
- backgroundWorker.ReportProgress(currentProgres, "正在添加..,共" + sumCount + "条,正在添加第:" + currentCount.ToString() + "条...");
- }
- catch { }
- }
- }
- MessageBoxCustom.Show("添加成功!共导入:" + dgv.Rows.Count + "条");
- this.DialogResult = DialogResult.OK;
- }
- else { MessageBoxCustom.Show("添加失败!"); }
- }, width: 350);
- }*/
- }
- else { MessageBoxCustom.Show( "请导入Excel文档!" ); }
- }
- catch ( Exception ex )
- {
- MessageBoxCustom.Show( ex.Message );
- }
- }
- /// <summary>
- /// 婚纱老客户
- /// </summary>
- void OldHSNew()
- {
- try
- {
- if (dgv.Rows.Count > 0)
- {
- // Gmlist = new List<string>();
- // List<string> namelist = new List<string>();
- LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker)
- { //总计数器
- float sumCount = dgv.Rows.Count;
- //当前计数器
- int currentCount = 0;
- DataTable erpCustomerNvDt = new DataTable();
- BindDataTableColumData(
- "Cus_CustomerNumber,Cus_DividedShop,Cus_Name,Cus_NamePinyin,Cus_Sex,Cus_Birthday,Cus_Telephone,Cus_QQ,Cus_DayForMarriage,Cus_CreateDateTime,Cus_CreateName"
- .Split(','),
- ref erpCustomerNvDt);
- DataTable erpCustomerGroupMembersNvDt = new DataTable();
- BindDataTableColumData(
- "GM_DividedShop,GM_CustomerGroupID,GM_CustomerID,GM_ProtagonistCustomer,GM_RelatedPersonID,GM_Master,GM_Relation,GM_IsOrder,GM_IsOrderNumber"
- .Split(','),
- ref erpCustomerGroupMembersNvDt);
- DataTable erpCustomerNanDt = new DataTable();
- BindDataTableColumData(
- "Cus_CustomerNumber,Cus_DividedShop,Cus_Name,Cus_NamePinyin,Cus_Sex,Cus_Birthday,Cus_Telephone,Cus_QQ,Cus_DayForMarriage,Cus_CreateDateTime,Cus_CreateName"
- .Split(','),
- ref erpCustomerNanDt);
- DataTable erpCustomerGroupMembersNanDt = new DataTable();
- BindDataTableColumData(
- "GM_DividedShop,GM_CustomerGroupID,GM_CustomerID,GM_Master,GM_Relation,GM_ProtagonistCustomer,GM_RelatedPersonID,GM_IsOrder,GM_IsOrderNumber"
- .Split(','),
- ref erpCustomerGroupMembersNanDt);
- DataTable oldOrderHistoryDt = new DataTable();
- BindDataTableColumData(
- "History_ID,History_Type,History_Money,History_OrderTime,History_CurrentID,History_CurrentTime"
- .Split(','),
- ref oldOrderHistoryDt);
- DataTable erpCustomerGroupDt = new DataTable();
- BindDataTableColumData(
- "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"
- .Split(','),
- ref erpCustomerGroupDt);
- DataTable erpSystemLogsDt = new DataTable();
- BindDataTableColumData(
- "Slogs_DividedShop,Slogs_Content,Slogs_CreateDatetime,Slogs_CreateName,Slogs_UserName,Slogs_Type,Slogs_Topic,Slogs_IP"
- .Split(','),
- ref erpSystemLogsDt);
- for (int i = 0; i < dgv.Rows.Count; i++)
- {
- // 存放添加sql语句
- //List<Helper.CommandInfo> sqllist = new List<Helper.CommandInfo>();
- DateTime strTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
- //主联系人ID
- string ID = LYFZ.BLL.BLL_ErpCustomer.GetClientNumber();
- //客户关系组
- string GMID = LYFZ.BLL.BLL_ErpCustomer.GetNewClientGroupNumber();
- string nanName = "";
- string nvName = "";
- //宝宝
- DataRow dr = null;
- //Model_ErpCustomer modelNan = new Model_ErpCustomer();
- //Model_ErpCustomer modelNv = new Model_ErpCustomer();
- if (dgv.Rows[i].Cells["女士名字"].Value.ToString().Trim() != "")
- {
- //女
- dr = erpCustomerNvDt.NewRow();
- dr["Cus_CustomerNumber"] = LYFZ.BLL.BLL_ErpCustomer.GetClientNumber(); //获取新编号
- dr["Cus_DividedShop"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- dr["Cus_Name"] = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(dgv.Rows[i].Cells["女士名字"].Value.ToString().Trim());
- if (dr["Cus_Name"].ToString_s() != "")
- {
- dr["Cus_NamePinyin"] = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin(dr["Cus_Name"].ToString_s()).ToLower();
- }
- dr["Cus_Sex"] = true; //获取新编号
- if (dgv.Rows[i].Cells["女士生日"].Value.ToString().Trim() != "")
- {
- dr["Cus_Birthday"] = Convert.ToDateTime(dgv.Rows[i].Cells["女士生日"].Value.ToString().Trim()).ToString("yyyy-MM-dd");
- }
- dr["Cus_Telephone"] = dgv.Rows[i].Cells["女士手机号"].Value.ToString().Trim();
- dr["Cus_QQ"] = dgv.Rows[i].Cells["女士QQ"].Value.ToString().Trim();
- if (dgv.Rows[i].Cells["婚期"].Value.ToString().Trim() != "")
- {
- dr["Cus_DayForMarriage"] = Convert.ToDateTime(dgv.Rows[i].Cells["婚期"].Value.ToString().Trim()).ToString("yyyy-MM-dd");
- }
- dr["Cus_CreateDateTime"] = strTime;
- dr["Cus_CreateName"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- nvName = dr["Cus_Name"].ToString_s();
- erpCustomerNvDt.Rows.Add(dr);
- //成员表
- DataRow gmDr = erpCustomerGroupMembersNvDt.NewRow();
- gmDr["GM_DividedShop"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- gmDr["GM_CustomerGroupID"] = GMID;
- gmDr["GM_CustomerID"] = dr["Cus_CustomerNumber"];
- gmDr["GM_ProtagonistCustomer"] = 1;
- gmDr["GM_RelatedPersonID"] = ID;
- if (dgv.Rows[i].Cells["女士手机号"].Value.ToString().Trim() != "")
- {
- gmDr["GM_Master"] = 1;
- gmDr["GM_Relation"] = "本人";
- }
- else
- {
- gmDr["GM_Master"] = 0;
- gmDr["GM_Relation"] = "夫妻";
- }
- gmDr["GM_IsOrder"] = dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim() != "" ? 1 : 0;
- gmDr["GM_IsOrderNumber"] = "";
- erpCustomerGroupMembersNvDt.Rows.Add(gmDr);
- //sqllist.Add(GM_Bll.GetAddCommandInfo(GM_Modela));
- }
- if (dgv.Rows[i].Cells["先生名字"].Value.ToString().Trim() != "")
- {
- //男
- dr = erpCustomerNanDt.NewRow();
- dr["Cus_CustomerNumber"] = ID;
- dr["Cus_DividedShop"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- dr["Cus_Name"] = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(dgv.Rows[i].Cells["先生名字"].Value.ToString().Trim());
- dr["Cus_NamePinyin"] = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin(dr["Cus_Name"].ToString_s()).ToLower();
- dr["Cus_Sex"] = false;
- if (dgv.Rows[i].Cells["先生生日"].Value.ToString().Trim() != "")
- {
- dr["Cus_Birthday"] = Convert.ToDateTime(dgv.Rows[i].Cells["先生生日"].Value.ToString().Trim()).ToString("yyyy-MM-dd");
- }
- dr["Cus_Telephone"] = dgv.Rows[i].Cells["先生手机号"].Value.ToString().Trim();
- dr["Cus_QQ"] = dgv.Rows[i].Cells["先生QQ"].Value.ToString().Trim();
- if (dgv.Rows[i].Cells["婚期"].Value.ToString().Trim() != "")
- {
- dr["Cus_DayForMarriage"] = Convert.ToDateTime(dgv.Rows[i].Cells["婚期"].Value.ToString().Trim()).ToString("yyyy-MM-dd");
- }
- dr["Cus_CreateDateTime"] = strTime;
- dr["Cus_CreateName"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- nanName = dr["Cus_Name"].ToString_s();
- erpCustomerNanDt.Rows.Add(dr);
- //sqllist.Add(Cus_Bll.GetAddCommandInfo(modelNan));
- //Model_ErpCustomerGroupMembers GM_Modelb = new Model_ErpCustomerGroupMembers();
- ///GM_DividedShop,GM_CustomerGroupID,GM_CustomerID,GM_Master,GM_Relation,GM_ProtagonistCustomer,GM_RelatedPersonID,GM_IsOrder,GM_IsOrderNumber
- DataRow gmDr = erpCustomerGroupMembersNanDt.NewRow();
- gmDr["GM_DividedShop"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- gmDr["GM_CustomerGroupID"] = GMID;
- gmDr["GM_CustomerID"] = ID;
- if (dgv.Rows[i].Cells["女士手机号"].Value.ToString().Trim() != "" && dgv.Rows[i].Cells["女士名字"].Value.ToString().Trim() != "")
- {
- gmDr["GM_Master"] = 0;
- gmDr["GM_Relation"] = "夫妻";
- }
- else { gmDr["GM_Master"] = 1; gmDr["GM_Relation"] = "本人"; }
- gmDr["GM_ProtagonistCustomer"] = 1;
- gmDr["GM_RelatedPersonID"] = ID;
- gmDr["GM_IsOrder"] = dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim() != "" ? 1 : 0;
- gmDr["GM_IsOrderNumber"] = "";
- //sqllist.Add(GM_Bll.GetAddCommandInfo(GM_Modelb));
- erpCustomerGroupMembersNanDt.Rows.Add(gmDr);
- }
- if (dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim() != "" && dgv.Rows[i].Cells["套系价格"].Value.ToString().Trim() != "")
- {
- dr = oldOrderHistoryDt.NewRow();
- dr["History_ID"] = GMID;
- dr["History_Type"] = dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim();
- dr["History_Money"] = Convert.ToInt32(dgv.Rows[i].Cells["套系价格"].Value.ToString().Trim());
- if (dgv.Rows[i].Cells["订单日期"].Value.ToString().Trim() != "")
- {
- dr["History_OrderTime"] = Convert.ToDateTime(dgv.Rows[i].Cells["订单日期"].Value.ToString().Trim());
- }
- dr["History_CurrentID"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- dr["History_CurrentTime"] = strTime;
- oldOrderHistoryDt.Rows.Add(dr);
- }
- //客户组表
- dr = erpCustomerGroupDt.NewRow();
- dr["GP_DividedShop"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- dr["GP_CustomerGroupID"] = GMID;
- dr["GP_GroupType"] = Type;
- dr["GP_CustomerType"] = "0";
- dr["GP_CustomerStatus"] = "正常";
- dr["GP_CreateDatetime"] = strTime;
- dr["GP_CreateName"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- dr["GP_CustomerSource"] = "";
- dr["GP_Remark"] = "";
- dr["GP_OrderNumber"] = "";
- dr["GP_LossReason"] = "";
- dr["GP_IntroducerCustomerID"] = "";
- dr["GP_DegreeOfIntent"] = "";
- dr["GP_BelongsPersonID"] = "";
- erpCustomerGroupDt.Rows.Add(dr);
- // namelist.Add("宝宝姓名:" + Baby.Cus_Name + ",家长姓名:" + RT_Cus_Model.Cus_Name);
- string item = "先生姓名:" + nanName + ",女士姓名:" + nvName;
- dr = erpSystemLogsDt.NewRow();
- dr["Slogs_DividedShop"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- dr["Slogs_Content"] = "添加联系人资料:" + item + ",时间:" + SDateTime.Now + "[" + HPSocketCS.Extended.CommonLibrary.ClientMarkID + ":" + HPSocketCS.Extended.CommonLibrary.ClientMarkName + "]";
- dr["Slogs_CreateDatetime"] = SDateTime.Now;
- dr["Slogs_CreateName"] = LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID;
- dr["Slogs_UserName"] = LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name;
- dr["Slogs_Type"] = LYFZ.EnumPublic.SystemLogsType.添加客户资料;
- dr["Slogs_Topic"] = LYFZ.EnumPublic.SystemLogsType.添加客户资料;
- dr["Slogs_IP"] = "-";
- erpSystemLogsDt.Rows.Add(dr);
- }
- List<string> dataTableNames = new List<string>();
- List<DataTable> dataTables = new List<DataTable>();
- dataTableNames.Add("tb_ErpCustomer");
- dataTableNames.Add("tb_ErpCustomerGroupMembers");
- dataTableNames.Add("tb_ErpCustomer");
- dataTableNames.Add("tb_ErpCustomerGroupMembers");
- dataTableNames.Add("tb_OldOrderHistory");
- dataTableNames.Add("tb_ErpCustomerGroup");
- dataTableNames.Add("tb_ErpSystemLogs");
- dataTables.Add(erpCustomerNvDt);
- dataTables.Add(erpCustomerGroupMembersNvDt);
- dataTables.Add(erpCustomerNanDt);
- dataTables.Add(erpCustomerGroupMembersNanDt);
- dataTables.Add(oldOrderHistoryDt);
- dataTables.Add(erpCustomerGroupDt);
- dataTables.Add(erpSystemLogsDt);
- orbll.ExecuteSqlBulkCopyByDataTable(dataTableNames, dataTables);
- }, width: 350);
- }
- else { MessageBoxCustom.Show("请导入Excel文档!"); }
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show(ex.Message);
- }
- }
- /// <summary>
- /// 写真,服务
- /// </summary>
- /// <param name="objtype">2=写真,3=服务</param>
- [Obsolete]
- void OldXZfw( int objtype )
- {
- try
- {
- if ( dgv.Rows.Count > 0 )
- {
- // List<string> namelist = new List<string>();
- // Gmlist = new List<string>();
- LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod( delegate ( object obj, BackgroundWorker backgroundWorker )
- {
- //总计数器
- float sumCount = dgv.Rows.Count;
- //当前计数器
- int currentCount = 0;
- for ( int i = 0; i < dgv.Rows.Count; i++ )
- {
- // 存放添加sql语句
- List<Helper.CommandInfo> sqllist = new List<Helper.CommandInfo>();
- DateTime strTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
- //主联系人ID
- string ID = LYFZ.BLL.BLL_ErpCustomer.GetClientNumber();
- //客户关系组
- string GMID = LYFZ.BLL.BLL_ErpCustomer.GetNewClientGroupNumber();
- Model_ErpCustomer modelNan = new Model_ErpCustomer();
- modelNan.Cus_CustomerNumber = ID;
- modelNan.Cus_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- modelNan.Cus_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter( dgv.Rows[i].Cells["姓名"].Value.ToString().Trim() );
- modelNan.Cus_NamePinyin = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin( modelNan.Cus_Name ).ToLower();
- modelNan.Cus_Sex = dgv.Rows[i].Cells["性别"].Value.ToString().Trim() == "男" ? false : true;
- if ( dgv.Rows[i].Cells["生日"].Value.ToString().Trim() != "" )
- {
- modelNan.Cus_Birthday = Convert.ToDateTime( dgv.Rows[i].Cells["生日"].Value.ToString().Trim() ).ToString( "yyyy-MM-dd" );
- }
- modelNan.Cus_Telephone = dgv.Rows[i].Cells["电话"].Value.ToString().Trim();
- modelNan.Cus_QQ = dgv.Rows[i].Cells["QQ"].Value.ToString().Trim();
- modelNan.Cus_CreateDateTime = strTime;
- modelNan.Cus_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- sqllist.Add( Cus_Bll.GetAddCommandInfo( modelNan ) );
- Model_ErpCustomerGroupMembers GM_Model = new Model_ErpCustomerGroupMembers();
- GM_Model.GM_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- GM_Model.GM_CustomerGroupID = GMID;
- GM_Model.GM_CustomerID = ID;
- GM_Model.GM_Master = 1;
- GM_Model.GM_ProtagonistCustomer = 1;
- GM_Model.GM_RelatedPersonID = ID;
- GM_Model.GM_Relation = "本人";
- GM_Model.GM_IsOrder = dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim() != "" ? 1 : 0;
- GM_Model.GM_IsOrderNumber = "";
- sqllist.Add( GM_Bll.GetAddCommandInfo( GM_Model ) );
- if ( dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim() != "" && dgv.Rows[i].Cells["套系价格"].Value.ToString().Trim() != "" )
- {
- BLL.BLL_OldOrderHistory bll_ooh = new BLL_OldOrderHistory();
- Model.Model_OldOrderHistory model_ooh = new Model_OldOrderHistory();
- model_ooh.History_ID = GMID;
- model_ooh.History_Type = dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim();
- model_ooh.History_Money = Convert.ToInt32( dgv.Rows[i].Cells["套系价格"].Value.ToString().Trim() );
- if ( dgv.Rows[i].Cells["订单日期"].Value.ToString().Trim() != "" )
- {
- model_ooh.History_OrderTime = Convert.ToDateTime( dgv.Rows[i].Cells["订单日期"].Value.ToString().Trim() );
- }
- model_ooh.History_CurrentID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- model_ooh.History_CurrentTime = strTime;
- sqllist.Add( bll_ooh.GetAddCommandInfo( model_ooh ) );
- }
- //客户组表
- Model_ErpCustomerGroup GP_Model = new Model_ErpCustomerGroup();
- GP_Model.GP_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- GP_Model.GP_CustomerGroupID = GMID;
- GP_Model.GP_GroupType = Type;
- GP_Model.GP_CustomerType = objtype;
- GP_Model.GP_CustomerStatus = "正常";
- GP_Model.GP_CreateDatetime = strTime;
- GP_Model.GP_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- GP_Model.GP_CustomerSource = "";
- GP_Model.GP_Remark = "";
- GP_Model.GP_OrderNumber = "";
- GP_Model.GP_LossReason = "";
- GP_Model.GP_IntroducerCustomerID = "";
- GP_Model.GP_DegreeOfIntent = "";
- GP_Model.GP_BelongsPersonID = "";
- sqllist.Add( GP_Bll.GetAddCommandInfo( GP_Model ) );
- Gmlist.Add( GMID );
- // namelist.Add("客户姓名:" + modelNan.Cus_Name);
- string item = "客户姓名:" + modelNan.Cus_Name;
- try
- {
- if ( LYFZ.BLL.BaseBllOperate.ExecuteSqlTran( sqllist ) > 0 )
- {
- //日志
- 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 );
- // DAL_ErpCustomer.UpdateAggregationCustomer(GMID);
- }
- }
- catch ( Exception ex )
- {
- MessageBoxCustom.Show( item + " 的客户导入失败:" + ex.Message, backgroundWorker: backgroundWorker );
- }
- currentCount++;
- if ( backgroundWorker != null )
- {
- try
- {
- int currentProgres = Convert.ToInt32( 1000 / sumCount * currentCount );
- backgroundWorker.ReportProgress( currentProgres, "共" + sumCount + "条,正在导入第" + currentCount.ToString() + "条..." );
- }
- catch { }
- }
- }
- }, width: 350 );
- /* if (clist.Count > 0)
- {
- LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- if (backgroundWorker != null)
- {
- try
- {
- backgroundWorker.ReportProgress(0, "准备中...请稍后!");
- }
- catch { }
- }
- if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0)
- {
- foreach (string item in namelist)
- {
- //日志
- LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.添加客户资料, "添加联系人资料:" + item, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
- }
- //总计数器
- float sumCount = Gmlist.Count;
- //当前计数器
- int currentCount = 0;
- for (int i = 0; i < Gmlist.Count; i++)
- {
- currentCount++;
- DAL_ErpCustomer.UpdateAggregationCustomer(Gmlist[i].ToString().Trim());
- if (backgroundWorker != null)
- {
- try
- {
- int currentProgres = Convert.ToInt32(1000 / sumCount * currentCount);
- backgroundWorker.ReportProgress(currentProgres, "正在添加..,共" + sumCount + "条,正在添加第:" + currentCount.ToString() + "条...");
- }
- catch { }
- }
- }
- MessageBoxCustom.Show("添加成功!共导入:" + dgv.Rows.Count + "条");
- this.DialogResult = DialogResult.OK;
- }
- else { MessageBoxCustom.Show("添加失败!"); }
- }, width: 350);
- }*/
- }
- else { MessageBoxCustom.Show( "请导入Excel文档!" ); }
- }
- catch ( Exception ex )
- {
- MessageBoxCustom.Show( ex.Message );
- }
- }
- void OldXZfwNew(int objtype)
- {
- try
- {
- if (dgv.Rows.Count > 0)
- {
- // List<string> namelist = new List<string>();
- // Gmlist = new List<string>();
- LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker)
- {
- //总计数器
- float sumCount = dgv.Rows.Count;
- //当前计数器
- int currentCount = 0;
- DataTable erpCustomerDt = new DataTable();
- BindDataTableColumData(
- "Cus_CustomerNumber,Cus_DividedShop,Cus_Name,Cus_NamePinyin,Cus_Sex,Cus_Birthday,Cus_Telephone,Cus_QQ,Cus_CreateDateTime,Cus_CreateName"
- .Split(','),
- ref erpCustomerDt);
- DataTable erpCustomerGroupMembersDt = new DataTable();
- BindDataTableColumData(
- "GM_DividedShop,GM_CustomerGroupID,GM_CustomerID,GM_Master,GM_ProtagonistCustomer,GM_RelatedPersonID,GM_Relation,GM_IsOrder,GM_IsOrderNumber"
- .Split(','),
- ref erpCustomerGroupMembersDt);
- DataTable oldOrderHistoryDt = new DataTable();
- BindDataTableColumData(
- "History_ID,History_Type,History_Money,History_OrderTime,History_CurrentID,History_CurrentTime"
- .Split(','),
- ref oldOrderHistoryDt);
- DataTable erpCustomerGroupDt = new DataTable();
- BindDataTableColumData(
- "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"
- .Split(','),
- ref erpCustomerGroupDt);
- DataTable erpSystemLogsDt = new DataTable();
- BindDataTableColumData(
- "Slogs_DividedShop,Slogs_Content,Slogs_CreateDatetime,Slogs_CreateName,Slogs_UserName,Slogs_Type,Slogs_Topic,Slogs_IP"
- .Split(','),
- ref erpSystemLogsDt);
- for (int i = 0; i < dgv.Rows.Count; i++)
- {
- // 存放添加sql语句
- //List<Helper.CommandInfo> sqllist = new List<Helper.CommandInfo>();
- DateTime strTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
- //主联系人ID
- string ID = LYFZ.BLL.BLL_ErpCustomer.GetClientNumber();
- //客户关系组
- string GMID = LYFZ.BLL.BLL_ErpCustomer.GetNewClientGroupNumber();
- string nanName = "";
- //宝宝
- DataRow dr = null;
- //Cus_CustomerNumber,Cus_DividedShop,Cus_Name,Cus_NamePinyin,Cus_Sex,Cus_Birthday,Cus_Telephone,Cus_QQ,Cus_CreateDateTime,Cus_CreateName
- dr = erpCustomerDt.NewRow();
- dr["Cus_CustomerNumber"] = ID;
- dr["Cus_DividedShop"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- dr["Cus_Name"] = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(dgv.Rows[i].Cells["姓名"].Value.ToString().Trim());
- dr["Cus_NamePinyin"] = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin(dr["Cus_Name"].ToString_s()).ToLower();
- dr["Cus_Sex"] = dgv.Rows[i].Cells["性别"].Value.ToString().Trim() == "男" ? false : true;
- if (dgv.Rows[i].Cells["生日"].Value.ToString().Trim() != "")
- {
- dr["Cus_Birthday"] = Convert.ToDateTime(dgv.Rows[i].Cells["生日"].Value.ToString().Trim()).ToString("yyyy-MM-dd");
- }
- dr["Cus_Telephone"] = dgv.Rows[i].Cells["电话"].Value.ToString().Trim();
- dr["Cus_QQ"] = dgv.Rows[i].Cells["QQ"].Value.ToString().Trim();
- dr["Cus_CreateDateTime"] = strTime;
- dr["Cus_CreateName"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- nanName = dr["Cus_Name"].ToString_s();
- erpCustomerDt.Rows.Add(dr);
- //sqllist.Add(Cus_Bll.GetAddCommandInfo(modelNan));
- //Model_ErpCustomerGroupMembers GM_Model = new Model_ErpCustomerGroupMembers();
- //GM_DividedShop,GM_CustomerGroupID,GM_CustomerID,GM_Master,GM_ProtagonistCustomer,GM_RelatedPersonID,GM_Relation,GM_IsOrder,GM_IsOrderNumber
- dr = erpCustomerGroupMembersDt.NewRow();
- dr["GM_DividedShop"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- dr["GM_CustomerGroupID"] = GMID;
- dr["GM_CustomerID"] = ID;
- dr["GM_Master"] = 1;
- dr["GM_ProtagonistCustomer"] = 1;
- dr["GM_RelatedPersonID"] = ID;
- dr["GM_Relation"] = "本人";
- dr["GM_IsOrder"] = dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim() != "" ? 1 : 0;
- dr["GM_IsOrderNumber"] = "";
- erpCustomerGroupMembersDt.Rows.Add(dr);
- if (dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim() != "" && dgv.Rows[i].Cells["套系价格"].Value.ToString().Trim() != "")
- {
- dr = oldOrderHistoryDt.NewRow();
- dr["History_ID"] = GMID;
- dr["History_Type"] = dgv.Rows[i].Cells["套系名称"].Value.ToString().Trim();
- dr["History_Money"] = Convert.ToInt32(dgv.Rows[i].Cells["套系价格"].Value.ToString().Trim());
- if (dgv.Rows[i].Cells["订单日期"].Value.ToString().Trim() != "")
- {
- dr["History_OrderTime"] = Convert.ToDateTime(dgv.Rows[i].Cells["订单日期"].Value.ToString().Trim());
- }
- dr["History_CurrentID"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- dr["History_CurrentTime"] = strTime;
- oldOrderHistoryDt.Rows.Add(dr);
- }
- //客户组表
- dr = erpCustomerGroupDt.NewRow();
- dr["GP_DividedShop"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- dr["GP_CustomerGroupID"] = GMID;
- dr["GP_GroupType"] = Type;
- dr["GP_CustomerType"] = objtype;
- dr["GP_CustomerStatus"] = "正常";
- dr["GP_CreateDatetime"] = strTime;
- dr["GP_CreateName"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- dr["GP_CustomerSource"] = "";
- dr["GP_Remark"] = "";
- dr["GP_OrderNumber"] = "";
- dr["GP_LossReason"] = "";
- dr["GP_IntroducerCustomerID"] = "";
- dr["GP_DegreeOfIntent"] = "";
- dr["GP_BelongsPersonID"] = "";
- erpCustomerGroupDt.Rows.Add(dr);
- // namelist.Add("客户姓名:" + modelNan.Cus_Name);
- string item = "客户姓名:" + nanName;
- dr = erpSystemLogsDt.NewRow();
- dr["Slogs_DividedShop"] = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- dr["Slogs_Content"] = "添加联系人资料:" + item + ",时间:" + SDateTime.Now + "[" + HPSocketCS.Extended.CommonLibrary.ClientMarkID + ":" + HPSocketCS.Extended.CommonLibrary.ClientMarkName + "]";
- dr["Slogs_CreateDatetime"] = SDateTime.Now;
- dr["Slogs_CreateName"] = LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID;
- dr["Slogs_UserName"] = LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name;
- dr["Slogs_Type"] = LYFZ.EnumPublic.SystemLogsType.添加客户资料;
- dr["Slogs_Topic"] = LYFZ.EnumPublic.SystemLogsType.添加客户资料;
- dr["Slogs_IP"] = "-";
- erpSystemLogsDt.Rows.Add(dr);
- }
- List<string> dataTableNames = new List<string>();
- List<DataTable> dataTables = new List<DataTable>();
- dataTableNames.Add("tb_ErpCustomer");
- dataTableNames.Add("tb_ErpCustomerGroupMembers");
- dataTableNames.Add("tb_OldOrderHistory");
- dataTableNames.Add("tb_ErpCustomerGroup");
- dataTableNames.Add("tb_ErpSystemLogs");
- dataTables.Add(erpCustomerDt);
- dataTables.Add(erpCustomerGroupMembersDt);
- dataTables.Add(oldOrderHistoryDt);
- dataTables.Add(erpCustomerGroupDt);
- dataTables.Add(erpSystemLogsDt);
- orbll.ExecuteSqlBulkCopyByDataTable(dataTableNames, dataTables);
- }, width: 350);
-
- }
- else { MessageBoxCustom.Show("请导入Excel文档!"); }
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show(ex.Message);
- }
- }
- #endregion
- #region 老客户检查操作
- /// <summary>
- /// 错误类型
- /// </summary>
- enum error
- {
- 手机号不能为空,
- 手机号已存在,
- 手机号必须是11位,
- 家长姓名不能为空,
- 宝宝生日错误,
- 宝宝性别只能是男或女或不填,
- 订单日期格式错误,
- 套系价格只能输入数字,
- 手机号在Excel中多次出现,
- 生日错误,
- 婚期错误,
- 姓名不能为空,
- 性别只能是男或女或不填,
- ok
- }
- /// <summary>
- /// 检查宝宝
- /// </summary>
- /// <returns></returns>
- StringBuilder checkBaby( DataRow data, DataTable tblClient )
- {
- StringBuilder ok = new StringBuilder();
- string list = "";
- list = cheSJ( data["手机号"].ToString().Trim(), tblClient ).ToString();
- ok.Append( list == error.ok.ToString() ? "" : list );
- if ( data["家长姓名"].ToString().Trim() == "" )
- {
- ok.Append( error.家长姓名不能为空.ToString() );
- }
- if ( data["宝宝生日"].ToString().Trim() != "" )
- {
- if ( !cheSR( data["宝宝生日"].ToString().Trim() ) )
- {
- ok.Append( error.宝宝生日错误.ToString() );
- }
- }
- if ( data["宝宝性别"].ToString().Trim() != "男" && data["宝宝性别"].ToString().Trim() != "女" && data["宝宝性别"].ToString().Trim() != "" )
- {
- ok.Append( error.宝宝性别只能是男或女或不填.ToString() );
- }
- if ( data["订单日期"].ToString().Trim() != "" )
- {
- if ( !cheDDRQ( data["订单日期"].ToString().Trim() ) )
- {
- ok.Append( error.订单日期格式错误.ToString() );
- }
- }
- if ( data["套系价格"].ToString().Trim() != "" )
- {
- if ( !cheTXJG( data["套系价格"].ToString().Trim() ) )
- {
- ok.Append( error.套系价格只能输入数字.ToString() );
- }
- }
- return ok;
- }
- /// <summary>
- /// 检查婚纱版
- /// </summary>
- /// <returns></returns>
- StringBuilder checkHS( DataRow data, DataTable tblClient )
- {
- StringBuilder ok = new StringBuilder();
- if ( dt.Rows.Count > 0 )
- {
- if ( data["女士名字"].ToString().Trim() != "" )
- {
- if ( data["女士手机号"].ToString().Trim() != "" )
- {
- string list = "";
- list = cheSJ( data["女士手机号"].ToString().Trim(), tblClient ).ToString();
- ok.Append( list == error.ok.ToString() ? "" : list );
- }
- }
- if ( data["先生名字"].ToString().Trim() != "" )
- {
- if ( data["先生手机号"].ToString().Trim() != "" )
- {
- string list = "";
- list = cheSJ( data["先生手机号"].ToString().Trim(), tblClient ).ToString();
- ok.Append( list == error.ok.ToString() ? "" : list );
- }
- }
- if ( data["先生生日"].ToString().Trim() != "" )
- {
- if ( cheSR( data["先生生日"].ToString() ) == false )
- {
- ok.Append( error.生日错误.ToString() );
- }
- }
- if ( data["女士生日"].ToString().Trim() != "" )
- {
- if ( cheSR( data["女士生日"].ToString() ) == false )
- {
- ok.Append( error.生日错误.ToString() );
- }
- }
- if ( data["婚期"].ToString().Trim() != "" )
- {
- if ( cheSR( data["婚期"].ToString() ) == false )
- {
- ok.Append( error.生日错误.ToString() );
- }
- }
- if ( data["套系价格"].ToString().Trim() != "" )
- {
- if ( cheTXJG( data["套系价格"].ToString() ) == false )
- {
- ok.Append( error.套系价格只能输入数字.ToString() );
- }
- }
- if ( data["订单日期"].ToString().Trim() != "" )
- {
- if ( cheDDRQ( data["订单日期"].ToString() ) == false )
- {
- ok.Append( error.订单日期格式错误.ToString() );
- }
- }
- }
- return ok;
- }
- /// <summary>
- /// 写真和服务
- /// </summary>
- /// <returns></returns>
- StringBuilder checkXZfw( DataRow data, DataTable tblClient )
- {
- StringBuilder ok = new StringBuilder();
- if ( dt.Rows.Count > 0 )
- {
- if ( data["姓名"].ToString().Trim() == "" )
- {
- ok.Append( error.姓名不能为空.ToString() );
- }
- if ( data["性别"].ToString().Trim() != "男" && data["性别"].ToString().Trim() != "女" )
- {
- ok.Append( error.性别只能是男或女或不填.ToString() );
- }
- string list = "";
- list = cheSJ( data["电话"].ToString().Trim(), tblClient ).ToString();
- ok.Append( list == error.ok.ToString() ? "" : list );
- if ( data["生日"].ToString().Trim() != "" )
- {
- if ( !cheSR( data["生日"].ToString().Trim() ) )
- {
- ok.Append( error.生日错误.ToString() );
- }
- }
- if ( data["套系价格"].ToString().Trim() != "" )
- {
- if ( !cheTXJG( data["套系价格"].ToString().Trim() ) )
- {
- ok.Append( error.套系价格只能输入数字.ToString() );
- }
- }
- if ( data["订单日期"].ToString().Trim() != "" )
- {
- if ( cheDDRQ( data["订单日期"].ToString() ) == false )
- {
- ok.Append( error.订单日期格式错误.ToString() );
- }
- }
- }
- return ok;
- }
- #endregion
- #region 意向客户添加操作
- /// <summary>
- /// 添加意向客户 婚纱 写真 服务
- /// </summary>
- bool addYixiang()
- {
- bool upData = true;
- try
- {
- if ( dgv.Rows.Count > 0 )
- {
- // Gmlist = new List<string>();
- // List<string> namelist = new List<string>();
- LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod( delegate ( object obj, BackgroundWorker backgroundWorker )
- {//总计数器
- try
- {
- float sumCount = dgv.Rows.Count;
- //当前计数器
- int currentCount = 0;
- for (int i = 0; i < dgv.Rows.Count; i++)
- { // 存放添加sql语句
- List<Helper.CommandInfo> sqllist = new List<Helper.CommandInfo>();
- DateTime strTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
- //主联系人ID
- string ID = LYFZ.BLL.BLL_ErpCustomer.GetClientNumber();
- //客户关系组
- string GMID = LYFZ.BLL.BLL_ErpCustomer.GetNewClientGroupNumber();
- Model_ErpCustomer model = new Model_ErpCustomer();
- if (dgv.Rows[i].Cells["订单类型"].Value.ToString().Trim() == "儿童")
- {
- model.Cus_CustomerNumber = ID;
- model.Cus_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- model.Cus_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(dgv.Rows[i].Cells["客户姓名"].Value.ToString().Trim());
- model.Cus_NamePinyin = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin(model.Cus_Name).ToLower();
- model.Cus_Sex = dgv.Rows[i].Cells["性别"].Value.ToString().Trim() == "男" ? false : true;
- if (dgv.Rows[i].Cells["生日"].Value.ToString().Trim() != "")
- {
- model.Cus_Birthday = Convert.ToDateTime(dgv.Rows[i].Cells["生日"].Value.ToString().Trim()).ToString("yyyy-MM-dd");
- }
- model.Cus_Telephone = dgv.Rows[i].Cells["电话"].Value.ToString().Trim();
- model.Cus_QQ = dgv.Rows[i].Cells["QQ"].Value.ToString().Trim();
- model.Cus_Address = dgv.Rows[i].Cells["地址"].Value.ToString().Trim();
- model.Cus_CreateDateTime = strTime;
- model.Cus_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- model.Cus_CustomerSource = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(dgv.Rows[i].Cells["客户来源"].Value.ToString().Trim());
- sqllist.Add(Cus_Bll.GetAddCommandInfo(model));
- Model_ErpCustomerGroupMembers GM_Model = new Model_ErpCustomerGroupMembers();
- GM_Model.GM_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- GM_Model.GM_CustomerGroupID = GMID;
- GM_Model.GM_CustomerID = ID;
- GM_Model.GM_Master = 1;
- GM_Model.GM_ProtagonistCustomer = 0;
- GM_Model.GM_RelatedPersonID = ID;
- GM_Model.GM_Relation = "亲人";
- GM_Model.GM_IsOrder = 0;
- GM_Model.GM_IsOrderNumber = "";
- sqllist.Add(GM_Bll.GetAddCommandInfo(GM_Model));
- //客户组表
- Model_ErpCustomerGroup GP_Model = new Model_ErpCustomerGroup();
- GP_Model.GP_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- GP_Model.GP_CustomerGroupID = GMID;
- GP_Model.GP_GroupType = Type;
- GP_Model.GP_ISIntentionCustomer = 1;
- GP_Model.GP_CustomerType = Lun(dgv.Rows[i].Cells["订单类型"].Value.ToString().Trim());
- GP_Model.GP_CustomerStatus = "意向";
- GP_Model.GP_CreateDatetime = strTime;
- GP_Model.GP_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- GP_Model.GP_CustomerSource = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(dgv.Rows[i].Cells["客户来源"].Value.ToString().Trim());
- GP_Model.GP_Remark = "";
- GP_Model.GP_OrderNumber = "";
- GP_Model.GP_LossReason = "";
- GP_Model.GP_IntroducerCustomerID = "";
- GP_Model.GP_DegreeOfIntent = "";
- GP_Model.GP_BelongsPersonID = "";
- sqllist.Add(GP_Bll.GetAddCommandInfo(GP_Model));
- Gmlist.Add(GMID);
- }
- else
- {
- // Model_ErpCustomer model = new Model_ErpCustomer();
- model.Cus_CustomerNumber = ID;
- model.Cus_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- model.Cus_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(dgv.Rows[i].Cells["客户姓名"].Value.ToString().Trim());
- model.Cus_NamePinyin = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin(model.Cus_Name).ToLower();
- model.Cus_Sex = dgv.Rows[i].Cells["性别"].Value.ToString().Trim() == "男" ? false : true;
- if (dgv.Rows[i].Cells["生日"].Value.ToString().Trim() != "")
- {
- model.Cus_Birthday = Convert.ToDateTime(dgv.Rows[i].Cells["生日"].Value.ToString().Trim()).ToString("yyyy-MM-dd");
- }
- model.Cus_Telephone = dgv.Rows[i].Cells["电话"].Value.ToString().Trim();
- model.Cus_QQ = dgv.Rows[i].Cells["QQ"].Value.ToString().Trim();
- model.Cus_Address = dgv.Rows[i].Cells["地址"].Value.ToString().Trim();
- model.Cus_CreateDateTime = strTime;
- model.Cus_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- model.Cus_CustomerSource = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(dgv.Rows[i].Cells["客户来源"].Value.ToString().Trim());
- sqllist.Add(Cus_Bll.GetAddCommandInfo(model));
- Model_ErpCustomerGroupMembers GM_Model = new Model_ErpCustomerGroupMembers();
- GM_Model.GM_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- GM_Model.GM_CustomerGroupID = GMID;
- GM_Model.GM_CustomerID = ID;
- GM_Model.GM_Master = 1;
- GM_Model.GM_ProtagonistCustomer = 1;
- GM_Model.GM_RelatedPersonID = ID;
- GM_Model.GM_Relation = "本人";
- GM_Model.GM_IsOrder = 0;
- GM_Model.GM_IsOrderNumber = "";
- sqllist.Add(GM_Bll.GetAddCommandInfo(GM_Model));
- //客户组表
- Model_ErpCustomerGroup GP_Model = new Model_ErpCustomerGroup();
- GP_Model.GP_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- GP_Model.GP_CustomerGroupID = GMID;
- GP_Model.GP_GroupType = Type;
- GP_Model.GP_CustomerType = Lun(dgv.Rows[i].Cells["订单类型"].Value.ToString().Trim());
- GP_Model.GP_CustomerStatus = "意向";
- GP_Model.GP_CreateDatetime = strTime;
- GP_Model.GP_ISIntentionCustomer = 1;
- GP_Model.GP_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- GP_Model.GP_CustomerSource = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(dgv.Rows[i].Cells["客户来源"].Value.ToString().Trim());
- GP_Model.GP_Remark = "";
- GP_Model.GP_OrderNumber = "";
- GP_Model.GP_LossReason = "";
- GP_Model.GP_IntroducerCustomerID = "";
- GP_Model.GP_DegreeOfIntent = "";
- GP_Model.GP_BelongsPersonID = "";
- sqllist.Add(GP_Bll.GetAddCommandInfo(GP_Model));
- Gmlist.Add(GMID);
- }
- // namelist.Add("客户姓名:" + model.Cus_Name);
- string item = "客户姓名:" + model.Cus_Name;
- try
- {
- if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(sqllist) > 0)
- {
- //日志
- 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);
- // DAL_ErpCustomer.UpdateAggregationCustomer(GMID);
- }
- }
- catch (Exception ex)
- {
- upData = false;
- MessageBoxCustom.Show(item + " 的客户导入失败:" + ex.Message, backgroundWorker: backgroundWorker);
- }
- currentCount++;
- if (backgroundWorker != null)
- {
- try
- {
- int currentProgres = Convert.ToInt32(1000 / sumCount * currentCount);
- backgroundWorker.ReportProgress(currentProgres, "共" + sumCount + "条,正在导入第" + currentCount.ToString() + "条...");
- }
- catch { }
- }
- }
- }
- catch(Exception ex)
- {
- upData = false;
- MessageBoxCustom.Show(ex.Message, "错误提示");
- }
- }, width: 350 );
- /* if (clist.Count > 0)
- {
- LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- if (backgroundWorker != null)
- {
- try
- {
- backgroundWorker.ReportProgress(0, "准备中...请稍后!");
- }
- catch { }
- }
- if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) >= 0)
- {
- foreach (string item in namelist)
- {
- //日志
- LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.添加客户资料, "添加联系人资料:" + item, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
- }
- //总计数器
- float sumCount = Gmlist.Count;
- //当前计数器
- int currentCount = 0;
- for (int i = 0; i < Gmlist.Count; i++)
- {
- currentCount++;
- DAL_ErpCustomer.UpdateAggregationCustomer(Gmlist[i].ToString().Trim());
- if (backgroundWorker != null)
- {
- try
- {
- int currentProgres = Convert.ToInt32(1000 / sumCount * currentCount);
- backgroundWorker.ReportProgress(currentProgres, "正在添加..,共" + sumCount + "条,正在添加第:" + currentCount.ToString() + "条...");
- }
- catch { }
- }
- }
- MessageBoxCustom.Show("添加成功!共导入:" + dgv.Rows.Count + "条");
- this.DialogResult = DialogResult.OK;
- }
- else { MessageBoxCustom.Show("添加失败!"); }
- }, width: 350);
- }*/
- }
- else {
- upData = false;
- MessageBoxCustom.Show( "请导入Excel文档!" );
- }
- }
- catch ( Exception ex )
- {
- upData = false;
- MessageBoxCustom.Show( ex.Message );
- }
- return upData;
- }
- #endregion
- #region 意向客户检查操作
- /// <summary>
- /// 检测意向客户 婚纱 写真 服务 儿童
- /// </summary>
- /// <returns></returns>
- StringBuilder UYixiang( DataRow data, DataTable tblClient )
- {
- StringBuilder ok = new StringBuilder();
- if ( data["客户姓名"].ToString().Trim() == "" )
- {
- ok.Append( error.姓名不能为空.ToString() );
- }
- if ( data["性别"].ToString().Trim() != "男" && data["性别"].ToString().Trim() != "女" )
- {
- ok.Append( error.性别只能是男或女或不填.ToString() );
- }
- string list = "";
- list = cheSJ( data["电话"].ToString().Trim(), tblClient ).ToString();
- ok.Append( list == error.ok.ToString() ? "" : list );
- if ( data["生日"].ToString().Trim() != "" )
- {
- if ( !cheSR( data["生日"].ToString().Trim() ) )
- {
- ok.Append( error.生日错误.ToString() );
- }
- }
- string Dindanleixing = data["订单类型"].ToString().Trim();
- if ( Dindanleixing == "" )
- {
- ok.Append( "类型不能为空," );
- }
- if ( Dindanleixing != "写真" && Dindanleixing != "服务" && Dindanleixing != "婚纱" && Dindanleixing != "儿童" )
- {
- ok.Append( "类型错误错误," );
- }
- return ok;
- }
- #endregion
- #region 其他客户检查操作
- StringBuilder checkOther( DataRow data, DataTable tblClient )
- {
- StringBuilder ok = new StringBuilder();
- if ( dt.Rows.Count > 0 )
- {
- if ( data["客户姓名"].ToString().Trim() == "" )
- {
- ok.Append( error.姓名不能为空.ToString() );
- }
- if ( data["性别"].ToString().Trim() != "男" && data["性别"].ToString().Trim() != "女" )
- {
- ok.Append( error.性别只能是男或女或不填.ToString() );
- }
- string list = "";
- list = cheSJ( data["电话"].ToString().Trim(), tblClient ).ToString();
- ok.Append( list == error.ok.ToString() ? "" : list );
- if ( data["生日"].ToString().Trim() != "" )
- {
- if ( !cheSR( data["生日"].ToString().Trim() ) )
- {
- ok.Append( error.生日错误.ToString() );
- }
- }
- }
- return ok;
- }
- #endregion
- #region 其他客户添加操作
- /// <summary>
- /// 其他客户添加
- /// </summary>
- void AddOther()
- {
- // List<string> namelist = new List<string>();
- LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod( delegate ( object obj, BackgroundWorker backgroundWorker )
- {//总计数器
- float sumCount = dgv.Rows.Count;
- //当前计数器
- int currentCount = 0;
- for ( int i = 0; i < dgv.Rows.Count; i++ )
- { // 存放添加sql语句
- List<Helper.CommandInfo> sqllist = new List<Helper.CommandInfo>();
- Model_ErpCustomer Cus_Model = new Model_ErpCustomer();
- Cus_Model.Cus_CustomerNumber = LYFZ.BLL.BLL_ErpCustomer.GetClientNumber();
- Cus_Model.Cus_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- Cus_Model.Cus_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter( dgv.Rows[i].Cells["客户姓名"].Value.ToString().Trim() );
- Cus_Model.Cus_NamePinyin = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin( Cus_Model.Cus_Name ).ToLower();
- Cus_Model.Cus_Sex = dgv.Rows[i].Cells["性别"].Value.ToString().Trim() == "男" ? false : true;
- if ( dgv.Rows[i].Cells["生日"].Value.ToString().Trim() != "" )
- {
- Cus_Model.Cus_Birthday = Convert.ToDateTime( dgv.Rows[i].Cells["生日"].Value.ToString().Trim() ).ToString( "yyyy-MM-dd" );
- }
- Cus_Model.Cus_Telephone = dgv.Rows[i].Cells["电话"].Value.ToString().Trim();
- Cus_Model.Cus_QQ = dgv.Rows[i].Cells["QQ"].Value.ToString().Trim();
- Cus_Model.Cus_Address = dgv.Rows[i].Cells["地址"].Value.ToString().Trim();
- Cus_Model.Cus_CreateDateTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
- Cus_Model.Cus_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- sqllist.Add( Cus_Bll.GetAddCommandInfo( Cus_Model ) );
- // namelist.Add("客户姓名:" + Cus_Model.Cus_Name);
- string item = "客户姓名:" + Cus_Model.Cus_Name;
- try
- {
- if ( LYFZ.BLL.BaseBllOperate.ExecuteSqlTran( sqllist ) > 0 )
- {
- //日志
- 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 );
- // DAL_ErpCustomer.UpdateAggregationCustomer(GMID);
- }
- }
- catch ( Exception ex )
- {
- MessageBoxCustom.Show( item + " 的客户导入失败:" + ex.Message, backgroundWorker: backgroundWorker );
- }
- currentCount++;
- if ( backgroundWorker != null )
- {
- try
- {
- int currentProgres = Convert.ToInt32( 1000 / sumCount * currentCount );
- backgroundWorker.ReportProgress( currentProgres, "共" + sumCount + "条,正在导入第" + currentCount.ToString() + "条..." );
- }
- catch { }
- }
- }
- /* if (clist.Count > 0)
- {
- if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) >= 0)
- {
- foreach (string item in namelist)
- {
- //日志
- 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);
- }
- MessageBoxCustom.Show("添加成功!共导入:" + dgv.Rows.Count + "条");
- this.DialogResult = DialogResult.OK;
- }
- else { MessageBoxCustom.Show("添加失败!"); }
- }*/
- }, width: 350 );
- }
- #endregion
- #region 判读公共方法
- /// <summary>
- /// 判断手机是否正确
- /// </summary>
- /// <returns></returns>
- error cheSJ( string SJ, DataTable tblClient )
- {
- if ( SJ == "" )
- {
- return error.手机号不能为空;
- }
- if ( SJ.ToString().Trim().Length != 11 )
- {
- return error.手机号必须是11位;
- }
- DataRow[] sjrow = tblClient.Select( " Cus_Telephone='" + SJ + "'" );
- if ( sjrow.Length > 0 )
- {
- return error.手机号已存在;
- }
- else if ( !check( SJ ) ) { return error.手机号在Excel中多次出现; } else { return error.ok; }
- }
- /// <summary>
- /// 判断生日是否正确
- /// </summary>
- /// <returns></returns>
- bool cheSR( string SR )
- {
- try
- {
- DateTime.Parse( SR );
- return true;
- }
- catch { return false; }
- }
- /// <summary>
- /// 判断套系价格
- /// </summary>
- /// <returns></returns>
- bool cheTXJG( string GJ )
- {
- try
- {
- int o;
- if ( !int.TryParse( GJ.Trim(), out o ) )
- {
- return false;
- }
- else { return true; }
- }
- catch { return false; }
- }
- /// <summary>
- /// 检查订单日期
- /// </summary>
- /// <returns></returns>
- bool cheDDRQ( string rq )
- {
- string sss = rq.Replace( "-", "" );
- if ( (rq.Length - sss.Length) == 1 )
- {
- rq = rq.Split( '-' )[0].Insert( 4, "-" ).Insert( 7, "-" );
- }
- try
- {
- DateTime.Parse( rq );
- return true;
- }
- catch { return true; }
- }
- #endregion
- #region 判读公共数据方法
- string DDRQ( string rq )
- {
- string sss = rq.Replace( "-", "" );
- if ( (rq.Length - sss.Length) == 1 )
- {
- rq = rq.Split( '-' )[0].Insert( 4, "-" ).Insert( 7, "-" );
- }
- return rq;
- }
- /// <summary>
- /// 遍历类型
- /// </summary>
- /// <param name="str"></param>
- /// <returns></returns>
- int Lun( string str )
- {
- int cLeixing = 0;
- switch ( str )
- {
- case "婚纱":
- cLeixing = 0;
- break;
- case "儿童":
- cLeixing = 1;
- break;
- case "写真":
- cLeixing = 2;
- break;
- case "服务":
- cLeixing = 3;
- break;
- }
- return cLeixing;
- }
- /// <summary>
- /// 封装当前手机号
- /// </summary>
- /// <param name="lie"></param>
- /// <returns></returns>
- string StrDianhua( string lie, DataTable dt )
- {
- string str = "";
- for ( int i = 0; i < dt.Rows.Count; i++ )
- {
- str += "'" + dt.Rows[i][lie].ToString().Trim() + "',";
- }
- str = str.Substring( 0, str.Length - 1 );
- return str;
- }
- /// <summary>
- /// 检查手机是存在 true 没有
- /// </summary>
- /// <param name="sj"></param>
- /// <returns></returns>
- public bool check( string sj )
- {
- if ( list.IndexOf( sj ) == -1 )
- {
- list.Add( sj );
- return true;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// 减除错误数据
- /// </summary>
- /// <param name="dt"></param>
- /// <param name="dgvNew"></param>
- /// <param name="cuowu"></param>
- public void PuAdd( string cuowu, int c )
- {
- DataRow row = dtError.NewRow();
- if ( dt != null && dt.Rows.Count > 0 )
- {
- for ( int i = 0; i < dt.Columns.Count; i++ )
- {
- row[i] = dt.Rows[c][i];
- }
- row[dt.Columns.Count] = cuowu;
- dtError.Rows.Add( row );
- }
- }
- #endregion
- }
- }
|