private void loadDialog(String strFormular) { Dialog.frmDialogFormular frm = new Dialog.frmDialogFormular(strFormular);//เรียกหน้าเพิ่มสูตรผลิต frm.dataGridView2.Visible = false; frm.dataGridView1.Dock = DockStyle.Fill; frm.tableLayoutPanel1.SetColumnSpan(frm.dataGridView1, 2); //frm.dataGridView1.MultiSelect = true; frm.ShowDialog(); if (frm.DialogResult == DialogResult.OK) { if (frm.getStatus() == "อนุมัติ") { String t = ""; String t2 = ""; if (rdoNetWell.Checked) { t = "อวนสามชั้นดี"; t2 = "1"; } else if (rdoNetFail.Checked) { t = "อวนสามชั้นซ่อม"; t2 = "2"; } string sql = "select p.pvwid,p.pvwnetprice from ProductionVillagerWage p inner join ProductionSize s on p.sizetypeid = s.szid where pvwstatusid = 4 and supplierid = " + Class.Function.GetTextIdx(txtVillager.Text) + " and szname = '" + frm.getFormularSize() + "' "; DataTable pvwnetprice = Class.DBConnString.clsDB.QueryDataTable(sql); if (pvwnetprice.Rows.Count > 0) { foreach (DataRow r in pvwnetprice.Rows) { dataGridView2.Rows.Add(frm.getFormularId(), frm.getFormularName(), "", "", r["pvwid"].ToString(), r["pvwnetprice"].ToString(), "", "", 4, t2, t); } } else { MessageBox.Show("ชาวบ้านนี้ยังไม่มีสูตร " + frm.getFormularName()); return; } if (t == "อวนสามชั้นดี") dataGridView2.Rows[dataGridView2.Rows.Count - 1].DefaultCellStyle.ForeColor = Color.Black; if (t == "อวนสามชั้นซ่อม") dataGridView2.Rows[dataGridView2.Rows.Count - 1].DefaultCellStyle.ForeColor = Color.Red; } else { MessageBox.Show("สูตรที่เลือกยังไม่อนุมัติ"); } } }
private void txtFormula_KeyDown(object sender, KeyEventArgs e) { if (Class.Function.GetTextIdx(txtJ.Text) != "") { if (e.KeyCode == Keys.Enter) { Dialog.frmDialogFormular Formular = new Dialog.frmDialogFormular(txtFormula.Text); Formular.ShowDialog(); if (Formular.DialogResult == DialogResult.OK) { string sql = "select pw.pwn7,pw.pwoutside from ProductionPrisonWage pw \n" + "inner join ProductionSize ps on pw.SizeTypeId = ps.SzId \n" + "where pw.employerid = " + Class.Function.GetTextIdx(txtJ.Text) + " AND szname = '" + Formular.getFormularSize() + "'"; DataTable pw = Class.DBConnString.clsDB.QueryDataTable(sql); if (pw.Rows.Count > 0) { foreach (DataRow r in pw.Rows) { dgvItem.Rows.Add(Formular.getFormularId(), Formular.getFormularName(), 0, 0, r["PwN7"].ToString(), r["PwOutSide"].ToString(), 0, 0, "", "", "", 1, 1); } } else { MessageBox.Show(Class.Function.GetTextName(txtJ.Text) + " ไม่มีสูตรผลิต " + Formular.getFormularName()); } } } } else { MessageBox.Show("กรุณาเลือกเรือนจำก่อน"); } }