Exemple #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (txtCarNo.Text == "")
            {
                MessageBox.Show("卡号不允许为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            //if (txtCarNumber.Text == "")
            //{
            //    MessageBox.Show("车牌号不允许为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //    return;
            //}
            //if (txtDriver.Text == "")
            //{
            //    MessageBox.Show("驾驶员姓名不允许为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //    return;
            //}
            //if (txtTare.Text == "")
            //{
            //    MessageBox.Show("汽车皮重不允许为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //    return;
            //}
            if (cmbContractNo.Text == "")
            {
                MessageBox.Show("合同编号不允许为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (txtBzWeight.Text == "")
            {
                MessageBox.Show("标准载重不允许为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string str = "select * from CarManage where cm_szqy = '" + ConnectionManger.G_MineArea + "' and cm_kcode = '" + txtCarNo.Text + "'";

            if (SQLHelper.IsPriExist(str))
            {
                MessageBox.Show("该卡号已录入过车辆信息!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                try
                {
                    //DataTable dtkh = select.select_CarManage_kh(txtCarNo.Text);
                    //if (dtkh.Rows.Count > 0)
                    //{

                    //}

                    str = "Insert into CarManage(cm_kcode,cm_carnumber,cm_jsy,cm_szqy,cn_code,cm_bzweight,cm_homeunit,cm_runsign) values('" + txtCarNo.Text + "','" + txtCarNumber.Text
                          + "','" + txtDriver.Text + "','" + ConnectionManger.G_MineArea + "','" + cmbContractNo.Text
                          + "','" + txtBzWeight.Text + "','" + cmbHomeUnit.Text + "','" + comboBox1.Text + "')";
                    SQLHelper.ExecuteNonQuery(CommandType.Text, str, null);
                }
                catch
                {
                    MessageBox.Show("请检查所填数据是否合法!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    this.Close();
                }
            }
        }