private void updateDataGridView() { if (this.searchClick == true) { string sj = this.year + this.month; String qStr = "select company,date,amount,type,status,ID from WeekPlanning where company " + (cmp != "" ? ("= '" + cmp + "'") : "is not null") + " and date " + (sj != "" ? ("like '" + sj + "%'") : "is not null") + " and week " + (z != "" ? ("= " + z) : "> 0") + " and type " + (ptype != "" ? (" = '" + ptype + "'") : "is not null") + " and (status " + (statues != "" ? (" = '" + statues + "')") : (" <> '已下达' and status <> '未下达')")); if (this.usrKind == "审批员") { qStr = "select company,date,amount,type,status,ID from WeekPlanning where company " + (cmp != "" ? ("= '" + cmp + "'") : "is not null") + " and date " + (year != "" ? ("like '" + year + "%'") : "is not null") + " and week " + (z != "" ? ("= " + z) : "> 0") + " and type " + (ptype != "" ? (" = '" + ptype + "'") : "is not null") + " and (status " + (statues != "" ? (" = '" + statues + "')") : (" <> '已下达' and status <> '未下达' and status <> '新增')")); } SQLquery query = new SQLquery(qStr); DataTable dt = query.doSelect(); if (dt == null) { MessageBox.Show("未查到符合条件的记录!", "提示"); } else { this.dataGridView1.Rows.Clear(); this.dataGridView1.Update(); for (int i = 0; i < dt.Rows.Count; i++) { string tem = dt.Rows[i][1].ToString(); string st = tem.Substring(0, 4) + "-" + tem.Substring(4, 2) + "-" + tem.Substring(6, 2); string et = tem.Substring(0, 4) + "-" + tem.Substring(8, 2) + "-" + tem.Substring(10, 2); this.dataGridView1.Rows.Add("false", i + 1, dt.Rows[i][0].ToString(), st, et, dt.Rows[i][2].ToString(), dt.Rows[i][3].ToString(), dt.Rows[i][4].ToString(), dt.Rows[i][5].ToString()); } } } }
private void updateDataGridView() { if (this.searchClick == true) { string sj = this.year + this.month; String qStr = "select company,date,amount,type,status,ID from MonthPlanning where company " + (cmp != "" ? ("= '" + cmp + "'") : "is not null") + " and date " + (sj != "" ? ("like '" + sj + "%'") : "is not null") + " and type " + (ptype != "" ? (" = '" + ptype + "'") : "is not null") + " and (status " + (statues != "" ? (" = '" + statues + "')") : (" = '已下达' or status = '未下达')")); SQLquery query = new SQLquery(qStr); DataTable dt = query.doSelect(); if (dt == null) { MessageBox.Show("未查到符合条件的记录!", "提示"); } else { this.dataGridView1.Rows.Clear(); this.dataGridView1.Update(); for (int i = 0; i < dt.Rows.Count; i++) { string tem = dt.Rows[i][1].ToString(); string st = tem.Substring(0, 4) + "-" + tem.Substring(4, 2) + "-" + tem.Substring(6, 2); string et = tem.Substring(0, 4) + "-" + tem.Substring(8, 2) + "-" + tem.Substring(10, 2); this.dataGridView1.Rows.Add("false", i + 1, dt.Rows[i][0].ToString(), st, et, dt.Rows[i][2].ToString(), dt.Rows[i][3].ToString(), dt.Rows[i][4].ToString(), "下达", "录入", dt.Rows[i][5].ToString()); if (dt.Rows[i][4].ToString() != "未下达") { Font f = new Font("宋体", 9, FontStyle.Strikeout); dataGridView1.Rows[i].Cells[8].Style.Font = f; } } } } }
private void 运输计划详细信息_Load(object sender, EventArgs e) { this.dataGridView1.AllowUserToAddRows = false; this.Text = "运输" + kind + "计划详细信息"; this.groupBox1.Text = "运输" + kind + "计划"; String qs1 = "select * from " + knd + "Planning where ID = '" + this.id + "'"; SQLquery q1 = new SQLquery(qs1); DataTable dt1 = q1.doSelect(); if (dt1 != null) { this.txt_cmp.Text = dt1.Rows[0][1].ToString(); string tem = dt1.Rows[0][2].ToString(); this.txt_zxsj.Text = tem.Substring(0, 4) + "-" + tem.Substring(4, 2) + "-" + tem.Substring(6, 2) + " 至 " + tem.Substring(0, 4) + "-" + tem.Substring(8, 2) + "-" + tem.Substring(10, 2); this.txt_type.Text = dt1.Rows[0][3].ToString(); this.txt_hj.Text = dt1.Rows[0][5].ToString(); this.txt_cjr.Text = dt1.Rows[0][6].ToString(); this.txt_time.Text = dt1.Rows[0][7].ToString(); this.txt_bz.Text = dt1.Rows[0][8].ToString(); this.txt_fj.Text = dt1.Rows[0][9].ToString(); } String qs2 = "select * from PlanningDetail where planID = '" + this.id + "'"; SQLquery q2 = new SQLquery(qs2); DataTable dt2 = q2.doSelect(); if (dt2 != null) { for (int i = 0; i < dt2.Rows.Count; i++) { this.dataGridView1.Rows.Add(dt2.Rows[i][0].ToString(), dt2.Rows[i][1].ToString(), dt2.Rows[i][2].ToString(), dt2.Rows[i][3].ToString(), dt2.Rows[i][4].ToString(), dt2.Rows[i][5].ToString()); } } }
private void btn_login_Click(object sender, EventArgs e) { String qStr = "select password,type from Usr where account = '" + this.txt_account.Text + "'"; SQLquery query = new SQLquery(qStr); DataTable dt = query.doSelect(); if (dt == null) { MessageBox.Show("用户不存在!", "提示"); } else if (dt.Rows[0][0].ToString() != this.txt_password.Text) { MessageBox.Show("密码错误!", "提示"); this.txt_password.Text = ""; } else if (dt.Rows[0][0].ToString() == this.txt_password.Text) { this.usrKind = dt.Rows[0][1].ToString(); this.txt_usrType.Text = dt.Rows[0][1].ToString(); this.txt_usrAccount.Text = this.txt_account.Text; this.menuEnabled = true; menuEnable(); } }
private void btn_delete_Click(object sender, EventArgs e) { for (int i = 0; i < this.dataGridView1.Rows.Count; i++) { if (this.dataGridView1.Rows[i].Cells[0].EditedFormattedValue.ToString() == "True") { if (this.dataGridView1.Rows[i].Cells[7].Value.ToString() == "新增" || this.dataGridView1.Rows[i].Cells[7].Value.ToString() == "不通过") { if (this.usrKind != "业务员") { MessageBox.Show("用户权限不够!", "提示"); return; } //删除年计划 deletePlan d = new deletePlan(this.dataGridView1.Rows[i].Cells["ID"].Value.ToString(), "年"); bool b = d.doDelete(); //得到对应月计划ID,删除对应月计划 String qStr = "select ID from MonthPlanning where planID = '" + this.dataGridView1.Rows[i].Cells["ID"].Value.ToString() + "'"; SQLquery query = new SQLquery(qStr); DataTable dt = query.doSelect(); if (dt != null) { for (int j = 0; j < dt.Rows.Count; j++) { //得到对应周计划ID,删除对应周计划 String qStr1 = "select ID from WeekPlanning where planID = '" + dt.Rows[j][0].ToString() + "'"; SQLquery query1 = new SQLquery(qStr1); DataTable dt1 = query1.doSelect(); if (dt1 != null) { for (int k = 0; k < dt1.Rows.Count; k++) { deletePlan d1 = new deletePlan(dt1.Rows[k][0].ToString(), "周"); d1.doDelete(); } } deletePlan d2 = new deletePlan(dt.Rows[j][0].ToString(), "月"); d2.doDelete(); } } if (b) { MessageBox.Show("删除计划成功!", "提示"); this.dataGridView1.Rows.RemoveAt(i); updateDataGridView(); } else { MessageBox.Show("删除计划失败!", "提示"); } } else { MessageBox.Show("该年计划不可删除!", "提示"); } } } }
private void 运输计划修改_Load(object sender, EventArgs e) { this.dataGridView1.AllowUserToAddRows = false; this.Text = "运输" + kind + "计划修改"; this.groupBox1.Text = "运输" + kind + "计划"; ld = new List <string>(); lm = new List <string>(); this.rb_railway.Checked = true; this.hjtxt = 0; this.totalMin = 0; this.totalUp = 0; String qs1 = "select * from " + knd + "Planning where ID = '" + this.id + "'"; SQLquery q1 = new SQLquery(qs1); DataTable dt1 = q1.doSelect(); if (dt1 != null) { this.txt_cmp.Text = dt1.Rows[0][1].ToString(); string tem = dt1.Rows[0][2].ToString(); this.txt_zxsj.Text = tem.Substring(0, 4) + "-" + tem.Substring(4, 2) + "-" + tem.Substring(6, 2) + " 至 " + tem.Substring(0, 4) + "-" + tem.Substring(8, 2) + "-" + tem.Substring(10, 2); this.txt_type.Text = dt1.Rows[0][3].ToString(); this.txt_cjr.Text = dt1.Rows[0][6].ToString(); this.txt_time.Text = dt1.Rows[0][7].ToString(); this.txt_bz.Text = dt1.Rows[0][8].ToString(); this.txt_fj.Text = dt1.Rows[0][9].ToString(); if (this.kind == "年") { //其下所以月计划量之和为计划量下限 String qStr2 = "select amount from MonthPlanning where planID = '" + this.id + "'"; SQLquery query2 = new SQLquery(qStr2); DataTable dt2 = query2.doSelect(); if (dt2 != null) { this.totalMin = Convert.ToDouble(dt2.Rows[0][0].ToString()); } } else if (this.kind == "月") { //其下所以月计划量之和为计划量下限 String qStr5 = "select amount from WeekPlanning where planID = '" + this.id + "'"; SQLquery query5 = new SQLquery(qStr5); DataTable dt5 = query5.doSelect(); if (dt5 != null) { this.totalMin = Convert.ToDouble(dt5.Rows[0][0].ToString()); } //对应年计划计划量减去此年计划下所有其他月计划量,为计划量上限 String qStr2 = "select amount from YearPlanning where ID = '" + dt1.Rows[0][10].ToString() + "'"; SQLquery query2 = new SQLquery(qStr2); DataTable dt2 = query2.doSelect(); if (dt2 != null) { this.totalUp = Convert.ToDouble(dt2.Rows[0][0].ToString()); } String qStr4 = "select ID,amount from MonthPlanning where planID = '" + dt1.Rows[0][10].ToString() + "'"; SQLquery query4 = new SQLquery(qStr4); DataTable dt4 = query4.doSelect(); if (dt4 != null) { for (int i = 0; i < dt4.Rows.Count; i++) { if (this.id != dt4.Rows[i][0].ToString()) { this.totalUp -= Convert.ToDouble(dt4.Rows[i][1].ToString()); } } } } else if (this.kind == "周") { String qStr2 = "select amount from MonthPlanning where ID = '" + dt1.Rows[0][10].ToString() + "'"; SQLquery query2 = new SQLquery(qStr2); DataTable dt2 = query2.doSelect(); if (dt2 != null) { this.totalUp = Convert.ToDouble(dt2.Rows[0][0].ToString()); } String qStr4 = "select ID,amount from WeekPlanning where planID = '" + dt1.Rows[0][10].ToString() + "'"; SQLquery query4 = new SQLquery(qStr4); DataTable dt4 = query4.doSelect(); if (dt4 != null) { for (int i = 0; i < dt4.Rows.Count; i++) { if (this.id != dt4.Rows[i][0].ToString()) { this.totalUp -= Convert.ToDouble(dt4.Rows[i][1].ToString()); } } } } } String qs3 = "select * from PlanningDetail where planID = '" + this.id + "'"; SQLquery q3 = new SQLquery(qs3); DataTable dt3 = q3.doSelect(); if (dt3 != null) { for (int i = 0; i < dt3.Rows.Count; i++) { this.dataGridView1.Rows.Add(dt3.Rows[i][0].ToString(), dt3.Rows[i][1].ToString(), dt3.Rows[i][2].ToString(), dt3.Rows[i][3].ToString(), dt3.Rows[i][4].ToString(), dt3.Rows[i][5].ToString(), "删除", dt3.Rows[i][7].ToString()); hjtxt += Convert.ToDouble(dt3.Rows[i][5].ToString()); } } this.txt_hj.Text = hjtxt.ToString("0.0"); this.isLoad = true; }