123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431 |
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace LYFZ.Software.MainBusiness.Dresses.DressView
- {
- public class UCDressCustomer : LYFZ.Software.UI.Dresses.DressView.UCDressCustomer
- {
- LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
- LYFZ.BLL.BLL_ErpCustomer ctbll = new BLL.BLL_ErpCustomer();
- public UCDressCustomer()
- {
- this.txtClientName.KeyDown += txtClientName_KeyDown;
- this.txtClientName.KeyPress += txtClientName_KeyPress;
- this.txtClientFixedPhone.KeyPress += txtClientFixedPhone_KeyPress;
- this.txtClientQQ.KeyPress += txtClientQQ_KeyPress;
- this.txtClientWorkUnit.KeyPress += txtClientWorkUnit_KeyPress;
- this.btnDial.Click += btnDial_Click;
- this.btnQQCall.Click += btnQQCall_Click;
- this.btnClientSelect.Click += btnClientSelect_Click;
- this.btn_CustomerEdit.Click += btn_CustomerEdit_Click;
- btn_CustomerEdit.Visible = false;
- }
- /// <summary>
- /// 保存数据控制
- /// </summary>
- /// <returns></returns>
- public LYFZ.Command.Result SaveCustomerData(ref string StrClientName, ref string StrClientTelephone,int indx=1)
- {
- #region 客户
- LYFZ.Command.Result<List<Helper.CommandInfo>> resultSQL = new Command.Result<List<Helper.CommandInfo>>();
- List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
- string StrTelephone = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.MaskedTextBoxExGetText(this.txtClientTelephone);
- string StrClientNumber = "";
- if (!string.IsNullOrEmpty(StrClientName))
- {
- StrClientName += "/";
- }
- if (!string.IsNullOrEmpty(StrClientTelephone))
- {
- StrClientTelephone += "/";
- }
- StrClientName += this.txtClientName.Text.ToString().Trim();
- StrClientTelephone += this.txtClientTelephone.Text.ToString().Trim().Replace(" ", "");
- if (this.txtClientName.Tag != null)
- {
- StrClientNumber = this.txtClientName.Tag.ToString().Trim();
-
- return new Command.Result<List<Helper.CommandInfo>>()
- {
- Status = true,
- StatusMsg = StrClientNumber
- };
- }
- else
- {
- if (ctbll.Exists("Cus_Telephone", StrTelephone) == true)//判断手机存在
- {
- MessageBoxCustom.Show("客户手机已经存在");
- return new Command.Result<List<Helper.CommandInfo>>()
- {
- Status = false,
- StatusMsg = "客户手机已经存在"
- };
- }
- LYFZ.Model.Model_ErpCustomer model = new Model.Model_ErpCustomer();
- model.Cus_CustomerNumber = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime().ToString("yyyyMMddHHmmssfff") + indx.ToString();//获取新编号
- model.Cus_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- model.Cus_CustomizeNumber = "";
- model.Cus_Type = "订单客户";
- model.Cus_ServiceType = "Clothing";
- model.Cus_Name = this.txtClientName.Text.ToString().Trim();
- model.Cus_Telephone = this.txtClientTelephone.Text.ToString().Trim().Replace(" ","");
- model.Cus_QQ = this.txtClientQQ.Text.ToString().Trim();
- model.Cus_Address = this.txtClientAddress.Text.ToString().Trim();
- model.Cus_WorkUnit = this.txtClientWorkUnit.Text.ToString().Trim();
- model.Cus_Birthday = this.txtClientBirthday.StrValue.Trim();
- if (this.chkClientBirthdayLunar.Checked == true)
- { model.Cus_BirthdayLunar = "1"; }
- else
- { model.Cus_BirthdayLunar = "0"; }
- model.Cus_DayForMarriage = this.txtClientDayForMarriage.StrValue.ToString();
- if (this.chkClientDayForMarriageLunar.Checked == true)
- { model.Cus_DayForMarriageLunar = "1"; }
- else
- { model.Cus_DayForMarriageLunar = "0"; }
- model.Cus_CreateDateTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
- model.Cus_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- clist.Add(ctbll.GetAddCommandInfo(model));
- StrClientNumber = model.Cus_CustomerNumber;
-
- return new Command.Result<List<Helper.CommandInfo>>()
- {
- Status = true,
- StatusMsg = StrClientNumber,
- clist = clist
- };
- }
- #endregion
- }
- public string StrOrderNumber { get; set; }
- public bool IsUpdateClientData = true;
- public void ReBindOrderNumber()
- {
- if (!string.IsNullOrEmpty(StrOrderNumber))
- {
- this.btnClientSelect.Visible = false;
- this.txtClientName.Width = this.txtClientQQ.Width;
- btn_CustomerEdit.Visible = false;
- //buttonForm1.Visible = false;
- }
- }
- public LYFZ.Command.Result CheckCustomerData()
- {
- if (string.IsNullOrEmpty(this.txtClientName.Text.Trim()))
- {
- MessageBoxCustom.Show("客户名称不能为空!");
- return new LYFZ.Command.Result()
- {
- Status = false,
- StatusMsg = "客户名称不能为空!"
- };
- }
- string StrTelephone = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.MaskedTextBoxExGetText(this.txtClientTelephone);
- if (string.IsNullOrEmpty(StrTelephone))
- {
- MessageBoxCustom.Show("客户手机号码不能为空!");
- return new LYFZ.Command.Result()
- {
- Status = false,
- StatusMsg = "客户手机号码不能为空!"
- };
- }
- else
- {
- if (StrTelephone.Length != 11)
- {
- MessageBoxCustom.Show("客户手机号码长度不足11位!");
- return new LYFZ.Command.Result()
- {
- Status = false,
- StatusMsg = "客户手机号码长度不足11位!"
- };
- }
- }
- int intMasse = this.txtClientBirthday.CheckDateValue(this.txtClientBirthday, this.chkClientBirthdayLunar);
- if (intMasse == 1)
- {
- MessageBoxCustom.Show("生日日期日期格式输入错误");
- return new LYFZ.Command.Result()
- {
- Status = false,
- StatusMsg = "生日日期日期格式输入错误"
- };
- }
- else if (intMasse == 2)
- {
- MessageBoxCustom.Show("生日日期:" + this.txtClientBirthday.StrValue.Trim() + "不是公历日期,若要保存请勾上农历");
- return new LYFZ.Command.Result()
- {
- Status = false,
- StatusMsg = "生日日期:" + this.txtClientBirthday.StrValue.Trim() + "不是公历日期,若要保存请勾上农历"
- };
- }
- intMasse = this.txtClientDayForMarriage.CheckDateValue(this.txtClientDayForMarriage, this.chkClientDayForMarriageLunar);
- if (intMasse == 1)
- {
- MessageBoxCustom.Show("婚期日期日期格式输入错误");
- return new LYFZ.Command.Result()
- {
- Status = false,
- StatusMsg = "婚期日期日期格式输入错误"
- };
- }
- else if (intMasse == 2)
- {
- MessageBoxCustom.Show("婚期日期:" + this.txtClientDayForMarriage.StrValue.Trim() + "不是公历日期,若要保存请勾上农历");
- return new LYFZ.Command.Result()
- {
- Status = false,
- StatusMsg = "婚期日期:" + this.txtClientDayForMarriage.StrValue.Trim() + "不是公历日期,若要保存请勾上农历"
- };
- }
- return new LYFZ.Command.Result()
- {
- Status = true
- };
- }
- /// <summary>
- /// 清空选择的客户
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void txtClientName_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Back)
- {
- if (this.txtClientName.Tag != null && string.IsNullOrEmpty(this.StrOrderNumber) && this.IsUpdateClientData)
- { this.ClearClientData(); }
- }
- }
- /// <summary>
- /// 客户工作单位输入限制
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void txtClientWorkUnit_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (Convert.ToString(e.KeyChar) == "-")
- { }
- else if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar) && !Char.IsLetterOrDigit(e.KeyChar))
- { e.Handled = true; }
- }
- /// <summary>
- /// 客户姓名输入限制
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void txtClientName_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar) && !Char.IsLetterOrDigit(e.KeyChar) && e.KeyChar != '_' && e.KeyChar != ' ')
- { e.Handled = true; }
- }
- /// <summary>
- /// 客户固定电话输入限制
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void txtClientFixedPhone_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (Convert.ToString(e.KeyChar) == "-")
- { }
- else if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
- { e.Handled = true; }
- }
- /// <summary>
- /// 客户QQ输入限制
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void txtClientQQ_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
- { e.Handled = true; }
- }
- /// <summary>
- /// 清空客户信息
- /// </summary>
- void ClearClientData()
- {
- this.txtClientName.Text = "";
- this.txtClientName.Tag = null;
- this.txtClientTelephone.Text = "";
- this.txtClientFixedPhone.Text = "";
- this.txtClientQQ.Text = "";
- this.txtClientAddress.Text = "";
- this.txtClientWorkUnit.Text = "";
- this.txtClientBirthday.Text = "";
- this.chkClientBirthdayLunar.Checked = false;
- this.txtClientDayForMarriage.Text = "";
- this.chkClientDayForMarriageLunar.Checked = false;
- this.txtClientName.ReadOnly = false;
- this.txtClientTelephone.ReadOnly = false;
- this.txtClientQQ.ReadOnly = false;
- this.txtClientAddress.ReadOnly = false;
- this.txtClientWorkUnit.ReadOnly = false;
- this.txtClientBirthday.ReadOnly = false;
- this.chkClientBirthdayLunar.Enabled = true;
- this.txtClientDayForMarriage.ReadOnly = false;
- this.chkClientDayForMarriageLunar.Enabled = true;
- this.txtClientFixedPhone.ReadOnly = false;
- btn_CustomerEdit.Visible = false;
- btn_CustomerEdit.Text = " 编辑";
- //buttonForm1.Visible = false;
- }
- /// <summary>
- /// 拨打电话
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnDial_Click(object sender, EventArgs e)
- {
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.PhoneCall(LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.MaskedTextBoxExGetText(this.txtClientTelephone));
- }
- /// <summary>
- /// QQ呼叫
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnQQCall_Click(object sender, EventArgs e)
- {
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.QQCall(this.txtClientQQ.Text.Trim());
- }
- /// <summary>
- /// 选择客户
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnClientSelect_Click(object sender, EventArgs e)
- {
- LYFZ.Software.MainBusiness.Dresses.DressManagement.FrmCusSelect frm = new DressManagement.FrmCusSelect();
- frm.ShowDialog();
- if (!string.IsNullOrEmpty(frm.StrClientNumber))
- { this.GetClientData(frm.StrClientNumber); }
- }
- /// <summary>
- /// 获取客户资料
- /// </summary>
- /// <param name="StrClientNumber"></param>
- /// <returns></returns>
- public void GetClientData(string StrClientNumber)
- {
- if (!string.IsNullOrEmpty(StrClientNumber))
- {
- DataTable dt = orbll.GetView_Custom("tb_ErpCustomer", StrWhere: "Cus_CustomerNumber='" + StrClientNumber + "'", ShowColumnName: "Cus_Name,Cus_CustomerNumber,Cus_Telephone,Cus_FixedPhone,Cus_QQ,Cus_Address,Cus_WorkUnit,Cus_Birthday,Cus_BirthdayLunar,Cus_DayForMarriage,Cus_DayForMarriageLunar").Tables[0];
- if (dt.Rows.Count > 0)
- {
- this.txtClientName.Text = dt.Rows[0]["Cus_Name"].ToString().Trim();
- this.txtClientName.Tag = dt.Rows[0]["Cus_CustomerNumber"].ToString().Trim();
- this.txtClientTelephone.Text = dt.Rows[0]["Cus_Telephone"].ToString().Trim();
- this.txtClientFixedPhone.Text = dt.Rows[0]["Cus_FixedPhone"].ToString().Trim();
- this.txtClientQQ.Text = dt.Rows[0]["Cus_QQ"].ToString().Trim();
- this.txtClientAddress.Text = dt.Rows[0]["Cus_Address"].ToString().Trim();
- this.txtClientWorkUnit.Text = dt.Rows[0]["Cus_WorkUnit"].ToString().Trim();
- this.txtClientBirthday.Text = dt.Rows[0]["Cus_Birthday"].ToString().Trim();
- if (dt.Rows[0]["Cus_BirthdayLunar"].ToString().Trim() == "1")
- { this.chkClientBirthdayLunar.Checked = true; }
- else
- { this.chkClientBirthdayLunar.Checked = false; }
- this.txtClientDayForMarriage.Text = dt.Rows[0]["Cus_DayForMarriage"].ToString().Trim();
- if (dt.Rows[0]["Cus_DayForMarriageLunar"].ToString().Trim() == "1")
- { this.chkClientDayForMarriageLunar.Checked = true; }
- else
- { this.chkClientDayForMarriageLunar.Checked = false; }
- this.txtClientName.ReadOnly = true;
- this.txtClientTelephone.ReadOnly = true;
- this.txtClientQQ.ReadOnly = true;
- this.txtClientAddress.ReadOnly = true;
- this.txtClientWorkUnit.ReadOnly = true;
- this.txtClientBirthday.ReadOnly = true;
- this.chkClientBirthdayLunar.Enabled = false;
- this.txtClientDayForMarriage.ReadOnly = true;
- this.chkClientDayForMarriageLunar.Enabled = false;
- this.txtClientFixedPhone.ReadOnly = true;
- btn_CustomerEdit.Visible = true;
- //buttonForm1.Visible = true;
- }
- }
- }
- void btn_CustomerEdit_Click(object sender, EventArgs e)
- {
- LYFZ.ComponentLibrary.ButtonEx btnEx = (LYFZ.ComponentLibrary.ButtonEx)sender;
- if (btnEx.Text.Trim() == "编辑")
- {
- this.SetCustomerEditEnable(false);
- btnEx.Text = " 保存";
- }
- else if (btnEx.Text.Trim() == "保存")
- {
- if (MessageBoxCustom.Show("如果修改客户信息,当前客户所关联的订单客户信息也会有变化\n是否继续?", "提示", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
- {
- LYFZ.Model.Model_ErpCustomer model = new Model.Model_ErpCustomer();
- BLL.BLL_ErpCustomer customerBll = new BLL.BLL_ErpCustomer();
- model = customerBll.GetModel("Cus_CustomerNumber", this.txtClientName.Tag.ToString().Trim());
- model.Cus_Name = this.txtClientName.Text.ToString().Trim();
- model.Cus_Telephone = this.txtClientTelephone.Text.ToString().Trim();
- model.Cus_QQ = this.txtClientQQ.Text.ToString().Trim();
- model.Cus_Address = this.txtClientAddress.Text.ToString().Trim();
- model.Cus_WorkUnit = this.txtClientWorkUnit.Text.ToString().Trim();
- model.Cus_Birthday = this.txtClientBirthday.StrValue.Trim();
- if (this.chkClientBirthdayLunar.Checked == true)
- { model.Cus_BirthdayLunar = "1"; }
- else
- { model.Cus_BirthdayLunar = "0"; }
- model.Cus_DayForMarriage = this.txtClientDayForMarriage.StrValue.ToString();
- if (this.chkClientDayForMarriageLunar.Checked == true)
- { model.Cus_DayForMarriageLunar = "1"; }
- else
- { model.Cus_DayForMarriageLunar = "0"; }
- if (customerBll.Update(model))
- {
- MessageBoxCustom.Show("修改成功!");
- }
- this.SetCustomerEditEnable(true);
- btnEx.Text = " 编辑";
- }
- }
- }
- public void SetCustomerEditEnable(bool bRead)
- {
- this.txtClientName.ReadOnly = bRead;
- this.txtClientTelephone.ReadOnly = bRead;
- this.txtClientQQ.ReadOnly = bRead;
- this.txtClientAddress.ReadOnly = bRead;
- this.txtClientWorkUnit.ReadOnly = bRead;
- this.txtClientBirthday.ReadOnly = bRead;
- this.chkClientBirthdayLunar.Enabled = true;
- this.txtClientDayForMarriage.ReadOnly = bRead;
- this.chkClientDayForMarriageLunar.Enabled = true;
- this.txtClientFixedPhone.ReadOnly = bRead;
- }
- public void BindShowAndHideDelete(bool b)
- {
- buttonForm1.Visible = b;
- }
- }
- }
|