using LYFZ.ComponentLibrary;
using LYFZ.DAL;
using LYFZ.Model;
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.OldCustomer
{
    public partial class FrmOldCustomerOtheEdit : LYFZ.Software.UI.Customers.OldCustomer.FrmOldCustomerOtheEdit
    {
        /// <summary>
        /// 客户组类型 1 为老客户 2 为意向客户
        /// </summary>
        public int type;
        public int ID;
        Boolean bl = false;
        /// <summary>
        /// 存放客户资料的Model泛型
        /// </summary>
        List<Model_ErpCustomer> GetModelList = new List<Model_ErpCustomer>();
        public FrmOldCustomerOtheEdit()
        {
            this.FormClosed += FrmOldCustomerOtheEdit_FormClosed;
            this.Shown += FrmOldCustomerDressAdd_Shown;
            this.btnAdding.Click += btnAdding_Click;
            this.dgvData.CellDoubleClick += dgvData_CellContentDoubleClick;
            this.chkLKH.Click += chkLKH_Click;
            this.chkPYJS.Click += chkPYJS_Click;
            this.chkQT.Click += chkQT_Click;
            this.btnDelete.Click += btnDelete_Click;
            this.btnClear.Click += btnClear_Click;
            this.btnlevel.Click += btnlevel_Click;
            this.btnRegion.Click += btnRegion_Click;
            this.btnSave.Click += btnSave_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.txtHistory_OrderTime.KeyPress += txtHistory_OrderTime_KeyPress;
        }
        /// <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(this.txtCus_QQ.Text.Trim());
        }
        /// <summary>
        /// 窗体加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void FrmOldCustomerDressAdd_Shown(object sender, EventArgs e)
        {
            //客户区域,客户来源
            LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_ClientSourec("AAAAAAC", this.cmbCus_Region, strHideFiled: "");
            LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_ClientSourec("AAAAAAF", this.cmbCus_CustomerSource, strHideFiled: "BFACBABGBGBJGDHIE,BFAFBCBADBDCABFDD");
            LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("BFADBIBEFCFCIDCDG", this.cmbtreevlevel, IsFirstNodeNull: true);
        }
        /// <summary>
        /// 关闭窗体
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void FrmOldCustomerOtheEdit_FormClosed(object sender, FormClosedEventArgs e)
        {
            if (bl)
            { this.DialogResult = DialogResult.OK; }
        }
        /// <summary>
        /// 修改添加到人员
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void dgvData_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (this.dgvData.SelectedRows.Count > 0)
            {
                //dgv修改操作
                foreach (Model_ErpCustomer model in GetModelList)
                {
                    if (model.Cus_CustomerNumber == this.dgvData.CurrentRow.Cells["CusCustomerNumber"].Value.ToString().Trim())
                    {
                        FrmAddContacts frm = new FrmAddContacts();
                        //状态
                        frm.Zhuangtai = "添加";
                        //将本条数据传到另一个窗体
                        frm.model = model;
                        if (frm.ShowDialog() == DialogResult.OK)
                        {
                            //先移除
                            GetModelList.Remove(model);
                            this.dgvData.Rows.Remove(this.dgvData.CurrentRow);
                            //后添加
                            Adddgvdata(frm.model);
                        }
                        break;
                    }
                }
            }
        }
        /// <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)
                {
                    foreach (Model_ErpCustomer model in GetModelList)
                    {
                        //判断获取当前选中的数据,并删除
                        if (model.Cus_CustomerNumber == this.dgvData.CurrentRow.Cells["CusCustomerNumber"].Value.ToString().Trim())
                        {
                            //删除去list里面移除
                            this.GetModelList.Remove(model);
                            //去dgv移除
                            this.dgvData.Rows.Remove(this.dgvData.CurrentRow);
                            return;
                        }
                    }
                }
            }
            else
            { MessageBoxCustom.Show("请选中要删除的内容"); }
        }
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void btnSave_Click(object sender, EventArgs e)
        {
            LYFZ.BLL.BLL_ErpCustomer bll = new BLL.BLL_ErpCustomer();
            LYFZ.BLL.BLL_ErpCustomerGroup GPbll = new BLL.BLL_ErpCustomerGroup();
            LYFZ.BLL.BLL_ErpCustomerGroupMembers GMbll = new BLL.BLL_ErpCustomerGroupMembers();
            LYFZ.Model.Model_ErpCustomer model = new Model.Model_ErpCustomer();
            Model.Model_ErpCustomerGroup modelGP = new Model.Model_ErpCustomerGroup();
            Model.Model_ErpCustomerGroupMembers modelGM = new Model.Model_ErpCustomerGroupMembers();
            LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
            List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
            //手机号
            string StrPhone = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.MaskedTextBoxExGetText(this.txtCus_Telephone);
            #region 输入不能为空
            if (string.IsNullOrEmpty(this.txtCus_Name.Text))
            { MessageBoxCustom.Show("客户姓名不能为空"); return; }

            if (string.IsNullOrEmpty(StrPhone))
            { MessageBoxCustom.Show("客户手机不能为空"); return; }
            if (!string.IsNullOrEmpty(StrPhone))
            {
                if (StrPhone.Length != 11)
                { MessageBoxCustom.Show("手机号码必须为11位数!"); return; }
            }
            if (chkLKH.Checked == false && chkQT.Checked == false && chkPYJS.Checked == false)
            { MessageBoxCustom.Show("请选择客户来源"); return; }
            int intMasse = this.txtCus_Birthday.CheckDateValue(this.txtCus_Birthday, this.chkHQ_Lunar);
            if (intMasse == 1) { MessageBoxCustom.Show("客户生日日期格式输入错误!"); return; }
            else if (intMasse == 2)
            { MessageBoxCustom.Show("客户生日:" + this.txtCus_Birthday.StrValue.Trim() + "不是公历日期,若要保存请勾上农历!"); return; }

            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
            DataTable tblClient = orbll.GetView_Custom("tb_ErpCustomer", StrWhere: "Cus_Telephone = '" + StrPhone + "'", ShowColumnName: "ID").Tables[0];
            if (tblClient.Rows.Count > 0)
            { MessageBoxCustom.Show("手机号已存在"); return; }
            #region Model
            DateTime strTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
            //客户组表
            modelGP.GP_CustomerGroupID = LYFZ.BLL.BLL_ErpCustomer.GetNewClientGroupNumber();
            modelGP.GP_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
            modelGP.GP_GroupType = type;
            modelGP.GP_CustomerType = 0;
            modelGP.GP_CustomerStatus = "正常";
            modelGP.GP_CreateDatetime = strTime;
            modelGP.GP_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
            modelGP.GP_CustomerSource = _CustomerSource();
            modelGP.GP_Remark = "";
            modelGP.GP_OrderNumber = "";
            modelGP.GP_LossReason = "";
            modelGP.GP_IntroducerCustomerID = "";
            modelGP.GP_DegreeOfIntent = "";
            modelGP.GP_BelongsPersonID = "";
            clist.Add(GPbll.GetAddCommandInfo(modelGP));

            //用户信息表
            model.Cus_CustomerNumber = LYFZ.BLL.BLL_ErpCustomer.GetClientNumber();
            model.Cus_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
            model.Cus_Type = "";
            model.Cus_ServiceType = "other";
            model.Cus_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(this.txtCus_Name.Text);
            model.Cus_NamePinyin = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin(model.Cus_Name).ToLower();
            if (this.rdoCus_Sex1_1.Checked == true)
            { model.Cus_Sex = false; }
            else { model.Cus_Sex = true; }
            //判断生日是否有填
            model.Cus_Birthday = this.txtCus_Birthday.StrValue.Trim();
            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_Birthday = "";
                model.Cus_BirthdayLunar = "";
                model.Cus_Zodiac = "";
            }
            model.Cus_DayForMarriage = this.txtHQ_Birthday.StrValue.Trim();
            if (model.Cus_DayForMarriage != "")
            {
                if (chkHQ_Lunar.Checked == true)
                { 
                    model.Cus_DayForMarriageLunar = "1"; 
                }
                else { 
                    model.Cus_DayForMarriageLunar = "0";
                }
            }
            else
            {
                model.Cus_DayForMarriage = "";
                model.Cus_DayForMarriageLunar = "";
            }
            model.Cus_Relations = "";
            model.Cus_QQ = this.txtCus_QQ.Text.ToString().Trim();
            model.Cus_MicroSignal = this.txtCus_MicroSignal.Text.ToString().Trim();
            model.Cus_Telephone = StrPhone;
            model.Cus_FixedPhone = this.txtCus_FixedPhone.Text.ToString().Trim();
            model.Cus_Region = this.cmbCus_Region.Text.ToString().Trim();
            model.Cus_Address = this.txtCus_Address.Text.ToString().Trim();
            model.Cus_WorkUnit = this.txtCus_WorkUnit.Text.ToString().Trim();
            model.Cus_BabyWeight = "";
            model.Cus_BornHospital = "";
            model.Cus_CustomerSource = "";
            model.Cus_Status = "";
            model.Cus_LossReason = "";
            model.Cus_DegreeOfIntent = "";
            model.Cus_TrackName = "";
            model.Cus_Remark = "";
            model.Cus_CreateDateTime = strTime;
            model.Cus_Grade = this.cmbtreevlevel.Text.Trim();
            model.Cus_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
            clist.Add(bll.GetAddCommandInfo(model));

            //成员表
            modelGM.GM_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
            modelGM.GM_CustomerGroupID = modelGP.GP_CustomerGroupID;
            modelGM.GM_CustomerID = model.Cus_CustomerNumber;
            modelGM.GM_Master = 1;
            modelGM.GM_ProtagonistCustomer = 1;
            modelGM.GM_RelatedPersonID = model.Cus_CustomerNumber;
            modelGM.GM_Relation = "本人";
            modelGM.GM_IsOrder = 0;
            modelGM.GM_IsOrderNumber = "";
            clist.Add(GMbll.GetAddCommandInfo(modelGM));
            #endregion

            if (dgvData.Rows.Count > 0)
            {
                Model_ErpCustomerGroupMembers modelGMitem = new Model_ErpCustomerGroupMembers();
                foreach (Model_ErpCustomer modelitem in GetModelList)
                {
                    modelGMitem.GM_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
                    modelGMitem.GM_CustomerGroupID = modelGP.GP_CustomerGroupID;
                    modelGMitem.GM_CustomerID = modelitem.Cus_CustomerNumber;
                    modelGMitem.GM_Master = 0;
                    modelGMitem.GM_ProtagonistCustomer = 1;
                    modelGMitem.GM_RelatedPersonID = model.Cus_CustomerNumber;
                    modelGMitem.GM_Relation = modelitem.Cus_Relations;
                    modelGMitem.GM_IsOrder = 0;
                    modelGMitem.GM_IsOrderNumber = "";
                    //组表
                    clist.Add(GMbll.GetAddCommandInfo(modelGMitem));
                    //客户表
                    clist.Add(bll.GetAddCommandInfo(modelitem));
                }
            }

            //新增  2015-9-9  老客户历史记录
            if (txtHistory_Money.Text != "" && txtHistory_Type.Text != "")
            {
                Model.Model_OldOrderHistory Model_ooh = new Model_OldOrderHistory();
                BLL.BLL_OldOrderHistory bll_ooh = new BLL.BLL_OldOrderHistory();
                Model_ooh.History_ID = modelGP.GP_CustomerGroupID;
                Model_ooh.History_Type = txtHistory_Type.Text.Trim();
                if (txtHistory_Money.Text != "")
                {
                    Model_ooh.History_Money = Convert.ToInt32(txtHistory_Money.Text);
                }
                else { Model_ooh.History_Money = 0; }
                if (this.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 (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) >= 0)
                {
                    bl = true;
                    DAL_ErpCustomer.UpdateAggregationCustomer(modelGP.GP_CustomerGroupID);
                    //日志
                    LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.添加客户资料, "添加婚纱版老客户资料客户组:" + modelGP.GP_CustomerGroupID + ",时间:" + SDateTime.Now, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
                    MessageBoxCustom.Show("保存成功");
                    btnClear_Click(sender, e);
                }
                else { MessageBoxCustom.Show("保存失败"); }
                return;
            }
        }
        /// <summary>
        /// 添加人员
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void btnAdding_Click(object sender, EventArgs e)
        {
            FrmAddContacts frm = new FrmAddContacts();
            //状态
            frm.Zhuangtai = "添加";
            if (frm.ShowDialog() == DialogResult.OK)
            {
                //返回一个用户Model
                Adddgvdata(frm.model);
            }
        }
        /// <summary>
        /// 将添加的人员放入DGV
        /// </summary>
        /// <param name="addmodel">人员的Model</param>
        void Adddgvdata(Model_ErpCustomer addmodel)
        {
            //人员信息的Model
            Model_ErpCustomer modelAdd = addmodel;
            //放入List
            GetModelList.Add(modelAdd);

            #region 赋值
            DataGridViewRow dgvr = new DataGridViewRow();
            DataGridViewCell cell = null;
            //姓名
            cell = new DataGridViewTextBoxCell();
            cell.Value = modelAdd.Cus_Name;
            dgvr.Cells.Add(cell);
            //手机号
            cell = new DataGridViewTextBoxCell();
            cell.Value = modelAdd.Cus_Telephone;
            dgvr.Cells.Add(cell);
            //QQ
            cell = new DataGridViewTextBoxCell();
            cell.Value = modelAdd.Cus_QQ;
            dgvr.Cells.Add(cell);
            //微信号
            cell = new DataGridViewTextBoxCell();
            cell.Value = modelAdd.Cus_MicroSignal;
            dgvr.Cells.Add(cell);
            //性别
            cell = new DataGridViewTextBoxCell();
            cell.Value = modelAdd.Cus_Sex == false ? "男" : "女";
            dgvr.Cells.Add(cell);
            //地区
            cell = new DataGridViewTextBoxCell();
            cell.Value = modelAdd.Cus_Region;
            dgvr.Cells.Add(cell);
            //地址
            cell = new DataGridViewTextBoxCell();
            cell.Value = modelAdd.Cus_Address;
            dgvr.Cells.Add(cell);
            //工作单位
            cell = new DataGridViewTextBoxCell();
            cell.Value = modelAdd.Cus_WorkUnit;
            dgvr.Cells.Add(cell);
            //生日
            cell = new DataGridViewTextBoxCell();
            cell.Value = modelAdd.Cus_Birthday;
            dgvr.Cells.Add(cell);
            //农历
            cell = new DataGridViewTextBoxCell();
            cell.Value = modelAdd.Cus_BirthdayLunar == "0" ? "公历" : "农历";
            dgvr.Cells.Add(cell);
            //固定电话
            cell = new DataGridViewTextBoxCell();
            cell.Value = modelAdd.Cus_FixedPhone;
            dgvr.Cells.Add(cell);
            //关系
            cell = new DataGridViewTextBoxCell();
            cell.Value = modelAdd.Cus_Relations;
            dgvr.Cells.Add(cell);
            //客户编号
            cell = new DataGridViewTextBoxCell();
            cell.Value = modelAdd.Cus_CustomerNumber;
            dgvr.Cells.Add(cell);
            #endregion
            //添加到dgv内,可做修改
            this.dgvData.Rows.Add(dgvr);
        }
        /// <summary>
        /// 清空
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void btnClear_Click(object sender, EventArgs e)
        {
            //姓名
            this.txtCus_Name.Text = "";
            this.txtCus_Address.Text = "";
            this.txtCus_Telephone.Text = "";
            this.txtCus_Birthday.StrValue = "";
            this.chkHQ_Lunar.Checked = false;
            this.txtCus_MicroSignal.Text = "";
            this.cmbCus_CustomerSource.Text = "";
            this.txtCus_QQ.Text = "";
            this.txtCus_Address.Text = "";
            this.txtCus_FixedPhone.Text = "";
            this.chkLKH.Checked = false;
            this.chkPYJS.Checked = false;
            this.chkQT.Checked = false;
            this.txtCus_WorkUnit.Text = "";
            this.cmbCus_Region.Text = "";
            this.cmbtreevlevel.TextFindTag("");
            this.txtHQ_Birthday.Text = "";
            this.chkHQ_Lunar.Checked = false;
            this.txtHistory_Money.Text = "";
            this.txtHistory_OrderTime.StrValue = "";
            this.txtHistory_Type.Text = "";
        }
        /// <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 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); }
        }
        /// <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>
        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 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 txtHistory_OrderTime_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>
        /// <returns></returns>
        public string _CustomerSource()
        {
            string GP_CustomerSource = "";
            if (this.chkLKH.Checked)
            { GP_CustomerSource = "老客户"; }
            else if (this.chkPYJS.Checked)
            { GP_CustomerSource = "朋友介绍"; }
            else if (this.chkQT.Checked)
            { GP_CustomerSource = this.cmbCus_CustomerSource.Text; }
            return GP_CustomerSource;
        }
    }
}