123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768 |
- using LYFZ.BLL;
- using LYFZ.ComponentLibrary;
- using LYFZ.DAL;
- using LYFZ.Model;
- using LYFZ.Software.MainBusiness.Customers.OldCustomer;
- 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;
- namespace LYFZ.Software.MainBusiness.Customers
- {
- public partial class FrmOldCustomerEdit : LYFZ.Software.UI.Customers.FrmOldCustomerEdit
- {
- LYFZ.BLL.BLL_ErpOrder orbll = new BLL_ErpOrder();
- LYFZ.BLL.BLL_ErpCustomer ctbll = new BLL.BLL_ErpCustomer();
- LYFZ.BLL.BLL_OldOrderHistory Bll_ooh = new BLL_OldOrderHistory();
- LYFZ.BLL.BLL_ErpCustomerGroupMembers gmbll = new BLL_ErpCustomerGroupMembers();
- /// <summary>
- /// 客户组编号
- /// </summary>
- public string GM;
- /// <summary>
- /// 主联系人ID
- /// </summary>
- string ThemaincontactID;
- /// <summary>
- /// 主联系人编号
- /// </summary>
- string SerialnumberID;
- /// <summary>
- /// 单子类型
- /// </summary>
- public string Leixing = "";
- /// <summary>
- /// 类型 1老客户 2意向客户
- /// </summary>
- public int type;
- Boolean bl = false;
- public FrmOldCustomerEdit()
- {
- this.FormClosed += FrmOldCustomerEdit_FormClosed;
- this.chkLKH.Click += chkLKH_Click;
- this.chkPYJS.Click += chkPYJS_Click;
- this.chkQT.Click += chkQT_Click;
- this.btnAdding.Click += btnAdding_Click;
- this.dgvData.CellDoubleClick += dgvData_CellDoubleClick;
- this.btnlevel.Click += btnlevel_Click;
- this.btnDelete.Click += btnDelete_Click;
- this.btnQQCall.Click += btnQQCall_Click;
- this.btnDial.Click += btnDial_Click;
- this.txtCus_FixedPhone.KeyPress += txtCus_FixedPhone_KeyPress;
- this.txtHistory_Money.KeyPress += txtHistory_Money_KeyPress;
- this.btnUnbind.Click += btnUnbind_Click;
- }
- /// <summary>
- /// 拨打电话
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnDial_Click(object sender, EventArgs e)
- {
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.PhoneCall(this.txtCus_Telephone);
- }
- /// <summary>
- /// QQ呼叫
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnQQCall_Click(object sender, EventArgs e)
- {
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.QQCall(txtCus_QQ.Text.Trim());
- }
- /// <summary>
- /// 列表双击修改事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void dgvData_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
- {
- try
- {
- if (dgvData.SelectedRows.Count > 0)
- {
- FrmAddContacts from = new FrmAddContacts();
- from.YouID = dgvData.CurrentRow.Cells["ID"].Value.ToString().Trim();
- from.GP = GM;
- from.GMID = dgvData.CurrentRow.Cells["GMID"].Value.ToString().Trim();
- from.Zhuangtai = "编辑";
- if (from.ShowDialog() == DialogResult.OK)
- {
- if (dgvData.Rows.Count > 0)
- {
- dgvData.Rows.Clear();
- }
- UpDgvData();
- bl = true;
- }
- }
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); }
- }
- /// <summary>
- /// 窗体关闭事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void FrmOldCustomerEdit_FormClosed(object sender, FormClosedEventArgs e)
- {
- if (bl)
- { this.DialogResult = DialogResult.OK; }
- }
- /// <summary>
- /// 更新
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnUpdate_Click(object sender, EventArgs e)
- {
- try
- {
- #region 输入不能为空
- if (string.IsNullOrEmpty(this.txtCus_Name.Text))
- {
- MessageBoxCustom.Show("姓名不能为空");
- return;
- }
- string StrPhone = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.MaskedTextBoxExGetText(this.txtCus_Telephone);
- if (!string.IsNullOrEmpty(StrPhone))
- {
- if (StrPhone.Length != 11)
- {
- MessageBoxCustom.Show("手机号码必须为11位数!");
- return;
- }
- DataTable tblClient = orbll.GetView_Custom("tb_ErpCustomer", StrWhere: "Cus_Telephone = '" + StrPhone + "' and ID <> '" + ThemaincontactID + "' ", ShowColumnName: "ID").Tables[0];
- if (tblClient.Rows.Count > 0)
- { MessageBoxCustom.Show("手机号已存在"); return; }
- }
- int intMasse = this.txtCus_Birthday.CheckDateValue(this.txtCus_Birthday, chkCus_Lunar);
- if (intMasse == 1) { MessageBoxCustom.Show("生日日期日期格式输入错误"); return; }
- else if (intMasse == 2)
- { MessageBoxCustom.Show("生日日期:" + this.txtCus_Birthday.StrValue.Trim() + "不是公历日期,若要保存请勾上农历"); return; }
- if (Leixing == "婚纱客户")
- {
- intMasse = this.txtHQ_Birthday.CheckDateValue(this.txtHQ_Birthday, chkHQ_Lunar);
- if (intMasse == 1) { MessageBoxCustom.Show("婚期日期日期格式输入错误"); return; }
- else if (intMasse == 2)
- { MessageBoxCustom.Show("婚期日期:" + this.txtHQ_Birthday.StrValue.Trim() + "不是公历日期,若要保存请勾上农历"); return; }
- }
- #endregion
- List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
- //得到一个实体类
- Model_ErpCustomer model = ctbll.GetModel(Convert.ToInt32(ThemaincontactID.Trim()));
- model.Cus_Type = "";
- model.Cus_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(this.txtCus_Name.Text.Trim());
- model.Cus_NamePinyin = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin(model.Cus_Name.Trim()).ToLower();
- if (this.radCus_Nan.Checked == true)
- { model.Cus_Sex = false; }
- else
- { model.Cus_Sex = true; }
- model.Cus_Birthday = txtCus_Birthday.StrValue.ToString();
- if (model.Cus_Birthday != "")
- {
- model.Cus_Zodiac = LYFZ.Command.Command_CalendarTurnLunar.GetZodiac(this.txtCus_Birthday.StrValue.Trim(), this.chkCus_Lunar.Checked); ;
- if (chkCus_Lunar.Checked == true)
- {
- model.Cus_BirthdayLunar = "1";
- }
- else {
- model.Cus_BirthdayLunar = "0";
- }
- }
- else
- {
- model.Cus_Zodiac = "";
- model.Cus_BirthdayLunar = "";
- }
- model.Cus_QQ = this.txtCus_QQ.Text;
- model.Cus_MicroSignal = this.txtCus_MicroSignal.Text;
- model.Cus_Telephone = StrPhone;
- model.Cus_FixedPhone = this.txtCus_FixedPhone.Text;
- model.Cus_Region = this.cmbCus_Region.Text;
- model.Cus_Address = this.txtCus_Address.Text;
- model.Cus_WorkUnit = this.txtCus_WorkUnit.Text;
- model.Cus_CustomerSource = cmbCus_CustomerSource.Text;
- model.Cus_Grade = this.cmbtreevlevel.Text.Trim();
- model.Cus_UpdateDateTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
- model.Cus_UpdateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- if (this.Leixing == "婚纱客户")
- {
- model.Cus_DayForMarriage = txtHQ_Birthday.StrValue.ToString();
- if (model.Cus_DayForMarriage != "")
- {
- if (chkHQ_Lunar.Checked == true)
- { model.Cus_DayForMarriageLunar = "1"; }
- else { model.Cus_DayForMarriageLunar = "0"; }
- }
- else
- { model.Cus_DayForMarriageLunar = ""; }
- }
- string laiyuan = "";
- if (this.chkLKH.Checked == true)
- { laiyuan = "老客户"; }
- if (this.chkPYJS.Checked == true)
- { laiyuan = "朋友介绍"; }
- if (chkQT.Checked == true)
- { laiyuan = cmbCus_CustomerSource.Text; }
- BLL_ErpCustomerGroup ctbl2 = new BLL_ErpCustomerGroup();
- Model.Model_ErpCustomerGroup model2 = ctbl2.GetModel("GP_CustomerGroupID", GM);
- clist.Add(ctbll.GetUpdateCommandInfo(model));
- model2.GP_CustomerSource = laiyuan;
- clist.Add(ctbl2.GetUpdateCommandInfo(model2));
- //新增 老客户历史记录表
- if (model_ooh != null)
- {
- model_ooh.History_Type = txtHistory_Type.Text;
- if (txtHistory_Money.Text != "")
- { model_ooh.History_Money = Convert.ToInt32(txtHistory_Money.Text); }
- else { model_ooh.History_Money = 0; }
- if (txtHistory_OrderTime.StrValue != "")
- {
- if (txtHistory_OrderTime.CheckDateValue(this.txtHistory_OrderTime) != 1)
- { model_ooh.History_OrderTime = Convert.ToDateTime(txtHistory_OrderTime.Text); }
- else
- { model_ooh.History_OrderTime = LYFZ.WinAPI.CustomPublicMethod.GetNullDateTime(); }
- }
- else
- { model_ooh.History_OrderTime = LYFZ.WinAPI.CustomPublicMethod.GetNullDateTime(); }
- clist.Add(Bll_ooh.GetUpdateCommandInfo(model_ooh));
- }
- //如果等于空 判断是否新建
- else if (txtHistory_Type.Text != "" && txtHistory_Money.Text != "")
- {
- model_ooh = new Model_OldOrderHistory();
- model_ooh.History_ID = GM;
- model_ooh.History_Type = txtHistory_Type.Text;
- model_ooh.History_Money = Convert.ToInt32(txtHistory_Money.Text);
- if (txtHistory_OrderTime.StrValue != "")
- {
- if (txtHistory_OrderTime.CheckDateValue(this.txtHistory_OrderTime) != 1)
- { model_ooh.History_OrderTime = Convert.ToDateTime(txtHistory_OrderTime.Text); }
- else { model_ooh.History_OrderTime = LYFZ.WinAPI.CustomPublicMethod.GetNullDateTime(); }
- }
- else { model_ooh.History_OrderTime = LYFZ.WinAPI.CustomPublicMethod.GetNullDateTime(); }
- model_ooh.History_CurrentTime = SDateTime.Now;
- model_ooh.History_CurrentID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- clist.Add(Bll_ooh.GetAddCommandInfo(model_ooh));
- }
- if (clist.Count > 0)
- {
- if (MessageBoxCustom.Show("您确定要保存吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No)
- { return; }
- if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0)
- {
- DAL_ErpCustomer.UpdateAggregationCustomer(GM);
- bl = true;
- //日志
- LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.修改客户资料, "修改联系人(婚纱客户时修改全部人):" + model.Cus_Name + ",:,时间:" + SDateTime.Now, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
- MessageBoxCustom.Show("保存成功");
- }
- else
- { MessageBoxCustom.Show("保存失败"); }
- }
- }
- catch (Exception ex) { MessageBoxCustom.Show(ex.Message); }
- }
- /// <summary>
- /// 添加
- /// </summary>
- void btnAdding_Click(object sender, EventArgs e)
- {
- FrmAddContacts frm = new FrmAddContacts();
- //状态
- frm.Zhuangtai = "添加";
- if (frm.ShowDialog() == DialogResult.OK)
- {
- if (frm.model != null)
- {
- List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
- Model_ErpCustomer model = frm.model;
- Model_ErpCustomerGroupMembers modelGMitem = new Model_ErpCustomerGroupMembers();
- modelGMitem.GM_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- modelGMitem.GM_CustomerGroupID = GM;
- modelGMitem.GM_CustomerID = model.Cus_CustomerNumber;
- modelGMitem.GM_Master = 0;
- modelGMitem.GM_ProtagonistCustomer = 0;
- modelGMitem.GM_RelatedPersonID = SerialnumberID;
- modelGMitem.GM_Relation = model.Cus_Relations;
- modelGMitem.GM_IsOrder = 0;
- modelGMitem.GM_IsOrderNumber = "";
- clist.Add(ctbll.GetAddCommandInfo(model));
- clist.Add(gmbll.GetAddCommandInfo(modelGMitem));
- if (clist.Count > 0)
- {
- if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) >= 0)
- {
- DAL_ErpCustomer.UpdateAggregationCustomer(GM);
- bl = true;
- //日志
- LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.添加客户资料, "联系人:" + frm.model.Cus_Name + ",添加联系人资料客户组:" + modelGMitem.GM_CustomerGroupID + ",时间:" + SDateTime.Now, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
- MessageBoxCustom.Show("保存成功");
- UpDgvData();
- }
- else { MessageBoxCustom.Show("保存失败"); }
- return;
- }
- }
- }
- }
- Model.Model_OldOrderHistory model_ooh = null;
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- protected override void FrmOldCustomerEdit_Load(object sender, EventArgs e)
- {
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.HidePhoneControls(this.txtCus_FixedPhone);
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.HidePhoneControls(this.txtCus_Telephone);
- this.Text = "修改老客户(" + this.Leixing + ")";
- if (this.Leixing == "婚纱客户")
- { this.panHS.Visible = true; }
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_ClientSourec("AAAAAAF", this.cmbCus_CustomerSource, strHideFiled: "BFACBABGBGBJGDHIE,BFAFBCBADBDCABFDD");
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_ClientSourec("AAAAAAC", this.cmbCus_Region, strHideFiled: "");
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("BFADBIBEFCFCIDCDG", this.cmbtreevlevel, IsFirstNodeNull: true);
- this.UpDgvData();
- }
- /// <summary>
- /// 解绑
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnUnbind_Click(object sender, EventArgs e)
- {
- if (this.txtMicroID.Text.Trim() == "已绑定")
- {
- LYFZ.Model.Model_ErpCustomer model = ctbll.GetModel(Convert.ToInt32(this.ThemaincontactID));
- model.Cus_OpenID = "";
- model.Cus_UpdateDateTime = SDateTime.Now;
- model.Cus_UpdateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- ctbll.Update(model);
- if (UnBindMicroData(model.Cus_CustomerNumber))
- {
- MessageBoxCustom.Show("解绑成功!");
- this.txtMicroID.Text = "未绑定";
- }
- else
- { MessageBoxCustom.Show("解绑失败"); }
- }
- }
- /// <summary>
- /// 获取其他成员资料
- /// </summary>
- void UpDgvData()
- {
- if (dgvData.Rows.Count > 0)
- { dgvData.Rows.Clear(); }
- BLL_OrderCustomer bll = new BLL_OrderCustomer();
- BLL_ErpCustomerGroup GPbll = new BLL_ErpCustomerGroup();
- Model_ErpCustomerGroup ModelGm = GPbll.GetModel("GP_CustomerGroupID", GM);
- DataTable dt = orbll.GetView_Custom("tb_ErpCustomerGroupMembers Left Join tb_ErpCustomer on GM_CustomerID = Cus_CustomerNumber", StrWhere: "GM_CustomerGroupID = '" + GM + "'", ShowColumnName: "tb_ErpCustomer.ID,Cus_Name,Cus_Sex,Cus_Birthday,Cus_BirthdayLunar,Cus_QQ,Cus_MicroSignal,Cus_Zodiac,Cus_DayForMarriage,Cus_DayForMarriageLunar,Cus_Telephone,Cus_FixedPhone,Cus_Region,Cus_Address,Cus_WorkUnit,Cus_CustomerNumber,Cus_Grade,Cus_Type,Cus_OpenID,GM_CustomerGroupID,GM_CustomerID,GM_RelatedPersonID,GM_Relation,tb_ErpCustomerGroupMembers.ID as GMID", filedOrder: "tb_ErpCustomer.ID").Tables[0];
- if (type != 2)
- {
- if (Bll_ooh.Exists("History_ID", GM))
- { model_ooh = Bll_ooh.GetModel("History_ID", GM); }
- }
- if (dt.Rows.Count > 0)
- {
- #region 获取数据
- for (int t = 0; t < dt.Rows.Count; t++)
- {
- if (dt.Rows[t]["GM_Relation"].ToString().Trim() != "本人")
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- DataGridViewCell cell = null;
- //姓名 0
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Cus_Name"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //性别 1
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Cus_Sex"].ToString().Trim() == "False" ? "男" : "女";
- dgvr.Cells.Add(cell);
- //生日 2
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Cus_Birthday"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //生日历类 3
- cell = new DataGridViewTextBoxCell();
- cell.Value = Lunar(dt.Rows[t]["Cus_BirthdayLunar"].ToString().Trim());
- dgvr.Cells.Add(cell);
- //QQ 4
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Cus_QQ"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //微信 5
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Cus_MicroSignal"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //手机 6
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Cus_Telephone"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //固定电话 7
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Cus_FixedPhone"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //地区 8
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Cus_Region"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //地址 9
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Cus_Address"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //工作单位 10
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Cus_WorkUnit"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //ID 11
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["ID"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //关系 12
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["GM_Relation"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //客户编号 13
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Cus_CustomerNumber"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //客户组GM的ID
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["GMID"].ToString().Trim();
- dgvr.Cells.Add(cell);
- dgvData.Rows.Add(dgvr);
- }
- else if (dt.Rows[t]["GM_Relation"].ToString().Trim() == "本人")
- {
- #region 赋值
- if (ModelGm.GP_CustomerSource == "老客户")
- {
- this.chkLKH.Checked = true;
- chkLKH_Click(null, null);
- }
- if (ModelGm.GP_CustomerSource == "朋友介绍")
- {
- this.chkPYJS.Checked = true;
- chkPYJS_Click(null, null);
- }
- if (ModelGm.GP_CustomerSource != "老客户" && ModelGm.GP_CustomerSource != "朋友介绍")
- {
- this.chkQT.Checked = true;
- chkQT_Click(null, null);
- cmbCus_CustomerSource.Text = ModelGm.GP_CustomerSource;
- }
- if (model_ooh != null)
- {
- txtHistory_Type.Text = model_ooh.History_Type;
- txtHistory_Money.Text = model_ooh.History_Money.ToString().Trim() != "0" ? model_ooh.History_Money.ToString() : "";
- DateTime ti1 = Convert.ToDateTime("1900-01-01");
- if (DateTime.Compare(model_ooh.History_OrderTime, ti1) < 0)
- { txtHistory_OrderTime.StrValue = ""; }
- else { txtHistory_OrderTime.StrValue = model_ooh.History_OrderTime.ToString("yyyy-MM-dd"); }
- }
- string Cus_BirthdayLunar = dt.Rows[t]["Cus_BirthdayLunar"].ToString();
- if (Cus_BirthdayLunar.ToString() == "1")
- { this.chkCus_Lunar.Checked = true; }
- //姓名
- this.txtCus_Name.Text = dt.Rows[t]["Cus_Name"].ToString();
- //生日
- this.txtCus_Birthday.Text = dt.Rows[t]["Cus_Birthday"].ToString();
- //QQ
- this.txtCus_QQ.Text = dt.Rows[t]["Cus_QQ"].ToString();
- //微信
- this.txtCus_MicroSignal.Text = dt.Rows[t]["Cus_MicroSignal"].ToString();
- //手机
- this.txtCus_Telephone.Text = dt.Rows[t]["Cus_Telephone"].ToString();
- //固定电话
- this.txtCus_FixedPhone.Text = dt.Rows[t]["Cus_FixedPhone"].ToString();
- //区域
- this.cmbCus_Region.Text = dt.Rows[t]["Cus_Region"].ToString();
- //地址
- this.txtCus_Address.Text = dt.Rows[t]["Cus_Address"].ToString();
- //单位
- this.txtCus_WorkUnit.Text = dt.Rows[t]["Cus_WorkUnit"].ToString();
- //等级
- this.cmbtreevlevel.TextFindTag(dt.Rows[t]["Cus_Grade"].ToString());
- //客户编号
- this.SerialnumberID = dt.Rows[t]["Cus_CustomerNumber"].ToString().Trim();
- if (this.Leixing == "婚纱客户")
- {
- this.txtHQ_Birthday.Text = dt.Rows[t]["Cus_DayForMarriage"].ToString().Trim();
- if (txtHQ_Birthday.Text != "")
- {
- if (dt.Rows[t]["Cus_DayForMarriageLunar"].ToString().Trim() == "1")
- { this.chkHQ_Lunar.Checked = true; }
- }
- }
- if (!Convert.ToBoolean(dt.Rows[t]["Cus_Sex"]))
- { this.radCus_Nan.Checked = true; }
- else
- { this.radCus_Nv.Checked = true; }
- this.ThemaincontactID = dt.Rows[t]["ID"].ToString().Trim();
- /*if (!string.IsNullOrEmpty(dt.Rows[t]["Cus_OpenID"].ToString().Trim()))
- { this.txtMicroID.Text = "已绑定"; }
- else
- { this.txtMicroID.Text = "未绑定"; }*/
- BindMicroData(dt.Rows[t]["Cus_CustomerNumber"].ToString().Trim());
- #endregion
- }
- }
- #endregion
- }
- }
- /// <summary>
- /// 客户微信绑定
- /// </summary>
- void BindMicroData(string customerID)
- {
- BLL_CustomerAndWxOpen bllWxOpen = new BLL_CustomerAndWxOpen();
- DataTable dt = bllWxOpen.GetCustomerDataByCustomerID(customerID);
- BLL.BLL_ErpMicroInterface bllInterface = new BLL.BLL_ErpMicroInterface();
- LYFZ.Model.Model_ErpMicroInterface modInterFace = new Model.Model_ErpMicroInterface();
- modInterFace = bllInterface.GetModelMicroInterface(LYFZ.BLL.BLL_ErpCompanyInfo.CurrentCompanyInfoID);
- if (string.IsNullOrEmpty(modInterFace.AppID))
- {
- modInterFace.AppID = "";
- }
- DataRow[] drList = dt.Select(" APPID = '" + modInterFace.AppID + "' ");
- if (drList.Length > 0)
- { this.txtMicroID.Text = "已绑定"; }
- else
- { this.txtMicroID.Text = "未绑定"; }
- }
- /// <summary>
- /// 解除客户微信绑定
- /// </summary>
- /// <param name="customerID"></param>
- bool UnBindMicroData(string customerID)
- {
- BLL_CustomerAndWxOpen bllWxOpen = new BLL_CustomerAndWxOpen();
- DataTable dt = bllWxOpen.GetCustomerDataByCustomerID(customerID);
- BLL.BLL_ErpMicroInterface bllInterface = new BLL.BLL_ErpMicroInterface();
- LYFZ.Model.Model_ErpMicroInterface modInterFace = new Model.Model_ErpMicroInterface();
- modInterFace = bllInterface.GetModelMicroInterface(LYFZ.BLL.BLL_ErpCompanyInfo.CurrentCompanyInfoID);
- if (string.IsNullOrEmpty(modInterFace.AppID))
- {
- modInterFace.AppID = "";
- }
- DataRow[] drList = dt.Select(" APPID = '" + modInterFace.AppID + "' ");
- if (drList.Length > 0)
- {
- bllWxOpen.Delete(drList[0]["ID"]);
- dt = bllWxOpen.GetCustomerDataByCustomerID(customerID);
- string strOpenID = "";
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- if (!string.IsNullOrEmpty(strOpenID))
- {
- strOpenID += "/";
- }
- strOpenID += dt.Rows[i]["APPID"] + ":" + dt.Rows[i]["WxOpenId"];
- }
- Model_ErpCustomer model = ctbll.GetModel(Convert.ToInt32(this.ThemaincontactID));
- model.Cus_OpenID = strOpenID;
- ctbll.Update(model);
- return true;
- //this.txtMicroID.Text = "已绑定";
- }
- else
- {
- return false;
- }
-
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnDelete_Click(object sender, EventArgs e)
- {
- if (this.dgvData.SelectedRows.Count > 0)
- {
- if (MessageBoxCustom.Show("是否删除?", "删除", MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- if (gmbll.Delete(Convert.ToInt32(this.dgvData.CurrentRow.Cells["GMID"].Value.ToString().Trim())) && ctbll.Delete(Convert.ToInt32(this.dgvData.CurrentRow.Cells["ID"].Value.ToString().Trim())))
- {
- DAL_ErpCustomer.UpdateAggregationCustomer(GM);
- bl = true;
- //日志
- LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.删除客户资料, "删除客户资料:客户姓名=" + this.dgvData.CurrentRow.Cells["CusName"].Value.ToString() + ",时间:" + SDateTime.Now, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
- MessageBoxCustom.Show("删除成功!");
- this.UpDgvData();
- }
- }
- }
- else
- { MessageBoxCustom.Show("请选择删除内容"); }
- }
- /// <summary>
- /// 设置客户等级
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnlevel_Click(object sender, EventArgs e)
- {
- LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet set = new InitialSet.FrmSystemSet();
- set.TypeName = "BFADBIBEFCFCIDCDG";
- set.Version = "Version";
- if (set.ShowDialog() == DialogResult.OK)
- { LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("BFADBIBEFCFCIDCDG", this.cmbtreevlevel, IsFirstNodeNull: true); }
- }
- /// <summary>
- /// 设置客户来源
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnCustomerSource_Click(object sender, EventArgs e)
- {
- LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet set = new InitialSet.FrmSystemSet();
- set.TypeName = "AAAAAAF";
- set.Version = "Version";
- if (set.ShowDialog() == DialogResult.OK)
- { LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_ClientSourec("AAAAAAF", this.cmbCus_CustomerSource, strHideFiled: "BFACBABGBGBJGDHIE,BFAFBCBADBDCABFDD"); }
- }
- /// <summary>
- /// 设置客户区域
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnRegion_Click(object sender, EventArgs e)
- {
- LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet set = new InitialSet.FrmSystemSet();
- set.TypeName = "AAAAAAC";
- set.Version = "Version";
- if (set.ShowDialog() == DialogResult.OK)
- { LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_ClientSourec("AAAAAAC", this.cmbCus_Region, strHideFiled: ""); }
- }
- /// <summary>
- /// 关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 输入框设置
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void txtHistory_Money_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
- { e.Handled = true; }
- }
- /// <summary>
- /// 输入框设置
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void txtCus_FixedPhone_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
- { e.Handled = true; }
- }
- /// <summary>
- /// 输入框设置
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void txtCus_Telephone_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
- { e.Handled = true; }
- }
- /// <summary>
- /// 输入框设置
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void txtCus_QQ_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
- { e.Handled = true; }
- }
- /// <summary>
- /// 单选框事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void chkQT_Click(object sender, EventArgs e)
- {
- this.chkLKH.Checked = false;
- this.chkPYJS.Checked = false;
- this.cmbCus_CustomerSource.Enabled = true;
- }
- /// <summary>
- /// 单选框事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void chkPYJS_Click(object sender, EventArgs e)
- {
- this.cmbCus_CustomerSource.Enabled = false;
- this.chkLKH.Checked = false;
- this.chkQT.Checked = false;
- }
- /// <summary>
- /// 单选框事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void chkLKH_Click(object sender, EventArgs e)
- {
- this.chkPYJS.Checked = false;
- this.chkQT.Checked = false;
- this.cmbCus_CustomerSource.Enabled = false;
- }
- /// <summary>
- /// 返回日历类别
- /// </summary>
- /// <param name="lun"></param>
- /// <returns></returns>
- string Lunar(string lun)
- {
- string luns = "";
- switch (lun)
- {
- case "0":
- luns = "公历";
- break;
- case "1":
- luns = "农历";
- break;
- case "2":
- luns = "农历润月";
- break;
- }
- return luns;
- }
- }
- }
|