using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace LYFZ.Software.MainBusiness.MembershipManage.SetSmallForm
{
public partial class MemberImportExcel : LYFZ.Software.UI.MembershipManage.SetSmallForm.MemberImportExcel
{
LYFZ.BLL.BLL_ErpCustomer ctbll = new BLL.BLL_ErpCustomer();
LYFZ.BLL.BLL_ErpMemberCard mcbll = new BLL.BLL_ErpMemberCard();
LYFZ.BLL.BLL_ErpCustomerGroup ctgpbll = new BLL.BLL_ErpCustomerGroup();
LYFZ.BLL.BLL_ErpSystemConfigure sgbll = new BLL.BLL_ErpSystemConfigure();
LYFZ.BLL.BLL_ErpMemberCardPoints mcpsbll = new BLL.BLL_ErpMemberCardPoints();
LYFZ.BLL.BLL_ErpMemberCardDiscount mcdtbll = new BLL.BLL_ErpMemberCardDiscount();
LYFZ.BLL.BLL_ErpMemberCardViceCard mcvcbll = new BLL.BLL_ErpMemberCardViceCard();
LYFZ.BLL.BLL_ErpCustomerGroupMembers ctgmbll = new BLL.BLL_ErpCustomerGroupMembers();
public MemberImportExcel()
{
this.Load += MemberImportExcel_Load;
this.btnOpenExcel.Click += btnOpenExcel_Click;
this.btnOpenPointsViceCard.Click += btnOpenPointsViceCard_Click;
this.btnOpenBackCashViceCard.Click += btnOpenBackCashViceCard_Click;
this.btnSaveed.Click += btnSaveed_Click;
this.btnDelete.Click += btnDelete_Click;
this.btnCancel.Click += btnCancel_Click;
this.dgvData.RowsAdded += dgvData_RowsAdded;
this.btnExport.Click += btnExport_Click;
}
void btnExport_Click(object sender, EventArgs e)
{
string[] strArray = "'*','0','0.00','00','00.','000002','000003','000005','000006','000008','000009','000011','000012','000013','000015','000016','000018','000020','000021','000026','000029','000030','000033','000035','000036','000038','000039','00005','000050','000052','000055','000058','000059','000061','000062','000065','000066','000068','000069','000080','000082','000083','000085','000090','000092','000093','000098','00010','000101','000102','0001026','000103','000105','000106','000108','000109','000110','000111','000112','000113','000115','000116','000119','00012','000120','000123','0001238','000126','0001266','000128','000130','000131','000132','000133','000135','000136','000138','000150','000151','000152','000153','000156','000158','000159','000160','000161','000162','000165','000166','000169','000180','000181','0001813','000182','000183','000185','000186','0001888','000190','000191','000192','000193','0002','000202','000203','000208','000209','000211','000212','000213','000215','000216','000219','000220','000222','000225','000226','000228','000229','000231','000232','000235','000238','000239','00025','000250','000251','000253','000258','000259','000260','000261','000263','000265','000268','000269','000280','000281','000282','000283','000286','000288','000289','000292','000293','000296','000298','000299','000300','000301','000305','000306','000309','000310','000311','000312','000313','000315','000316','000318','000322','000323','000325','000326','000329','000330','000332','000333','000335','000336','000338','000339','000351','000360','000362','000365','000381','000385','000390','000393','000395','000396','000501','000502','000508','000509','000510','000511','000513','000515','000516','000518','000539','000552','000553','000556','000562','000563','000565','000566','000568','000581','000583','000588','000592','000593','000608','00061','000612','000615','000616','000619','000623','000626','000628','000630','000631','000632','000633','000638','000650','000652','000656','000658','000659','000661','000665','000668','000669','000681','000682','000683','000685','000686','000688','000689','000690','000691','000692','000693','000695','000696','000698','000802','000803','000806','000808','000809','000810','000815','000816','000818','000819','000821','000822','000823','000826','000829','000831','000835','000836','000839','000853','000855','000858','000860','000861','000862','000863','000865','000866','000868','000886','000890','000891','000893','000895','000896','000898','000900','000901','000902','000903','000905','000908','000909','000910','000911','000912','000915','000916','000920','000923','000938','00095','000950','000951','000953','000958','00096','000960','000965','000968','000980','000981','000982','000983','000985','000986','000988','000989','000990','000991','000993','000995','000996','000999','001','0010','001000','0010003','001001','001003','001005','001008','001009','001010','001012','001016','001018','001020','001021','001023','001025','001026','001029','001030','001032','001033','001035','001036','001039','001050','001061','001062','001063','001068','001069','001080','001085','001086','001088','001089','001090','001091','001092','001095','001098','001099','0011','001100','001101','001103','001105','001106','0011060','001108','001109','001110','001111','001113','001118','001120','001121','001122','001123','001125','001126','001131','001133','001135','001139','001152','001156','001160','001162','001163','001165','001168','001180','001181','001182','001183','001185','001186','001188','001189','001192','0011933','001195','001196','001198','001200','001201','001203','001205','001206','001208','001209','001213','001215','001216','001220','001221','001222','001229','001232','001233','001235','001238','001239','00125','001253','001255','001256','001260','001261','001262','001263','001269','001280','001282','001285','001286','001291','001292','001293','001295','001298','001301','001305','001306','001308','001312','001318','001321','001322','001323','001325','001338','001352','001353','001355','001356','001359','001360','001361','001362','001363','001366','001380','001381','001382','001383','001385','001386','001390','001391','001395','001396','001398','001399','001501','001502','001506','001508','001509','001511','001515','001518','001519','001520','001523','001525','001526','001529','001530','001531','001532','001533','001536','001539','001552','001553','001555','001556','001559','001561','001562','001563','001566','001568','001569','001580','001581','001582','001585','001586','001589','00159','001590','001591','001595','001596','001598','001599','001600','001602','001603','001605','001606','001608','001609','001611','001612','001615','001618','001621','001622','001626','001628','001629','001630','001635','001636','001650','001651','001652','001653','001655','001656','001658','001659','001661','0016610','001662','001665','001666','001668','001681','001682','001683','001686','001689','001690','001691','001692','001695','001698','001800','001806','001810','001812','001815','001816','001818','001819','001820','001821','001823','001825','001829','001831','001832','001833','001836','001839','001850','001851','001852','001855','001888','001889','001890','001891','001893','001895','001896','001899','001900','001901','001902','001903','001905','001906','001908','001909','001912','001920','001921','001930','001935','001936','001939','001950','001951','001953','001955','002','0020','00213','0023','00241','00350','0036','00391','004','00560','006','008','009','00910','0112','013','014','015','016','017','0170','018','019','02','020','021','022','023','024','026','027','028','029','03','030','031','032','0320','0328','034','035','036','0368','050','0569','0633','0820','0832','0833','0838','0851','0856','0858','0880','0888','0892','1','1019','10305','1109','111328','112455','1166','1169','1193','12','1202','1211','1221','1223','1230','1231','123456','1281','1288','13','13028577008','13098049309','13098051661','13098051666','13098075556','13098090777','13119201123','13119203966','13119230111','13119242555','13119252333','13119290321','13220010077','13220065613','13239188366','13239188888','13239227999','13244115333','13244198885','13259323130','13279112211','13309111418','13325313322','13359115777','13359116264','13369269875','13369280321','13369281933','13369285665','13369294010','13379114933','13379532009','13379539911','13379559821','13389117427','13391163631','13402900110','13402903965','13402904847','13402905187','13402905680','13409110316','13409110963','13409111942','13409112216','13409112412','13409114652','13409114662','13409117467','13409117543','13409118467','13429713154','13468543515','13468548121','13468580150','13468590140','13468592723','13468596355','13468596533','13468861341','13468863746','13468870635','13468871299','13468872240','13468873122','13468873689','13468877793','13468879775','13468961271','13468969626','13474340200','13474342844','13474345729','13474380899','13474384448','13474385070','13474404237','13474410790','13474411691','13474412223','13474412301','13474416140','13474419640','13474419662','13474419777','13474424222','13474425583','13474427796','13474427844','13474433611','13474435522','13474435533','13474437076','13474565658','13474568785','13474568885','13474570840','13474572264','13474573457','13474573493','13474574433','13484411136','13484411377','13484411456','13484411557','13484412345','13484416109','13484418387','13484643493','13484647093','13484658178','13484659442','13484659521','13484659722','13484685067','13484688265','13484965265','13484967899','13484969329','13484971265','13484973036','13484976971','13484977868','13488240225','13488245428','13488247265','13488249559','13488249735','13488254099','13488257520.','13488257854','13488258940','13488259936','13488280435','13488281602','13488288484','13488289574','13488373979','13488414221','13488416589','13488419026','13494569902','13509110342','13509111173','13509112378','13509114802','13509116574','13509117197','13571103141','13571103354','13571110766','13571112522','13571113177','13571113329','13571114377','13571117593','13571118634','13571121727','13571125398','13571126774','13571127565','13571131141','13571136171','13571137833','13571138066','13571138488','13571139937','13571142769','13571143995','13571144695','13571145020','13571145649','13571147877','13571149402','13571149444','13571151141','13571151823','13571157799','13571159060','13571159351','13572633343','13619111677','13619112191','13619114450','13619115070','13619116264','13619116591','13619117416','13619117647','13619119694','13629116560','13629211166','13629218041','13630240657','13630240790','13630242724','13630245032','13630245166','13630247875','13630249465','13636721034','13636722938','13636722939','13636723248','13636863494','13636868388','13636868412','13636872057','13636875774','13636877480','13636878367','13636878642','13639210548','13649113535','13649115986','13649116967','13649119764','13669115014','13669116338','13679112507','13689211618','13689217792','13698641569','13729344440','13772250512','13772258193','13772268994','13772275334','13772277174','13772278246','13772283335','13772288731','13772290267','13772292994','13772858144','13772862785','13772871807','13772878105','13772878756','13772880515','13772882375','13772886726','13772887557','13772888675','13772889089','13772891273','13772893633','13772895196','13772897110','13809110724','13809111047','13809115263','13809115306','13809116100','13891100424','13891100737','13891102001','13891102059','13891104737','13891111834','13891113447','13891113642','13891116006','13891120395','13891120815','13891124240','13891125435','13891129292','13891130824','13891130945','13891132540','13891134913','13891138453','13891141829','13891154757','13891156700','13891158755','13891159787','13891159859','13891164516','13891166461','13891169001','13891171822','13891173728','13891175454','13891176692','13891180530','13891182300','13891184474','13891187445','13891188867','13891189045','13891196521','13892106464','13892109542','13892112608','13892118021','13892120807','13892125610','13892126601','13892129566','13892131543','13892136744','13892137504','13892141450','13892141779','13892142237','13892144319','13892147263','13892147361','13892147862','13892148377','13892149711','13892160154','13892164437','13892166285','13892166404','13892167375','13892171966','13892181160','13892189141','13892195321','13892196314','13892197727','13931104472','13991771872','13991774435','13991787308','13991787481','13991792705','13991795545','13991796179','13991796741','13992101094','13992103494','13992111160','13992111734','13992113390','13992113391','13992118367','13992134855','13992137620','13992140456','13992144366','13992147594','13992149677','13992150500','13992150858','13992154041','13992154633','13992156642','13992157155','13992163034','13992166555','13992175833','13992181664','13992183386','13992187258','13992192564','13992194566','13992198485','14','15','15009211772','15009219379','15029311716','15029314030','15029315482','15091010789','15091111929','15091117332','15091118234','15091118467','15091212075','15091218114','15091314044','15091417999','15091742792','15091812992','15091814443','1510','15114913377','15129340516','15129343199','15129388400','15129417177','15129512241','15129519940','15129593939','15129594007','15129597543','15129598786','15149118229','1516','15191107762','15191131332','15191133663','15191142814','15191146467','15191154424','15191157175','15191176093','15191180797','15229119033','15229440903','15229517651','15229690474','15249115113','15249119114','15291112443','15291114948','15291115945','15291115947','15291121522','15291132000','15291142611','15291144947','15291146916','15291148330','15291163600','15291164211','15291169952','15291179093','15291949396','15293714450','15319556434','15319556771','15319582655','15591102118','15591102222','15594336555','15594389198','15594709333','15594713945','15596688213','15596968383','15609116543','15619118880','15619860309','15667666788','15669111856','15691111124','15829111122','15829112787','15829113121','15829114110','15829414771','15829810994','15829815388','15829992871','15829993422','15829993789','15829999002','15829999839','15877311142','15877312346','15877312984','15877317733','15877411192','15877411351','15877413739','15877414222','15877416880','15877417230','15877418644','15877419793','15877525558','15877663291','15877665044','15877666584','15877675808','15891010143','15891012319','15891014353','15891014406','15891050909','15891059555','15891112920','15891115347','15891116626','15891143833','15891143949','15891144769','15891144925','15891313010','15891419647','15891570540','15891611789','15891641140','15891649985','15891684801','15891686778','15891688808','15909110749','15909112406','15909112577','15909114117','15909114233','15909114322','15909117818','15909141230','15909143156','15909146600','15909183215','15909188625','15909212572','15909214798','15909216611','15909223346','15909227544','15929071678','15929114299','15929114854','15929118333','15929410564','15929413456','15929414818','15929572713','15929573004','15929579765','15929610903','15929818003','15929850962','15929857691','15991101192','15991111124','15991113062','15991113799','15991118085','15991119761','15991120124','15991120507','15991410419','15991413221','15991416424','15991425632','15991540359','15991541481','15991547118','15991549359','15991550666','15991552301','15991555414','15991560937','15991570797','15991572109','15991581380','15991582243','15991588567','15991596967','15991599994','15991642678','15991928283','15991928535','18029215976','18091105528','18220114333','18220132388','18220136552','18220149924','18220155120','18240812936','18247773905','18291104557','18291126336','18291130507','18291155662','18291175677','18291192200','18292105673','18292120500','18292144860','18329817135','18391114145','18391163340','18391178397','18609115058','18609116185','18609119211','18609292882','18609297319','18627486005','18691119300','18691140287','18691466997','18691467090','18700108190','18700117703','18700134431','18700137046','18700137055','18700148857','18700177224','18700793212','18709119778','18717324181','18717410666','18717410888','18717513477','18729812900','18740315855','18740513111','18740518851','18740616237','18791111236','18791111348','18791114229','18791115430.','18791116117','18791199050','18809110476','18809113241','18829118088','18835608857','18891107110','18909111103','18992100588','18992107640','18992120743','18992132611','18992170099','18992189933','19469354855','195','19809118490','2','20','22','2337','2434','258','265','2678','3','3044','3336','4250','4475','4488','4513','4534','4546','4572','4721','495','5955','636','699','7099','7755','7980','80931','83538','90002','90009','90010','90026','90030','90031','90051','90052','90053','90059','90060','90061','90062','90063','90065','90066','90068','90069','90080','90088','90090','90091','90100','90101','90102','90103','90105','90106','90109','90111','90115','90116','90118','90119','90121','90122','90126','90128','90129','90130','90131','90132','90133','90135','90136','90138','90139','90151','90152','90153','90158','9016','90160','90161','90162','90163','90165','90168','90169','90182','90185','90188','90189','90193','90195','90196','90198','90199','90201','90202','90203','90205','90208','90209','90210','902111','90212','90215','90216','90218','90219','90220','90225','90228','90229','90230','90231','90232','90235','90236','90239','90251','90262','90265','90266','90268','90281','90282','90283','90286','90291','90293','90296','90299','90302','90303','90306','90309','90558','9449','952'".Split(',');
Hashtable htdata = new Hashtable();
for (int i = 0; i < strArray.Length; i++)
{
if (htdata.ContainsKey(strArray[i].Trim()))
{ htdata[strArray[i].Trim()] = Convert.ToInt32(htdata[strArray[i].Trim()]) + 1; }
else
{ htdata[strArray[i].Trim()] = 1; }
}
string StrString = "";
foreach (DictionaryEntry item in htdata)
{
if (Convert.ToInt32(item.Value) > 1)
{ StrString += "'" + item.Key + "',"; }
}
string SJ = htdata.Count + " " + StrString;
//this.dgvData.ExportDataTable();
DataTable NewTable = new DataTable();
for (int i = 0; i < this.dgvData.Columns.Count; i++)
{
NewTable.Columns.Add(this.dgvData.Columns[i].Name.Trim(), typeof(string));
}
for (int i = 0; i < this.dgvData.Rows.Count; i++)
{
DataRow newRow = NewTable.NewRow();
for (int j = 0; j < this.dgvData.Columns.Count; j++)
{
newRow[this.dgvData.Columns[j].Name.Trim()] = this.dgvData.Rows[i].Cells[this.dgvData.Columns[j].Name.Trim()].Value.ToString().Trim();
}
NewTable.Rows.Add(newRow);
}
string StrFilePath = StringPath + "_检测过数据.xls";
//bool IsTrue = LYFZ.Command.Command_ExportExcel.DataTable2Sheet(StrFilePath, NewTable, "Sheet1", IsCoveredExistingFile: true);
bool IsTrue = false;
LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod(delegate (object obj, System.ComponentModel.BackgroundWorker backgroundWorker)
{
try
{
IsTrue = LYFZ.WinAPI.CustomPublicMethod.DataGridViewToExcel(StrFilePath, NewTable, null, backgroundWorker);
if (IsTrue)
{
MessageBoxCustom.Show("数据导出成功!");
}
else
{
MessageBoxCustom.Show("数据导出失败!");
}
}
catch (Exception ex)
{
MessageBoxCustom.Show(String.Format("导出数据出错:{0}", ex.Message));
}
});
MessageBoxCustom.Show("导出完毕");
}
private EnumOpenType CurrentOpenType;
string StrUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
public bool IsSaveed = false;
string StringPath = "";
char[] StrListChar = ",./;'*-+`~!#$%^&<>?|:".ToCharArray();
///
/// 窗体加载事件
///
///
///
void MemberImportExcel_Load(object sender, EventArgs e)
{
this.flowLayoutPanel1.Location = new Point((this.panelEx2.Width - this.flowLayoutPanel1.Width) / 2, this.flowLayoutPanel1.Location.Y);
string strColumns = "客户姓名,客户性别,手机号码,会员卡号";
this.dgvData.DataColumns(strColumns);
}
///
/// 打开(Excel)
///
///
///
void btnOpenExcel_Click(object sender, EventArgs e)
{
this.CurrentOpenType = EnumOpenType.主会员;
string strColumns = "客户姓名,客户性别,手机号码,QQ,出生日期,客户婚期,会员卡号,可用金额,可用积分,会员折扣";
this.dgvData.DataColumns(strColumns);
try
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
DialogResult dres = openFileDialog1.ShowDialog();
if (DialogResult.OK.Equals(dres))
{
this.dgvData.Rows.Clear();
DataTable tblMember = LYFZ.WinAPI.CustomPublicMethod.GetExcelDatatable(openFileDialog1.FileName);
if (tblMember != null)
{
try
{
LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
{
backgroundWorker.ReportProgress(0, "正在获取数据...");
DataTable tbl2 = mcbll.GetView_Custom("tb_ErpCustomer", StrWhere: "Cus_Telephone != ''", ShowColumnName: "Cus_Telephone,Cus_CustomerNumber").Tables[0];
DataTable tbl = mcbll.GetView_Custom("tb_ErpMemberCard Left Join tb_ErpCustomer on Cus_CustomerNumber = Mc_CustomerNumber", StrWhere: "Mc_CradNumber != '' and Mc_Status = '1'", filedOrder: "tb_ErpMemberCard.ID ASC", ShowColumnName: "Mc_CustomerNumber,Mc_CradNumber,Cus_Name,Cus_Telephone").Tables[0];
Hashtable htData = new Hashtable();
#region 数据检查
for (int i = 0; i < tblMember.Rows.Count; i++)
{
backgroundWorker.ReportProgress(0, "正在检测第" + (i + 1) + "条,共" + tblMember.Rows.Count + "条");
string StrMages = "";
if (tblMember.Rows[i]["手机号码"] == null)
{ StrMages += "手机号码为空;"; }
else if (string.IsNullOrEmpty(tblMember.Rows[i]["手机号码"].ToString().Trim()))
{ StrMages += "手机号码为空;"; }
else if (tblMember.Rows[i]["手机号码"].ToString().Trim().Length != 11 || !LYFZ.Command.Command_Validate.IsPhone(tblMember.Rows[i]["手机号码"].ToString().Trim()))
{ StrMages += "手机号码格式不正确;"; }
if (tblMember.Rows[i]["客户性别"] == null)
{ StrMages += "客户性别为空;"; }
else if (string.IsNullOrEmpty(tblMember.Rows[i]["客户性别"].ToString().Trim()))
{ StrMages += "客户性别为空;"; }
else if (tblMember.Rows[i]["客户性别"].ToString().Trim() != "男" && tblMember.Rows[i]["客户性别"].ToString().Trim() != "女")
{ StrMages += "客户性别不是'男'或'女';"; }
if (tblMember.Rows[i]["手机号码"] != null && !string.IsNullOrEmpty(tblMember.Rows[i]["手机号码"].ToString().Trim()))
{
DataRow[] dtRow2 = tbl2.Select("Cus_Telephone = '" + tblMember.Rows[i]["手机号码"].ToString().Trim() + "'");
if (dtRow2.Length > 0)
{
DataRow[] dtRow3 = tbl.Select("Mc_CustomerNumber = '" + dtRow2[0]["Cus_CustomerNumber"].ToString().Trim() + "'");
if (dtRow3.Length > 0)
{ StrMages += "手机号码找到客户在系统中存在会员卡;"; }
}
else if (tblMember.Rows[i]["客户姓名"] == null && string.IsNullOrEmpty(tblMember.Rows[i]["客户姓名"].ToString().Trim()))
{ StrMages += "客户姓名为空;"; }
DataRow[] dtRow = tblMember.Select("手机号码 = '" + tblMember.Rows[i]["手机号码"].ToString().Trim() + "'");
if (dtRow.Length > 1)
{ StrMages += "手机号码有重复(" + dtRow.Length + ");"; }
if (LYFZ.Command.Command_Validate.IsContainChinese(tblMember.Rows[i]["手机号码"].ToString().Trim()))
{ StrMages += "手机号码有中文;"; }
if (!LYFZ.Command.Command_Validate.IsPhone(tblMember.Rows[i]["手机号码"].ToString().Trim()))
{ StrMages += "手机号码格式不正确;"; }
for (int j = 0; j < this.StrListChar.Length; j++)
{
if (tblMember.Rows[i]["手机号码"].ToString().Trim().Contains(this.StrListChar[j].ToString().Trim()))
{ StrMages += "手机号码含有非法字符;"; break; }
}
}
else
{ StrMages += "手机号码为空;"; }
if (tblMember.Rows[i]["会员卡号"] != null)
{
if (!string.IsNullOrEmpty(tblMember.Rows[i]["会员卡号"].ToString().Trim()))
{
DataRow[] dtRow2 = tbl.Select("Mc_CradNumber = '" + tblMember.Rows[i]["会员卡号"].ToString().Trim() + "'");
if (dtRow2.Length > 0)
{ StrMages += "会员卡号在系统中存在;"; }
DataRow[] dtRow1 = tblMember.Select("会员卡号 = '" + tblMember.Rows[i]["会员卡号"].ToString().Trim() + "'");
if (dtRow1.Length > 1)
{ StrMages += "会员卡号有重复(" + dtRow1.Length + ");"; }
if (LYFZ.Command.Command_Validate.IsContainChinese(tblMember.Rows[i]["会员卡号"].ToString().Trim()))
{ StrMages += "会员卡号有中文;"; }
try
{
if (LYFZ.Command.Command_Validate.IsNumeric(tblMember.Rows[i]["会员卡号"].ToString().Trim()))
{
if (Convert.ToInt32(tblMember.Rows[i]["会员卡号"]) == 0)
{ StrMages += "会员卡号不全部为0;"; }
}
}
catch
{ }
for (int j = 0; j < this.StrListChar.Length; j++)
{
if (tblMember.Rows[i]["会员卡号"].ToString().Trim().Contains(this.StrListChar[j].ToString().Trim()))
{ StrMages += "会员卡号含有非法字符;"; break; }
}
}
}
else
{
if (tblMember.Rows[i]["手机号码"] != null)
{
if (!string.IsNullOrEmpty(tblMember.Rows[i]["手机号码"].ToString().Trim()))
{
DataRow[] dtRow2 = tbl.Select("会员卡号 = '" + tblMember.Rows[i]["手机号码"].ToString().Trim() + "'");
if (dtRow2.Length > 0)
{ StrMages += "手机号码在系统中做会员存在;"; }
}
}
}
if (tblMember.Rows[i]["可用金额"] != null)
{
if (!string.IsNullOrEmpty(tblMember.Rows[i]["可用金额"].ToString().Trim()))
{
if (!LYFZ.Command.Command_Validate.IsNumeric(tblMember.Rows[i]["可用金额"].ToString().Trim()))
{ StrMages += "可用金额格式错误;"; }
}
}
if (tblMember.Rows[i]["可用积分"] != null)
{
if (!string.IsNullOrEmpty(tblMember.Rows[i]["可用积分"].ToString().Trim()))
{
if (!LYFZ.Command.Command_Validate.IsNumeric(tblMember.Rows[i]["可用积分"].ToString().Trim()))
{ StrMages += "可用积分格式错误;"; }
}
}
if (!string.IsNullOrEmpty(StrMages))
{ htData[tblMember.Rows[i]] = StrMages; }
}
#endregion
backgroundWorker.ReportProgress(0, "正在处理数据...");
DataTable NewTable = new DataTable();
for (int i = 0; i <= tblMember.Columns.Count; i++)
{
if (i == tblMember.Columns.Count)
{ NewTable.Columns.Add("错误说明", typeof(string)); }
else
{ NewTable.Columns.Add(tblMember.Columns[i].ColumnName.Trim(), typeof(string)); }
}
foreach (DictionaryEntry item in htData)
{
try
{
DataRow dtRow = (DataRow)item.Key;
DataRow newRow = NewTable.NewRow();
for (int j = 0; j < dtRow.Table.Columns.Count; j++)
{
switch (dtRow.Table.Columns[j].ColumnName.Trim())
{
case "出生日期":
case "客户婚期":
if (!string.IsNullOrEmpty(dtRow[dtRow.Table.Columns[j].ColumnName.Trim()].ToString().Trim()))
{ newRow[dtRow.Table.Columns[j].ColumnName.Trim()] = Convert.ToDateTime(dtRow[dtRow.Table.Columns[j].ColumnName.Trim()]).ToString("yyyy-MM-dd"); }
else
{ newRow[dtRow.Table.Columns[j].ColumnName.Trim()] = ""; }
break;
default:
newRow[dtRow.Table.Columns[j].ColumnName.Trim()] = dtRow[dtRow.Table.Columns[j].ColumnName.Trim()].ToString().Trim();
break;
}
}
newRow["错误说明"] = item.Value.ToString().Trim();
NewTable.Rows.Add(newRow);
tblMember.Rows.Remove(dtRow);
}
catch
{ }
}
try
{
this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
{ this.dgvData.DataSource(tblMember, strHideField: ""); }));
}
catch
{ }
if (NewTable.Rows.Count > 0)
{
StringPath = System.IO.Path.GetDirectoryName(openFileDialog1.FileName) + "\\" + System.IO.Path.GetFileNameWithoutExtension(openFileDialog1.FileName);
string StrFilePath = StringPath + "_有问题数据.xls"; //+ System.IO.Path.GetExtension(openFileDialog1.FileName);
backgroundWorker.ReportProgress(0, "正在导出有问题数据...");
bool IsTrue = LYFZ.WinAPI.CustomPublicMethod.DataGridViewToExcel(StrFilePath, NewTable, null, backgroundWorker);
//LYFZ.ComponentLibrary.DataGridViewExport.DataTableToExcel(NewTable, IsShowSave: false, StrFileName: StrFilePath, ExportOKPrompt: "检查数据完毕!\r\n要导入的Excel中有问题数据已挑出另存于:\r\n" + StrFilePath); }));
if (IsTrue)
{
try
{
this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
{ MessageBoxCustom.Show("检查数据完毕!\r\n要导入的Excel中有问题数据已挑出另存于:\r\n" + StrFilePath); }));
}
catch
{ }
}
}
});
}
catch (Exception ex)
{ MessageBoxCustom.Show(ex.Message.ToString()); }
}
}
}
catch (Exception ex)
{ MessageBoxCustom.Show(new System.Diagnostics.StackTrace(new System.Diagnostics.StackFrame(true)).ToString() + "\r\n错误消息:" + ex.Message); }
}
///
/// 打开积分副卡
///
///
///
void btnOpenPointsViceCard_Click(object sender, EventArgs e)
{
this.CurrentOpenType = EnumOpenType.积分副卡;
string strColumns = "客户姓名,手机号码,积分副卡号";
this.dgvData.DataColumns(strColumns);
try
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
DialogResult dres = openFileDialog1.ShowDialog();
if (DialogResult.OK.Equals(dres))
{
this.dgvData.Rows.Clear();
DataTable tblMember = LYFZ.WinAPI.CustomPublicMethod.GetExcelDatatable(openFileDialog1.FileName);
if (tblMember != null)
{
if (tblMember.Columns["积分副卡号"] == null || tblMember.Columns["手机号码"] == null)
{ MessageBoxCustom.Show("积分副卡模板格式不正确定!"); return; }
DataTable tbl2 = mcbll.GetView_Custom("tb_ErpCustomer", StrWhere: "Cus_Telephone != ''", ShowColumnName: "Cus_Telephone,Cus_CustomerNumber").Tables[0];
DataTable tbl = mcbll.GetView_Custom("tb_ErpMemberCard Left Join tb_ErpCustomer on Cus_CustomerNumber = Mc_CustomerNumber", StrWhere: "Mc_CradNumber != '' and Mc_Status = '1'", filedOrder: "tb_ErpMemberCard.ID ASC", ShowColumnName: "Mc_CustomerNumber,Mc_CradNumber,Cus_Name,Cus_Telephone").Tables[0];
DataTable tbl3 = mcbll.GetView_Custom("tb_ErpMemberCardViceCard", StrWhere: "Mvc_Status = '1'", ShowColumnName: "Mvc_ViceCardNumber").Tables[0];
Hashtable htData = new Hashtable();
#region 数据检查
for (int i = 0; i < tblMember.Rows.Count; i++)
{
string StrMages = "";
if (tblMember.Rows[i]["手机号码"] == null)
{ StrMages += "手机号码为空;"; }
else if (string.IsNullOrEmpty(tblMember.Rows[i]["手机号码"].ToString().Trim()))
{ StrMages += "手机号码为空;"; }
else if (tblMember.Rows[i]["手机号码"].ToString().Trim().Length != 11 || !LYFZ.Command.Command_Validate.IsPhone(tblMember.Rows[i]["手机号码"].ToString().Trim()))
{ StrMages += "手机号码格式不正确;"; }
else
{
DataRow[] dtRow2 = tbl2.Select("Cus_Telephone = '" + tblMember.Rows[i]["手机号码"].ToString().Trim() + "'");
if (dtRow2.Length > 0)
{
DataRow[] dtRow3 = tbl.Select("Mc_CustomerNumber = '" + dtRow2[0]["Cus_CustomerNumber"].ToString().Trim() + "'");
if (dtRow3.Length <= 0)
{ StrMages += "客户在系统中未办理会员;"; }
}
else
{ StrMages += "手机号码未找到此客户;"; }
//DataRow[] dtRow = tblMember.Select("手机号码 = '" + tblMember.Rows[i]["手机号码"].ToString().Trim() + "'");
//if (dtRow.Length > 1)
//{ StrMages += "手机号码有重复(" + dtRow.Length + ");"; }
}
if (tblMember.Rows[i]["积分副卡号"] != null)
{
if (!string.IsNullOrEmpty(tblMember.Rows[i]["积分副卡号"].ToString().Trim()))
{
DataRow[] dtRow2 = tbl.Select("Mc_CradNumber = '" + tblMember.Rows[i]["积分副卡号"].ToString().Trim() + "'");
if (dtRow2.Length > 0)
{ StrMages += "副卡号在系统中做主卡号存在;"; }
DataRow[] dtRow1 = tblMember.Select("积分副卡号 = '" + tblMember.Rows[i]["积分副卡号"].ToString().Trim() + "'");
if (dtRow1.Length > 1)
{ StrMages += "副卡号有重复(" + dtRow1.Length + ");"; }
DataRow[] dtRow3 = tbl3.Select("Mvc_ViceCardNumber = '" + tblMember.Rows[i]["积分副卡号"].ToString().Trim() + "'");
if (dtRow3.Length > 0)
{ StrMages += "副卡号在系统中做副卡号存在;"; }
}
else
{ StrMages += "副卡号为空;"; }
}
else
{ StrMages += "副卡号为空;"; }
if (!string.IsNullOrEmpty(StrMages))
{ htData[tblMember.Rows[i]] = StrMages; }
}
#endregion
DataTable NewTable = new DataTable();
for (int i = 0; i <= tblMember.Columns.Count; i++)
{
if (i == tblMember.Columns.Count)
{ NewTable.Columns.Add("错误说明", typeof(string)); }
else
{ NewTable.Columns.Add(tblMember.Columns[i].ColumnName.Trim(), typeof(string)); }
}
foreach (DictionaryEntry item in htData)
{
try
{
DataRow dtRow = (DataRow)item.Key;
DataRow newRow = NewTable.NewRow();
for (int j = 0; j < dtRow.Table.Columns.Count; j++)
{
newRow[dtRow.Table.Columns[j].ColumnName.Trim()] = dtRow[dtRow.Table.Columns[j].ColumnName.Trim()].ToString().Trim();
}
newRow["错误说明"] = item.Value.ToString().Trim();
NewTable.Rows.Add(newRow);
tblMember.Rows.Remove(dtRow);
}
catch
{ }
}
if (NewTable.Rows.Count > 0)
{
string StrFilePath = System.IO.Path.GetDirectoryName(openFileDialog1.FileName) + "\\" + System.IO.Path.GetFileNameWithoutExtension(openFileDialog1.FileName);
StrFilePath += "_有问题数据.xls";// +System.IO.Path.GetExtension(openFileDialog1.FileName);
try
{
LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
{
bool IsTrue = LYFZ.WinAPI.CustomPublicMethod.DataGridViewToExcel(StrFilePath, NewTable,null ,backgroundWorker);
//LYFZ.Command.Command_ExportExcel.DataTable2Sheet(StrFilePath, NewTable, "Sheet1", IsCoveredExistingFile: true);
//LYFZ.ComponentLibrary.DataGridViewExport.DataTableToExcel(NewTable, IsShowSave: false, StrFileName: StrFilePath, ExportOKPrompt: "检查数据完毕!\r\n要导入的Excel中有问题数据已挑出另存于:\r\n" + StrFilePath); }));
if (IsTrue)
{
try
{
this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
{ MessageBoxCustom.Show("检查数据完毕!\r\n要导入的Excel中有问题数据已挑出另存于:\r\n" + StrFilePath); }));
}
catch
{ }
}
});
}
catch (Exception ex) { MessageBoxCustom.Show(ex.Message.ToString()); }
}
this.dgvData.DataSource(tblMember, strHideField: "");
}
}
}
catch (Exception ex)
{ MessageBoxCustom.Show("错误消息:" + ex.Message + "\r\n" + new System.Diagnostics.StackTrace(new System.Diagnostics.StackFrame(true)).ToString()); }
}
///
/// 打开返现副卡
///
///
///
void btnOpenBackCashViceCard_Click(object sender, EventArgs e)
{
}
///
/// 保存
///
///
///
void btnSaveed_Click(object sender, EventArgs e)
{
DateTime StrTime = SDateTime.Now;
List clist = new List();
DataTable tbl = mcbll.GetView_Custom("tb_ErpMemberCard Left Join tb_ErpCustomer on Cus_CustomerNumber = Mc_CustomerNumber", StrWhere: "Mc_Status = '1'", filedOrder: "tb_ErpMemberCard.ID ASC", ShowColumnName: "Mc_CustomerNumber,Mc_Number,Mc_CradNumber,Cus_Name,Cus_Telephone").Tables[0];
if (this.CurrentOpenType == EnumOpenType.主会员)
{
#region 主会员
DataTable tbl2 = mcbll.GetView_Custom("tb_ErpCustomer", StrWhere: "Cus_Telephone != ''", ShowColumnName: "Cus_Telephone,Cus_CustomerNumber").Tables[0];
string StrMagess = "";
string StrMagess2 = "";
try
{
LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
{
for (int i = 0; i < this.dgvData.Rows.Count; i++)
{
backgroundWorker.ReportProgress(0, "正在检测第" + (i + 1) + "条,共" + this.dgvData.Rows.Count + "条");
string StrClientPhone = "";
string StrClientName = "";
string StrClientSex = "";
string StrClientBirthday = "";
string StrClientQQ = "";
string StrClientDayForMarriage = "";
string StrMebmerCardNumber = "";
string StrMemberAvailableAmount = "0";
string StrMemberAvailablePoints = "0";
string StrMemberDiscount = "0";
#region 获取数据
try
{
this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
{
StrClientPhone = this.dgvData.Rows[i].Cells["手机号码"].Value.ToString().Trim();
StrClientName = this.dgvData.Rows[i].Cells["客户姓名"].Value.ToString().Trim();
StrClientSex = this.dgvData.Rows[i].Cells["客户性别"].Value.ToString().Trim();
if (string.IsNullOrEmpty(StrClientSex))
{ StrClientSex = "女"; }
if (!string.IsNullOrEmpty(this.dgvData.Rows[i].Cells["出生日期"].Value.ToString().Trim()))
{ StrClientBirthday = LYFZ.Command.Command_Validate.DateTimeToString(this.dgvData.Rows[i].Cells["出生日期"].Value); }
if (!string.IsNullOrEmpty(this.dgvData.Rows[i].Cells["QQ"].Value.ToString().Trim()))
{
if (LYFZ.Command.Command_Validate.IsNumeric(this.dgvData.Rows[i].Cells["QQ"].Value.ToString().Trim()))
{ StrClientQQ = this.dgvData.Rows[i].Cells["QQ"].Value.ToString().Trim(); }
}
if (!string.IsNullOrEmpty(this.dgvData.Rows[i].Cells["客户婚期"].Value.ToString().Trim()))
{ StrClientDayForMarriage = LYFZ.Command.Command_Validate.DateTimeToString(this.dgvData.Rows[i].Cells["客户婚期"].Value); }
StrMebmerCardNumber = this.dgvData.Rows[i].Cells["会员卡号"].Value.ToString().Trim();
if (!string.IsNullOrEmpty(this.dgvData.Rows[i].Cells["可用金额"].Value.ToString().Trim()))
{
if (LYFZ.Command.Command_Validate.IsNumeric(this.dgvData.Rows[i].Cells["可用金额"].Value.ToString().Trim()))
{ StrMemberAvailableAmount = this.dgvData.Rows[i].Cells["可用金额"].Value.ToString().Trim(); }
}
if (!string.IsNullOrEmpty(this.dgvData.Rows[i].Cells["可用积分"].Value.ToString().Trim()))
{
if (LYFZ.Command.Command_Validate.IsNumeric(this.dgvData.Rows[i].Cells["可用积分"].Value.ToString().Trim()))
{ StrMemberAvailablePoints = this.dgvData.Rows[i].Cells["可用积分"].Value.ToString().Trim(); }
}
if (!string.IsNullOrEmpty(this.dgvData.Rows[i].Cells["会员折扣"].Value.ToString().Trim()))
{
if (LYFZ.Command.Command_Validate.IsNumeric(this.dgvData.Rows[i].Cells["会员折扣"].Value.ToString().Trim()))
{ StrMemberDiscount = this.dgvData.Rows[i].Cells["会员折扣"].Value.ToString().Trim(); }
}
}));
}
catch
{ }
#endregion
#region 客户资料
string StrClientNumber = "";
bool isMember = false;
LYFZ.Model.Model_ErpCustomer model_Client = null;
DataRow[] dtRow2 = tbl2.Select("Cus_Telephone = '" + StrClientPhone + "'");
if (dtRow2.Length > 0)
{
StrClientNumber = dtRow2[0]["Cus_CustomerNumber"].ToString().Trim();
DataRow[] dtRow = tbl.Select("Mc_CustomerNumber = '" + dtRow2[0]["Cus_CustomerNumber"].ToString().Trim() + "'");
if (dtRow.Length > 0)
{ isMember = true; StrMagess2 += "[客户已有会员:" + StrClientPhone + "]"; }
StrMagess += "[客户电话:" + StrClientPhone + "]";
}
else
{
model_Client = new Model.Model_ErpCustomer();
model_Client.Cus_CustomerNumber = LYFZ.BLL.BLL_ErpCustomer.GetClientNumber();
model_Client.Cus_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
model_Client.Cus_Type = "";
model_Client.Cus_MicroSignal = "";
model_Client.Cus_Zodiac = "";
model_Client.Cus_Address = "";
model_Client.Cus_WorkUnit = "";
model_Client.Cus_CreateDateTime = StrTime;
model_Client.Cus_CreateName = StrUserID;
model_Client.Cus_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(StrClientName);
model_Client.Cus_NamePinyin = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin(StrClientName).ToLower();
model_Client.Cus_Sex = false;
if (StrClientSex == "女")
{ model_Client.Cus_Sex = true; }
model_Client.Cus_Telephone = StrClientPhone;
model_Client.Cus_QQ = StrClientQQ;
model_Client.Cus_Birthday = StrClientBirthday;
if (string.IsNullOrEmpty(StrClientBirthday))
{ model_Client.Cus_BirthdayLunar = ""; }
else
{
model_Client.Cus_Zodiac = LYFZ.Command.Command_CalendarTurnLunar.GetZodiac(StrClientBirthday, false);
model_Client.Cus_BirthdayLunar = "0";
}
model_Client.Cus_DayForMarriage = StrClientDayForMarriage;
if (string.IsNullOrEmpty(StrClientDayForMarriage))
{ model_Client.Cus_DayForMarriageLunar = ""; }
else
{ model_Client.Cus_DayForMarriageLunar = "0"; }
clist.Add(ctbll.GetAddCommandInfo(model_Client));
//客户组表
LYFZ.Model.Model_ErpCustomerGroup modelClientGroup = new Model.Model_ErpCustomerGroup();
modelClientGroup.GP_OrderNumber = "";
modelClientGroup.GP_CustomerGroupID = LYFZ.BLL.BLL_ErpCustomer.GetNewClientGroupNumber();
modelClientGroup.GP_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
modelClientGroup.GP_GroupType = 1;
modelClientGroup.GP_CustomerType = -1;
modelClientGroup.GP_CustomerStatus = "正常";
modelClientGroup.GP_LossReason = "";
modelClientGroup.GP_DegreeOfIntent = "";
modelClientGroup.GP_CustomerSource = "";
modelClientGroup.GP_IntroducerCustomerID = "";
modelClientGroup.GP_Remark = "";
modelClientGroup.GP_BelongsPersonID = "";
modelClientGroup.GP_CreateDatetime = StrTime;
modelClientGroup.GP_CreateName = StrUserID;
modelClientGroup.GP_ISIntentionCustomer = 0;
modelClientGroup.GP_RemindEvent = "";
clist.Add(ctgpbll.GetAddCommandInfo(modelClientGroup));
//客户成员表
LYFZ.Model.Model_ErpCustomerGroupMembers modelClientMember = new Model.Model_ErpCustomerGroupMembers();
modelClientMember.GM_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
modelClientMember.GM_CustomerGroupID = modelClientGroup.GP_CustomerGroupID;
modelClientMember.GM_CustomerID = model_Client.Cus_CustomerNumber;
modelClientMember.GM_Master = 1;
modelClientMember.GM_ProtagonistCustomer = 1;
modelClientMember.GM_RelatedPersonID = modelClientMember.GM_CustomerID;
modelClientMember.GM_Relation = "本人";
modelClientMember.GM_IsOrder = 0;
modelClientMember.GM_IsOrderNumber = "";
clist.Add(ctgmbll.GetAddCommandInfo(modelClientMember));
}
#endregion
#region 会员资料
if (!isMember)
{
bool IsFind = false;
if (!string.IsNullOrEmpty(StrMebmerCardNumber))
{
DataRow[] dtRow = tbl.Select("Mc_CradNumber = '" + StrMebmerCardNumber + "'");
if (dtRow.Length > 0)
{
StrMagess += "[会员卡号:" + StrClientPhone + "]";
IsFind = true;
}
}
else
{
DataRow[] dtRow = tbl.Select("Mc_CradNumber = '" + StrClientPhone + "'");
if (dtRow.Length > 0)
{
StrMagess += "[会员卡号:" + StrClientPhone + "]";
IsFind = true;
}
}
if (!IsFind)
{
LYFZ.Model.Model_ErpSystemConfigure sgModel = LYFZ.BLL.OrderPayment_Member.GetNewMenberNumber(i);
clist.Add(sgbll.GetUpdateCommandInfo(sgModel));
LYFZ.Model.Model_ErpMemberCard model_MCard = new Model.Model_ErpMemberCard();
model_MCard.Mc_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
if (model_Client == null)
{ model_MCard.Mc_CustomerNumber = StrClientNumber; }
else
{ model_MCard.Mc_CustomerNumber = model_Client.Cus_CustomerNumber; }
model_MCard.Mc_Money = Convert.ToDecimal(StrMemberAvailableAmount);
model_MCard.Mc_Number = sgModel.Sconfig_Value;
if (!string.IsNullOrEmpty(StrMebmerCardNumber))
{ model_MCard.Mc_CradNumber = StrMebmerCardNumber; }
else
{ model_MCard.Mc_CradNumber = StrClientPhone; }
model_MCard.Mc_CardType = "无";
model_MCard.Mc_TraderPassword = "";
model_MCard.Mc_UsedNumber = "";
model_MCard.Mc_Status = "1";
model_MCard.Mc_Remark = "";
model_MCard.Mc_OpenCardSource = "会员导入," + new System.Diagnostics.StackTrace(new System.Diagnostics.StackFrame(true)).ToString();
model_MCard.Mc_CreateDatetime = StrTime;
model_MCard.Mc_CreateName = StrUserID;
clist.Add(mcbll.GetAddCommandInfo(model_MCard));
#region 会员积分
int intPoints = Convert.ToInt32(Convert.ToDecimal(StrMemberAvailablePoints));
LYFZ.Model.Model_ErpMemberCardPoints model_Points = mcpsbll.GetModel("Mcps_Number", model_MCard.Mc_Number);
if (model_Points.ID <= 0)
{
model_Points = new Model.Model_ErpMemberCardPoints();
model_Points.Mcps_Number = model_MCard.Mc_Number;
model_Points.Mcps_TotalPoints = intPoints;
model_Points.Mcps_AvailablePoints = intPoints;
model_Points.Mcps_OpenCardSource = "会员导入," + new System.Diagnostics.StackTrace(new System.Diagnostics.StackFrame(true)).ToString();
model_Points.Mcps_UpdateDateTime = StrTime;
model_Points.Mcps_UpdateName = StrUserID;
clist.Add(mcpsbll.GetAddCommandInfo(model_Points));
}
#endregion
#region 会员折扣
decimal decDiscount = Convert.ToDecimal(StrMemberDiscount);
if (decDiscount > 0)
{
LYFZ.Model.Model_ErpMemberCardDiscount model_Discount = mcdtbll.GetModel("Mcdt_Number", model_MCard.Mc_Number);
if (model_Discount.ID <= 0)
{
model_Discount = new Model.Model_ErpMemberCardDiscount();
model_Discount.Mcdt_Number = model_MCard.Mc_Number;
model_Discount.Mcdt_Discount = decDiscount;
model_Discount.Mcdt_UpdateDateTime = StrTime;
model_Discount.Mcdt_UpdateName = StrUserID;
clist.Add(mcdtbll.GetAddCommandInfo(model_Discount));
}
}
#endregion
}
}
#endregion
}
});
}
catch (Exception ex)
{
MessageBoxCustom.Show(ex.Message.ToString());
return;
}
if (clist.Count > 0)
{
if (!string.IsNullOrEmpty(StrMagess2))
{ StrMagess += "\r\n" + StrMagess2; }
if (!string.IsNullOrEmpty(StrMagess))
{
LYFZ.Software.MainBusiness.MembershipManage.SetSmallForm.MemberImportRepeat frm = new MemberImportRepeat();
frm.StrText = "在系统中已经存在,选择'是'为继续保存但不对客户数据做修改,选择'否'为取消保存操作?";
frm.StrMagess = StrMagess;
frm.ShowDialog();
if (!frm.IsSaveed)
{ return; }
//if (MessageBoxCustom.Show(StrMagess + "\r\n在系统中已经存在,选择'是'为继续保存但不对客户数据做修改,选择'否'为取消保存操作?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No)
//{ return; }
}
else
{
if (MessageBoxCustom.Show("是否确定要导入?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No)
{ return; }
}
int IsExecuteSqlTran = 0;
try
{
LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
{
backgroundWorker.ReportProgress(0, "保存正在提交中,请稍等...");
IsExecuteSqlTran = LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist);
if (IsExecuteSqlTran > 0)
{ LYFZ.DAL.DAL_ErpCustomer.UpdateAggregationCustomerAll(); }
});
}
catch (Exception ex) { MessageBoxCustom.Show(ex.Message.ToString()); }
if (IsExecuteSqlTran > 0)
{
this.IsSaveed = true;
MessageBoxCustom.Show("导入成功!");
this.Close();
}
else
{ MessageBoxCustom.Show("导入失败!"); }
}
#endregion
}
else if (this.CurrentOpenType == EnumOpenType.积分副卡)
{
#region 积分副卡
DataTable tbl2 = mcbll.GetView_Custom("tb_ErpMemberCardViceCard", StrWhere: "Mvc_Status = '1'", filedOrder: "ID ASC", ShowColumnName: "*").Tables[0];
string StrMagess = "";
string StrMagess2 = "";
try
{
LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
{
int NumberCount = 1;
string StrMcNumber = LYFZ.BLL.BLL_ErpMemberCard.GetViceCardLastViceNumber();
LYFZ.Model.Model_ErpMemberCardViceCard model = null;
for (int i = 0; i < this.dgvData.Rows.Count; i++)
{
backgroundWorker.ReportProgress(0, "正在检测第" + (i + 1) + "条");
string StrClientPhone = "";
string StrClientName = "";
string StrMebmerViceCardNumber = "";
#region 获取数据
try
{
this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
{
StrClientPhone = this.dgvData.Rows[i].Cells["手机号码"].Value.ToString().Trim();
StrClientName = this.dgvData.Rows[i].Cells["客户姓名"].Value.ToString().Trim();
StrMebmerViceCardNumber = this.dgvData.Rows[i].Cells["积分副卡号"].Value.ToString().Trim();
}));
}
catch
{ }
#endregion
#region 获取主会员卡卡编号
DataRow[] dtRow = tbl.Select("Cus_Telephone = '" + StrClientPhone + "'");
if (dtRow.Length > 0)
{
DataRow[] dtRow2 = tbl2.Select("Mvc_ViceCardNumber = '" + StrMebmerViceCardNumber + "'");
if (dtRow2.Length <= 0)
{
model = new Model.Model_ErpMemberCardViceCard();
model.Mvc_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
model.Mvc_ViceNumber = LYFZ.BLL.BLL_ErpMemberCard.GetNewViceCardNumber(StrMcNumber, ref NumberCount);
model.Mvc_Number = dtRow[0]["Mc_Number"].ToString().Trim();
model.Mvc_ViceCardNumber = StrMebmerViceCardNumber;
model.Mvc_ViceCardType = "积分副卡";
model.Mvc_ViceMoney = 0;
model.Mvc_ViceTraderPassword = "";
model.Mvc_Status = "1";
model.Mvc_UsedNumber = "";
model.Mvc_Remark = "";
model.Mvc_CashBackGroup = -1;
model.Mvc_OpenCardSource = "副卡导入";
model.Mvc_CreateDatetime = StrTime;
model.Mvc_CreateName = this.StrUserID;
clist.Add(mcvcbll.GetAddCommandInfo(model));
}
else
{ StrMagess2 += "[积分副卡号:" + StrClientPhone + "]"; }
}
else
{ StrMagess += "[客户电话:" + StrClientPhone + "]"; }
#endregion
}
});
}
catch (Exception ex) { MessageBoxCustom.Show(ex.Message.ToString()); }
if (clist.Count > 0)
{
string StrMagessT = "";
if (!string.IsNullOrEmpty(StrMagess))
{ StrMagessT = "在系统中未找到客户:(" + StrMagess + ")"; }
if (!string.IsNullOrEmpty(StrMagess2))
{ StrMagessT += "在系统已存在的副卡:(" + StrMagess2 + ")"; }
if (!string.IsNullOrEmpty(StrMagess))
{ MessageBoxCustom.Show(StrMagess, "温馨提示", MessageBoxButtons.YesNo); return; }
else
{
if (MessageBoxCustom.Show("是否确定要导入?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No)
{ return; }
}
int IsExecuteSqlTran = 0;
try
{
LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
{
backgroundWorker.ReportProgress(0, "保存正在提交中,请稍等...");
IsExecuteSqlTran = LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist);
});
}
catch (Exception ex) { MessageBoxCustom.Show(ex.Message.ToString()); }
if (IsExecuteSqlTran > 0)
{
this.IsSaveed = true;
MessageBoxCustom.Show("导入成功!");
this.Close();
}
else
{ MessageBoxCustom.Show("导入失败!"); }
}
#endregion
}
}
///
/// 移除
///
///
///
void btnDelete_Click(object sender, EventArgs e)
{
if (this.dgvData.Rows.Count > 0)
{
if (this.dgvData.CurrentRow != null)
{
if (this.dgvData.CurrentRow.Index >= 0)
{ this.dgvData.Rows.Remove(this.dgvData.CurrentRow); }
}
}
}
///
/// 取消
///
///
///
void btnCancel_Click(object sender, EventArgs e)
{ this.Close(); }
///
/// 添加行是发生事件
///
///
///
void dgvData_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
{
if (this.CurrentOpenType == EnumOpenType.主会员)
{
if (this.dgvData.Rows[e.RowIndex].Cells["出生日期"].Value != null)
{
if (!string.IsNullOrEmpty(this.dgvData.Rows[e.RowIndex].Cells["出生日期"].Value.ToString().Trim()))
{ this.dgvData.Rows[e.RowIndex].Cells["出生日期"].Value = LYFZ.Command.Command_Validate.DateTimeToString(this.dgvData.Rows[e.RowIndex].Cells["出生日期"].Value); }
}
if (this.dgvData.Rows[e.RowIndex].Cells["客户婚期"].Value != null)
{
if (!string.IsNullOrEmpty(this.dgvData.Rows[e.RowIndex].Cells["客户婚期"].Value.ToString().Trim()))
{ this.dgvData.Rows[e.RowIndex].Cells["客户婚期"].Value = LYFZ.Command.Command_Validate.DateTimeToString(this.dgvData.Rows[e.RowIndex].Cells["客户婚期"].Value); }
}
}
}
///
/// 打开要导入的类型
///
enum EnumOpenType
{
主会员,
积分副卡,
返现副卡
}
}
}