Beispiel #1
0
        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;
            }
        }
Beispiel #2
0
 public FmDCCRecall(DCCCustomerRecordInfo info = null)
 {
     InitializeComponent();
     initForm(info);
 }