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_Click(object sender, EventArgs e)
 {
     Dialog.frmDialogFormular frm = new Dialog.frmDialogFormular();
     frm.dataGridView2.Visible = false;
     frm.dataGridView1.Dock = DockStyle.Fill;
     frm.tableLayoutPanel1.SetColumnSpan(frm.dataGridView1, 2);
     frm.toolStrip1.Enabled = false;
     frm.ShowDialog();
     if (frm.DialogResult == DialogResult.OK)
     {
         if (frm.getStatus() == "อนุมัติ")
         {
             Fm = frm.getFormularId();
             this.txtFormula.Text = frm.getFormularName();
         }
         else
         {
             MessageBox.Show("สูตรที่เลือกยังไม่อนุมัติ");
         }
     }
 }
 private void loadDialog()
 {
     /*เรียกหน้าจัดการสูตรผลิต*/
     Dialog.frmDialogFormular frm = new Dialog.frmDialogFormular(textBox7.Text);
     frm.dataGridView2.Visible = false;
     frm.dataGridView1.Dock = DockStyle.Fill;
     frm.tableLayoutPanel1.SetColumnSpan(frm.dataGridView1, 2);
     frm.toolStrip1.Enabled = false;
     frm.ShowDialog();
     if (frm.DialogResult == DialogResult.OK)
     {
         if (frm.getStatus() == "อนุมัติ")
         {
             textBox7.Text = frm.getFormularId();
             textBox8.Text = frm.getFormularName();
             textBox9.Text = frm.getCateName();
             CateId = frm.getCateId();
             textBox10.Focus();
         }
         else {
             MessageBox.Show("สูตรที่เลือกยังไม่อนุมัติ");
         }
     }
 }