private void button3_Click(object sender, EventArgs e) { if (DGrdWork.RowCount <= 0 || DGrdMaterial.RowCount <= 0) { MessageBox.Show("单据生成不完整,填充完整后单击 '生成单据'", "存入数据库失败", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (TxtContractNu.Text == "") { TxtContractNu.BackColor = Color.Red; MessageBox.Show("合同编号不能为空'", "存入数据库失败", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } DataSet Ds = new DataSet(); if ((Ds = Db.Search("SELECT * FROM GongDan where HeTongBianHao='" + TxtContractNu.Text + "'")) != null && Ds.Tables[0].Rows.Count > 0) { MessageBox.Show("该单号已存在!!"); return; } string temp = ""; if (GongDanSqlStr != "") { Db.DataProcess(GongDanSqlStr); temp += " 工单 "; } if (LiaoDanSqlStr != "") { Db.DataProcess(LiaoDanSqlStr); temp += " 料单 "; } if (CanShuDanSqlStr != "") { Db.DataProcess(CanShuDanSqlStr); temp += " 参数单 "; } MessageBox.Show(temp + "保存成功"); DGrdWork.Rows.Clear(); DGrdDemand.Rows.Clear(); DGrdMaterial.Rows.Clear(); GongDanSqlStr = ""; LiaoDanSqlStr = ""; CanShuDanSqlStr = ""; }
private void button4_Click(object sender, EventArgs e) { if (CboxSearch.Text == "") { return; } Db.DataProcess("Delete from GongDan where HeTongBianHao='" + CboxSearch.Text + "'"); Db.DataProcess("Delete from LiaoDan where HeTongBianHao='" + CboxSearch.Text + "'"); Db.DataProcess("Delete from CanShuDan where HeTongBianHao='" + CboxSearch.Text + "'"); Search("SELECT * FROM GongDan"); FillCbox(); }