//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;
}
///
/// 客户组编号集合
///
List Gmlist = new List();
///
/// 存放添加sql语句
///
// List clist = new List();
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;
///
/// 客户类型 0 为其它客户(客户管理中的其他客户,只添加到用户表) 1 为老客户 2 为意向客户
///
public int Type;
///
/// 订单类型
///
public int Leixing;
Customer Cus = new Customer();
string Url = "";
System.Data.DataTable dt;
System.Data.DataTable dtOK;
System.Data.DataTable dtError;
// DataGridViewEc dgvex;
List list = new List();
#region 关闭
///
/// 关闭按钮
///
void btnClose_Click( object sender, EventArgs e )
{
try
{
this.Close();
}
catch ( Exception ex )
{
MessageBoxCustom.Show( ex.Message );
}
}
#endregion
#region 打开Excel按钮
///
/// 打开Excel按钮
///
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();
//其他客户
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 保存
///
/// 保存按钮
///
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 判断数据
///
/// 判断数据
///
///
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();
///
/// 儿童老客户
///
[Obsolete]
///放弃已弃用
void OldBaby()
{
try
{
if ( dgv.Rows.Count > 0 )
{
DateTime strTime = SDateTime.Now;
// List namelist = new List();
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 sqllist = new List();
//主联系人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 namelist = new List();
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 sqllist = new List();
//主联系人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 dataTableNames = new List();
List dataTables = new List();
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);
}
}
///
/// 婚纱老客户
///
[Obsolete]
void OldHS()
{
try
{
if ( dgv.Rows.Count > 0 )
{
// Gmlist = new List();
// List namelist = new List();
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 sqllist = new List();
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 );
}
}
///
/// 婚纱老客户
///
void OldHSNew()
{
try
{
if (dgv.Rows.Count > 0)
{
// Gmlist = new List();
// List namelist = new List();
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 sqllist = new List();
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 dataTableNames = new List();
List dataTables = new List();
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);
}
}
///
/// 写真,服务
///
/// 2=写真,3=服务
[Obsolete]
void OldXZfw( int objtype )
{
try
{
if ( dgv.Rows.Count > 0 )
{
// List namelist = new List();
// Gmlist = new List();
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 sqllist = new List();
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 namelist = new List();
// Gmlist = new List();
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 sqllist = new List();
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 dataTableNames = new List();
List dataTables = new List();
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 老客户检查操作
///
/// 错误类型
///
enum error
{
手机号不能为空,
手机号已存在,
手机号必须是11位,
家长姓名不能为空,
宝宝生日错误,
宝宝性别只能是男或女或不填,
订单日期格式错误,
套系价格只能输入数字,
手机号在Excel中多次出现,
生日错误,
婚期错误,
姓名不能为空,
性别只能是男或女或不填,
ok
}
///
/// 检查宝宝
///
///
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;
}
///
/// 检查婚纱版
///
///
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;
}
///
/// 写真和服务
///
///
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 意向客户添加操作
///
/// 添加意向客户 婚纱 写真 服务
///
bool addYixiang()
{
bool upData = true;
try
{
if ( dgv.Rows.Count > 0 )
{
// Gmlist = new List();
// List namelist = new List();
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 sqllist = new List();
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 意向客户检查操作
///
/// 检测意向客户 婚纱 写真 服务 儿童
///
///
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 其他客户添加操作
///
/// 其他客户添加
///
void AddOther()
{
// List namelist = new List();
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 sqllist = new List();
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 判读公共方法
///
/// 判断手机是否正确
///
///
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; }
}
///
/// 判断生日是否正确
///
///
bool cheSR( string SR )
{
try
{
DateTime.Parse( SR );
return true;
}
catch { return false; }
}
///
/// 判断套系价格
///
///
bool cheTXJG( string GJ )
{
try
{
int o;
if ( !int.TryParse( GJ.Trim(), out o ) )
{
return false;
}
else { return true; }
}
catch { return false; }
}
///
/// 检查订单日期
///
///
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;
}
///
/// 遍历类型
///
///
///
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;
}
///
/// 封装当前手机号
///
///
///
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;
}
///
/// 检查手机是存在 true 没有
///
///
///
public bool check( string sj )
{
if ( list.IndexOf( sj ) == -1 )
{
list.Add( sj );
return true;
}
else
{
return false;
}
}
///
/// 减除错误数据
///
///
///
///
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
}
}