Beispiel #1
0
        private void Car_management1_Click(object sender, EventArgs e)
        {
            //在操作区域内部添加选项卡页,显示StopCar窗体
            StopCar stopCar = new StopCar();

            AddTabPage("车辆管理", stopCar);
            invit();
            Car_management.BackColor = Color.FromArgb(230, 230, 250);
        }
        private void btn_add_Click(object sender, EventArgs e)
        {
            bool result = StopCar.IsVehicleNumber(Car_num_tb.Text);

            //非空验证 以及判断车位属性是不是私有车位
            if (type11_tb.Text == "私有车位")
            {
                if (Car_name_tb.Text == "" || tell_ttbb.Text == "" || Car_num_tb.Text == "" || Car_typeee.Text == "" || addres_tb.Text == "")
                {
                    MessageBox.Show(type11_tb.Text + " 所有信息不能为空!", "提示");
                    return;
                }
            }
            if (type11_tb.Text == "租用车位")
            {
                if (Car_name_tb.Text == "" || tell_ttbb.Text == "" || Car_num_tb.Text == "" || Car_typeee.Text == "" || addres_tb.Text == "" || years_tb.Text == "")
                {
                    MessageBox.Show(type11_tb.Text + " 所有信息不能为空!", "提示");
                    return;
                }
            }
            if (Car_num_tb.Text == "")
            {
                MessageBox.Show("车牌号不能为空!", "提示");
                return;
            }
            if (result == false)
            {
                MessageBox.Show("请输入正确的车牌号!", "提示");
                return;
            }
            //电信手机号码正则
            string dianxin = @"^1[35789][01379]\d{8}$";
            Regex  dReg    = new Regex(dianxin);   //实例化对象
                                                   //联通手机号正则
            string liantong = @"^1[345678][01256]\d{8}$";
            Regex  tReg     = new Regex(liantong); //实例化对象
                                                   //移动手机号正则
            string yidong = @"^(134[012345678]\d{7}|1[34578][012356789]\d{8})$";
            Regex  yReg   = new Regex(yidong);     //实例化对象

            //判断输入的手机号码格式是否正确
            if (!(dReg.IsMatch(tell_ttbb.Text) || tReg.IsMatch(tell_ttbb.Text) || yReg.IsMatch(tell_ttbb.Text)))
            {
                MessageBox.Show("手机号格式错误,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); //弹框提示
                tell_ttbb.Text = "";                                                                       //如果手机号码格式不正确则输入框变成空
                return;
            }
            if (type11_tb.Text == "私有车位")
            {
                //添加车位信息SQL语句
                string inserSql = string.Format("update carport set Car_name='{0}',Address='{1}',Tell='{2}',Car_num='{3}',Car_type='{4}',tenancy_term='30' where ID='{6}'", Car_name_tb.Text.Trim(), addres_tb.Text.Trim(), tell_ttbb.Text.Trim(), Car_num_tb.Text.Trim(), Car_typeee.Text.Trim(), years_tb.Text.Trim(), ID.id);
                if (DBHepler.ExecuteNonQuery(inserSql))
                {
                    this.Close();
                }
            }
            if (type11_tb.Text == "公共车位" || type11_tb.Text == "租用车位")
            {
                //添加车位信息SQL语句
                string inserSQl = string.Format("update carport set Car_name='{0}',Address='{1}',Tell='{2}',Car_num='{3}',Car_type='{4}',tenancy_term='{5}' where ID='{6}'", Car_name_tb.Text.Trim(), addres_tb.Text.Trim(), tell_ttbb.Text.Trim(), Car_num_tb.Text.Trim(), Car_typeee.Text.Trim(), years_tb.Text.Trim(), ID.id);
                if (DBHepler.ExecuteNonQuery(inserSQl))
                {
                    this.Close();
                }
            }
        }