private void toolStripButton1_Click(object sender, EventArgs e)
 {
     if (dataGridView1.Columns[0].Name != "ProductionWaitId") return;//ตรวจสอบสถานะใบรอตรวจ
     ProductionNew.ProductionChecking pc = new ProductionChecking();//เรียกหน้าเพิ่มใบรอตรวจ
     pc.ShowDialog();
     if (pc.DialogResult == DialogResult.OK) {
         loadFirst(" where p.ProductionWaitStatusid in(0,1) and p.ProductionRcStatusid in(0)  ");
     }
 }
        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (whe != "")
            {
                toolStripButton10_Click(sender, e);
                return;
            }

            string sqlselect = "select ProductionWaitStatusId from productionwaithead where ProductionWaitId = '" + dataGridView1.CurrentRow.Cells["ProductionWaitId"].Value.ToString() + "' ";
            int value = Convert.ToInt16 (Class.DBConnString.clsDB.QueryExecuteScalarNonAlert(sqlselect));
            if (value != 2)
            {
                if (dataGridView1.Columns[0].Name != "ProductionWaitId")
                {
                    if (dataGridView1.CurrentRow.Cells["ConfirmName"].Value.ToString() == "อนุมัติ") return;
                    ProductionNew.frmCheckingWait ck = new frmCheckingWait(dataGridView1.CurrentRow.Cells[1].Value.ToString());//เรียกหน้า สินค้ารอตรวจ
                    ck.ShowDialog();
                    if (ck.DialogResult == DialogResult.OK)
                    {
                        loadChecking();
                    }
                }
                else
                {
                    String n = "0";
                    if (dataGridView1.Rows[e.RowIndex].Cells["ProductionWaitStatusName"].Value.ToString() == "รอตรวจ" &&
                        dataGridView1.Rows[e.RowIndex].Cells["productionrcstatusname"].Value.ToString() == "ปกติ")
                    {
                        n = "1";
                    }
                    ProductionNew.ProductionChecking pc = new ProductionChecking(dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(), n);//เรียกหน้าตรวจสอบคุณภาพสินค้า
                    pc.ShowDialog();
                    if (pc.DialogResult == DialogResult.OK)
                    {
                        loadFirst(" where p.ProductionWaitStatusid in(0,1) and p.ProductionRcStatusid in(0)  ");
                    }
                }
            }
            else
            {
                ProductionNew.ProductionChecking2 pc = new ProductionChecking2(dataGridView1.Rows[e.RowIndex].Cells["ProductionWaitId"].Value.ToString());//เรียกหน้าตรวจสอบคุณภาพสินค้า
                pc.ShowDialog();
                if (pc.DialogResult == DialogResult.OK)
                {
                    loadFirst(" where p.ProductionWaitStatusid =2 and p.ProductionRcStatusid in(0)  ");
                }
            }
        }