/*เรียก Dialog สูตรผลิต*/
        private void loadDialog()
        {
            Dialog.frmDialogFormular frm = new Dialog.frmDialogFormular(1);
            frm.dataGridView2.Visible = false;
            frm.dataGridView1.Dock = DockStyle.Fill;
            frm.tableLayoutPanel1.SetColumnSpan(frm.dataGridView1, 2);
            //frm.toolStrip1.Enabled = false;
            frm.dataGridView1.MultiSelect = true;
            frm.ShowDialog();
            if (frm.DialogResult == DialogResult.OK)
            {
                if (frm.getStatusList().Count != 0)
                {
                    if (frm.getStatusList()[0] == "อนุมัติ")
                    {
                        this.textBox2.Text = "[" +frm.getFormularId() + "] " + frm.getFormularName();
                    }
                    else
                    {
                        MessageBox.Show("สูตรที่เลือกยังไม่อนุมัติ");
                    }
                }

            }
        }
 private void loadDialog(String strFormular)
 {
     Dialog.frmDialogFormular frm = new Dialog.frmDialogFormular(strFormular);//เรียกหน้าเพิ่มสูตรผลิต
     //Dialog.frmDialogFormular frm = new Dialog.frmDialogFormular(1);
     frm.dataGridView2.Visible = false;
     frm.dataGridView1.Dock = DockStyle.Fill;
     frm.tableLayoutPanel1.SetColumnSpan(frm.dataGridView1, 2);
     //frm.toolStrip1.Enabled = false;
     frm.dataGridView1.MultiSelect = true;
     frm.ShowDialog();
     if (frm.DialogResult == DialogResult.OK)
     {
         for (int s = 0; s < frm.getStatusList().Count; s++ )
         {
             if (frm.getStatusList()[s] == "อนุมัติ")
             {
                 String t = "";
                 if (radioButton1.Checked)
                 {
                     t = "อวนดี";
                 }
                 else if (radioButton2.Checked)
                 {
                     t = "อวนซ่อมเรือนจำ";
                 }
                 else
                 {
                     t = "อวนซ่อมบริษัท";
                 }
                 if (dataGridView2.Rows.Count == 0)
                 {
                     last_pallet_id = Class.Function.ReturnId("ProductionWaitDetailId", "ProductionWaitDetail");
                     dataGridView2.Rows.Add(last_pallet_id, frm.getFormularIdList()[s], frm.getFormularNameList()[s], "", "", frm.getUnitList()[s], "", "", "", "", "", "", "", "",t);
                     //เก็บข้อมูลรายการสินค้า
                 }
                 else
                 {
                     dataGridView2.Rows.Add(++last_pallet_id, frm.getFormularIdList()[s], frm.getFormularNameList()[s], "", "", frm.getUnitList()[s], "", "", "", "", "", "", "","",t);
                     //เก็บข้อมูลรายการสินค้า
                 }
                 if (t == "อวนดี") dataGridView2.Rows[dataGridView2.Rows.Count - 1].DefaultCellStyle.ForeColor = Color.Black;
                 if (t == "อวนซ่อมเรือนจำ") dataGridView2.Rows[dataGridView2.Rows.Count - 1].DefaultCellStyle.ForeColor = Color.Blue;
                 if (t == "อวนซ่อมบริษัท") dataGridView2.Rows[dataGridView2.Rows.Count - 1].DefaultCellStyle.ForeColor = Color.Chocolate;
             }
             else
             {
                 MessageBox.Show("สูตรที่เลือกยังไม่อนุมัติ");
             }
         }
     }
 }
        private void txtFormula_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                Dialog.frmDialogFormular r = new Dialog.frmDialogFormular(txtFormula.Text);
                r.StartPosition = FormStartPosition.CenterScreen;
                r.ShowDialog();

                if (r.DialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    txtFormula.Text = "["+r.getFormularId()+"] " + r.getFormularName() + "";
                    label7.Text = r.getUnit();
                }
            }
        }
 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 txtFormula_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                Dialog.frmDialogFormular frm = new Dialog.frmDialogFormular(txtFormula.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 == System.Windows.Forms.DialogResult.OK)
                {
                    txtFormula.Text = "[" + frm.getFormularId() + "] " + frm.getFormularName() + "";
                    label7.Text = frm.getUnit();
                }
            }
        }
        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("กรุณาเลือกเรือนจำก่อน");
     }
 }
        private void btn_Click(object sender, EventArgs e)/*เมื่อมีการ click ปุ่มการทำงาน*/
        {
            switch(NewFrm){

                case "Supplier" ://เรียก Dialog ข้อมูลผู้ขาย
                    Dialog.frmDialogSearchSupplier Supplier;
                    String[] spSupplier = NewTxt.Text.Split(']');
                    if (spSupplier.Length < 2)
                    {
                        Supplier = new Dialog.frmDialogSearchSupplier(NewTxt.Text);
                    }
                    else
                    {
                        Supplier = new Dialog.frmDialogSearchSupplier(spSupplier[1]);
                    }
                    Supplier.ShowDialog();
                    if (Supplier.DialogResult == DialogResult.OK)
                    {
                        NewTxt.Text = "[" + Supplier.GetSuplierId() + "] " + Supplier.GetSuplierName();
                    }
                    SendKeys.Send("{TAB}");
                    break;
                case "Branch"://เรียก Dialog ข้อมูลสาขา
                    Dialog.frmDialogSearchBranch Branch;
                    String[] spBranch = NewTxt.Text.Split(']');
                    if (spBranch.Length < 2)
                    {
                        Branch = new Dialog.frmDialogSearchBranch(NewTxt.Text);
                    }
                    else
                    {
                        Branch = new Dialog.frmDialogSearchBranch(spBranch[1]);
                    }
                    Branch.ShowDialog();
                    if (Branch.DialogResult == DialogResult.OK)
                    {
                        NewTxt.Text = "[" + Branch.GetBranchId() + "] " + Branch.GetBranchName();

                    }
                    SendKeys.Send("{TAB}");
                    break;
                case "Shipper"://เรียก Dialog ข้อมูลขนส่ง
                    Dialog.frmDialogSearchShipper Shipper;
                    String[] spShipper = NewTxt.Text.Split(']');
                    if (spShipper.Length < 2)
                    {
                        Shipper = new Dialog.frmDialogSearchShipper(NewTxt.Text);
                    }
                    else
                    {
                        Shipper = new Dialog.frmDialogSearchShipper(spShipper[1]);
                    }
                    Shipper.ShowDialog();
                    if (Shipper.DialogResult == DialogResult.OK)
                    {
                        NewTxt.Text = "[" + Shipper.GetShipperId() + "] " + Shipper.GetShipperName();
                    }
                    SendKeys.Send("{TAB}");
                    break;
                case "Employer"://เรียก Dialog ข้อมูลเรือนจำ
                    Dialog.frmDialogSearchEmployer Employer;
                    String[] spEmployer = NewTxt.Text.Split(']');
                    if (spEmployer.Length < 2)
                    {
                        Employer = new Dialog.frmDialogSearchEmployer(NewTxt.Text);
                    }
                    else
                    {
                        Employer = new Dialog.frmDialogSearchEmployer(spEmployer[1]);
                    }
                    Employer.ShowDialog();
                    if (Employer.DialogResult == DialogResult.OK)
                    {
                        NewTxt.Text = "[" + Employer.GetEmployerId() + "] " + Employer.GetEmployerName();
                    }
                    SendKeys.Send("{TAB}");
                    break;
                case "CardFormula"://เรียก Dialog ข้อมูลเรือนจำ
                    ProductionNew.DialogSelectFormula SelectFormula;
                    String[] spSelectFormula = NewTxt.Text.Split(']');
                    if (spSelectFormula.Length < 2)
                    {
                        SelectFormula = new ProductionNew.DialogSelectFormula(NewTxt.Text);
                    }
                    else
                    {
                        SelectFormula = new ProductionNew.DialogSelectFormula(spSelectFormula[1]);
                    }
                    SelectFormula.ShowDialog();
                    if (SelectFormula.DialogResult == DialogResult.OK)
                    {
                        NewTxt.Text = "[" + SelectFormula.GetFmId() + "] " + SelectFormula.GetFmName();
                    }
                    SendKeys.Send("{TAB}");
                    break;
                case "Product"://เรียก Dialog ข้อมูลรายการสินค้า
                    Dialog.frmDialogSearchProduct Product;
                    String[] spProduct = NewTxt.Text.Split(']');
                    if (spProduct.Length < 2)
                    {
                        Product = new Dialog.frmDialogSearchProduct(NewTxt.Text);
                    }
                    else
                    {
                        Product = new Dialog.frmDialogSearchProduct(spProduct[1]);
                    }
                    Product.ShowDialog();
                    if (Product.DialogResult == DialogResult.OK)
                    {
                        NewTxt.Text = "[" + Product.GetProductId() + "] " + Product.GetProductName();
                    }
                    SendKeys.Send("{TAB}");
                    break;
                case "Customer"://เรียก Dialog ข้อมูลลูกค้า
                    Dialog.frmDialogSearchCustomer Customer;
                    String[] spCustomer = NewTxt.Text.Split(']');
                    if (spCustomer.Length < 2)
                    {
                        Customer = new Dialog.frmDialogSearchCustomer(NewTxt.Text);
                    }
                    else
                    {
                        Customer = new Dialog.frmDialogSearchCustomer(spCustomer[1]);
                    }
                    Customer.ShowDialog();
                    if (Customer.DialogResult == DialogResult.OK)
                    {
                        NewTxt.Text = "[" + Customer.GetCustomerId() + "] " + Customer.GetCustomerName();
                    }
                    SendKeys.Send("{TAB}");
                    break;
                case "CustomerInv"://เรียก Dialog ข้อมูลลูกค้าต่างประเทศ
                    SalePosNew.DialogCustomerInv CustomerInv;
                    String[] spCustomerInv = NewTxt.Text.Split(']');
                    if (spCustomerInv.Length < 2)
                    {
                        CustomerInv = new SalePosNew.DialogCustomerInv(NewTxt.Text,2);
                    }
                    else
                    {
                        CustomerInv = new SalePosNew.DialogCustomerInv(spCustomerInv[1],2);
                    }
                    CustomerInv.ShowDialog();
                    if (CustomerInv.DialogResult == DialogResult.OK)
                    {
                        NewTxt.Text = "[" + CustomerInv.GetCustomerId() + "] " + CustomerInv.GetCustomerName();
                    }
                    SendKeys.Send("{TAB}");
                    break;
                case "CustomerTHA"://เรียก Dialog ข้อมูลลูกค้าเฉพาะลูกค้าไทย
                    SalePosNew.DialogCustomerInv CustomerTHA;
                    String[] spCustomerTHA = NewTxt.Text.Split(']');
                    if (spCustomerTHA.Length < 2)
                    {
                        CustomerTHA = new SalePosNew.DialogCustomerInv(NewTxt.Text, 1);
                    }
                    else
                    {
                        CustomerTHA = new SalePosNew.DialogCustomerInv(spCustomerTHA[1], 1);
                    }
                    CustomerTHA.ShowDialog();
                    if (CustomerTHA.DialogResult == DialogResult.OK)
                    {
                        NewTxt.Text = "[" + CustomerTHA.GetCustomerId() + "] " + CustomerTHA.GetCustomerName();
                    }
                    SendKeys.Send("{TAB}");
                    break;

                case "Stock"://เรียก Dialog ข้อมูลคลังสินค้า
                    Dialog.frmDialogSearchStocks Stock;
                    String[] spStock = NewTxt.Text.Split(']');
                    if (spStock.Length < 2)
                    {
                        if (notInList != "")
                        {
                            Stock = new Dialog.frmDialogSearchStocks(NewTxt.Text, notInList,stock);
                        }
                        else 
                        {
                            Stock = new Dialog.frmDialogSearchStocks(NewTxt.Text,stock);
                        }
                    }
                    else
                    {
                        if (notInList != "")
                        {
                            Stock = new Dialog.frmDialogSearchStocks(spStock[1], notInList,stock);
                        }
                        else
                        {
                            Stock = new Dialog.frmDialogSearchStocks(spStock[1],stock);
                        }
                    }
                    Stock.ShowDialog();
                    if (Stock.DialogResult == DialogResult.OK)
                    {
                        NewTxt.Text = "[" + Stock.GetStockId() + "] " + Stock.GetStockName();
                        SendKeys.Send("{TAB}");
                    }
                    SendKeys.Send("{TAB}");
                    break;
                case "FormuLar"://เรียก Dialog ข้อมูลสูตรผลิต
                    Dialog.frmDialogFormular FormuLar;
                    String[] spFormuLar = NewTxt.Text.Split(']');
                    if (spFormuLar.Length < 2)
                    {
                        FormuLar = new Dialog.frmDialogFormular(NewTxt.Text);
                    }
                    else
                    {
                        FormuLar = new Dialog.frmDialogFormular(spFormuLar[1]);
                    }
                    FormuLar.ShowDialog();
                    if (FormuLar.DialogResult == DialogResult.OK)
                    {
                        NewTxt.Text = "[" + FormuLar.getFormularId() + "]" + FormuLar.getFormularName();
                    }
                    SendKeys.Send("{TAB}");
                    break;
                case "NettingFail"://เรียก Dialog ข้อมูลประเภาสินค้าที่เสีย
                    ProductionNew.frmNettingFail NettingFail;
                    String[] spNettingFail = NewTxt.Text.Split(']');
                    if (spNettingFail.Length < 2)
                    {
                        NettingFail = new ProductionNew.frmNettingFail(NewTxt.Text);
                    }
                    else
                    {
                        NettingFail = new ProductionNew.frmNettingFail(spNettingFail[1]);
                    }
                    NettingFail.ShowDialog();
                    if (NettingFail.DialogResult == DialogResult.OK)
                    {
                        NewTxt.Text = "[" + NettingFail.getCateId() + "]" + NettingFail.getCateName();
                        SendKeys.Send("{TAB}");
                    }
                    SendKeys.Send("{TAB}");
                    break;
                case "Material"://เรียก Dialog ข้อมูลวัตถุดิบ
                    Dialog.frmDialogCateNet Material;
                    String[] spMaterial = NewTxt.Text.Split(']');
                    if (spMaterial.Length < 2)
                    {
                        Material = new Dialog.frmDialogCateNet(NewTxt.Text);
                    }
                    else
                    {
                        Material = new Dialog.frmDialogCateNet(spMaterial[1]);
                    }
                    Material.toolStripButton5.Enabled = true;
                    Material.ShowDialog();
                    if (Material.DialogResult == DialogResult.OK)
                    {
                        NewTxt.Text = "[" + Material.getMidString() + "]" + Material.getMnameString();
                    }
                    SendKeys.Send("{TAB}");
                    break;
                case "ACustomer"://เรียก Dialog ข้อมูลคลังสินค้า
                    StockAsiaDrink.DialogSearchCOStock ACustomer;
                    String[] spACustomer = NewTxt.Text.Split(']');
                    if (spACustomer.Length < 2)
                    {
                        ACustomer = new StockAsiaDrink.DialogSearchCOStock(NewTxt.Text);
                    }
                    else
                    {
                        ACustomer = new StockAsiaDrink.DialogSearchCOStock(spACustomer[1]);
                    }
                    ACustomer.ShowDialog();
                    if (ACustomer.DialogResult == DialogResult.OK)
                    {
                        NewTxt.Text = "[" + ACustomer.GetCustomerId() + "] " + ACustomer.GetCustomerName();
                    }
                    SendKeys.Send("{TAB}");
                    break;

                case "BranchReceive"://เรียก Dialog ข้อมูลสาขาที่รับ
                    Dialog.frmDialogSearchBranch br;
                    String[] spBr = NewTxt.Text.Split(']');
                    if (spBr.Length < 2)
                    {
                        br = new Dialog.frmDialogSearchBranch(NewTxt.Text, Class.DBConnString.sDb);
                    }
                    else
                    {
                        br = new Dialog.frmDialogSearchBranch(spBr[1], Class.DBConnString.sDb);
                    }
                    br.ShowDialog();
                    if (br.DialogResult == DialogResult.OK)
                    {
                        NewTxt.Text = "[" + br.GetBranchId() + "] " + br.GetBranchName();
                    }
                    SendKeys.Send("{TAB}");
                    break;

                case "AShipper"://เรียก Dialog ข้อมูลขนส่ง
                    Dialog.frmDialogSearchShipper AShipper;
                    String[] spAShipper = NewTxt.Text.Split(']');
                    if (spAShipper.Length < 2)
                    {
                        AShipper = new Dialog.frmDialogSearchShipper(NewTxt.Text);
                    }
                    else
                    {
                        AShipper = new Dialog.frmDialogSearchShipper(spAShipper[1]);
                    }
                    AShipper.ShowDialog();
                    if (AShipper.DialogResult == DialogResult.OK)
                    {
                        NewTxt.Text = "[" + AShipper.GetShipperId() + "] " + AShipper.GetShipperName();
                    }
                    SendKeys.Send("{TAB}");
                    break;

                case "username"://เรียก Dialog ข้อมูลขนส่ง
                    Requirement .DialogUserName  username;
                    String[] spusername = NewTxt.Text.Split(']');
                    if (spusername.Length < 2)
                    {
                        username = new Requirement.DialogUserName(NewTxt.Text);
                    }
                    else
                    {
                        username = new Requirement.DialogUserName(spusername[1]);
                    }
                    username.ShowDialog();
                    if (username.DialogResult == DialogResult.OK)
                    {
                        NewTxt.Text = "[" + username.GetUserName() + "] " + username.GetName();
                    }
                    SendKeys.Send("{TAB}");
                    break;
                case "usernameAll"://เรียก Dialog ข้อมูลขนส่ง
                    Requirement.DialogUserNameAll usernameAll;
                    String[] spusernameAll = NewTxt.Text.Split(']');
                    if (spusernameAll.Length < 2)
                    {
                        usernameAll = new Requirement.DialogUserNameAll(NewTxt.Text);
                    }
                    else
                    {
                        usernameAll = new Requirement.DialogUserNameAll(spusernameAll[1]);
                    }
                    usernameAll.ShowDialog();
                    if (usernameAll.DialogResult == DialogResult.OK)
                    {
                        NewTxt.Text = "[" + usernameAll.GetUserName() + "] " + usernameAll.GetName();
                    }
                    SendKeys.Send("{TAB}");
                    break;
                case "Req"://เรียก Dialog ข้อมูลขนส่ง
                    Requirement.DialogReq  Req;
                    String[] spReq = NewTxt.Text.Split(']');
                    if (spReq.Length < 2)
                    {
                        Req = new Requirement.DialogReq(NewTxt.Text);
                    }
                    else
                    {
                        Req = new Requirement.DialogReq(spReq[1]);
                    }
                    Req.ShowDialog();
                    if (Req.DialogResult == DialogResult.OK)
                    {
                        NewTxt.Text = "[" + Req.GetReqId() + "] " + Req.GetTitle();
                    }
                    SendKeys.Send("{TAB}");
                    break;
                // 7/5/58 test frmSentConsignmentnew
                case "ASid"://เรียก Dialog ข้อมูลใบเบิก
                    Dialog.frmDialogSearchRequis ASid;
                    String[] spASid = NewTxt.Text.Split(']');
                    if (spASid.Length < 2)
                    {
                        ASid = new Dialog.frmDialogSearchRequis(NewTxt.Text);
                    }
                    else
                    {
                        ASid = new Dialog.frmDialogSearchRequis(spASid[1]);
                    }
                    ASid.ShowDialog();
                    if (ASid.DialogResult == DialogResult.OK)
                    {
                        NewTxt.Text = "[" + ASid.GetShipperId() + "] " + ASid.GetShipperName();
                    }
                    SendKeys.Send("{TAB}");
                    break;
                // end 7/5/58 test frmSentConsignmentnew
                case "ProductAsiadrink"://เรียก Dialog ข้อมูลรายการสินค้าของสต็อกย่อย 
                    Dialog.frmDialogSearchProductStockAsiadrink ProductAsiadrink;
                    String[] spProductAsiadrink = NewTxt.Text.Split(']');
                    if (spProductAsiadrink.Length < 2)
                    {
                        ProductAsiadrink = new Dialog.frmDialogSearchProductStockAsiadrink(NewTxt.Text);
                    }
                    else
                    {
                        ProductAsiadrink = new Dialog.frmDialogSearchProductStockAsiadrink(spProductAsiadrink[1]);
                    }
                    ProductAsiadrink.ShowDialog();
                    if (ProductAsiadrink.DialogResult == DialogResult.OK)
                    {
                        NewTxt.Text = "[" + ProductAsiadrink.GetProductId() + "] " + ProductAsiadrink.GetProductName();
                    }
                    SendKeys.Send("{TAB}");
                    break;
                case "TRCustomer"://เรียก Dialog ข้อมูลลูกค้า
                    Transf.DialogSearchTRCustomer TRCustomer;
                    String[] SRCustomer = NewTxt.Text.Split(']');
                    if (SRCustomer.Length < 2)
                    {
                        TRCustomer = new Transf.DialogSearchTRCustomer(NewTxt.Text);
                    }
                    else
                    {
                        TRCustomer = new Transf.DialogSearchTRCustomer(SRCustomer[1]);
                    }
                    TRCustomer.ShowDialog();
                    if (TRCustomer.DialogResult == DialogResult.OK)
                    {
                        NewTxt.Text = "[" + TRCustomer.GetCustomerId() + "] " + TRCustomer.GetCustomerName();
                    }
                    SendKeys.Send("{TAB}");
                    break;
                // end 7/5/58 test frmSentConsignmentnew
                case "testfunction"://เรียก Dialog ข้อมูลสาขา
                    StockAsiaDrink.DialogSearchBranch ProductAsiadrink1;
                    String[] spProductAsiadrink1 = NewTxt.Text.Split(']');
                    if (spProductAsiadrink1.Length < 2)
                    {
                        ProductAsiadrink1 = new StockAsiaDrink.DialogSearchBranch(NewTxt.Text);
                    }
                    else
                    {
                        ProductAsiadrink1 = new StockAsiaDrink.DialogSearchBranch(spProductAsiadrink1[1]);
                    }
                    ProductAsiadrink1.ShowDialog();
                    if (ProductAsiadrink1.DialogResult == DialogResult.OK)
                    {
                        NewTxt.Text = "[" + ProductAsiadrink1.GetProductId() + "] " + ProductAsiadrink1.GetProductName();
                    }
                    SendKeys.Send("{TAB}");
                    break;

                case "TRCustomer2"://เรียก Dialog ข้อมูลธนาคาร
                    StockAsiaDrink.DialogSearchBank TRCustomer2;
                    String[] SRCustomer2 = NewTxt.Text.Split(']');
                    if (SRCustomer2.Length < 2)
                    {
                        TRCustomer2 = new StockAsiaDrink.DialogSearchBank(NewTxt.Text);
                    }
                    else
                    {
                        TRCustomer2 = new StockAsiaDrink.DialogSearchBank(SRCustomer2[1]);
                    }
                    TRCustomer2.ShowDialog();
                    if (TRCustomer2.DialogResult == DialogResult.OK)
                    {
                        NewTxt.Text = "[" + TRCustomer2.GetCustomerId() + "] " + TRCustomer2.GetCustomerName();
                        //NewTxt.Text = TRCustomer2.GetCustomerId();
                    }
                    SendKeys.Send("{TAB}");
                    break;

                case "DialogDeposit"://เรียก Dialog ข้อมูลมัดจำ
                    SalePosNew.DialogDeposit DialogDeposit;
                    //String[] SRDialogDeposit = NewTxt.Text.Split(']');
                    String SRDialogDeposit = NewTxt.Text;
                    DialogDeposit = new SalePosNew.DialogDeposit(SRDialogDeposit, notInList);
                    DialogDeposit.ShowDialog();
                    if (DialogDeposit.DialogResult == DialogResult.OK)
                    {
                        NewTxt.Text = DialogDeposit.GetCustomerId();
                    }
                    SendKeys.Send("{TAB}");
                    break;

                case "ProductCallToReport"://เรียก Dialog ข้อมูลสินค้าในคลังสินค้าย่อย
                    StockAsiaDrink.DialogSearchProductReport ProductCallToReport;
                    String[] SRProductCallToReport = NewTxt.Text.Split(']');
                    if (SRProductCallToReport.Length < 2)
                    {
                        ProductCallToReport = new StockAsiaDrink.DialogSearchProductReport(NewTxt.Text);
                    }
                    else
                    {
                        ProductCallToReport = new StockAsiaDrink.DialogSearchProductReport(SRProductCallToReport[1]);
                    }
                    ProductCallToReport.ShowDialog();
                    if (ProductCallToReport.DialogResult == DialogResult.OK)
                    {
                        NewTxt.Text = "[" + ProductCallToReport.GetCustomerId() + "] " + ProductCallToReport.GetCustomerName();
                        //NewTxt.Text = TRCustomer2.GetCustomerId();
                    }
                    SendKeys.Send("{TAB}");
                    break;

                case "DialogSaleVat"://เรียก Dialog ข้อมูลการขาย
                    SalePosNew.DialogSaleVat DialogSaleVat;
                    String[] spDialogSaleVat = NewTxt.Text.Split(' ');
                    if (spDialogSaleVat.Length < 2)
                    {
                        DialogSaleVat = new SalePosNew.DialogSaleVat(NewTxt.Text);
                    }
                    else
                    {
                        DialogSaleVat = new SalePosNew.DialogSaleVat(spDialogSaleVat[1]);
                    }
                    DialogSaleVat.ShowDialog();
                    if (DialogSaleVat.DialogResult == DialogResult.OK)
                    {
                        NewTxt.Text = "" + DialogSaleVat.GetCustomerId() + "";
                    }
                    SendKeys.Send("{TAB}");
                    break;
                case "Employee"://เรียก Dialog ข้อมูลรายการพนักงาน
                    Dialog.frmDialogSearchEmployee Employee;
                    String[] spEmployee = NewTxt.Text.Split(']');
                    if (spEmployee.Length < 2)
                    {
                        Employee = new Dialog.frmDialogSearchEmployee(NewTxt.Text);
                    }
                    else
                    {
                        Employee = new Dialog.frmDialogSearchEmployee(spEmployee[1]);
                    }
                    Employee.ShowDialog();
                    if (Employee.DialogResult == DialogResult.OK)
                    {
                        NewTxt.Text = "[" + Employee.GetEmployeeId() + "] " + Employee.GetEmployeeName();
                    }
                    SendKeys.Send("{TAB}");
                    break;
                case "Week"://เรียก Dialog ข้อมูลสัปดาห์
                    DataAnalysis.DialogWeek DialogWeek;
                    String SDialogWeek = NewTxt.Text;
                    DialogWeek = new DataAnalysis.DialogWeek(NewTxt.Text);
                    DialogWeek.StartPosition = FormStartPosition.CenterScreen;
                    DialogWeek.ShowDialog();
                    if (DialogWeek.DialogResult == DialogResult.OK)
                    {
                        NewTxt.Text = DialogWeek.GetData();
                    }
                    SendKeys.Send("{TAB}");
                    break;
                case "productTranfer"://เรียก Dialog ข้อมูลรายการแจ้งโอนเงินเรือนจำ
                    Dialog.DialogProductTranfer productTranfer;
                    String[] SProductTranfer = NewTxt.Text.Split(']');
                    if (SProductTranfer.Length < 2)
                    {
                        productTranfer = new Dialog.DialogProductTranfer(NewTxt.Text);
                    }
                    else
                    {
                        productTranfer = new Dialog.DialogProductTranfer(SProductTranfer[1]);
                    }
                    productTranfer.ShowDialog();
                    if (productTranfer.DialogResult == DialogResult.OK)
                    {
                        NewTxt.Text ="[" + productTranfer.returnVal() + "]";
                    }
                    SendKeys.Send("{TAB}");
                    break;
                //case "ProductCustomer":
                //    SalePosNew.DialogProductCustomer ProductCustomer;
                //    String[] spProductCustomer = NewTxt.Text.Split(' ');
                //    if (spProductCustomer.Length < 2)
                //    {
                //        ProductCustomer = new SalePosNew.DialogProductCustomer(NewTxt.Text);
                //    }
                //    else
                //    {
                //        ProductCustomer = new SalePosNew.DialogProductCustomer(spProductCustomer[1]);
                //    }
                //    ProductCustomer.ShowDialog();
                //    if (ProductCustomer.DialogResult == DialogResult.OK)
                //    {
                //        NewTxt.Text = "" + ProductCustomer.GetCustomerId() + "";
                //    }
                //    SendKeys.Send("{TAB}");
                //    break;
/*
                case "Shipping":
                    Dialog.DialogSearchShipping BillSale;
                    String[] spBillSale = NewTxt.Text.Split(']');
                    if (spBillSale.Length < 2)
                    {
                        BillSale = new Dialog.DialogSearchShipping(NewTxt.Text);
                    }
                    else
                    {
                        BillSale = new Dialog.DialogSearchShipping(spBillSale[1]);
                    }
                    BillSale.ShowDialog();
                    if (BillSale.DialogResult == DialogResult.OK)
                    {
                        NewTxt.Text = BillSale.GetBillSaleId();

                    }
                    SendKeys.Send("{TAB}");
                    break;
  */              
            }
        }
 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("สูตรที่เลือกยังไม่อนุมัติ");
         }
     }
 }