private void txtCPhone_Leave(object sender, EventArgs e) { string phone = this.txtCPhone.Text.Trim(); if (string.IsNullOrEmpty(phone)) { if (!string.IsNullOrEmpty(recordInfo.Customer.Phone)) errorProvider.SetError(this.txtCPhone, "不能为空", ErrorType.Warning); return; } // 未做修改,不查询 if (newRecordInfo.Customer.Phone == phone) { return; } var customers = CustomerBusiness.Instance.GetCustomers(new CustomerInfo() { ShopId = GlobalCaches.Instance.CurUser.ShopId, Phone = phone }); CustomerInfo info = null; if (customers == null || customers.Count == 0) info = new CustomerInfo() { Phone = phone, Name = this.txtCName.Text.Trim(), Industry = this.txtCIndustry.Text.Trim(), Address = this.txtCAddress.Text.Trim() }; else info = customers.FirstOrDefault(); newRecordInfo.FrontRecord.CustomerId = info.Id; // 如果根据 手机号查询出的顾客存在 就取顾客的记录,如果不存在 就取当前记录 newRecordInfo.FrontRecord.Id = info.Id == 0 ? newRecordInfo.FrontRecord.Id : 0; newRecordInfo.Customer = info; this.txtCName.DataBindings.Clear(); this.txtCPhone.DataBindings.Clear(); this.txtCIndustry.DataBindings.Clear(); this.txtCAddress.DataBindings.Clear(); this.txtCurCar.DataBindings.Clear(); this.txtCName.DataBindings.Add("Text", info, "Name"); this.txtCPhone.DataBindings.Add("Text", info, "Phone"); this.txtCIndustry.DataBindings.Add("Text", info, "Industry"); this.txtCAddress.DataBindings.Add("Text", info, "Address"); this.txtCurCar.DataBindings.Add("Text", info, "CurCar"); this.cbCNature.SelectedIndex = info.Nature ?? 0; if (info.Id == 0) this.cbCNature.SelectedIndex = 0; else this.cbCNature.SelectedItem = GlobalCaches.Instance.ConstantInfos.FirstOrDefault(m => m.Id == info.Nature); if (info.RegionId == null) this.cbRegion.SelectedIndex = 0; else this.cbRegion.SelectedItem = GlobalCaches.Instance.RegionInfos.FirstOrDefault(m => m.Id == info.RegionId); }
private void initForm(FrontCustomerRecordInfo info) { FrontRecordInfo frontInfo = new FrontRecordInfo(); CustomerInfo customerInfo = new CustomerInfo(); DBModelBase.Clone<FrontRecordInfo>(info.FrontRecord, ref frontInfo); DBModelBase.Clone<CustomerInfo>(info.Customer, ref customerInfo); newRecordInfo.FrontRecord = frontInfo; newRecordInfo.Customer = customerInfo; recordInfo = info; this.Btn_OK.Click += Btn_OK_Click; this.txtCName.DataBindings.Add("Text", customerInfo, "Name"); this.txtCPhone.DataBindings.Add("Text", customerInfo, "Phone"); this.txtCIndustry.DataBindings.Add("Text", customerInfo, "Industry"); this.txtCAddress.DataBindings.Add("Text", customerInfo, "Address"); this.txtCurCar.DataBindings.Add("Text", customerInfo, "CurCar"); customerLevels = PurposeLevelBusiness.Instance.GetPurposeLevels(); this.cbCLevel.Properties.Items.AddRange(customerLevels.ToArray()); this.cbRegion.Properties.Items.AddRange(GlobalCaches.Instance.RegionInfos); this.cbCNature.Properties.Items.AddRange(GlobalCaches.Instance.ConstantInfos.Where(e => e.TypeValue == (int)BasicConstantType.CNature).ToArray()); //this.cbCarLicence.Properties.Items.AddRange(GloablCaches.Instance.ConstantInfos.Where(e => e.TypeValue == (int)BasicConstantType.CarLicence).ToArray()); this.cbCarType.Properties.Items.AddRange(GlobalCaches.Instance.CarTypes); this.cbFrontSource.Properties.Items.AddRange(GlobalCaches.Instance.ConstantInfos.Where(e => e.TypeValue == (int)BasicConstantType.FrontSource).ToArray()); this.cbConsultant.Properties.Items.AddRange(GlobalCaches.Instance.ConsultantInfos); if (customerInfo.Id == 0) this.cbCNature.SelectedIndex = 0; else this.cbCNature.SelectedItem = GlobalCaches.Instance.ConstantInfos.FirstOrDefault(e => e.Id == customerInfo.Nature); if (customerInfo.RegionId.HasValue) this.cbRegion.SelectedItem = GlobalCaches.Instance.RegionInfos.FirstOrDefault(e => e.Id == customerInfo.RegionId); else this.cbRegion.SelectedIndex = 0; //if (frontInfo.CarLicence == null) // this.cbCarLicence.SelectedIndex = 0; //else // this.cbCarLicence.SelectedItem = GloablCaches.Instance.ConstantInfos.FirstOrDefault(e => e.Id == frontInfo.CarLicence); if (string.IsNullOrEmpty(frontInfo.LevelCode)) this.cbCLevel.SelectedIndex = 0; else this.cbCLevel.SelectedItem = customerLevels.FirstOrDefault(e => e.Code == frontInfo.LevelCode); if (frontInfo.PurposeCar.HasValue) this.cbCarType.SelectedItem = GlobalCaches.Instance.CarTypes.FirstOrDefault(e => e.Id == frontInfo.PurposeCar); else this.cbCarType.SelectedIndex = 0; if (frontInfo.Source.HasValue) this.cbFrontSource.SelectedItem = GlobalCaches.Instance.ConstantInfos.FirstOrDefault(e => e.Id == frontInfo.Source); else this.cbFrontSource.SelectedIndex = 0; if (frontInfo.ConsultantId > 0) this.cbConsultant.SelectedItem = GlobalCaches.Instance.ConsultantInfos.FirstOrDefault(e => e.Id == frontInfo.ConsultantId); this.txtRemark.DataBindings.Add("Text", frontInfo, "Remark"); this.txtCNum.EditValue = frontInfo.CustomerNum; this.rdDriveStatus.SelectedIndex = frontInfo.DriveStatus.HasValue ? frontInfo.DriveStatus.Value - 1 : -1; this.rdInstallment.SelectedIndex = frontInfo.Installment.HasValue ? frontInfo.Installment.Value - 1 : -1; this.rdReplace.SelectedIndex = frontInfo.Replace.HasValue ? frontInfo.Replace.Value - 1 : -1; // 只有店内经理可以修改客户的销售顾问 this.cbConsultant.Enabled = GlobalCaches.Instance.CurUser.RoleId <= GlobalConstants.RoleIdSysManager; }
private void initForm(DCCCustomerRecordInfo info) { if (info != null) { DCCRecordInfo dccInfo = new DCCRecordInfo(); CustomerInfo customerInfo = new CustomerInfo(); DBModelBase.Clone<DCCRecordInfo>(info.DCCRecord, ref dccInfo); DBModelBase.Clone<CustomerInfo>(info.Customer, ref customerInfo); recordInfo = info; newRecordInfo.Customer = customerInfo; newRecordInfo.DCCRecord = dccInfo; } this.Btn_OK.Click += Btn_OK_Click; this.txtCName.DataBindings.Add("Text", newRecordInfo.Customer, "Name"); this.txtCPhone.DataBindings.Add("Text", newRecordInfo.Customer, "Phone"); this.txtCAddress.DataBindings.Add("Text", newRecordInfo.Customer, "Address"); this.cbRegion.Properties.Items.AddRange(GlobalCaches.Instance.RegionInfos); if (newRecordInfo.Customer.RegionId.HasValue) this.cbRegion.SelectedItem = GlobalCaches.Instance.RegionInfos.FirstOrDefault(e => e.Id == newRecordInfo.Customer.RegionId); else this.cbRegion.SelectedIndex = 0; this.rbSex.SelectedIndex = newRecordInfo.Customer.Sex.HasValue ? newRecordInfo.Customer.Sex.Value - 1 : -1; purposeLevels = PurposeLevelBusiness.Instance.GetPurposeLevels(); this.cbCarType.Properties.Items.AddRange(GlobalCaches.Instance.CarTypes); this.cbCLevel.Properties.Items.AddRange(purposeLevels.ToArray()); this.cbDCCSource.Properties.Items.AddRange(GlobalCaches.Instance.ConstantInfos.Where(e => e.TypeValue == (int)BasicConstantType.DCCSource).ToArray()); this.cbRecaller.Properties.Items.AddRange(GlobalCaches.Instance.ConsultantInfos); if (newRecordInfo.DCCRecord.PurposeCar.HasValue) this.cbCarType.SelectedItem = GlobalCaches.Instance.CarTypes.FirstOrDefault(e => e.Id == newRecordInfo.DCCRecord.PurposeCar); else this.cbCarType.SelectedIndex = 0; if (string.IsNullOrEmpty(newRecordInfo.DCCRecord.LevelCode)) this.cbCLevel.SelectedIndex = 0; else this.cbCLevel.SelectedItem = purposeLevels.FirstOrDefault(e => e.Code == newRecordInfo.DCCRecord.LevelCode); if (newRecordInfo.DCCRecord.Source.HasValue) this.cbDCCSource.SelectedItem = GlobalCaches.Instance.ConstantInfos.FirstOrDefault(e => e.Id == newRecordInfo.DCCRecord.Source); else this.cbDCCSource.SelectedIndex = 0; this.rbDCCStatus.SelectedIndex = newRecordInfo.DCCRecord.Status.HasValue ? newRecordInfo.DCCRecord.Status.Value - 1 : -1; this.rbToShop.SelectedIndex = newRecordInfo.DCCRecord.ToShop.HasValue ? newRecordInfo.DCCRecord.ToShop.Value - 1 : -1; this.dtToShopTime.EditValue = newRecordInfo.DCCRecord.ToShopTime.HasValue ? newRecordInfo.DCCRecord.ToShopTime.Value : DateTime.Now.AddDays(3); this.rbInstallment.SelectedIndex = newRecordInfo.DCCRecord.Installment.HasValue ? newRecordInfo.DCCRecord.Installment.Value - 1 : -1; this.dtVisitTime.EditValue = newRecordInfo.DCCRecord.VisitTime.HasValue ? newRecordInfo.DCCRecord.VisitTime.Value : DateTime.Now.AddDays(-3); if (newRecordInfo.DCCRecord.DCCRecallerId.HasValue) this.cbRecaller.SelectedItem = GlobalCaches.Instance.ConsultantInfos.FirstOrDefault(e => e.Id == newRecordInfo.DCCRecord.DCCRecallerId); else this.cbRecaller.SelectedIndex = 0; this.txtRemark.DataBindings.Add("Text", newRecordInfo.DCCRecord, "RecallDesc"); if (IsNew) { this.txtCPhone.Leave += txtCPhone_Leave; } }
private void txtCPhone_Leave(object sender, EventArgs e) { string phone = this.txtCPhone.Text.Trim(); if (string.IsNullOrEmpty(phone)) { if (!string.IsNullOrEmpty(recordInfo.Customer.Phone)) errorProvider.SetError(this.txtCPhone, "不能为空", ErrorType.Warning); return; } if (newRecordInfo.Customer.Phone == phone) return; var customers = CustomerBusiness.Instance.GetCustomers(new CustomerInfo() { ShopId = GlobalCaches.Instance.CurUser.ShopId, Phone = phone }); CustomerInfo info = null; if (customers == null || customers.Count == 0) info = new CustomerInfo() { Phone = phone, Name = this.txtCName.Text.Trim(), RegionId = ((RegionInfo)this.cbRegion.SelectedItem).Id, Sex = this.rbSex.SelectedIndex + 1, Address = this.txtCAddress.Text.Trim() }; else info = customers.FirstOrDefault(); newRecordInfo.Customer = info; newRecordInfo.DCCRecord.CustomerId = info.Id; // 如果根据 手机号查询出的顾客存在 就取顾客的记录,如果不存在 就取当前记录 newRecordInfo.DCCRecord.Id = IsNew ? 0 : recordInfo.DCCRecord.Id; this.txtCName.DataBindings.Clear(); this.txtCPhone.DataBindings.Clear(); this.txtCAddress.DataBindings.Clear(); this.txtCName.DataBindings.Add("Text", info, "Name"); this.txtCPhone.DataBindings.Add("Text", info, "Phone"); this.txtCAddress.DataBindings.Add("Text", info, "Address"); this.rbSex.SelectedIndex = info.Sex.HasValue ? info.Sex.Value - 1 : -1; if (info.RegionId.HasValue) this.cbRegion.SelectedItem = GlobalCaches.Instance.RegionInfos.FirstOrDefault(m => m.Id == info.RegionId.Value); else this.cbRegion.SelectedIndex = 0; }
public FmOrderInfo(OrderRecordInfo info = null, CustomerInfo cInfo = null) { InitializeComponent(); customerInfo = cInfo == null ? new CustomerInfo() : cInfo; initForm(info); }
private void txtCPhone_Leave(object sender, EventArgs e) { string phone = this.txtCPhone.Text.Trim(); if (string.IsNullOrEmpty(phone)) { return; } var customers = CustomerBusiness.Instance.GetCustomers(new CustomerInfo() { ShopId = GlobalCaches.Instance.CurUser.ShopId, Phone = phone }); if (customers == null || customers.Count == 0) { errorProvider.SetError(this.txtCPhone, "客户信息不存在", ErrorType.Warning); return; } customerInfo = customers.FirstOrDefault(); this.txtCName.Text = customerInfo.Name; }
private void txtCPhone_Leave(object sender, EventArgs e) { string phone = this.txtCPhone.Text.Trim(); if (string.IsNullOrEmpty(phone)) return; if (phone == customerInfo.Phone) return; var customers = CustomerBusiness.Instance.GetCustomers(new CustomerInfo() { ShopId = GlobalCaches.Instance.CurUser.ShopId, Phone = phone }); if (customers == null || customers.Count == 0) customerInfo = new CustomerInfo() { Phone = phone, Name = this.txtCName.Text.Trim() }; else customerInfo = customers.FirstOrDefault(); this.txtCName.DataBindings.Clear(); this.txtCPhone.DataBindings.Clear(); this.txtCName.DataBindings.Add("Text", customerInfo, "Name"); this.txtCPhone.DataBindings.Add("Text", customerInfo, "Phone"); }