void Btn_OK_Click(object sender, EventArgs e) { if (!Validate()) return; try { FrontRecordInfo recordInfo = new FrontRecordInfo() { ShopId = GlobalCaches.Instance.CurUser.ShopId, ArrivalTime = DateTime.Now, CustomerNum = Convert.ToInt32(this.txtCNum.Text), ConsultantId = ((UserInfo)this.cbConsultant.SelectedItem).Id, Remark = this.txtDesc.Text, Recorder = GlobalCaches.Instance.CurUser.RealName }; FrontRecordBusiness.Instance.AddFrontRecord(recordInfo); this.DialogResult = DialogResult.OK; } catch (Exception ex) { XtraMessageBox.Show(string.Format("保存失败,请联系管理员,信息如下:\r\n{0}", ex.Message), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
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; }