using LYFZ.Model.API; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; namespace LYFZ.Software.MainBusiness.DoorCityProcess.NewOrderCustomControls { public class UCustomerInfo:LYFZ.Software.UI.DoorCityProcess.NewOrderCustomControls.UCustomerInfo { public UCustomerInfo() { this.ucControlID = LYFZ.WinAPI.CustomPublicMethod.GenerateUniqueID(); if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OtherPermissionsSet, LYFZ.CustomAttributes.OperatingAuthority.ProhibitViewCustomerPhoneNumber) && !LYFZ.BLL.BLL_ErpUser.IsAdministrator()) { this.txtCusTelephone.PasswordChar = '*'; this.txtCusFixedPhone.PassChar = '*'; } this.Load += UCustomerInfo_Load; this.lbSetCusRelation.Click += LbSetCusRelation_Click; this.lbSetCusRegion.Click += LbSetCusRegion_Click; this.lbSetCusRegion.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.StoresOPenSingle, LYFZ.CustomAttributes.OperatingAuthority.OrderClientRegionSet); this.lbSetCusRelation.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.StoresOPenSingle, LYFZ.CustomAttributes.OperatingAuthority.OrderClientRelationSet); this.pictAddClient.Click += PictAddClient_Click; this.PictDelete.Click += PictDelete_Click; this.btnDial.Click += BtnDial_Click; this.btnQQCall.Click += BtnQQCall_Click; this.txtCusName.KeyUp += TxtCusName_KeyUp; this.txtCusTelephone.KeyUp += TxtCusTelephone_KeyUp; this.lbBtnSelectSameName.Click += LbBtnSelectSameName_Click; this.PictEdit.Click += PictEdit_Click; this.PictReset.Click += PictReset_Click; // this.txtCusTelephone.TextChanged += TxtCusTelephone_TextChanged; } /* private void TxtCusTelephone_TextChanged(object sender, EventArgs e) { TxtCusTelephone_KeyUp(null, null); }*/ private void PictReset_Click(object sender, EventArgs e) { this.ClearCustomerInfo(); this.txtTips.Hide(); } private void PictEdit_Click(object sender, EventArgs e) { if (this.isNewOrder) { this.txtCusName.ReadOnly = true; } else { this.txtCusName.ReadOnly = false; } this.txtCusTelephone.ReadOnly = false; } LYFZ.BLL.BLL_ErpCustomer customerBll = new BLL.BLL_ErpCustomer(); public UCustomerInfo(bool isMain) : this() { this.IsMainCustomer = isMain; if (isMain) { this.PictDelete.Hide(); } else { this.PictDelete.Show(); } } string ucControlID = ""; /// /// 当前控件ID /// public string UcControlID { get { return ucControlID; } } string tempStrWhere = ""; private void LbBtnSelectSameName_Click(object sender, EventArgs e) { string CusTelephone = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.MaskedTextBoxExGetText(this.txtCusTelephone); LYFZ.Software.MainBusiness.DoorCityProcess.SuperSmallForm.OrderHistoryCustomerSuperSmallForm frm = new SuperSmallForm.OrderHistoryCustomerSuperSmallForm(); frm.StrWhere = this.tempStrWhere; frm.ShowDialog(); if (frm.IsSaveed) { if (frm.model == null) { return; } if (frm.model.Cus_Telephone == null) { frm.model.Cus_Telephone = ""; } this.SetSelectCustomerInfo(frm.model); } } void SetSelectCustomerInfo(LYFZ.Model.Model_ErpCustomer model) { if (!string.IsNullOrEmpty(model.Cus_CustomerNumber.Trim())) { //判断是否有相同客户存在 bool IsSelectExist = this.ChkIsSelectExistCustomer(this.ucControlID, model.Cus_Telephone.Trim(), model.Cus_CustomerNumber); if (IsSelectExist) { this.panelTips.Visible = false; this.txtTips.Text = ""; this.txtCusTelephone.Text = ""; MessageBoxCustom.Show(String.Format("你选择的客户“{0}”在当前订单已存在,一个订单不能同时存在两个相同的客户", model.Cus_Name)); return; } } if (this.IsMainCustomer) { if (!this.AutoSelectionIntentionOrderCustomer(model.Cus_Telephone.Trim())) { this.SetCustomerInfo(model, ""); } } else { this.SetCustomerInfo(model, ""); } } /// /// 自动选择意向客户 /// /// bool AutoSelectionIntentionOrderCustomer(string _CusTelephone) { if (String.IsNullOrEmpty(_CusTelephone)) { return false; } DataRow row = customerBll.GetIntentionOrderCustomer(_CusTelephone.Trim()); if (row != null) { string IntentionOrderNumber = ""; string IntentionCustomerGroupID = ""; string IntentionCustomerID = ""; if (row["GP_OrderNumber"] != null) IntentionOrderNumber = row["GP_OrderNumber"].ToString(); if (row["GP_CustomerGroupID"] != null) IntentionCustomerGroupID = row["GP_CustomerGroupID"].ToString(); if (row["GM_CustomerID"] != null) IntentionCustomerID = row["GM_CustomerID"].ToString(); DialogResult digResult = MessageBoxCustom.Show(String.Format("根据您输入的手机号:'{0}' 在系统查找到有一个未完成的意向,您是否要对本意向进行完成订单?", _CusTelephone.Trim()), "温馨提示", MessageBoxButtons.YesNoCancel); if (digResult == DialogResult.Yes) { if (this.EventSelectIntentionOrderCustomer != null) { this.EventSelectIntentionOrderCustomer(this, IntentionOrderNumber, IntentionCustomerGroupID, IntentionCustomerID); } } else if (digResult == DialogResult.No && !String.IsNullOrEmpty(IntentionCustomerID)) { LYFZ.Model.Model_ErpCustomer modelClientModel = customerBll.GetModel("Cus_CustomerNumber", IntentionCustomerID); if (modelClientModel.ID > 0) { this.SetCustomerInfo(modelClientModel, ""); } else { txtCusTelephone.Text = _CusTelephone.Substring(0, _CusTelephone.Length - 1); txtCusTelephone.ForCharMaskedTextBox(); } } else { txtCusTelephone.Text = _CusTelephone.Substring(0, _CusTelephone.Length - 1); txtCusTelephone.ForCharMaskedTextBox(); } return true; } else { return false; } } public delegate void SelectIntentionOrderCustomer(UCustomerInfo uCustomer,string _IntentionOrderNumber,string _IntentionCustomerGroupID,string _IntentionCustomerID); /// /// 用event 关键字声明事件对象 /// [Category("控件扩展事件"), Description("自动加载意向订单客户")] public event SelectIntentionOrderCustomer EventSelectIntentionOrderCustomer; //临时客户电话 string tempCusTelephone = ""; void ChkTelephone(string _Telephone) { if (!string.IsNullOrEmpty(_Telephone.Trim())) { //判断是否有相同客户存在 bool IsSelectExist = this.ChkIsSelectExistCustomer(this.ucControlID, _Telephone.Trim(), ""); if (IsSelectExist) { this.txtCusTelephone.Text = ""; MessageBoxCustom.Show(String.Format("你输入的手机号“{0}”在当前订单已存在", _Telephone)); return; } } } private void TxtCusTelephone_KeyUp(object sender, KeyEventArgs e) { string CusTelephone = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.MaskedTextBoxExGetText(this.txtCusTelephone); this.ChkTelephone(CusTelephone); if (CusTelephone.ToLower().Trim() != this.tempCusTelephone.ToLower().Trim()) { this.tempCusTelephone = CusTelephone.Trim(); int cusCount = 0; if (CusTelephone.Trim().Length > 6) { if (CusTelephone.Length == 11) { this.tempStrWhere = String.Format("Cus_Telephone='{0}'", CusTelephone.Trim()); cusCount = customerBll.GetRecordCount(this.tempStrWhere); this.SetDuplicateNameTips(cusCount); bool isMessageBoxCustom = false; if (this.IsMainCustomer) { if (!this.AutoSelectionIntentionOrderCustomer(CusTelephone)) { isMessageBoxCustom = true; } } else { isMessageBoxCustom = true; } if (cusCount > 0 && isMessageBoxCustom) { if (MessageBoxCustom.Show("根据电话<" + CusTelephone + ">查找到" + cusCount.ToString() + "位相同客户,是否要加载此客户资料?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No) { txtCusTelephone.Text = CusTelephone.Substring(0, CusTelephone.Length - 1); txtCusTelephone.ForCharMaskedTextBox(); } else { if (cusCount == 1) { LYFZ.Model.Model_ErpCustomer modelClientModel = customerBll.GetModel("Cus_Telephone", CusTelephone.Trim()); this.SetSelectCustomerInfo(modelClientModel); } else { this.LbBtnSelectSameName_Click(this.lbBtnSelectSameName, null); } } } } else { this.tempStrWhere = String.Format("Cus_Telephone Like '{0}%'", CusTelephone.Trim()); cusCount = customerBll.GetRecordCount(this.tempStrWhere); this.SetDuplicateNameTips(cusCount); } } else { this.panelTips.Hide(); } } } void SetDuplicateNameTips(int count) { if (count > 0) { this.panelTips.Show(); this.txtTips.Text = String.Format("根据名字和电话查找到 {0} 个类似客户", count); } else { this.txtTips.Text = ""; this.panelTips.Hide(); } } //临时客户名 string tempCusName = ""; private void TxtCusName_KeyUp(object sender, KeyEventArgs e) { if (this.txtCusName.Text.ToLower().Trim() != this.tempCusName.ToLower().Trim()) { this.tempCusName = this.txtCusName.Text.Trim(); if (!String.IsNullOrEmpty(this.txtCusName.Text.Trim())) { string StrWhere = ""; string StrPhone = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.MaskedTextBoxExGetText(this.txtCusTelephone); if (StrPhone.Length >= 11) { StrWhere = " And Cus_Telephone Like '" + StrPhone.Trim() + "%'"; } this.tempStrWhere = String.Format("Cus_Name like '%{0}%' and Cus_Type != '儿童' {1}", this.txtCusName.Text.Trim(), StrWhere); int cusCount = customerBll.GetRecordCount(this.tempStrWhere); this.SetDuplicateNameTips(cusCount); } else { this.panelTips.Hide(); } } } /// /// 绑定客户信息 /// /// public void GetClientValueData(Api_ErpOrderModel erpModel) { string StrTelephone = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.MaskedTextBoxExGetText(this.txtCusTelephone); if (erpModel.customerData == null) { erpModel.customerData = new List(); } string cusAttrString = CusAttrType.Other_.ToString(); if (this.IsMainCustomer) { cusAttrString = CusAttrType.Man_.ToString(); } Api_CustomerModel apiModel = new Api_CustomerModel() { cusAttr = cusAttrString, ClientModel = new API_ClientDataModel(), cus_Type = "成人" }; apiModel.ClientModel.ID = this.currentCustomer.ID; apiModel.ClientModel.CusRelations = this.cmbtreevCusRelation.Text.Trim(); apiModel.ClientModel.CusAddress = this.txtCusAddress.Text.Trim(); apiModel.ClientModel.Cus_Birthday = this.maskBirthday.StrValue.Trim(); apiModel.ClientModel.Cus_BirthdayLunar = ""; apiModel.ClientModel.Cus_Zodiac = ""; if (apiModel.ClientModel.Cus_Birthday != "") { apiModel.ClientModel.Cus_BirthdayLunar = this.chkBirthday.Checked ? "1" : "0"; apiModel.ClientModel.Cus_Zodiac = LYFZ.Command.Command_CalendarTurnLunar.GetZodiac(apiModel.ClientModel.Cus_Birthday, this.chkBirthday.Checked); } apiModel.ClientModel.CusIDNumber = ""; // if (LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.EnabledIDNumber) // { apiModel.ClientModel.CusIDNumber = this.maskedIDNumber.StrValue; // } apiModel.ClientModel.Cus_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(this.txtCusName.Text.Trim()); apiModel.ClientModel.Cus_NamePinyin = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin(apiModel.ClientModel.Cus_Name.Trim()).ToLower(); apiModel.ClientModel.CusQQ = this.txtCusQQ.Text.Trim(); apiModel.ClientModel.CusRegion = this.cmbtreevCusRegion.Text.Trim(); apiModel.ClientModel.Cus_Sex = this.rdoCusSex1.Checked ? false : true; apiModel.ClientModel.CusTelephone = StrTelephone; apiModel.ClientModel.CusMicroSignal = this.txtMicroSignal.Text.Trim(); apiModel.ClientModel.CusWorkUnit = this.txtCusWorkUnit.Text.Trim(); apiModel.ClientModel.CusFixedPhone = this.txtCusFixedPhone.Text.Trim(); apiModel.userRelation = string.IsNullOrEmpty(this.cmbtreevCusRelation.Text.Trim()) ? "未知" : this.cmbtreevCusRelation.Text.Trim(); apiModel.ClientModel.CusRelations = string.IsNullOrEmpty(this.cmbtreevCusRelation.Text.Trim()) ? "未知" : this.cmbtreevCusRelation.Text.Trim(); erpModel.customerData.Add(apiModel); } /// /// 弹出QQ对话框 /// /// /// private void BtnQQCall_Click(object sender, EventArgs e) { LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.QQCall(this.txtCusQQ.Text.Trim()); } /// /// 拨打电话 /// /// /// private void BtnDial_Click(object sender, EventArgs e) { LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.PhoneCall(this.txtCusTelephone); } bool isChildCustomer = false; /// /// 是否为儿童版客户 /// public bool IsChildCustomer { get { return isChildCustomer; } set { isChildCustomer = value; } } bool isMainCustomer = true; /// /// 是否为主客户 /// public bool IsMainCustomer { get {return isMainCustomer; } set { isMainCustomer = value; } } /// /// 删除客户 /// /// /// public void PictDelete_Click(object sender, EventArgs e) { Control tempParentControl = this.Parent; this.Parent.Controls.Remove(this); RefreshParentHeight(tempParentControl); try { UCustomerInfo tempUcusInfo = GetLastUCustomerInfo(tempParentControl); tempUcusInfo.SetShowAddClient(true); } catch { } } /// /// 获取指定容器内的最后一个控件 /// /// /// static UCustomerInfo GetLastUCustomerInfo(Control control) { return (UCustomerInfo)control.Controls[control.Controls.Count - 1]; } int _UCustomerAddMaximum = 5; /// /// 可添加客户最大数 /// public int UCustomerAddMaximum { set { _UCustomerAddMaximum = value; } get { return _UCustomerAddMaximum; } } /// /// 新增客户控件 /// /// /// public void PictAddClient_Click(object sender, EventArgs e) { int tempCount = GetUCustomerCount(this.Parent); if (tempCount < this.UCustomerAddMaximum) { AddClientToParentControls(); RefreshParentHeight(this.Parent); } else { MessageBoxCustom.Show(String.Format("最多只能添加{0}个客户", this.UCustomerAddMaximum)); } } /// /// 添加客户控件并返回新加的控件对象 /// /// public UCustomerInfo AddClientToParentControls() { UCustomerInfo uCusInfo = new UCustomerInfo(false); uCusInfo.UCustomerAddMaximum = this.UCustomerAddMaximum; uCusInfo.isChildCustomer = this.IsChildCustomer; uCusInfo.AddClientToParentControls(this.Parent); this.SetShowAddClient(false); return uCusInfo; } private bool ChkIsSelectExistCustomer(string _ucControlID, string _Telephone, string cusNumber) { bool retBl = false; foreach (Control control in this.Parent.Controls) { if (control is UCustomerInfo) { UCustomerInfo tmpCus = (UCustomerInfo)control; if (tmpCus.UcControlID.ToLower() != _ucControlID.ToLower()) { if (!String.IsNullOrEmpty(cusNumber)) retBl = string.IsNullOrEmpty(tmpCus.CurrentCustomer.Cus_CustomerNumber)?false:tmpCus.CurrentCustomer.Cus_CustomerNumber.ToLower() == cusNumber.ToLower(); if (!retBl) { string CusTelephone = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.MaskedTextBoxExGetText(tmpCus.txtCusTelephone); if (!String.IsNullOrEmpty(CusTelephone)) retBl = CusTelephone.Trim().ToLower() == _Telephone.ToLower(); } } } } return retBl; } /// /// 添加到指定的容器中 /// /// public void AddClientToParentControls(Control control) { if (this.Parent == null) { this.SetUcusInfoText(String.Format("客户资料")); if (this.IsChildCustomer) { this.SetChildClientRelationText(); } else { this.SetClientRelationText(); } control.Controls.Add(this); } } /// /// 设置关系标题为宝宝 /// void SetChildClientRelationText() { this.SetClientRelationText(String.Format("与宝宝关系")); } /// /// 设置关系标题为客户 /// void SetClientRelationText() { this.SetClientRelationText(String.Format("与客户关系")); } /// /// 获取指定容器内 客户资料控件的个数 /// /// /// public int GetUCustomerCount(Control control) { int tempCount = 0; foreach (Control con in control.Controls) { if (con is UCustomerInfo) { tempCount++; } } return tempCount; } /// /// 刷新父容器高度 /// /// public static void RefreshParentHeight(Control control) { try { int tempIndex = 0; foreach (Control con in control.Controls) { if (con is UCustomerInfo) { tempIndex++; UCustomerInfo tempCus= (UCustomerInfo)con; if (!tempCus.IsMainCustomer) { tempCus.SetUcusInfoText(String.Format("第{0}联系人",tempIndex)); } } } UCustomerInfo tempUcusInfo = GetLastUCustomerInfo(control); control.Height = tempUcusInfo.Location.Y + tempUcusInfo.Height + 50; } catch (Exception ex) { MessageBoxCustom.Show(String.Format("父容器高度刷新出错:{0}", ex.Message)); } } /// /// 设置标题 /// /// public void SetUcusInfoText(string text) { this.lblClientText.Text = text; } /// /// 设置关系标题 /// /// public void SetClientRelationText(string text) { this.lblClientRelation.Text = text; } /// /// 刷新客户关系 /// void RefreshCusRelation() { foreach (Control control in this.Parent.Controls) { if (control is UCustomerInfo) { UCustomerInfo tmp = (UCustomerInfo)control; tmp.BindCusRelation(); } } } /// /// 刷新客户地区 /// void RefreshCusRegion() { foreach (Control control in this.Parent.Controls) { if (control is UCustomerInfo) { UCustomerInfo tmp = (UCustomerInfo)control; tmp.BindCusRegion(); } } } public delegate void UCustomerInfo_CusRelationSet(UCustomerInfo ucOBJ, ComponentLibrary.ComboBoxTreeViewEx cbxTreeView); /// /// 客户关系设置事件对象 /// [Category("控件扩展事件"), Description("客户关系设置")] public event UCustomerInfo_CusRelationSet CusRelationSet; public delegate void UCustomerInfo_CusRegionSet(UCustomerInfo ucOBJ, ComponentLibrary.ComboBoxTreeViewEx cbxTreeView); /// /// 客户地区设置事件 /// [Category("控件扩展事件"), Description("客户地区设置")] public event UCustomerInfo_CusRegionSet CusRegionSet; private void LbSetCusRegion_Click(object sender, EventArgs e) { LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet frm = new InitialSet.FrmSystemSet(); frm.TypeName = BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.客户地区).ToUpper(); frm.IsLoadAllCategory = false; if (frm.ShowDialog() == DialogResult.OK) { LoadAllSystemCategory(); if (this.CusRegionSet != null) { this.CusRegionSet(this,this.cmbtreevCusRegion); } RefreshCusRegion(); } } private void LbSetCusRelation_Click(object sender, EventArgs e) { LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet frm = new InitialSet.FrmSystemSet(); frm.TypeName = BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.客户关系).ToUpper(); frm.IsLoadAllCategory = false; if (frm.ShowDialog() == DialogResult.OK) { LoadAllSystemCategory(); if (this.CusRelationSet != null) { this.CusRelationSet(this, this.cmbtreevCusRelation); } RefreshCusRelation(); } } void LoadAllSystemCategory() { LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker) { LYFZ.BLL.WageStatisticsProcess.LoadAllSystemCategory(); }); } private void UCustomerInfo_Load(object sender, EventArgs e) { BindCusRelation(); BindCusRegion(); if (LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.EnabledIDNumber) { this.panelIDNumber.Show(); } else { this.panelIDNumber.Hide(); } } /// /// 设置显示隐藏客户关系 /// /// public void SetShowRelation(bool isShow) { if (isShow) { this.panelRelation.Show(); } else { this.panelRelation.Hide(); } } /// /// 设置显示隐藏客户添加按钮 /// /// public void SetShowAddClient(bool isShow) { if (isShow) { this.Height += 24; this.plAddKeFu.Show(); } else { this.plAddKeFu.Hide(); this.Height -= 24; } } /// /// 绑定客户关系 /// public void BindCusRelation() { FinancialManagement.frmEditStatisticsProgram.BindTreeView_SystemCategory(BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.客户关系).ToUpper(), this.cmbtreevCusRelation.TreeView, isExpandAll: false); } /// /// 绑定客户地区 /// public void BindCusRegion() { FinancialManagement.frmEditStatisticsProgram.BindTreeView_SystemCategory(BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.客户地区).ToUpper(), this.cmbtreevCusRegion.TreeView, isExpandAll: false); } LYFZ.Model.Model_ErpCustomerGroup currentCustomerGroup = new Model.Model_ErpCustomerGroup(); /// /// 当前客户组 /// public LYFZ.Model.Model_ErpCustomerGroup CurrentCustomerGroup { get { return currentCustomerGroup; } } LYFZ.Model.Model_ErpCustomerGroupMembers currentGroupMember = new Model.Model_ErpCustomerGroupMembers(); /// /// 当前客户成员数据 /// public LYFZ.Model.Model_ErpCustomerGroupMembers CurrentGroupMember { get { return currentGroupMember; } } LYFZ.Model.Model_ErpCustomer currentCustomer = new Model.Model_ErpCustomer(); /// /// 当前客户 /// public LYFZ.Model.Model_ErpCustomer CurrentCustomer { get { return currentCustomer; } } /// /// 清空客户信息 /// public void ClearCustomerInfo() { this.currentCustomerGroup = new Model.Model_ErpCustomerGroup(); this.currentGroupMember = new Model.Model_ErpCustomerGroupMembers(); this.currentCustomer = new Model.Model_ErpCustomer(); this.txtCusName.Text = ""; this.rdoCusSex2.Checked = true; this.maskBirthday.StrValue = ""; this.chkBirthday.Checked = false; this.cmbtreevCusRelation.Text = ""; this.cmbtreevCusRegion.Text = ""; this.cmbtreevCusRelation.Tag = ""; this.txtCusTelephone.Text = ""; this.txtCusQQ.Text = ""; this.txtCusFixedPhone.Text = ""; this.txtCusWorkUnit.Text = ""; this.txtCusAddress.Text = ""; this.maskedIDNumber.Text = ""; this.txtCusName.ReadOnly = false; this.txtCusTelephone.ReadOnly = false; } /// /// 是否为新开订单 /// bool isNewOrder = true; /// /// 设置客户资料 /// /// /// /// public void SetCustomerInfo(LYFZ.Model.Model_ErpCustomerGroup customerGroup, LYFZ.Model.Model_ErpCustomerGroupMembers groupMember, LYFZ.Model.Model_ErpCustomer customer) { this.isNewOrder = false; this.currentCustomerGroup = customerGroup; this.currentGroupMember = groupMember; this.SetCustomerInfo(customer, groupMember.GM_Relation); } public void SetCustomerInfo(LYFZ.Model.Model_ErpCustomer customer,string relation) { this.txtCusName.ReadOnly = true; this.txtCusTelephone.ReadOnly = true; this.currentCustomer = customer; if (customer == null) { return; } this.txtCusName.Text = customer.Cus_Name; if (customer.Cus_Sex) { this.rdoCusSex2.Checked = true; } else { this.rdoCusSex1.Checked = true; } this.maskBirthday.StrValue = customer.Cus_Birthday; this.chkBirthday.Checked = LYFZ.Command.Command_Validate.DateLunar(customer.Cus_BirthdayLunar); this.cmbtreevCusRelation.TextFindTag(relation); this.cmbtreevCusRegion.TextFindTag(customer.Cus_Region); this.txtCusTelephone.Text = customer.Cus_Telephone; this.txtCusQQ.Text = customer.Cus_QQ; this.txtCusFixedPhone.Text = customer.Cus_FixedPhone; this.txtCusWorkUnit.Text = customer.Cus_WorkUnit; this.txtCusAddress.Text = customer.Cus_Address; this.maskedIDNumber.Text = customer.Cus_IDNumber; this.txtMicroSignal.Text = customer.Cus_MicroSignal; } /// /// 设置客户资料 /// /// public void SetHospitalClientValue(LYFZ.Model.Model_ErpHospitalClient model) { this.ClearCustomerInfo(); if (model != null) { this.txtCusAddress.Text = model.Hct_HomeAddress; this.chkBirthday.Checked = false; this.txtCusName.Text = model.Hct_CustomerName; this.txtCusQQ.Text = model.Hct_QQ; this.cmbtreevCusRegion.Text = model.Hct_CustomerRegions; this.rdoCusSex2.Checked = true; this.txtCusTelephone.Text = model.Hct_MyselfMobile; this.txtCusFixedPhone.Text = model.Hct_FamilyPhone; this.TxtCusTelephone_KeyUp(null,null); } } /// /// 设置老客户信息 /// /// /// 主要客户联系人的客户编号 public void SetOldCustomerInfo(List cusList, string mainClientNumber) { this.ClearCustomerInfo(); List tempCusList = cusList.FindAll(c => c.Cus_Type != "儿童"||!String.IsNullOrEmpty(c.Cus_Telephone)); if (tempCusList != null) { if (tempCusList.Count > 0) { LYFZ.Model.Model_ErpCustomer mainTempCus = cusList.Find(c => c.Cus_CustomerNumber.ToLower() == mainClientNumber.ToLower()); if (mainTempCus == null || mainTempCus.ID <= 0) { mainTempCus = tempCusList[0]; } this.SetCustomerInfo(mainTempCus, ""); //其它联系人 UCustomerInfo newCusInfo = null; foreach (LYFZ.Model.Model_ErpCustomer cus in tempCusList) { if (cus.Cus_CustomerNumber.ToLower() != mainTempCus.Cus_CustomerNumber.ToLower()) { if (newCusInfo == null) { newCusInfo = this.AddClientToParentControls(); } else { newCusInfo = newCusInfo.AddClientToParentControls(); } UCustomerInfo.RefreshParentHeight(this.Parent); newCusInfo.SetCustomerInfo(cus, ""); } } } } } } }