void Calculate(int col, int row)
 {
     if (col == 4)
     {
         if (Class.Function.checkNulltxt(textBox3) == 0) { dataGridView2.CurrentRow.Cells[col].Value = ""; return; }
         String sql = "select * from productionprisonwage p where p.employerid = " + Class.Function.GetTextId(textBox3.Text) + " and p.SizeTypeId = " +
             "(select SzId from productionFormular f where f.FmId = '" + dataGridView2.Rows[row].Cells[1].Value.ToString() + "')";
         DataTable dt = Class.DBConnString.clsDB.QueryDataTable(sql);//ดึงข้อมูลสูตรผลิต
         if (dt.Rows.Count < 1)
         {
             DialogResult dialogResult = MetroFramework.MetroMessageBox.Show(this, "ไม่พบการกำหนดค่าจ้างเรือนจำ คุณต้องการเพิ่มเดี๋ยวนี้หรือไม่", "คำเตือน", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
             if (dialogResult == DialogResult.Yes)
             {
                 ProductionNew.frmPrisonWage pw = new frmPrisonWage();//เรียกหน้าจัดการข้อมูลเรือนจำ
                 pw.ShowDialog();
                 if (pw.DialogResult == DialogResult.OK)
                 {
                     dt = Class.DBConnString.clsDB.QueryDataTable(sql);
                     dataGridView2.Rows[row].Cells["PwId"].Value = dt.Rows[0]["PwId"].ToString();//เก็บรหัสค่าจ้างเรือนจำ
                     dataGridView2.Rows[row].Cells["PwN7"].Value = (Convert.ToDouble(dt.Rows[0]["PwN7"].ToString()) *
                         Convert.ToDouble(dataGridView2.Rows[row].Cells["Quantity"].Value.ToString())).ToString();//เก็บค่าจ้างหมายเลข 7
                     dataGridView2.Rows[row].Cells["PwOutSide"].Value = (Convert.ToDouble(dt.Rows[0]["PwOutSide"].ToString()) *
                         Convert.ToDouble(dataGridView2.Rows[row].Cells["Quantity"].Value.ToString())).ToString();//เก็บค่าจ้างที่จ่างเกิน
                     dataGridView2.Rows[row].Cells["PwPB"].Value = PayPBPerMonth == 0 ? (Convert.ToDouble(dt.Rows[0]["PwPB"].ToString()) *
                         Convert.ToDouble(dataGridView2.Rows[row].Cells["Quantity"].Value.ToString())).ToString() : "0";//เก็บค่าข้าง ผบ
                     dataGridView2.Rows[row].Cells["PwShip"].Value = (Convert.ToDouble(dt.Rows[0]["PwShip"].ToString()) *
                         Convert.ToDouble(dataGridView2.Rows[row].Cells["Quantity"].Value.ToString())).ToString();//เก็บค่าขนส่ง
                     dataGridView2.Rows[row].Cells["PwOther"].Value = (Convert.ToDouble(dt.Rows[0]["PwOther"].ToString()) *
                         Convert.ToDouble(dataGridView2.Rows[row].Cells["Quantity"].Value.ToString())).ToString();//เก็บค่าจ้างอื่นๆ
                     dataGridView2.Rows[row].Cells["Total"].Value = (Convert.ToDouble(dt.Rows[0]["PwTotal"].ToString()) *
                         Convert.ToDouble(dataGridView2.Rows[row].Cells["Quantity"].Value.ToString())).ToString();//เก็บค่าจ้างทั้งหมด
                     SumTotal();
                 }
             }
             else if (dialogResult == DialogResult.No)
             {
                 dataGridView2.CurrentRow.Cells[col].Value = "";
             }
         }
         else
         {
             dataGridView2.Rows[row].Cells["PwId"].Value = dt.Rows[0]["PwId"].ToString();//เก็บรหัสค่าจ้างเรือนจำ
             dataGridView2.Rows[row].Cells["PwN7"].Value = (Convert.ToDouble(dt.Rows[0]["PwN7"].ToString()) *
                 Convert.ToDouble(dataGridView2.Rows[row].Cells["Quantity"].Value.ToString())).ToString();//เก็บค่าจ้างหมายเลข 7
             dataGridView2.Rows[row].Cells["PwOutSide"].Value = (Convert.ToDouble(dt.Rows[0]["PwOutSide"].ToString()) *
                 Convert.ToDouble(dataGridView2.Rows[row].Cells["Quantity"].Value.ToString())).ToString();//เก็บค่าจ้างที่จ่างเกิน
             dataGridView2.Rows[row].Cells["PwPB"].Value = (Convert.ToDouble(dt.Rows[0]["PwPB"].ToString()) *
                 Convert.ToDouble(dataGridView2.Rows[row].Cells["Quantity"].Value.ToString())).ToString();//เก็บค่าข้าง ผบ
             dataGridView2.Rows[row].Cells["PwShip"].Value = (Convert.ToDouble(dt.Rows[0]["PwShip"].ToString()) *
                 Convert.ToDouble(dataGridView2.Rows[row].Cells["Quantity"].Value.ToString())).ToString();//เก็บค่าขนส่ง
             dataGridView2.Rows[row].Cells["PwOther"].Value = (Convert.ToDouble(dt.Rows[0]["PwOther"].ToString()) *
                 Convert.ToDouble(dataGridView2.Rows[row].Cells["Quantity"].Value.ToString())).ToString();//เก็บค่าจ้างอื่นๆ
             dataGridView2.Rows[row].Cells["Total"].Value = (Convert.ToDouble(dt.Rows[0]["PwTotal"].ToString()) *
                 Convert.ToDouble(dataGridView2.Rows[row].Cells["Quantity"].Value.ToString())).ToString();//เก็บค่าจ้างทั้งหมด
             SumTotal();
         }
     }
 }
示例#2
0
 private void จดการคาจางToolStripMenuItem1_Click(object sender, EventArgs e)
 {
     ProductionNew.frmPrisonWage frm = new ProductionNew.frmPrisonWage();
     //frm.MdiParent = this;
     frm.Show();
 }