using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; using LYFZ.ComponentLibrary; using LYFZ.Model.API; namespace LYFZ.Software.MainBusiness.DoorCityProcess.SetCustomControls { public partial class OrderClientParentsControlsEx : LYFZ.Software.UI.DoorCityProcess.SetCustomControls.OrderClientParentsControlsEx { LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder(); LYFZ.BLL.BLL_ErpCustomer ctbll = new BLL.BLL_ErpCustomer(); LYFZ.BLL.BLL_ErpSystemCategory scbll = new BLL.BLL_ErpSystemCategory(); bool IsShowPhone = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OtherPermissionsSet, LYFZ.CustomAttributes.OperatingAuthority.ProhibitViewCustomerPhoneNumber); public OrderClientParentsControlsEx() { if (this.IsShowPhone && !LYFZ.BLL.BLL_ErpUser.IsAdministrator()) { this.txtCusTelephone.PasswordChar = '*'; this.txtCusFixedPhone.PassChar = '*'; } this.PictEdit.Click += PictEdit_Click; this.PictReset.Click += PictReset_Click; this.PictDelete.Click += PictDelete_Click; this.btnTips.Click += btnTips_Click; this.btnDial.Click += btnDial_Click; this.btnQQCall.Click += btnQQCall_Click; this.btnSet.Click += btnSet_Click; this.btnSetRegion.Click += btnSetRegion_Click; this.txtCusName.EventTextBoxEx_TextChanged += txtCusName_EventTextBoxEx_TextChanged; this.txtCusName.KeyDown += txtCusName_KeyDown; this.txtCusTelephone.TextChanged += txtCusTelephone_TextChanged; this.txtCusTelephone.Leave += txtCusTelephone_Leave; this.txtCusTelephone.KeyDown += txtCusTelephone_KeyDown; this.txtCusAddress.KeyPress += txtCusAddress_KeyPress; this.txtCusFixedPhone.KeyPress += txtCusFixedPhone_KeyPress; this.txtCusName.KeyPress += txtCusName_KeyPress; this.txtCusQQ.KeyPress += txtCusQQ_KeyPress; this.txtCusWorkUnit.KeyPress += txtCusWorkUnit_KeyPress; // 权限 this.btnSetRegion.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.StoresOPenSingle, LYFZ.CustomAttributes.OperatingAuthority.OrderClientRegionSet); this.btnSet.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.StoresOPenSingle, LYFZ.CustomAttributes.OperatingAuthority.OrderClientRelationSet); this.panelIDNumber.Visible = LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.EnabledIDNumber; LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_ClientRelation("BFABDBAJBJCEBDJCJ", this.cmbtreevCusRelation); LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_ClientRelation("AAAAAAC", this.cmbtreevCusRegion, true); } /// /// 是否是修改订单(从订单报表、保存后这里都会为true) /// public bool IsUpdateOrderLoad = false; public delegate void OrderClientParents_PictDeleteClick(LYFZ.Software.MainBusiness.DoorCityProcess.SetCustomControls.OrderClientParentsControlsEx senderEx); /// /// 用event 关键字声明事件对象 /// [Category("控件扩展事件"), Description("删除客户")] public event OrderClientParents_PictDeleteClick DeleteClick; /// /// 删除事件 /// /// /// private void PictDelete_Click(object sender, EventArgs e) { if (this.DeleteClick != null) { if (MessageBoxCustom.Show("你确定要删除吗!", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No) { return; } this.DeleteClick(this); this.Parent.Controls.Remove(this); } } /// /// 重置 /// /// /// private void PictReset_Click(object sender, EventArgs e) { if (MessageBoxCustom.Show("重置后数据将会清空,您确定要重置吗?", "温馨提示", MessageBoxButtons.YesNo) != DialogResult.No) { this.SetClientValue(null); this.IsPictEditShow = false; this.IsPictResetShow = false; } } /// /// 编辑 /// /// /// private void PictEdit_Click(object sender, EventArgs e) { this.SetClientEdit(this.IsUpdateOrderLoad); } public delegate string OrderClientParents_IsExistClient(string StrControlsName, string StrClientNumber); /// /// 用event 关键字声明事件对象 /// [Category("控件扩展事件"), Description("提示详情")] public event OrderClientParents_IsExistClient IsExistClient; /// /// 提示详情 /// /// /// void btnTips_Click(object sender, EventArgs e) { string StrPhone = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.MaskedTextBoxExGetText(this.txtCusTelephone); LYFZ.Software.MainBusiness.DoorCityProcess.SuperSmallForm.OrderHistoryCustomerSuperSmallForm frm = new SuperSmallForm.OrderHistoryCustomerSuperSmallForm(); if (this.txtCusName.Text.Trim().Length > 0 && StrPhone.Length > 0) { frm.StrWhere = "Cus_Telephone Like '" + StrPhone.Trim() + "%' And Cus_Name like '%" + this.txtCusName.Text.Trim() + "%' and Cus_Type != '儿童'"; } else if (this.txtCusName.Text.Trim().Length > 0 && StrPhone.Length <= 0) { frm.StrWhere = "Cus_Name like '%" + this.txtCusName.Text.Trim() + "%' and Cus_Type != '儿童'"; } else if (this.txtCusName.Text.Trim().Length <= 0 && StrPhone.Length > 0) { frm.StrWhere = "Cus_Telephone Like '" + StrPhone.Trim() + "%'"; } //if (!Convert.ToBoolean(this.btnTips.Tag)) //{ // string StrPhone = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.MaskedTextBoxExGetText(this.txtCusTelephone); // frm.StrWhere = "Cus_Telephone Like '" + StrPhone.Trim() + "%'"; //} //else //{ frm.StrWhere = " Cus_Name like '%" + this.txtCusName.Text.Trim() + "%' and Cus_Type != '儿童'"; } frm.ShowDialog(); if (frm.IsSaveed) { if (this.IsExistClient != null && !string.IsNullOrEmpty(frm.model.Cus_CustomerNumber.Trim())) { //判断是否有相同客户存在 string StrTitleName = this.IsExistClient(this.Name.Trim(), frm.model.Cus_CustomerNumber); if (!string.IsNullOrEmpty(StrTitleName)) { this.panelTips.Visible = false; this.txtTips.Text = ""; MessageBoxCustom.Show("你选择的客户在" + StrTitleName + "已存在,一个订单不能同时存在两个相同的客户"); return; } } //获取选择的客户是否存在意向订单 DataTable tbl = orbll.GetView_Custom("View_CustomerGroupAndCustomerGroupMembersAndErpCustomer", StrWhere: "GP_GroupType = '2' and Cus_CustomerNumber = '" + frm.model.Cus_CustomerNumber + "'", ShowColumnName: "GP_CustomerGroupID", GroupBy: "GP_CustomerGroupID,GP_OrderNumber").Tables[0]; if (tbl.Rows.Count > 0) { //如果只存在一个意向订单,那么就直接提示是否要获取 if (tbl.Rows.Count == 1) { DataTable tblOrderNumber = orbll.GetView_Custom("tb_ErpCustomerGroup", StrWhere: "GP_CustomerGroupID = '" + tbl.Rows[0]["GP_CustomerGroupID"].ToString().Trim() + "'", ShowColumnName: "GP_OrderNumber").Tables[0]; if (tblOrderNumber.Rows[0]["GP_OrderNumber"].ToString().Trim() != "") { if (MessageBoxCustom.Show("根据你选择的客户:'" + frm.model.Cus_Name.Trim() + "' 电话:'" + frm.model.Cus_Telephone + "' 系统查找到'" + frm.model.Cus_Name.Trim() + "'有一个未完成的意向订单,您是否要对意向订单进行完成订单?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (this.UpdateOrderGroup != null) { this.UpdateOrderGroup("OrderNumber|" + tblOrderNumber.Rows[0]["GP_OrderNumber"].ToString().Trim()); } } } else { if (!lblClientName.Text.Contains("其他联系人")) { if (MessageBoxCustom.Show("根据你选择的客户:'" + frm.model.Cus_Name.Trim() + "' 电话:'" + frm.model.Cus_Telephone + "' 系统查找到'" + frm.model.Cus_Name.Trim() + "'有一个未完成的意向客户组,您是否要对意向客户组进行完成订单?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (this.UpdateOrderGroup != null) { this.UpdateOrderGroup("ClientGroup|" + tbl.Rows[0]["GP_CustomerGroupID"].ToString().Trim()); } } } } } else { LYFZ.Software.MainBusiness.DoorCityProcess.SuperSmallForm.SelectIntentClientSuperSmallForm frmIntent = new SuperSmallForm.SelectIntentClientSuperSmallForm(); frmIntent.StrInputClientName = frm.model.Cus_Name.Trim(); frmIntent.tblOrderGroup = tbl; frmIntent.ShowDialog(); if (!frmIntent.IsSaveed) { return; } if (!string.IsNullOrEmpty(frmIntent.SelectOrderNumber)) { this.UpdateOrderGroup("IntentClient|" + tbl.Rows[0]["GP_OrderNumber"].ToString().Trim() + "," + tbl.Rows[0]["GP_CustomerGroupID"].ToString().Trim()); } else { if (this.UpdateOrderGroup != null) { if (!lblClientName.Text.Contains("其他联系人")) { this.UpdateOrderGroup("ClientGroup|" + tbl.Rows[0]["GP_CustomerGroupID"].ToString().Trim()); } } } } } this.SetClientValue(frm.model, true); this.IsPictResetShow = true; this.IsPictEditShow = true; } } /// /// 拨打电话 /// /// /// void btnDial_Click(object sender, EventArgs e) { LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.PhoneCall(this.txtCusTelephone); } /// /// QQ呼叫 /// /// /// void btnQQCall_Click(object sender, EventArgs e) { LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.QQCall(this.txtCusQQ.Text.Trim()); } public delegate void OrderClientParents_RelationSet(object obj); /// /// 用event 关键字声明事件对象 /// [Category("控件扩展事件"), Description("关系设置")] public event OrderClientParents_RelationSet RelationSet; /// /// 设置 /// /// /// void btnSet_Click(object sender, EventArgs e) { LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet frm = new InitialSet.FrmSystemSet(); frm.TypeName = "BFABDBAJBJCEBDJCJ"; frm.Version = "Version"; if (frm.ShowDialog() == DialogResult.OK) { if (this.RelationSet != null) { this.RelationSet(this.cmbtreevCusRelation); } else { LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_ClientRelation("BFABDBAJBJCEBDJCJ", this.cmbtreevCusRelation); } } } public delegate void OrderClientParents_RegionSet(object obj); /// /// 用event 关键字声明事件对象 /// [Category("控件扩展事件"), Description("地区设置")] public event OrderClientParents_RegionSet RegionSet; /// /// 地区设置 /// /// /// void btnSetRegion_Click(object sender, EventArgs e) { LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet frm = new InitialSet.FrmSystemSet(); frm.TypeName = "AAAAAAC"; frm.Version = "Version"; if (frm.ShowDialog() == DialogResult.OK) { if (this.RegionSet != null) { this.RegionSet(this.cmbtreevCusRegion); } else { LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_ClientRelation("AAAAAAC", this.cmbtreevCusRegion, true); } } } /// /// 姓名输入事件——模糊查询 /// /// /// void txtCusName_EventTextBoxEx_TextChanged(object sender, EventArgs e) { if (this.IsTextChanged) { this.txtCusName.Tag = ""; this.txtTips.Text = ""; this.panelTips.Visible = false; if (this.txtCusName.Text.Trim() != "") { string StrWhere = ""; string StrPhone = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.MaskedTextBoxExGetText(this.txtCusTelephone); if (StrPhone.Length > 0) { StrWhere = " And Cus_Telephone Like '" + StrPhone.Trim() + "%'"; } DataTable tbl = ctbll.GetListCustomer("Cus_Name", "Cus_Name like '" + this.txtCusName.Text.Trim() + "%' and Cus_Type != '儿童'" + StrWhere).Tables[0]; if (tbl.Rows.Count > 0) { this.btnTips.Tag = true; this.panelTips.Visible = true; this.txtTips.Text = "找到类似客户:" + tbl.Rows.Count + " (根据名字和电话查找)"; } } } } /// /// 姓名输入后回车 /// /// /// void txtCusName_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (this.btnTips.Visible) { this.btnTips_Click(this, null); } } } public delegate void OrderClientParents_UpdateOrderGroup(object obj); /// /// 用event 关键字声明事件对象 /// [Category("控件扩展事件"), Description("地区设置")] public event OrderClientParents_UpdateOrderGroup UpdateOrderGroup; /// /// 电话输入事件——模糊查询 /// /// /// void txtCusTelephone_TextChanged(object sender, EventArgs e) { if (this.IsTextChanged) { this.panelTips.Visible = false; this.txtTips.Text = ""; string CusTelephone = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.MaskedTextBoxExGetText(this.txtCusTelephone); if (CusTelephone != "" && CusTelephone.Trim().Length > 6) { if (CusTelephone.Length == 11) { DataTable dtRow = orbll.GetView_Custom("tb_ErpCustomer", StrWhere: "Cus_Telephone Like '" + CusTelephone + "%'", ShowColumnName: "ID, Cus_CustomerNumber, Cus_Telephone, Cus_Name").Tables[0]; if (dtRow.Rows.Count > 0) { DataTable tbl = orbll.GetView_Custom("View_CustomerGroupAndCustomerGroupMembersAndErpCustomer", StrWhere: "GP_GroupType = '2' and Cus_CustomerNumber = '" + dtRow.Rows[0]["Cus_CustomerNumber"].ToString().Trim() + "'", ShowColumnName: "GP_CustomerGroupID", GroupBy: "GP_CustomerGroupID").Tables[0]; if (tbl.Rows.Count > 0) { DataTable tblOrderNumber = orbll.GetView_Custom("tb_ErpCustomerGroup", StrWhere: "GP_CustomerGroupID = '" + tbl.Rows[0]["GP_CustomerGroupID"].ToString().Trim() + "'", ShowColumnName: "GP_OrderNumber").Tables[0]; if (tblOrderNumber.Rows[0]["GP_OrderNumber"].ToString().Trim() != "") { DialogResult dirst = MessageBoxCustom.Show("根据你选择的客户:'" + dtRow.Rows[0]["Cus_Name"].ToString().Trim() + "' 电话:'" + dtRow.Rows[0]["Cus_Telephone"].ToString().Trim() + "' 系统查找到'" + dtRow.Rows[0]["Cus_Name"].ToString().Trim() + "'有一个未完成的意向订单,您是否要对意向订单进行完成订单?", "温馨提示", MessageBoxButtons.YesNoCancel); if (dirst == DialogResult.Yes) { this.IsPictResetShow = true; this.IsPictEditShow = true; if (this.UpdateOrderGroup != null) { this.UpdateOrderGroup("OrderNumber|" + tblOrderNumber.Rows[0]["GP_OrderNumber"].ToString().Trim()); } } else if (dirst == DialogResult.No) { LYFZ.Model.Model_ErpCustomer modelClientModel = ctbll.GetModel(Convert.ToInt32(dtRow.Rows[0]["ID"].ToString().Trim())); this.SetClientValue(modelClientModel); this.SetClientEdit(false); } else { txtCusTelephone.Text = CusTelephone.Substring(0, CusTelephone.Length - 1); txtCusTelephone.ForCharMaskedTextBox(); } } else { if (!lblClientName.Text.Contains("其他联系人")) { DialogResult dirst = MessageBoxCustom.Show("根据你选择的客户:'" + dtRow.Rows[0]["Cus_Name"].ToString().Trim() + "' 电话:'" + dtRow.Rows[0]["Cus_Telephone"].ToString().Trim() + "' 系统查找到'" + dtRow.Rows[0]["Cus_Name"].ToString().Trim() + "'有一个未完成的意向客户组,您是否要对意向客户组进行完成订单?", "温馨提示", MessageBoxButtons.YesNoCancel); if (dirst == DialogResult.Yes) { LYFZ.Model.Model_ErpCustomer modelClientModel = ctbll.GetModel(Convert.ToInt32(dtRow.Rows[0]["ID"].ToString().Trim())); this.SetClientValue(modelClientModel, true); this.IsPictResetShow = true; this.IsPictEditShow = true; if (this.UpdateOrderGroup != null) { this.UpdateOrderGroup("ClientGroup|" + tbl.Rows[0]["GP_CustomerGroupID"].ToString().Trim()); } } else if (dirst == DialogResult.No) { LYFZ.Model.Model_ErpCustomer modelClientModel = ctbll.GetModel(Convert.ToInt32(dtRow.Rows[0]["ID"].ToString().Trim())); this.SetClientValue(modelClientModel); this.SetClientEdit(false); } else { txtCusTelephone.Text = CusTelephone.Substring(0, CusTelephone.Length - 1); txtCusTelephone.ForCharMaskedTextBox(); } } } } else { if (MessageBoxCustom.Show("根据电话<" + CusTelephone + ">查找到1位相同客户,是否要加载此客户资料?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No) { txtCusTelephone.Text = CusTelephone.Substring(0, CusTelephone.Length - 1); txtCusTelephone.ForCharMaskedTextBox(); } else { LYFZ.Model.Model_ErpCustomer modelClientModel = ctbll.GetModel(Convert.ToInt32(dtRow.Rows[0]["ID"].ToString().Trim())); this.SetClientValue(modelClientModel); this.PictEdit.Tag = true; this.SetClientEdit(false); this.IsPictResetShow = true; this.IsPictEditShow = true; } } } } else { string StrWhere = ""; if (this.txtCusName.Text.Trim().Length > 0) { StrWhere = " And Cus_Name like '%" + this.txtCusName.Text.Trim() + "%' and Cus_Type != '儿童'"; } DataTable dt = orbll.GetView_Custom("tb_ErpCustomer", StrWhere: "Cus_Telephone Like '" + CusTelephone + "%'" + StrWhere, ShowColumnName: "Count(ID) AS CountID").Tables[0]; if (Convert.ToInt32(dt.Rows[0]["CountID"]) > 0) { this.btnTips.Tag = true; this.panelTips.Visible = true; this.txtTips.Text = "找到类似客户:" + dt.Rows[0]["CountID"].ToString().Trim() + " (根据电话查找)"; } } } } } public delegate void OrderClientParents_PhoneLeave(object objForm); /// /// 用event 关键字声明事件对象 /// [Category("控件扩展事件"), Description("地区设置")] public event OrderClientParents_PhoneLeave PhoneLeave; /// /// 电话号码离开事件 /// /// /// void txtCusTelephone_Leave(object sender, EventArgs e) { if (this.PhoneLeave != null) { this.PhoneLeave(this); } } /// /// 电话输入后回车 /// /// /// void txtCusTelephone_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (this.btnTips.Visible) { this.btnTips_Click(this, null); } } } #region 输入限制 /// /// 地址输入限制 /// /// /// void txtCusAddress_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; } } /// /// 固定输入限制 /// /// /// void txtCusFixedPhone_KeyPress(object sender, KeyPressEventArgs e) { if (Convert.ToString(e.KeyChar) == "-") { } else if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar)) { e.Handled = true; } } /// /// 姓名输入限制 /// /// /// void txtCusName_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; } } /// /// QQ输入限制 /// /// /// void txtCusQQ_KeyPress(object sender, KeyPressEventArgs e) { if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar)) { e.Handled = true; } } /// /// 工作单位输入限制 /// /// /// void txtCusWorkUnit_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; } } #endregion #region 属性 /// /// 电话号码和姓名值变化是否进入 /// private bool IsTextChanged = true; private string _strClientAttribute; /// /// 客户属性 /// public string StrClientAttribute { get { return _strClientAttribute; } set { _strClientAttribute = value; } } private string _lblClientName; /// /// 标题 /// public string LblClientName { get { return _lblClientName; } set { _lblClientName = value; this.lblClientName.Text = this._lblClientName; } } private bool _isPictDeleteShow; /// /// 是否显示移除客户控件 /// public bool IsPictDeleteShow { get { return _isPictDeleteShow; } set { _isPictDeleteShow = value; this.PictDelete.Visible = _isPictDeleteShow; } } private bool _isPictEdit; /// /// 是否显示编辑 /// public bool IsPictEditShow { get { return _isPictEdit; } set { _isPictEdit = value; this.PictEdit.Visible = _isPictEdit; } } private bool _isPictResetShow; /// /// 重置 /// public bool IsPictResetShow { get { return _isPictResetShow; } set { _isPictResetShow = value; this.PictReset.Visible = _isPictResetShow; } } private bool _isShowRelation; /// /// 是否显示关系 /// public bool IsShowRelation { get { return _isShowRelation; } set { _isShowRelation = value; if (_isShowRelation) { this.panelRelation.Visible = true; } else { this.panelRelation.Visible = false; } } } private string _lblRelationText; /// /// 关系的名称 /// public string LblRelationText { get { return _lblRelationText; } set { _lblRelationText = value; this.lblClientRelation.Text = this._lblRelationText; } } private LYFZ.Model.Model_ErpCustomer _modelCilent; /// /// 当前的选择的客户资料 /// public LYFZ.Model.Model_ErpCustomer modelCilent { get { return _modelCilent; } set { _modelCilent = value; } } /// /// 电话号码符号 /// /// public void isShowPhoneSymbol(bool IsValue) { this.labelEx13.Visible = IsValue; } private string _strClientPhone; /// /// 客户电话 /// public string StrClientPhone { get { _strClientPhone = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.MaskedTextBoxExGetText(this.txtCusTelephone); return _strClientPhone; } set { _strClientPhone = value; this.txtCusTelephone.Text = _strClientPhone; this.modelCilent = null; } } private ComboBoxTreeViewEx _cmbtreevRelation; /// /// 客户关系 /// public ComboBoxTreeViewEx CmbtreevRelation { get { _cmbtreevRelation = this.cmbtreevCusRelation; return _cmbtreevRelation; } set { _cmbtreevRelation = value; this.cmbtreevCusRelation = _cmbtreevRelation; } } private ComboBoxTreeViewEx _cmbtreevRegion; /// /// 客户地区 /// public ComboBoxTreeViewEx CmbtreevRegion { get { _cmbtreevRegion = this.cmbtreevCusRegion; return _cmbtreevRegion; } set { _cmbtreevRegion = value; this.cmbtreevCusRegion = _cmbtreevRegion; } } #endregion /// /// 绑定客户信息 /// /// /// public void GetClientValueData(Api_ErpOrderModel erpModel, ref string MainClientRelation) { string StrTelephone = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.MaskedTextBoxExGetText(this.txtCusTelephone); if (erpModel.customerData == null) { erpModel.customerData = new List(); } Api_CustomerModel apiModel = new Api_CustomerModel() { cusAttr = this.StrClientAttribute, ClientModel = new API_ClientDataModel(), cus_Type = "成人" }; LYFZ.Software.MainBusiness.DoorCityProcess.SetCustomControls.ClientModel model = new ClientModel(); if (this.modelCilent != null) { model.ID = this.modelCilent.ID; } else { model.ID = -1; } //if (this.panelRelation.Visible) //{ // if (this.cmbtreevCusRelation.Text.Trim() == "") // { MessageBoxCustom.Show(this.lblClientName.Text + this.lblClientRelation.Text.Trim() + "不能为空!"); return null; } // model.CusRelations = this.cmbtreevCusRelation.Text.Trim(); //} //else //{ model.CusRelations = ""; } apiModel.ClientModel.ID = model.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(model.CusBirthday, 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()); model.CusName = apiModel.ClientModel.Cus_Name; apiModel.ClientModel.Cus_NamePinyin = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin(model.CusName.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(); /*if (MainClientRelation == "") { MainClientRelation = this.cmbtreevCusRelation.Text.Trim(); }*/ if (MainClientRelation == "" && this.IsShowRelation) { MainClientRelation = this.cmbtreevCusRelation.Text.Trim(); if (string.IsNullOrEmpty(MainClientRelation)) { if (cmbtreevCusRelation.Nodes.Count>0) { MainClientRelation = cmbtreevCusRelation.Nodes[0].Text; } else { MainClientRelation = "未知"; //ExMessageBoxCustom.Show("客户关系无数据,不可保存,请添加客户关系!!"); } } } if (this.IsShowRelation) { 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); } /// /// 获取客户资料 /// public LYFZ.Software.MainBusiness.DoorCityProcess.SetCustomControls.ClientModel GetClientValue(ref string MainClientRelation) { int intMasse = this.maskBirthday.CheckDateValue(this.maskBirthday, this.chkBirthday); if (intMasse == 1) { MessageBoxCustom.Show(this.lblClientName.Text + "生日日期格式输入错误!"); return null; } else if (intMasse == 2) { MessageBoxCustom.Show(this.lblClientName.Text + "生日:" + this.maskBirthday.StrValue.Trim() + "不是公历日期,若要保存请勾上农历!"); return null; } if (this.txtCusName.Text.Trim() == "") { MessageBoxCustom.Show(this.lblClientName.Text + "姓名不能为空!"); return null; } string StrTelephone = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.MaskedTextBoxExGetText(this.txtCusTelephone); if (StrTelephone == this.txtCusFixedPhone.Text.Trim()) { if (!string.IsNullOrEmpty(this.txtCusFixedPhone.Text.Trim()) && !string.IsNullOrEmpty(StrTelephone)) { MessageBoxCustom.Show(this.lblClientName.Text + "手机号与固定电话不能一样!"); this.txtCusTelephone.Text = ""; return null; } } if (this.StrClientAttribute == "Man_") { if (string.IsNullOrEmpty(StrTelephone)) { MessageBoxCustom.Show(this.lblClientName.Text + "手机号不能为空!"); return null; } else { if (StrTelephone.Length != 11) { MessageBoxCustom.Show(this.lblClientName.Text + "手机号长度不足11位!"); return null; } } } LYFZ.Software.MainBusiness.DoorCityProcess.SetCustomControls.ClientModel model = new ClientModel(); if (this.modelCilent != null) { model.ID = this.modelCilent.ID; } else { model.ID = -1; } //if (this.panelRelation.Visible) //{ // if (this.cmbtreevCusRelation.Text.Trim() == "") // { MessageBoxCustom.Show(this.lblClientName.Text + this.lblClientRelation.Text.Trim() + "不能为空!"); return null; } // model.CusRelations = this.cmbtreevCusRelation.Text.Trim(); //} //else //{ model.CusRelations = ""; } model.CusRelations = this.cmbtreevCusRelation.Text.Trim(); model.CusAddress = this.txtCusAddress.Text.Trim(); model.CusBirthday = this.maskBirthday.StrValue.Trim(); model.CusBirthdayLunar = ""; model.CusZodiac = ""; if (model.CusBirthday != "") { model.CusBirthdayLunar = this.chkBirthday.Checked ? "1" : "0"; model.CusZodiac = LYFZ.Command.Command_CalendarTurnLunar.GetZodiac(model.CusBirthday, this.chkBirthday.Checked); } model.CusIDNumber = ""; if (LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.EnabledIDNumber) { model.CusIDNumber = this.maskedIDNumber.StrValue; } model.CusName = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(this.txtCusName.Text.Trim()); model.CusNamePinyin = LYFZ.Command.Command_ChineseToPinyin.GetChineseSpellPinyin(model.CusName.Trim()).ToLower(); model.CusQQ = this.txtCusQQ.Text.Trim(); model.CusRegion = this.cmbtreevCusRegion.Text.Trim(); model.CusSex = this.rdoCusSex1.Checked ? false : true; model.CusTelephone = StrTelephone; model.CusMicroSignal = this.txtMicroSignal.Text.Trim(); model.CusWorkUnit = this.txtCusWorkUnit.Text.Trim(); model.CusFixedPhone = this.txtCusFixedPhone.Text.Trim(); if (MainClientRelation == "") { MainClientRelation = this.cmbtreevCusRelation.Text.Trim(); } return model; } /// /// 设置客户资料 /// /// public void SetClientValue(LYFZ.Model.Model_ErpCustomer model, bool IsReadOnly = false, string MainClientRelation = "") { this.IsTextChanged = false; if (model == null) { this.txtCusAddress.Text = ""; this.maskBirthday.StrValue = ""; this.chkBirthday.Checked = false; this.txtCusName.Text = ""; this.txtCusQQ.Text = ""; this.cmbtreevCusRegion.Text = ""; this.rdoCusSex2.Checked = true; this.txtCusTelephone.Text = ""; this.txtMicroSignal.Text = ""; this.txtCusWorkUnit.Text = ""; this.txtCusFixedPhone.Text = ""; this.cmbtreevCusRelation.Text = ""; this.maskedIDNumber.Text = ""; } else { this.txtCusAddress.Text = model.Cus_Address; this.maskBirthday.StrValue = model.Cus_Birthday; this.chkBirthday.Checked = model.Cus_BirthdayLunar == "1" ? true : false; this.txtCusName.Text = model.Cus_Name; this.txtCusQQ.Text = model.Cus_QQ; this.cmbtreevCusRegion.Text = model.Cus_Region; if (model.Cus_Sex) { this.rdoCusSex2.Checked = true; } else { this.rdoCusSex1.Checked = true; } this.txtCusTelephone.Text = model.Cus_Telephone; this.txtMicroSignal.Text = model.Cus_MicroSignal; this.txtCusWorkUnit.Text = model.Cus_WorkUnit; this.txtCusFixedPhone.Text = model.Cus_FixedPhone; this.cmbtreevCusRelation.Text = ""; this.cmbtreevCusRelation.Tag = ""; this.maskedIDNumber.Text = model.Cus_IDNumber; } this.cmbtreevCusRelation.TextFindTag(MainClientRelation); this.modelCilent = model; if (IsReadOnly) { this.txtCusAddress.ReadOnly = true; this.maskBirthday.ReadOnly = true; this.chkBirthday.Enabled = false; this.txtCusName.ReadOnly = true; this.txtCusQQ.ReadOnly = true; this.cmbtreevCusRegion.Enabled = false; this.rdoCusSex1.Enabled = false; this.rdoCusSex2.Enabled = false; this.txtCusTelephone.ReadOnly = true; this.txtMicroSignal.ReadOnly = true; this.txtCusWorkUnit.ReadOnly = true; this.txtCusFixedPhone.ReadOnly = true; this.cmbtreevCusRelation.Enabled = false; this.maskedIDNumber.ReadOnly = true; } else { this.txtCusAddress.ReadOnly = false; this.maskBirthday.ReadOnly = false; this.chkBirthday.Enabled = true; this.txtCusName.ReadOnly = false; this.txtCusQQ.ReadOnly = false; this.cmbtreevCusRegion.Enabled = true; this.rdoCusSex1.Enabled = true; this.rdoCusSex2.Enabled = true; this.txtCusTelephone.ReadOnly = false; this.txtMicroSignal.ReadOnly = false; this.txtCusWorkUnit.ReadOnly = false; this.txtCusFixedPhone.ReadOnly = false; this.cmbtreevCusRelation.Enabled = true; this.maskedIDNumber.ReadOnly = false; } this.panelTips.Visible = false; this.panelTips.Tag = null; this.IsTextChanged = true; } /// /// 设置客户资料 /// /// public void setHospitalClientValue(LYFZ.Model.Model_ErpHospitalClient model) { if (model == null) { this.txtCusAddress.Text = ""; this.maskBirthday.StrValue = ""; this.chkBirthday.Checked = false; this.txtCusName.Text = ""; this.txtCusQQ.Text = ""; this.cmbtreevCusRegion.Text = ""; this.rdoCusSex1.Checked = true; this.txtCusTelephone.Text = ""; this.txtMicroSignal.Text = ""; this.txtCusWorkUnit.Text = ""; this.txtCusFixedPhone.Text = ""; this.cmbtreevCusRelation.Text = ""; this.maskedIDNumber.Text = ""; } else { this.txtCusAddress.Text = model.Hct_HomeAddress; this.maskBirthday.StrValue = "";// LYFZ.Command.Command_Validate.DateTimeToString(model.Hct_BabyBirthday); this.chkBirthday.Checked = false;// model.Hct_AreLunar; 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.txtMicroSignal.Text = ""; this.txtCusWorkUnit.Text = ""; this.txtCusFixedPhone.Text = model.Hct_FamilyPhone; this.cmbtreevCusRelation.Text = ""; this.cmbtreevCusRelation.Tag = ""; this.maskedIDNumber.Text = ""; } } /// /// 编辑客户 /// public void SetClientEdit(bool IsUpdateName = false) { Image img = null; if (Convert.ToBoolean(this.PictEdit.Tag)) { this.txtCusAddress.ReadOnly = true; this.maskBirthday.ReadOnly = true; this.chkBirthday.Enabled = false; this.txtCusQQ.ReadOnly = true; this.cmbtreevCusRegion.Enabled = false; this.rdoCusSex1.Enabled = false; this.rdoCusSex2.Enabled = false; this.txtCusTelephone.ReadOnly = true; this.txtMicroSignal.ReadOnly = true; this.txtCusWorkUnit.ReadOnly = true; this.txtCusFixedPhone.ReadOnly = true; this.txtCusName.ReadOnly = true; this.cmbtreevCusRelation.Enabled = false; this.maskedIDNumber.ReadOnly = true; this.PictEdit.Tag = false; img = LYFZ.ComponentLibrary.Properties.Resources.pitEdit; this.toolTip1.SetToolTip(this.PictEdit, "进入编辑"); } else { this.txtCusAddress.ReadOnly = false; this.maskBirthday.ReadOnly = false; this.chkBirthday.Enabled = true; this.txtCusQQ.ReadOnly = false; this.cmbtreevCusRegion.Enabled = true; this.rdoCusSex1.Enabled = true; this.rdoCusSex2.Enabled = true; this.txtCusTelephone.ReadOnly = false; this.txtMicroSignal.ReadOnly = false; this.txtCusWorkUnit.ReadOnly = false; this.txtCusFixedPhone.ReadOnly = false; //this.txtCusName.ReadOnly = true; if (IsUpdateName) { this.txtCusName.ReadOnly = false; } else { this.txtCusName.ReadOnly = true; } this.cmbtreevCusRelation.Enabled = true; this.maskedIDNumber.ReadOnly = false; this.PictEdit.Tag = true; img = LYFZ.ComponentLibrary.Properties.Resources.pitEditOk; this.toolTip1.SetToolTip(this.PictEdit, "编辑OK"); } this.PictEdit.Image = img; } } public class ClientModel { #region Model private int _id; private string _cus_name; private string _cus_namepinyin; private bool _cus_sex; private string _cus_birthday; private string _cus_birthdaylunar; private string _cus_IDNumber; private string _cus_relations; private string _cus_qq; private string _cus_microsignal; private string _cus_telephone; private string _cus_fixedphone; private string _cus_region; private string _cus_address; private string _cus_workunit; private string _cus_zodiac; /// /// ID /// public int ID { set { _id = value; } get { return _id; } } /// /// 客户姓名 /// public string CusName { set { _cus_name = value; } get { return _cus_name; } } /// /// 客户姓名拼音 /// public string CusNamePinyin { get { return _cus_namepinyin; } set { _cus_namepinyin = value; } } /// /// 客户性别 0(false):男,1(true):女 /// public bool CusSex { set { _cus_sex = value; } get { return _cus_sex; } } /// /// 客户生日 /// public string CusBirthday { set { _cus_birthday = value; } get { return _cus_birthday; } } /// /// 生日历类 0:公历 1:农历 2:农历润月 /// public string CusBirthdayLunar { set { _cus_birthdaylunar = value; } get { return _cus_birthdaylunar; } } /// /// 称呼、关系、与宝贝关系 /// public string CusRelations { set { _cus_relations = value; } get { return _cus_relations; } } /// /// 客户QQ /// public string CusQQ { set { _cus_qq = value; } get { return _cus_qq; } } /// /// 微信号 /// public string CusMicroSignal { set { _cus_microsignal = value; } get { return _cus_microsignal; } } /// /// 客户电话 /// public string CusTelephone { set { _cus_telephone = value; } get { return _cus_telephone; } } /// /// 客户固定电话 /// public string CusFixedPhone { set { _cus_fixedphone = value; } get { return _cus_fixedphone; } } /// /// 客户所在地区 /// public string CusRegion { set { _cus_region = value; } get { return _cus_region; } } /// /// 客户地址 /// public string CusAddress { set { _cus_address = value; } get { return _cus_address; } } /// /// 客户工作单位 /// public string CusWorkUnit { set { _cus_workunit = value; } get { return _cus_workunit; } } /// /// 生肖 /// public string CusZodiac { set { _cus_zodiac = value; } get { return _cus_zodiac; } } /// /// 客户身份证号 /// public string CusIDNumber { get { return _cus_IDNumber; } set { _cus_IDNumber = value; } } #endregion Model } }