private void InitQueryControlDataSource()   //初始化查询控件数据项
        {
            dtp_repairs_time_s.Value = DateTime.Now.AddMonths(-1);
            dtp_repairs_time_e.Value = DateTime.Now.AddDays(1);
            dtp_approval_date_s.Value = DateTime.Now.AddMonths(-1);
            dtp_approval_date_e.Value = DateTime.Now.AddDays(1);

            txt_vehicle_no.ChooserClick += delegate //车牌号
            {
                var vechicleChooser = new frmVehicleGrade();
                var result = vechicleChooser.ShowDialog();
                if (result != DialogResult.OK) return;
                txt_vehicle_no.Text = vechicleChooser.strLicensePlate;
            };
            txt_customer_code.ChooserClick += delegate  //客户编码(同时会更新客户名称)
            {
                var custChooser = new frmCustomerInfo();
                var result = custChooser.ShowDialog();
                if (result != DialogResult.OK) return;
                txt_customer_code.Text = custChooser.strCustomerNo;
                txt_customer_name.Caption = custChooser.strCustomerName;
            };
            CommonCtrl.CmbBindDict(cbo_bill_type_yt, "bill_type_yt", true);    //单据类型
            CommonCtrl.CmbBindDict(cbo_info_status, "sys_service_info_status", true);  //单据状态
            CommonCtrl.CmbBindDict(cbo_approve_status_yt, "review_status_name_yt", true);  //宇通单据状态
        }
 private void InitQueryControlDataSource()   //初始化查询控件数据项
 {
     txt_vehicle_no.ChooserClick += delegate //车牌号
     {
         try
         {
             var vechicleChooser = new frmVehicleGrade();
             var result = vechicleChooser.ShowDialog();
             if (result != DialogResult.OK) return;
             txt_vehicle_no.Text = vechicleChooser.strLicensePlate;
         }
         catch (Exception ex)
         {
             _loggingService.WriteLog(ex);
         }
     };
     txt_customer_code.ChooserClick += delegate  //客户编码(同时会更新客户名称)
     {
         try
         {
             var custChooser = new frmCustomerInfo();
             var result = custChooser.ShowDialog();
             if (result != DialogResult.OK) return;
             txt_customer_code.Text = custChooser.strCustomerNo;
             txt_customer_name.Caption = custChooser.strCustomerName;
         }
         catch (Exception ex)
         {
             _loggingService.WriteLog(ex);
         }
     };
     CommonCtrl.CmbBindDict(cbo_bill_type_yt, "bill_type_yt", true);    //单据类型
     CommonCtrl.CmbBindDict(cbo_approve_status_yt, "review_status_name_yt", true);  //宇通单据状态
 }
 private void InitQueryControlDataSource()   //初始化查询控件数据项
 {
     if ((fld_vehicle_no.ValueControl as ExtTextChooser) != null)
     {
         (fld_vehicle_no.ValueControl as ExtTextChooser).ChooserClick += delegate //车牌号
         {
             var vechicleChooser = new frmVehicleGrade();
             var result = vechicleChooser.ShowDialog();
             if (result != DialogResult.OK) return;
             fld_vehicle_no.Value = fld_vehicle_no.DisplayValue = vechicleChooser.strLicensePlate;
         };
     }
     if ((fld_customer_code.ValueControl as ExtTextChooser) != null)
     {
         (fld_customer_code.ValueControl as ExtTextChooser).ChooserClick += delegate //客户编码(同时会更新客户名称)
         {
             var custChooser = new frmCustomerInfo();
             var result = custChooser.ShowDialog();
             if (result != DialogResult.OK) return;
             fld_customer_code.DisplayValue = custChooser.strCustomerNo;
             fld_customer_code.Value = custChooser.strCustomerName;
         };
     }
     fld_info_status.ContentTypeName = fld_info_status_yt.ContentTypeName = fld_receipt_type.ContentTypeName = "DbDic";
     fld_info_status.ContentTypeParameter = "sys_service_info_status";//单据状态
     fld_info_status_yt.ContentTypeParameter = "review_status_name_yt";//宇通单据状态
     fld_receipt_type.ContentTypeParameter = "bill_type_yt"; //单据类型
 }
 //车牌号选择
 private void txtlicense_plate_ChooserClick(object sender, EventArgs e)
 {
     frmVehicleGrade frmVehicleGrad = new frmVehicleGrade();
     if (frmVehicleGrad.ShowDialog() == DialogResult.OK)
     {
         txtlicense_plate.Text = frmVehicleGrad.strLicensePlate;
     }
 }
 //车牌号选择
 private void txtcVehicleNO_ChooserClick(object sender, EventArgs e)
 {
     frmVehicleGrade frmVehicle = new frmVehicleGrade();
     DialogResult result = frmVehicle.ShowDialog();
     if (result == DialogResult.OK)
     {
         txtcVehicleNO.Text = frmVehicle.strLicensePlate;
     }
 }
 /// <summary>
 /// 车牌号选择器事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtCarNO_ChooserClick(object sender, EventArgs e)
 {
     frmVehicleGrade frmVehicle = new frmVehicleGrade();
     DialogResult result = frmVehicle.ShowDialog();
     if (result == DialogResult.OK)
     {
         txtCarNO.Text = frmVehicle.strLicensePlate;               
         txtEngineNo.Caption = frmVehicle.strEngineNum;
         txtCarType.Text = frmVehicle.strModel;               
     }
 }
        private void InitControlDataSource() //初始化数据字段控件数据
        {
            try
            {
                #region 设置控件验证值
                txt_repairer_mobile.VerifyTypeName = txt_link_man_mobile.VerifyTypeName = "Phone";
                txt_repairer_mobile.ShowError = txt_link_man_mobile.ShowError = true;
                txt_customer_postcode.VerifyTypeName = "Postcode";
                txt_customer_postcode.ShowError = true;
                txt_feedback_num.VerifyTypeName = "Integer";
                txt_feedback_num.ShowError = true;
                txt_other_money.VerifyTypeName = txt_man_hour_subsidy.VerifyTypeName = txt_ccf.VerifyTypeName = txt_journey_subsidy.VerifyTypeName = txt_maintain_mileage.VerifyTypeName = txt_travel_mileage.VerifyTypeName = "UFloat";
                txt_other_money.ShowError = txt_man_hour_subsidy.ShowError = txt_ccf.ShowError = txt_journey_subsidy.ShowError = txt_maintain_mileage.ShowError = txt_travel_mileage.ShowError = true;
                #endregion

                dtp_goout_back_time.Value = dtp_goout_time.Value = dtp_maintain_time.Value = dtp_parts_buy_time.Value = dtp_repairs_time.Value = dtp_start_work_time.Value = dtp_complete_work_time.Value = DBHelper.GetCurrentTime();
                dgv_tb_maintain_three_guaranty_accessory.TableName = "tb_maintain_three_guaranty";
                dgv_tb_maintain_three_guaranty_accessory.TableNameKeyValue = TgId;

                #region 基础数据
                var isSecondStation = DBHelper.GetSingleValue("根据公司编码获取是否为二级站", GlobalStaticObj.CommAccCode, "tb_company", "category", "sap_code = '" + GlobalStaticObj.ServerStationCode+ "'", "");
                if (!String.IsNullOrEmpty(isSecondStation))
                {
                    chk_whether_second_station_true.Checked = isSecondStation == "1";    //一级站
                    chk_whether_second_station_false.Checked = isSecondStation == "2";    //二级站
                }
                txt_service_station_code.Text = GlobalStaticObj.ServerStationCode; //当前服务站代码
                txt_service_station_name.Caption = GlobalStaticObj.ServerStationName; //当前服务站名称

                dtp_repairs_time.Value = DateTime.Now;  //报修日期(系统默认当前时间)

                //txt_service_station_code.ChooserClick += delegate   //服务站选择器
                //{
                //    var signInfoChooser = new FormSignInfoChooser();
                //    var result = signInfoChooser.ShowDialog();
                //    if (result != DialogResult.OK) return;
                //    txt_service_station_code.Text = signInfoChooser.SignCode;
                //    txt_service_station_code.Tag = signInfoChooser.SignId;
                //    txt_service_station_name.Caption = signInfoChooser.SignName;
                //};

                CommonCtrl.CmbBindDict(cbo_receipt_type, "bill_type_yt", false);   //宇通单据类型
                CommonCtrl.CmbBindDict(cbo_cost_type_service_zczg, "cost_type_care_policy_yt", false);   //费用类型(政策照顾)
                CommonCtrl.BindComboBoxByTable(cbo_product_notice_no, "tb_product_no", "service_code", "activities", false);   //产品改进通知

                CommonCtrl.CmbBindDict(cbo_whether_go_out, "sys_true_false", false);   //是否外出
                cbo_whether_go_out.SelectedValue = DbDic2Enum.FALSE;    //是否外出(默认选择为否)

                CommonCtrl.CmbBindDict(cbo_refit_case, "refit_case", false);   //改装情况
                cbo_refit_case.SelectedValue = DbDic2Enum.REFIT_CASE_FALSE;    //改装请款(默认选择为无改装)

                DataSources.BindComBoxDataEnum(cbo_promise_guarantee, typeof(DataSources.EnumYesNo), false);   //特殊约定质保
                cbo_promise_guarantee.SelectedValue = DataSources.EnumYesNo.NO;    //特殊约定质保(默认选择为否)
                UIAssistants.BindingServiceStationUser(cbo_approver_name_yt, true, "请选择");

                txt_appraiser_name.ChooserClick += delegate   //鉴定人选择器
                {
                    var chooser = new frmUsers{ cbo_data_source = { SelectedValue = "1", Enabled = false } };
                    var result = chooser.ShowDialog();
                    if (result != DialogResult.OK) return;
                    if (String.IsNullOrEmpty(chooser.User_Name) || String.IsNullOrEmpty(chooser.CrmId))
                    {
                        MessageBoxEx.Show("无效的数据,获取不到用户的CRM信息");
                        return;
                    }
                    //txt_approver_name_yt.Text = chooser.contName;
                    //txt_approver_name_yt.Tag = chooser.crmId;
                    txt_appraiser_name.Text = chooser.User_Name;
                    txt_appraiser_name.Tag = chooser.CrmId;
                };

                txt_repair_man.ChooserClick += delegate   //维修人选择器
                {
                    var chooser = new frmUsers{ cbo_data_source = { SelectedValue = "1", Enabled = false } };
                    var result = chooser.ShowDialog();
                    if (result != DialogResult.OK) return;
                    if (String.IsNullOrEmpty(chooser.User_Name) || String.IsNullOrEmpty(chooser.CrmId))
                    {
                        MessageBoxEx.Show("无效的数据,获取不到用户的CRM信息");
                        return;
                    }
                    //txt_approver_name_yt.Text = chooser.contName;
                    //txt_approver_name_yt.Tag = chooser.crmId;
                    txt_repair_man.Text = chooser.User_Name;
                    txt_repair_man.Tag = chooser.CrmId;
                };

                CommonCtrl.BindComboBoxByTable(cbo_cost_type_service_fwhd, "tb_product_no", "service_code", "activities", false);   //费用类型(服务活动) unknow

                CommonCtrl.CmbBindDict(cbo_customer_property, "custom_property_yt", false);   //客户性质
                txt_vehicle_use_corp.ChooserClick += delegate  //车辆使用单位选择器
                {
                    var custChooser = new frmCustomerInfo();
                    var result = custChooser.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        if (String.IsNullOrEmpty(custChooser.CustomerInfo.CustName) || String.IsNullOrEmpty(custChooser.CustomerInfo.SAPCode))
                        {
                            MessageBoxEx.Show("选择的数据不符合使用要求");
                            return;
                        }
                        txt_vehicle_use_corp.Text = custChooser.CustomerInfo.CustName;
                        txt_vehicle_use_corp.Tag = custChooser.CustomerInfo.SAPCode;
                    }
                };
                txt_customer_code.ChooserClick += delegate  //客户信息选择器
                {
                    var custChooser = new frmCustomerInfo();
                    var result = custChooser.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        if (String.IsNullOrEmpty(custChooser.CustomerInfo.CustCode))
                        {
                            MessageBoxEx.Show("选择的数据不符合使用要求");
                            return;
                        }
                        txt_customer_code.Text = custChooser.CustomerInfo.CustCode;
                        txt_customer_code.Tag = custChooser.CustomerInfo.CustId;
                        txt_customer_name.Caption = custChooser.CustomerInfo.CustName;
                        txt_customer_address.Caption = custChooser.CustomerInfo.CustAddress;
                        txt_customer_postcode.Caption = custChooser.CustomerInfo.ZipCode;

                        //联系人数据                
                        var dpt = DBHelper.GetTable("联系人数据", "(select tr.relation_object_id, tr.is_default tr_is_default, tb.*  from tb_contacts tb inner join tr_base_contacts tr on tb.cont_id = tr.cont_id) a", "*",
                            string.Format(" a.relation_object_id='{0}'", custChooser.CustomerInfo.CustId), "", "");
                        if (dpt != null && dpt.Rows.Count > 0)
                        {
                            for (var i = 0; i < dpt.Rows.Count; i++)
                            {
                                var dpr = dpt.Rows[i];
                                if (CommonCtrl.IsNullToString(dpr["tr_is_default"]) == "1")
                                {
                                    txt_linkman.Caption = CommonCtrl.IsNullToString(dpr["cont_name"]);
                                    txt_link_man_mobile.Caption = CommonCtrl.IsNullToString(dpr["cont_phone"]);
                                }
                            }
                        }
                        ValidationCustomer();
                    }
                };
                txt_customer_code.Leave += delegate     //客户信息校验
                {
                    ValidationCustomer();
                };
                #endregion

                #region 车辆信息
                CommonCtrl.BindComboBoxByDictionarr(cbo_fault_cause, "cause_fault_yt", false);   //故障原因
                CommonCtrl.BindComboBoxByDictionarr(cbo_fault_duty_corp, "fault_company_yt", false);   //故障责任单位
                txt_vehicle_no.ChooserClick += delegate  //车辆选择器
                {
                    var chooser = new frmVehicleGrade();
                    var result = chooser.ShowDialog();
                    if (result != DialogResult.OK) return;
                    txt_vehicle_no.Text = chooser.strLicensePlate; //车牌号
                    txt_depot_no.Text = chooser.Turner;  //车工号
                    txt_vehicle_vin.Caption = chooser.strVIN;   //VIN
                    txt_engine_num.Caption = chooser.strEngineNum; //发动机号
                    txt_vehicle_model.Tag = chooser.strModel;  //车型
                    ValidationVehicle();
                    //txt_maintain_mileage.Caption = chooser.MaintainMileage; //协议保养里程
                    //txt_maintain_time.Caption = chooser.MaintainTime;    //协议保养日期
                };
                txt_depot_no.ChooserClick += delegate  //车工号选择器
                {
                    var chooser = new frmVehicleGrade();
                    var result = chooser.ShowDialog();
                    if (result != DialogResult.OK) return;
                    txt_vehicle_no.Text = chooser.strLicensePlate; //车牌号
                    txt_depot_no.Text = chooser.Turner;  //车工号
                    txt_vehicle_vin.Caption = chooser.strVIN;   //VIN
                    txt_engine_num.Caption = chooser.strEngineNum; //发动机号
                    txt_vehicle_model.Tag = chooser.strModel;  //车型
                    ValidationDepto();
                    //txt_maintain_mileage.Caption = chooser.MaintainMileage; //协议保养里程
                    //txt_maintain_time.Caption = chooser.MaintainTime;    //协议保养日期
                };
                txt_vehicle_no.Leave += delegate     //车辆信息校验
                {
                    //ValidationVehicle();
                };
                txt_depot_no.Leave += delegate     //车辆信息校验
                {
                    ValidationDepto();
                };

                txt_vehicle_model.ChooserClick += delegate  //车型选择器
                {
                    var chooser = new frmVehicleModels();
                    var result = chooser.ShowDialog();
                    if (result != DialogResult.OK) return;
                    txt_vehicle_model.Text = chooser.VMName;  //车型
                    txt_vehicle_model.Tag = chooser.VMID;
                    _vmClass = chooser.VMClass;
                };

                txt_fault_system.ChooserClick += delegate  //故障系统选择器
                {
                    var chooser = new FormChooserFault();
                    var result = chooser.ShowDialog();
                    if (result != DialogResult.OK) return;

                    txt_fault_system.Text = chooser.SystemName;
                    txt_fault_system.Tag = chooser.SystemCode;
                    txt_fault_assembly.Caption = chooser.AssemblyName;
                    txt_fault_assembly.Tag = chooser.AssemblyCode;
                    txt_fault_part.Caption = chooser.PartmName;
                    txt_fault_part.Tag = chooser.PartCode;
                    //txt_fault_schema.Text = chooser.SchemaName;
                    //txt_fault_schema.Tag = chooser.SchemaCode;

                };
                txt_fault_schema.ChooserClick += delegate  //故障模式选择器
                {
                    var chooser = new FormChooserFaultModel();
                    var result = chooser.ShowDialog();
                    if (result != DialogResult.OK) return;
                    txt_fault_schema.Text = chooser.FmeaName;
                    txt_fault_schema.Tag = chooser.FmeaCode;
                };
                #endregion

                #region 外出信息
                CommonCtrl.BindComboBoxByDictionarr(cbo_whether_yt, "sys_true_false", false);   //是否宇通车
                if(cbo_whether_yt.Items.Contains("0")) cbo_whether_yt.SelectedValue = "0";
                CommonCtrl.BindComboBoxByDictionarr(cbo_means_traffic, "traffic_mode_yt", false);   //外出交通方式
                if (cbo_means_traffic.Items.Count > 0) cbo_means_traffic.SelectedIndex = 0;
                cbo_means_traffic.SelectedIndexChanged += delegate
                {
                    if (CommonCtrl.IsNullToString(cbo_means_traffic.SelectedValue) ==
                        DbDic2Enum.TRAFFIC_MODE_YT_100000000)
                    {
                        txt_journey_subsidy.Enabled = false;
                    }
                    else
                    {
                        txt_journey_subsidy.Enabled = true;
                    }
                };

                UIAssistants.BindingServiceStationUser(cbo_goout_approver, true, "请选择"); //外出批准人选择器
                
                #endregion

                #region 配件信息
                dtp_parts_buy_time.Value = DateTime.Now;
                //txt_parts_buy_corp.ChooserClick += delegate  //配件购买单位(客户选择器)
                //{
                //    var custChooser = new frmChooseCompany();
                //    var result = custChooser.ShowDialog();
                //    if (result == DialogResult.OK)
                //    {
                //        txt_parts_buy_corp.Text = custChooser.Sap_Code;
                //    }
                //};
                CommonCtrl.BindComboBoxByDictionarr(cbo_contain_man_hour_cost, "sys_true_false", false);   //是否包含工时费
                cbo_contain_man_hour_cost.SelectedValue = DbDic2Enum.TRUE;

                txt_parts_code.ChooserClick += delegate  //配件编号(配件选择器)
                {
                    var chooser = new frmParts();
                    var result = chooser.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        txt_parts_code.Text = chooser.CarPartsCode;
                        txt_materiel_describe.Caption = chooser.PartsName;
                    }
                };
                //txt_first_install_station.ChooserClick += delegate  //首次安装服务站(客户选择器)
                //{
                //    var custChooser = new frmChooseCompany();
                //    var result = custChooser.ShowDialog();
                //    if (result == DialogResult.OK)
                //    {
                //        txt_first_install_station.Text = custChooser.Sap_Code;
                //    }
                //};
                CommonCtrl.BindComboBoxByDictionarr(cbo_part_guarantee_period, "parts_warranty_agreement_yt", false);   //协议保养日期
                #endregion

                #region 经办人
                txt_responsible_opid.ChooserClick += delegate   //经办人选择器
                {
                    var chooser = new frmUsers();
                    var result = chooser.ShowDialog();
                    if (result != DialogResult.OK) return;
                    txt_responsible_opid.Text = chooser.User_Name;
                    txt_responsible_opid.Tag = chooser.User_ID;
                    txt_org_name.Caption = chooser.OrgName;
                    txt_org_name.Tag = chooser.OrgId;
                };
                #endregion
            }
            catch (Exception ex)
            {
                //日记记录
            }
        }
 /// <summary>
 /// 车牌号选择器事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtCarNO_ChooserClick(object sender, EventArgs e)
 {
     try
     {
         frmVehicleGrade frmVehicle = new frmVehicleGrade();
         DialogResult result = frmVehicle.ShowDialog();
         if (result == DialogResult.OK)
         {
             txtCarNO.Text = frmVehicle.strLicensePlate;
             txtCarType.Text = GetVmodel(frmVehicle.strModel);
             txtCarType.Tag = frmVehicle.strModel;
             txtCustomNO.Text = frmVehicle.strCustCode;
             txtCustomNO.Tag = frmVehicle.strCustId;
             txtCustomName.Caption = frmVehicle.strCustName;
             txtContact.Caption = frmVehicle.strContactName;
             txtContactPhone.Caption = frmVehicle.strContactPhone;
         }
     }
     catch (Exception ex)
     {
         HXCPcClient.GlobalStaticObj.GlobalLogService.WriteLog(ex);
     }
 }
示例#9
0
 private void txtCarNO_ChooserClick(object sender, EventArgs e)
 {
     frmVehicleGrade frmVehicle = new frmVehicleGrade();
     DialogResult result = frmVehicle.ShowDialog();
     if (result == DialogResult.OK)
     {
         txtCarNO.Text = frmVehicle.strLicensePlate;
         txtVIN.Caption = frmVehicle.strVIN;
         txtCarType.Text = GetVmodel(frmVehicle.strModel);
         txtCarType.Tag = frmVehicle.strModel;
         cobCarBrand.SelectedValue = frmVehicle.strBrand;
         txtYardCode.Caption = frmVehicle.Turner;
         txtCustomNO.Text = frmVehicle.strCustName;
         txtCustomNO.Tag = frmVehicle.strCustId;               
     }
 }
示例#10
0
 private void txtCarNO_ChooserClick(object sender, EventArgs e)
 {
     frmVehicleGrade frmVehicle = new frmVehicleGrade();
     DialogResult result = frmVehicle.ShowDialog();
     if (result == DialogResult.OK)
     {
         txtCarNO.Text = frmVehicle.strLicensePlate;
         txtVIN.Caption = frmVehicle.strVIN; 
         cobCarBrand.SelectedValue = frmVehicle.strBrand;
     }
 }
 /// <summary>
 /// 车牌号选择器事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtCarNO_ChooserClick(object sender, EventArgs e)
 {
     try
     {
         frmVehicleGrade frmVehicle = new frmVehicleGrade();
         DialogResult result = frmVehicle.ShowDialog();
         if (result == DialogResult.OK)
         {
             txtCarNO.Text = frmVehicle.strLicensePlate;
             txtVIN.Caption = frmVehicle.strVIN;
             txtEngineNo.Caption = frmVehicle.strEngineNum;
             txtCarType.Text = GetVmodel(frmVehicle.strModel);
             txtCarType.Tag = frmVehicle.strModel;
             cobCarBrand.SelectedValue = frmVehicle.strBrand;
             //cobColor.SelectedValue = frmVehicle.strColor;
             txtturner.Caption = frmVehicle.Turner;
             txtCustomNO.Text = frmVehicle.strCustCode;
             txtCustomNO.Tag = frmVehicle.strCustId;
             GetMemberInfo(frmVehicle.strCustId);
             txtCustomName.Caption = frmVehicle.strCustName;
             txtContact.Caption = frmVehicle.strContactName;
             txtContactPhone.Caption = frmVehicle.strContactPhone;
             txtBalanceCompany.Text = frmVehicle.strCustName;
             txtBalanceCompany.Tag = frmVehicle.strCustId;
         }
     }
     catch (Exception ex)
     {
         HXCPcClient.GlobalStaticObj.GlobalLogService.WriteLog(ex);
     }
 }
        private void InitDataGridCellFormatting()   //初始化数据表格
        {
            try
            {
                dgvVehicle.CellFormatting += delegate(object sender, DataGridViewCellFormattingEventArgs args)
                {
                    UIAssistants.DgvCellDataConvert2DicData(dgvVehicle, args, "v_brand");
                    UIAssistants.DgvCellDataConvert2DicData(dgvVehicle, args, "v_model");
                };

                #region 车辆信息
                dgvVehicle.ReadOnly = false;
                dgvVehicle.Rows.Add(3);
                dgvVehicle.AllowUserToAddRows = true;
                tb_vehicle_license_plate.ReadOnly = true;
                tb_vehicle_remark.ReadOnly = true;
                tb_vehicle_v_brand.ReadOnly = true;
                tb_vehicle_v_id.ReadOnly = true;
                tb_vehicle_v_model.ReadOnly = true;
                tb_vehicle_vin.ReadOnly = true;

                dgvVehicle.CellClick += delegate(object sender, DataGridViewCellEventArgs args)
                {
                    if (args.ColumnIndex < 0) return;
                    //if (dgvVehicle.Columns[args.ColumnIndex] != tb_vehicle_license_plate) return;
                    var chooser = new frmVehicleGrade();
                    var result = chooser.ShowDialog();
                    if (result != DialogResult.OK) return;
                    var strId = chooser.strLicensePlate;
                    var dpt = DBHelper.GetTable("查询车辆档案信息", "tb_vehicle", "*", " license_plate='" + strId + "'", "", "");
                    if (dpt.Rows.Count <= 0) return;
                    var dpr = dpt.Rows[0];
                    dgvVehicle.Rows[args.RowIndex].Cells["tb_vehicle_license_plate"].Value = CommonCtrl.IsNullToString(dpr["license_plate"]);
                    dgvVehicle.Rows[args.RowIndex].Cells["tb_vehicle_remark"].Value = CommonCtrl.IsNullToString(dpr["remark"]);
                    dgvVehicle.Rows[args.RowIndex].Cells["tb_vehicle_v_brand"].Value = CommonCtrl.IsNullToString(dpr["v_brand"]);
                    dgvVehicle.Rows[args.RowIndex].Cells["tb_vehicle_v_id"].Value = CommonCtrl.IsNullToString(dpr["v_id"]);
                    dgvVehicle.Rows[args.RowIndex].Cells["tb_vehicle_v_model"].Value = CommonCtrl.IsNullToString(dpr["v_model"]);
                    dgvVehicle.Rows[args.RowIndex].Cells["tb_vehicle_vin"].Value = CommonCtrl.IsNullToString(dpr["vin"]);
                };
                #endregion

                #region 联系人信息
                dgvcontacts.CellFormatting += delegate(object sender, DataGridViewCellFormattingEventArgs args)
                {
                    UIAssistants.DgvCellDataConvert2DicData(dgvcontacts, args, "cont_post");
                    UIAssistants.DgvCellDataConvert2Datetime(dgvcontacts, args, "cont_birthday");
                };

                dgvcontacts.ReadOnly = false;
                dgvcontacts.Rows.Add(3);
                dgvcontacts.AllowUserToAddRows = true;
                cont_name.ReadOnly = true;
                cont_post.ReadOnly = true;
                cont_phone.ReadOnly = true;
                cont_tel.ReadOnly = true;
                cont_birthday.ReadOnly = true;
                cont_email.ReadOnly = true;
                is_default.ReadOnly = false;
                remark.ReadOnly = true;

                dgvcontacts.CellContentClick += delegate(object sender, DataGridViewCellEventArgs e)
                {
                    if (e.RowIndex > -1 && e.ColumnIndex > -1)//双击表头或列头时不起作用   
                    {
                        //获取控件的值
                        for (int i = 0; i < dgvcontacts.Rows.Count; i++)
                        {
                            dgvcontacts.Rows[i].Cells["is_default"].Value = "0";
                        }
                        dgvcontacts.Rows[e.RowIndex].Cells["is_default"].Value = "1";
                    }
                };

                dgvcontacts.CellClick += delegate(object sender, DataGridViewCellEventArgs args)
                {
                    if (args.ColumnIndex < 0 || args.RowIndex < 0) return;
                    if (dgvcontacts.Columns[args.ColumnIndex] != cont_name) return;
                     var frmPart = new frmContacts();
                    var result = frmPart.ShowDialog();
                    if (result != DialogResult.OK) return;
                    var strId = frmPart.contID;
                    var dpt = DBHelper.GetTable("查询联系人信息", "v_contacts", string.Format("*,{0} phone ,{1} tel", EncryptByDB.GetDesFieldValue("cont_phone"), EncryptByDB.GetDesFieldValue("cont_tel")), " cont_id='" + strId + "'", "", "");
                    if (dpt.Rows.Count <= 0) return;
                    var dpr = dpt.Rows[0];
                    dgvcontacts.Rows[args.RowIndex].Cells["cont_id"].Value = CommonCtrl.IsNullToString(dpr["cont_id"]);
                    dgvcontacts.Rows[args.RowIndex].Cells["cont_name"].Value = CommonCtrl.IsNullToString(dpr["cont_name"]);
                    dgvcontacts.Rows[args.RowIndex].Cells["cont_post"].Value = CommonCtrl.IsNullToString(dpr["cont_post_name"]);
                    dgvcontacts.Rows[args.RowIndex].Cells["cont_phone"].Value = CommonCtrl.IsNullToString(dpr["phone"]);
                    dgvcontacts.Rows[args.RowIndex].Cells["cont_tel"].Value = CommonCtrl.IsNullToString(dpr["tel"]);
                    dgvcontacts.Rows[args.RowIndex].Cells["cont_birthday"].Value = CommonCtrl.IsNullToString(dpr["cont_birthday"]);
                    dgvcontacts.Rows[args.RowIndex].Cells["cont_email"].Value = CommonCtrl.IsNullToString(dpr["cont_email"]);
                    dgvcontacts.Rows[args.RowIndex].Cells["is_default"].Value = "0";
                    dgvcontacts.Rows[args.RowIndex].Cells["remark"].Value = CommonCtrl.IsNullToString(dpr["remark"]);
                };
                #endregion
            }
            catch (Exception)
            {

            }
        }
 /// <summary>
 /// 车牌号选择器事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtCarNO_ChooserClick(object sender, EventArgs e)
 {
     frmVehicleGrade frmVehicle = new frmVehicleGrade();
     DialogResult result = frmVehicle.ShowDialog();
     if (result == DialogResult.OK)
     {
         txtCarNO.Text = frmVehicle.strLicensePlate;
         txtCarType.Text = GetDicName(frmVehicle.strModel);
         txtCarType.Tag = frmVehicle.strModel;
         txtCustomNO.Text = frmVehicle.strCustCode;
         txtCustomNO.Tag = frmVehicle.strCustId;
         txtCustomName.Caption = frmVehicle.strCustName;
     }
 }