123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Globalization;
- using LYFZ.ComponentLibrary;
- using System.Web.UI.WebControls;
- using LYFZ.DAL;
- using LYFZ.Software.MainBusiness.Customers.OldCustomer;
- using LYFZ.BLL;
- namespace LYFZ.Software.MainBusiness.Customers
- {
- public partial class FrmOldCustomer : LYFZ.Software.UI.Customers.FrmOldCustomer
- {
- private delegate void UpdateControl();
- public FrmOldCustomer()
- {
- this.btnAdd.Click += btnAdd_Click;
- this.btnUpdate.Click += btnUpdate_Click;
- this.btnSlect.Click += btnSlect_Click;
- this.btnDelete.Click += btnDelete_Click;
- this.btnExport.Click += btnExport_Click;
- this.btnClose.Click += btnClose_Click;
- this.btnTexting.Click += btnTexting_Click;
- this.Shown += FrmOldCustomer_Shown;
- this.chkHs.Click += chkHs_Click;
- this.chkEt.Click += chkEt_Click;
- this.chkXz.Click += chkXz_Click;
- this.chkFw.Click += chkFw_Click;
- this.Type = 1;
- this.btnExcel.Click += btnExcel_Click;
- this.dgv.CellDoubleClick += dgv_CellDoubleClick;
- this.Resize += FrmOldCustomer_Resize;
- orbll.UpdateNullDataToLunar();
- // 虚拟模式;
- this.dgv.VirtualMode = true;
- this.dgv.CellValueNeeded += Dgv_CellValueNeeded;
- }
- DataTable newTable = new DataTable();
- private void Dgv_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e)
- {
- if (newTable != null && newTable.Rows.Count == 0 && e.RowIndex == newTable.Rows.Count)
- return;
- DataGridViewRow dgr = this.dgv.Rows[e.RowIndex];
- if (e.RowIndex % 2 == 0)
- {//偶行;
- dgr.DefaultCellStyle.BackColor = System.Drawing.Color.PowderBlue;
- }
- else
- {//奇行;
- dgr.DefaultCellStyle.BackColor = System.Drawing.Color.PapayaWhip;
- }
- //客户组编号
- if (e.ColumnIndex == 0)
- e.Value = newTable.Rows[e.RowIndex]["GP_CustomerGroupID"].ToString().Trim();
- //名字
- if (e.ColumnIndex == 1)
- e.Value = newTable.Rows[e.RowIndex]["Cus_Name"].ToString().Trim();
- //性别
- if (e.ColumnIndex == 2)
- e.Value = newTable.Rows[e.RowIndex]["Cus_Sex_cs"].ToString().Trim();
- //手机
- if (e.ColumnIndex == 3)
- e.Value = newTable.Rows[e.RowIndex]["Cus_Telephone"].ToString().Trim();
- //区域
- if (e.ColumnIndex == 4)
- e.Value = newTable.Rows[e.RowIndex]["Cus_Region"].ToString().Trim();
- //客户类型 0 为婚纱订单客户 1 为儿童订单客户 2 写真订单客户 3 为服务套系 4 为其它订单客户
- if (e.ColumnIndex == 5)
- e.Value = GetType(newTable.Rows[e.RowIndex]["GP_CustomerType"].ToString().Trim());
- //客户来源;
- if (e.ColumnIndex == 6)
- e.Value = newTable.Rows[e.RowIndex]["GP_CustomerSource"].ToString().Trim();
- //客户生日
- if (e.ColumnIndex == 7)
- e.Value = newTable.Rows[e.RowIndex]["Cus_BirthdayText"].ToString().Trim();
- //客户婚期
- if (e.ColumnIndex == 8)
- e.Value = newTable.Rows[e.RowIndex]["Cus_DayForMarriageText"].ToString().Trim();
- //添加时间
- if (e.ColumnIndex == 9)
- e.Value = newTable.Rows[e.RowIndex]["GP_CreateDatetime"].ToString().Trim();
- //套系名称
- if (e.ColumnIndex == 10)
- e.Value = newTable.Rows[e.RowIndex]["History_Type"].ToString().Trim();
- //套系价格
- if (e.ColumnIndex == 11)
- e.Value = newTable.Rows[e.RowIndex]["History_Money"].ToString().Trim();
- //订单时间
- if (e.ColumnIndex == 12)
- e.Value = newTable.Rows[e.RowIndex]["History_OrderTime"].ToString().Trim();
- }
- /// <summary>
- /// 客户类型
- /// </summary>
- public int Type;
- LYFZ.BLL.BLL_ErpOrder orbll = new BLL_ErpOrder();
- LYFZ.BLL.BLL_ErpCustomer ctbll = new BLL_ErpCustomer();
- LYFZ.BLL.BLL_ErpCustomerGroup cgbll = new BLL.BLL_ErpCustomerGroup();
- LYFZ.BLL.BLL_ErpCustomerGroupMembers cgmbll = new BLL.BLL_ErpCustomerGroupMembers();
- LYFZ.BLL.BLL_OldOrderHistory oohbll = new BLL.BLL_OldOrderHistory();
- LYFZ.BLL.BLL_ErpSystemLogs slogbll = new BLL_ErpSystemLogs();
- List<LYFZ.Software.MainBusiness.EnumPermissions.BusinessType> Versions = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetBusinessTypeList();
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void FrmOldCustomer_Shown(object sender, EventArgs e)
- {
- this.chkEt.Visible = false;
- this.chkXz.Visible = false;
- this.chkHs.Visible = false;
- for (int i = 0; i < this.Versions.Count; i++)
- {
- LYFZ.Software.MainBusiness.EnumPermissions.BusinessType Version = this.Versions[i];
- if (Version.ToString() == EnumPermissions.BusinessType.写真版.ToString())
- { this.chkXz.Visible = true; }
- if (Version.ToString() == EnumPermissions.BusinessType.婚纱版.ToString())
- { this.chkHs.Visible = true; }
- if (Version.ToString() == EnumPermissions.BusinessType.儿童版.ToString())
- { this.chkEt.Visible = true; }
- }
- this.PublicFunctionRows();
- this.btnAdd.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OldCustomerCompetence, CustomAttributes.OperatingAuthority.Add);
- this.btnUpdate.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OldCustomerCompetence, CustomAttributes.OperatingAuthority.Update);
- this.btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OldCustomerCompetence, CustomAttributes.OperatingAuthority.Delete);
- this.btnExport.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OldCustomerCompetence, CustomAttributes.OperatingAuthority.DataExport);
- this.btnTexting.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OldCustomerCompetence, CustomAttributes.OperatingAuthority.SMSSend);
- this.btnExcel.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OldCustomerCompetence, LYFZ.CustomAttributes.OperatingAuthority.DataImport);
- }
- /// <summary>
- /// 查询
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnSlect_Click(object sender, EventArgs e)
- { this.PublicFunctionRows(); }
- /// <summary>
- /// 增加
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnAdd_Click(object sender, EventArgs e)
- {
- string StrClientType = "";
- if (this.chkHs.Checked == false && this.chkEt.Checked == false && this.chkXz.Checked == false && this.chkFw.Checked == false)
- {
- FrmOrdersCustomerRecord frm = new FrmOrdersCustomerRecord();
- if (frm.ShowDialog() == DialogResult.OK)
- { StrClientType = frm.DindanType.Trim(); }
- else
- { return; }
- }
- if (chkHs.Checked || StrClientType == "0")//0 为婚纱订单客户
- {
- LYFZ.Software.MainBusiness.Customers.OldCustomer.FrmOldCustomerOtheEdit frmHS = new OldCustomer.FrmOldCustomerOtheEdit();
- frmHS.type = this.Type;
- if (frmHS.ShowDialog() == DialogResult.OK)
- { this.PublicFunctionRows(); }
- }
- else if (chkEt.Checked || StrClientType == "1")//1 为儿童订单客户
- {
- LYFZ.Software.MainBusiness.Customers.OldCustomer.FrmOldCustomerPortraitEdit frmET = new OldCustomer.FrmOldCustomerPortraitEdit();
- frmET.type = this.Type;
- if (frmET.ShowDialog() == DialogResult.OK)
- { this.PublicFunctionRows(); }
- }
- else if (chkXz.Checked || StrClientType == "2") // 2 写真订单客户
- {
- LYFZ.Software.MainBusiness.Customers.OldCustomer.FrmOldCustomerPortraitAdd frmXZ = new OldCustomer.FrmOldCustomerPortraitAdd();
- frmXZ.type = this.Type;
- if (frmXZ.ShowDialog() == DialogResult.OK)
- { this.PublicFunctionRows(); }
- }
- else if (chkFw.Checked || StrClientType == "3")// 3 为服务套系
- {
- LYFZ.Software.MainBusiness.Customers.OldCustomer.FrmOldCustomerOtherAdd frmFW = new OldCustomer.FrmOldCustomerOtherAdd();
- frmFW.type = this.Type;
- if (frmFW.ShowDialog() == DialogResult.OK)
- { this.PublicFunctionRows(); }
- }
- }
- /// <summary>
- /// 双击列表修改
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void dgv_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
- {
- try
- {
- if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
- {
- if (this.dgv.SelectedRows.Count > 0)
- {
- if (!LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OldCustomerCompetence, CustomAttributes.OperatingAuthority.Update))
- { return; }
- if (this.dgv.CurrentRow.Cells["GP_CustomerType"].Value.ToString() == "儿童客户")
- {
- FrmOldCustomerEditBaby from = new FrmOldCustomerEditBaby();
- from.GM = this.dgv.CurrentRow.Cells["GP_CustomerGroupID"].Value.ToString();
- from.type = this.Type;
- if (from.ShowDialog() == DialogResult.OK)
- { this.PublicFunctionRows(); }
- }
- else
- {
- FrmOldCustomerEdit from = new FrmOldCustomerEdit();
- from.GM = this.dgv.CurrentRow.Cells["GP_CustomerGroupID"].Value.ToString();
- from.Leixing = this.dgv.CurrentRow.Cells["GP_CustomerType"].Value.ToString();
- from.type = this.Type;
- if (from.ShowDialog() == DialogResult.OK)
- { this.PublicFunctionRows(); }
- }
- }
- }
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); }
- }
- /// <summary>
- /// 修改
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnUpdate_Click(object sender, EventArgs e)
- {
- try
- {
- if (this.dgv.SelectedRows.Count == 0)
- { MessageBoxCustom.Show("请选择你要编辑的数据!"); return; }
- if (this.dgv.CurrentRow.Cells["GP_CustomerType"].Value.ToString() == "儿童客户")
- {
- FrmOldCustomerEditBaby from = new FrmOldCustomerEditBaby();
- from.GM = this.dgv.CurrentRow.Cells["GP_CustomerGroupID"].Value.ToString();
- from.type = this.Type;
- if (from.ShowDialog() == DialogResult.OK)
- { this.PublicFunctionRows(); }
- }
- else
- {
- FrmOldCustomerEdit from = new FrmOldCustomerEdit();
- from.GM = this.dgv.CurrentRow.Cells["GP_CustomerGroupID"].Value.ToString();
- from.Leixing = this.dgv.CurrentRow.Cells["GP_CustomerType"].Value.ToString();
- from.type = this.Type;
- if (from.ShowDialog() == DialogResult.OK)
- { this.PublicFunctionRows(); }
- }
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnDelete_Click(object sender, EventArgs e)
- {
- try
- {
- if (this.dgv.SelectedRows.Count == 0)
- {
- MessageBoxCustom.Show("请选中你要删除的数据!");
- return;
- }
- if (MessageBoxCustom.Show("你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
- List<string> StrGroupList = new List<string>();
- for (int i = 0; i < this.dgv.SelectedRows.Count; i++)
- { StrGroupList.Add(this.dgv.SelectedRows[i].Cells["GP_CustomerGroupID"].Value.ToString().Trim()); }
- int IsExecuteSqlTran = 0;
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- for (int i = 0; i < StrGroupList.Count; i++)
- {
- clist.Add(cgmbll.GetDeleteCommandInfo(whereStr: "GM_CustomerGroupID='" + StrGroupList[i].Trim() + "' "));
- clist.Add(cgbll.GetDeleteCommandInfo(whereStr: "GP_CustomerGroupID='" + StrGroupList[i].Trim() + "'"));
- clist.Add(oohbll.GetDeleteCommandInfo(whereStr: "History_ID='" + StrGroupList[i].Trim() + "'"));
- DataTable tblGroupMembers = orbll.GetView_Custom("tb_ErpCustomerGroupMembers", StrWhere: "GM_CustomerGroupID = '" + StrGroupList[i].Trim() + "'", ShowColumnName: "GM_CustomerID").Tables[0];
- for (int j = 0; j < tblGroupMembers.Rows.Count; j++)
- {
- DataTable tblClient = orbll.GetView_Custom("tb_ErpCustomer", StrWhere: "Cus_CustomerNumber = '" + tblGroupMembers.Rows[j]["GM_CustomerID"].ToString().Trim() + "'", ShowColumnName: "Cus_Name,Cus_Telephone").Tables[0];
- DataTable tblTwoSales = orbll.GetView_Custom("tb_ErpTwoSalesOrder", StrWhere: "Tsorder_CustomerNumber = '" + tblGroupMembers.Rows[j]["GM_CustomerID"].ToString().Trim() + "'", ShowColumnName: "ID").Tables[0];
- DataTable tblGroupMembers2 = orbll.GetView_Custom("tb_ErpCustomerGroupMembers", StrWhere: "GM_CustomerGroupID != '" + StrGroupList[i].Trim() + "' And GM_CustomerID = '" + tblGroupMembers.Rows[j]["GM_CustomerID"].ToString().Trim() + "'", ShowColumnName: "ID").Tables[0];
- if (tblTwoSales.Rows.Count <= 0 && tblGroupMembers2.Rows.Count <= 0)
- {
- DataTable dt = orbll.GetView_Custom("tb_ErpMemberCard", StrWhere: "Mc_CustomerNumber = '" + tblGroupMembers.Rows[j]["GM_CustomerID"].ToString().Trim() + "' And Mc_Status = '1' And Mc_CradNumber != ''", ShowColumnName: "ID").Tables[0];
- if (dt.Rows.Count <= 0)
- { clist.Add(ctbll.GetDeleteCommandInfo(whereStr: "Cus_CustomerNumber='" + tblGroupMembers.Rows[j]["GM_CustomerID"].ToString().Trim() + "'")); }
- if (tblClient.Rows.Count > 0)
- {
- clist.Add(slogbll.GetAddCommandInfo(LYFZ.BLL.BLL_ErpSystemLogs.GetWriteLogModel(LYFZ.EnumPublic.SystemLogsType.删除客户资料, "删除联系人:" + tblClient.Rows[0]["Cus_Name"].ToString().Trim() + ",电话:" + tblClient.Rows[0]["Cus_Telephone"].ToString().Trim() + "客户编号:" + tblGroupMembers.Rows[j]["GM_CustomerID"].ToString().Trim() + ",时间:" + SDateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name, StrInfoID: LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID())));
- }
- }
- else
- { clist.Add(slogbll.GetAddCommandInfo(LYFZ.BLL.BLL_ErpSystemLogs.GetWriteLogModel(LYFZ.EnumPublic.SystemLogsType.删除客户资料, "删除客户组编号:" + StrGroupList[i].Trim() + ",时间:" + SDateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name, StrInfoID: LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID()))); }
- }
- }
- if (clist.Count > 0)
- {
- IsExecuteSqlTran = LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist);
- if (IsExecuteSqlTran > 0)
- {
- for (int i = 0; i < StrGroupList.Count; i++)
- { DAL_ErpCustomer.UpdateAggregationCustomer(StrGroupList[i].Trim()); }
- }
- }
- });
- if (IsExecuteSqlTran > 0)
- {
- MessageBoxCustom.Show("删除成功!");
- this.PublicFunctionRows();
- }
- else
- { MessageBoxCustom.Show("删除失败!"); }
- ////批量删除 速度过慢
- //List<Helper.CommandInfo> ctlist = new List<Helper.CommandInfo>();
- //List<string> datelist = new List<string>();
- //List<string> namelist = new List<string>();
- //StringBuilder where = new StringBuilder();
- //int DeleteCount = 0;
- //LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- //{
- // //串客户组ID
- // for (int i = 0; i < dgv.SelectedRows.Count; i++)
- // {
- // if (i + 1 != dgv.SelectedRows.Count)
- // { where.Append("'" + dgv.SelectedRows[i].Cells["GP_CustomerGroupID"].Value.ToString().Trim() + "',"); }
- // else
- // { where.Append("'" + dgv.SelectedRows[i].Cells["GP_CustomerGroupID"].Value.ToString().Trim() + "'"); }
- // }
- // //根据客户组查客户ID
- // DataTable dtList = orbll.GetView_Custom("SELECT GM_CustomerID FROM tb_ErpCustomerGroupMembers where GM_CustomerGroupID in (" + where.ToString() + ") group by GM_CustomerID ").Tables[0];
- // foreach (DataGridViewRow item in dgv.SelectedRows)
- // {
- // ctlist.Add(cgmbll.GetDeleteCommandInfo(whereStr: "GM_CustomerGroupID='" + item.Cells["GP_CustomerGroupID"].Value.ToString() + "' "));
- // ctlist.Add(cgbll.GetDeleteCommandInfo(whereStr: "GP_CustomerGroupID='" + item.Cells["GP_CustomerGroupID"].Value.ToString() + "'"));
- // ctlist.Add(oohbll.GetDeleteCommandInfo(whereStr: "History_ID='" + item.Cells["GP_CustomerGroupID"].Value.ToString() + "'"));
- // datelist.Add(item.Cells["GP_CustomerGroupID"].Value.ToString());
- // namelist.Add(item.Cells["Cus_Name"].Value.ToString());
- // }
- // DeleteCount = LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(ctlist);
- //if (DeleteCount > 0)
- //{
- // string Cusid = "";
- // //串客户ID
- // foreach (DataRow row in dtList.Rows)
- // { Cusid += "'" + row[0].ToString() + "',"; }
- // Cusid = Cusid.Substring(0, Cusid.Length - 1);
- // //查二消表
- // DataTable dtTwo = orbll.GetView_Custom("select Tsorder_CustomerNumber from tb_ErpTwoSalesOrder where Tsorder_CustomerNumber in (" + Cusid + ")").Tables[0];
- // //查客户成员表
- // DataTable dtCus = orbll.GetView_Custom("select GM_CustomerID from tb_ErpCustomerGroupMembers where GM_CustomerID in (" + Cusid + ")").Tables[0];
- // //循环客户ID次数
- // for (int i = 0; i < Cusid.Split(',').Length; i++)
- // {
- // //如果二消表或者 成员表都没有数据可直接删除
- // if (dtTwo.Select(" Tsorder_CustomerNumber = " + Cusid.Split(',')[i].ToString() + "").Length < 1 && dtCus.Select("GM_CustomerID=" + Cusid.Split(',')[i].ToString()).Length < 1)
- // { ctbll.Delete("Cus_CustomerNumber=" + Cusid.Split(',')[i].ToString()); }
- // }
- // 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);
- // }
- // foreach (string item in datelist)
- // { DAL_ErpCustomer.UpdateAggregationCustomer(item); }
- //}
- //});
- //if (DeleteCount > 0)
- //{
- // this.Bind();
- // MessageBoxCustom.Show("删除成功!");
- //}
- //else
- //{ MessageBoxCustom.Show("删除失败!"); }
- }
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); }
- }
- /// <summary>
- /// 关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 导出
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnExport_Click(object sender, EventArgs e)
- {
- this.dgv.ExportDataTable();
- }
- /// <summary>
- /// 发短信
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnTexting_Click(object sender, EventArgs e)
- {
- try
- {
- string Sj1 = "";
- LYFZ.Software.MainBusiness.SMSManagement.SmsSend.FrmSendSms set = new SMSManagement.SmsSend.FrmSendSms();
- if (dgv.SelectedRows.Count == 0)
- {
- MessageBoxCustom.Show("选择你要发送短信的客户!");
- return;
- }
- for (int i = 0; i < dgv.SelectedRows.Count; i++)
- {
- //检查手机合法性
- string tempPhones = this.dgv.SelectedRows[i].Cells["客户电话"].Value.ToString();
- string okPhones = "";
- LYFZ.WinAPI.CustomPublicMethod.ValidationPhones(tempPhones.Replace('/', ','), ref okPhones);
- okPhones = okPhones.Trim().Trim(',');
- foreach (string phone in okPhones.Split(','))
- {
- if (phone.Trim().Length >= 11 && !Sj1.Contains(phone))
- { Sj1 += phone + ","; }
- }
- }
- set.Phone = Sj1.Trim(',');
- set.ShowDialog();
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); }
- }
- /// <summary>
- /// 创建行
- /// </summary>
- void PublicFunctionRows()
- {
- if (this.dgv.Rows.Count > 0)
- { this.dgv.Rows.Clear(); }
- StringBuilder str = new StringBuilder();
- string keyword = this.cmbQueryText.Text.Trim();
- str.Append(" and tempTB_AggregationCustomer.GP_GroupType='1' ");
- if (!string.IsNullOrEmpty(keyword))
- {
- str.Append(" and (Cus_Name like '%" + keyword + "%' or Cus_Name_py like '%" + keyword + "%' or Cus_Telephone like '%" + keyword + "%' or Cus_Region like '%" + keyword + "%') ");
- if (chkFw.Checked)//服务
- { str.Append(" and tempTB_AggregationCustomer.GP_CustomerType = '3' "); }
- else if (chkHs.Checked)//婚纱
- { str.Append(" and tempTB_AggregationCustomer.GP_CustomerType = '0' "); }
- else if (chkEt.Checked)//儿童
- { str.Append(" and tempTB_AggregationCustomer.GP_CustomerType = '1' "); }
- else if (chkXz.Checked)//写真
- { str.Append(" and tempTB_AggregationCustomer.GP_CustomerType = '2' "); }
- }
- else
- {
- if (chkFw.Checked)//服务
- { str.Append(" and tempTB_AggregationCustomer.GP_CustomerType = '3'"); }
- else if (chkHs.Checked)//婚纱
- { str.Append(" and tempTB_AggregationCustomer.GP_CustomerType = '0'"); }
- else if (chkEt.Checked)//儿童
- { str.Append(" and tempTB_AggregationCustomer.GP_CustomerType = '1'"); }
- else if (chkXz.Checked)//写真
- { str.Append(" and tempTB_AggregationCustomer.GP_CustomerType = '2'"); }
- }
-
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- newTable = LYFZ.BLL.BLL_ErpOrderView.GetData_ClientManagementClientOld(str.ToString().Trim());
- });
- #if IGNORE
- for (int t = 0; t < newTable.Rows.Count; t++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- DataGridViewCell cell = null;
- //客户组编号
- cell = new DataGridViewTextBoxCell();
- cell.Value = newTable.Rows[t]["GP_CustomerGroupID"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //名字
- cell = new DataGridViewTextBoxCell();
- cell.Value = newTable.Rows[t]["Cus_Name"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //性别
- cell = new DataGridViewTextBoxCell();
- cell.Value = newTable.Rows[t]["Cus_Sex_cs"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //手机
- cell = new DataGridViewTextBoxCell();
- cell.Value = newTable.Rows[t]["Cus_Telephone"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //区域
- cell = new DataGridViewTextBoxCell();
- cell.Value = newTable.Rows[t]["Cus_Region"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //客户类型 0 为婚纱订单客户 1 为儿童订单客户 2 写真订单客户 3 为服务套系 4 为其它订单客户
- cell = new DataGridViewTextBoxCell();
- cell.Value = GetType(newTable.Rows[t]["GP_CustomerType"].ToString().Trim());
- dgvr.Cells.Add(cell);
- //客户来源;
- cell = new DataGridViewTextBoxCell();
- cell.Value = newTable.Rows[t]["GP_CustomerSource"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //客户生日
- cell = new DataGridViewTextBoxCell();
- cell.Value = newTable.Rows[t]["Cus_BirthdayText"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //客户婚期
- cell = new DataGridViewTextBoxCell();
- cell.Value = newTable.Rows[t]["Cus_DayForMarriageText"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //添加时间
- cell = new DataGridViewTextBoxCell();
- cell.Value = newTable.Rows[t]["GP_CreateDatetime"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //套系名称
- cell = new DataGridViewTextBoxCell();
- cell.Value = newTable.Rows[t]["History_Type"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //套系价格
- cell = new DataGridViewTextBoxCell();
- cell.Value = newTable.Rows[t]["History_Money"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //订单时间
- cell = new DataGridViewTextBoxCell();
- cell.Value = newTable.Rows[t]["History_OrderTime"].ToString().Trim();
- dgvr.Cells.Add(cell);
- this.dgv.Rows.Add(dgvr);
- }
- #endif
- this.dgv.RowCount = newTable.Rows.Count;
- this.lblTotalCount.Text = "总条数:" + newTable.Rows.Count;
- //this.ucPagerEx1.PageCurrent = 1;
- //this.ucPagerEx1.PageSize = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetPageSize();//3;分页条数
- //this.ucPagerEx1.Bind();
- }
- /// <summary>
- /// 导出Excel
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnExcel_Click(object sender, EventArgs e)
- {
- if (this.Type == 1)
- {
- ImportExcel excel = new ImportExcel();
- FrmOrdersCustomerRecord frm = new FrmOrdersCustomerRecord();
- if (frm.ShowDialog() == DialogResult.OK)
- {
- excel.Type = this.Type;
- excel.Leixing = Convert.ToInt32(frm.DindanType);
- if (excel.ShowDialog() == DialogResult.OK)
- { this.PublicFunctionRows(); }
- }
- }
- if (this.Type == 2)
- {
- ImportExcel excel = new ImportExcel();
- excel.Type = this.Type;
- if (excel.ShowDialog() == DialogResult.OK)
- { this.PublicFunctionRows(); }
- }
- }
- /// <summary>
- /// 窗体大小发生变化
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void FrmOldCustomer_Resize(object sender, EventArgs e)
- {
- switch (this.panelTotalCount.Location.Y)
- {
- case 3: this.flowLayoutPanel1.Height = 36; break;
- case 37: this.flowLayoutPanel1.Height = 70; break;
- }
- }
- /// <summary>
- /// 写真
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void chkXz_Click(object sender, EventArgs e)
- {
- this.chkHs.Checked = false;
- this.chkEt.Checked = false;
- this.chkFw.Checked = false;
- this.PublicFunctionRows();
- }
- /// <summary>
- /// 儿童
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void chkEt_Click(object sender, EventArgs e)
- {
- this.chkHs.Checked = false;
- this.chkFw.Checked = false;
- this.chkXz.Checked = false;
- this.PublicFunctionRows();
- }
- /// <summary>
- /// 婚纱
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void chkHs_Click(object sender, EventArgs e)
- {
- this.chkEt.Checked = false;
- this.chkFw.Checked = false;
- this.chkXz.Checked = false;
- this.PublicFunctionRows();
- }
- /// <summary>
- /// 服务
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void chkFw_Click(object sender, EventArgs e)
- {
- this.chkHs.Checked = false;
- this.chkEt.Checked = false;
- this.chkXz.Checked = false;
- this.PublicFunctionRows();
- }
- /// <summary>
- /// 订单类型
- /// </summary>
- /// <param name="Gotype"> 0 为婚纱订单客户 1 为儿童订单客户 2 写真订单客户 3 为服务套系 4 为其它订单客户</param>
- /// <returns></returns>
- string GetType(string Gotype)
- {
- string Tpy = "";
- switch (Gotype)
- {
- case "1":
- Tpy = "儿童客户";
- break;
- case "2":
- Tpy = "写真客户";
- break;
- case "3":
- Tpy = "服务客户";
- break;
- case "0":
- Tpy = "婚纱客户";
- break;
- case "4":
- Tpy = "其他客户";
- break;
- }
- return Tpy;
- }
- }
- }
|