private void BtnAddPM_Click(object sender, EventArgs e) { //if (txtPMNo.Text == "") //{ // MessageBox.Show("品名代码不允许为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error); // return; //} if (txtPM.Text == "") { MessageBox.Show("品名不允许为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string str = "select * from GoodsName where gn_name = '" + txtPM.Text + "' and gn_area='" + ConnectionManger.G_MineArea + "'"; if (SQLHelper.IsPriExist(str)) { MessageBox.Show("该品名已存在!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { try { str = "Insert into GoodsName(gn_area,gn_name) values('" + ConnectionManger.G_MineArea + "','" + txtPM.Text + "')"; SQLHelper.ExecuteNonQuery(CommandType.Text, str, null); ShowPMInfo(); ClearPM(); } catch { MessageBox.Show("请检查所填数据是否合法!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void BtnAddGH_Click(object sender, EventArgs e) { //if (txtGHNo.Text == "") //{ // MessageBox.Show("供货单位代码不允许为空!","提示信息",MessageBoxButtons.OK ,MessageBoxIcon.Error ); // return; //} if (txtGHDW.Text == "") { MessageBox.Show("供货单位不允许为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string str = "select * from SupplyUnit where su_area = '" + ConnectionManger.G_MineArea + "' and su_unit = '" + txtGHDW.Text + "'"; if (SQLHelper.IsPriExist(str)) { MessageBox.Show("该供货单位已存在!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { try { str = "Insert into SupplyUnit(su_area,su_unit) values('" + ConnectionManger.G_MineArea + "','" + txtGHDW.Text + "')"; SQLHelper.ExecuteNonQuery(CommandType.Text, str, null); ShowGHDWInfo(); ClearGHDW(); } catch { MessageBox.Show("请检查所填数据是否合法!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
//修改 private void Button2_Click(object sender, EventArgs e) { if (TxtName.Text == "") { MessageBox.Show("用户名不允许为空!", "用户信息修改", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (TxtPsw.Text == "") { MessageBox.Show("密码不允许为空!", "用户信息修改", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (CmbType.Text == "") { MessageBox.Show("请选择用户类型!", "用户信息修改", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string str = "select * from user_table where user_area = '" + ConnectionManger.G_MineArea + "' and user_name = '" + TxtName.Text + "'"; if (SQLHelper.IsPriExist(str)) { str = "update user_table set user_pwd = '" + TxtPsw.Text + "',user_lever='" + CmbType.Text + "' where user_area = '" + ConnectionManger.G_MineArea + "' and user_name = '" + TxtName.Text + "'"; SQLHelper.ExecuteNonQuery(CommandType.Text, str, null); UpdateDataGridView1(); MessageBox.Show("用户信息修改成功!", "用户信息修改", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { MessageBox.Show("该用户名不存在!", "用户信息修改", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//FrmContractInfo frms = new FrmContractInfo(); private void btnAdd_Click(object sender, EventArgs e) { if (txtContractNo.Text == "") { MessageBox.Show("合同编号不允许为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (cmbGoodsName.Text == "") { MessageBox.Show("品名不允许为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (cmbSupplyUnit.Text == "") { MessageBox.Show("供货单位不允许为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (cmbReciveUnit.Text == "") { MessageBox.Show("收货单位不允许为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (txtSumWeight.Text == "") { MessageBox.Show("合同总量不允许为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (txtWeight.Text == "") { MessageBox.Show("已运量不允许为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string str = "select cn_code from ContractNews where cn_area = '" + ConnectionManger.G_MineArea + "' and cn_code = '" + txtContractNo.Text + "'"; if (SQLHelper.IsPriExist(str)) { MessageBox.Show("该合同编号已存在!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { try { str = "Insert into ContractNews(cn_code,cn_hwmc,cn_area,su_unit,ru_unit,cn_htzl,cn_yysl,cn_time) values('" + txtContractNo.Text + "','" + cmbGoodsName.Text + "','" + ConnectionManger.G_MineArea + "','" + cmbSupplyUnit.Text + "','" + cmbReciveUnit.Text + "','" + txtSumWeight.Text + "','" + txtWeight.Text + "','" + DateTime.Now.ToString("yyyy-MM-dd") + "')"; SQLHelper.ExecuteNonQuery(CommandType.Text, str, null); MessageBox.Show("该合同信息添加成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); //frms.UpdateDataGrid(FrmContractInfo.start, FrmContractInfo.end, ""); } catch { MessageBox.Show("请检查所填数据是否合法!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { this.Close(); } } }
private void Button3_Click(object sender, EventArgs e) { string str = "select * from user_table where user_area = '" + ConnectionManger.G_MineArea + "' and user_name = '" + TxtName.Text + "'"; if (SQLHelper.IsPriExist(str)) { DialogResult result = MessageBox.Show("删除后数据不可恢复,确定要删除选中数据?", "用户信息删除", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (result == DialogResult.Cancel) { return; } str = "delete from user_table where user_area = '" + ConnectionManger.G_MineArea + "' and user_name = '" + TxtName.Text + "'"; SQLHelper.ExecuteNonQuery(CommandType.Text, str, null); UpdateDataGridView1(); MessageBox.Show("用户信息删除成功!", "用户信息删除", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { MessageBox.Show("该用户名不存在!", "用户信息删除", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//添加 private void Button1_Click(object sender, EventArgs e) { if (TxtName.Text == "") { MessageBox.Show("用户名不允许为空!", "添加用户信息", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (TxtPsw.Text == "") { MessageBox.Show("密码不允许为空!", "添加用户信息", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (CmbType.Text == "") { MessageBox.Show("请选择用户类型!", "添加用户信息", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string str = "select * from user_table where user_area = '" + ConnectionManger.G_MineArea + "' and user_name = '" + TxtName.Text + "'"; if (SQLHelper.IsPriExist(str)) { MessageBox.Show("该用户信息已存在!", "添加用户信息", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { str = "insert into user_table values('" + TxtName.Text + "','" + TxtPsw.Text + "','" + ConnectionManger.G_MineArea + "','" + CmbType.Text + "')"; SQLHelper.ExecuteNonQuery(CommandType.Text, str, null); ClearUserInfo(); UpdateDataGridView1(); MessageBox.Show("户信息添加成功!", "添加用户信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } catch { MessageBox.Show("请检查所填用户信息是否合法!", "用户添加失败", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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(); } } }