Exemplo n.º 1
0
        private bool CheckInfoBeforeAdd()
        {
            if (!Regex.IsMatch(txb_VehicleNum.Text, @"^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$"))
            {
                MessageBox.Show("请填写正确的车牌号");
                return(false);
            }

            if (cmb_VehicleKind.Text == "")
            {
                MessageBox.Show("请选择车辆类型");
                return(false);
            }

            if (cmb_VehicleType.Text == "")
            {
                MessageBox.Show("请填写正确的车牌号");
                return(false);
            }

            if (cbx_IsNewCustomer.Checked == false && SelectUserGrid.SelectedRows.Count <= 0)
            {
                MessageBox.Show("请选择车辆的所属人员");
                return(false);
            }

            if (cbx_IsNewCustomer.Checked == true && !CheckInfo())
            {
                MessageBox.Show("新增人员信息填写不正确");
                return(false);
            }
            if (cbx_IsNewCustomer.Checked == true && txb_CustomerName.Text != "" && txb_IDCard.Text != "")
            {
                DAL.DAL_CustomerInfo customerdal = new DAL.DAL_CustomerInfo();
                DAL.DAO.CustomerDao  customerdao = new DAL.DAO.CustomerDao();

                customerdao.Name   = this.txb_CustomerName.Text;
                customerdao.Sex    = this.cmb_CustomerSex.Text;
                customerdao.Nation = this.cmb_Nation.Text;
                if (cmb_CustomerType.SelectedIndex == 0)
                {
                    customerdao.Istemp = 0;
                }
                else
                {
                    customerdao.Istemp = 1;
                }
                customerdao.Idcard  = this.txb_IDCard.Text;
                customerdao.Address = this.txb_Address.Text;

                if (!customerdal.insertCustomerInfo(customerdao))
                {
                    MessageBox.Show("新增人员时出现错误!添加车辆失败");
                    return(false);
                }
                vehicle_ownerid = customerdal.GetCustomerIDWithIDCard(customerdao.Idcard);
            }
            return(true);
        }