//ตรวจสอบประเภทน้ำหนักและเก็บค่าจำนวนและน้ำหนักสินค้าจาก Dialog private void checkType(String type) { String ID = dgvProduct.CurrentRow.Cells["ProductID"].Value.ToString();//เก็บรหัสสินค้า String qtyp = dgvProduct.CurrentRow.Cells["QuantityPack"].Value.ToString();//เก็บจำนวนแพ็ค String qty = dgvProduct.CurrentRow.Cells["Quantity"].Value.ToString();//เก็บจำนวน String tw = dgvProduct.CurrentRow.Cells["Detail"].Value.ToString();//เก็บเลขที่รายการ Requisition.frmAddReq FrmAddReq = new Requisition.frmAddReq(type, ID, tw, qtyp, qty);//เรียก Dialog เพิ่มข้อมูลน้ำหนัก FrmAddReq.ShowDialog(); if (FrmAddReq.DialogResult == DialogResult.Yes) { foreach (DataGridViewRow row in dgvProduct.Rows) { if (row.Cells["ProductID"].Value.ToString() == ID)//ตรวจสอบรหัสสินค้า { row.Cells["QuantityPack"].Value = ""; row.Cells["QuantityPack"].Value = FrmAddReq.txtPack.Text;//เก็บจำนวนแพ็ค row.Cells["Quantity"].Value = ""; row.Cells["Quantity"].Value = FrmAddReq.txtSale.Text;//เก็บจำนวน row.Cells["Weight"].Value = ""; row.Cells["Weight"].Value = FrmAddReq.txtWeight.Text;//เก็บน้ำหนัก row.Cells["Type"].Value = type;//เก็บประเภท row.Cells["Detail"].Value = ""; row.Cells["Note"].Value = FrmAddReq.txtNote.Text;//เก็บหมายเหตุ row.Cells["Total"].Value = (Convert.ToDouble(row.Cells["Quantity"].Value) * Convert.ToDouble(row.Cells["CostPrice"].Value)).ToString();//เก็บต้นทุน foreach (DataGridViewRow roww in FrmAddReq.dgvWeight.Rows) { foreach (DataGridViewCell cell in roww.Cells) { if (roww.Index < FrmAddReq.dgvWeight.RowCount - 1) if (!cell.Size.IsEmpty) row.Cells["Detail"].Value += cell.Value + "#";//เก็บข้อมูลน้ำหนัก } } SetDgvWeightH(row.Cells["Detail"].Value.ToString(), dgvWeight, type);//แสดงข้อมูลน้ำหนักสินค้า txtSumCost.Text = sumTotal("Total");//เก็บค่าต้นทุนรวม } } } }
private void checkType(String type) { String PodtID = dgvReceive.CurrentRow.Cells[0].Value.ToString(); String qtyp = dgvReceive.CurrentRow.Cells[2].Value.ToString(); String qty = dgvReceive.CurrentRow.Cells[4].Value.ToString(); String tw = dgvReceive.CurrentRow.Cells[9].Value.ToString(); Requisition.frmAddReq FrmAddReq = new Requisition.frmAddReq(type, PodtID, tw,qtyp,qty); FrmAddReq.ShowDialog(); if (FrmAddReq.DialogResult == DialogResult.Yes) { foreach (DataGridViewRow row in dgvReceive.Rows) { if (row.Cells[0].Value.ToString() == PodtID) { row.Cells[2].Value = ""; row.Cells[2].Value = FrmAddReq.txtPack.Text; row.Cells[4].Value = ""; row.Cells[4].Value = FrmAddReq.txtSale.Text; row.Cells[6].Value = ""; row.Cells[6].Value = FrmAddReq.txtWeight.Text; row.Cells[8].Value = type; row.Cells[9].Value = ""; row.Cells[10].Value = FrmAddReq.txtNote.Text; foreach (DataGridViewRow roww in FrmAddReq.dgvWeight.Rows) { foreach (DataGridViewCell cell in roww.Cells) { if (roww.Index < FrmAddReq.dgvWeight.RowCount - 1) if (!cell.Size.IsEmpty) row.Cells[9].Value += cell.Value + "#"; } } SetDgvWeightH(row.Cells[9].Value.ToString(), dgvWeight, type); } } } }
//ตรวจสอบประเภทน้ำหนักและเก็บค่าจำนวนและน้ำหนักสินค้าจาก Dialog private void checkType(String type) { String ID = dataGridView2.CurrentRow.Cells["ProductID"].Value.ToString();//เก็บรหัสสินค้า String qtyp = dataGridView2.CurrentRow.Cells["QuantityPack"].Value.ToString();//เก็บจำนวนแพ็ค String qty = dataGridView2.CurrentRow.Cells["Quantity"].Value.ToString();//เก็บจำนวน String tw = dataGridView2.CurrentRow.Cells["Detail"].Value.ToString();//เก็บเลขที่รายการ //DataTable dt = Class.Function.GetContentAsDataTable(dataGridView1); //DataRow[] r = dt.Select("mid = " + dataGridView2.CurrentRow.Cells["Mid"].Value.ToString()); //String q = ""; //String d = ""; //for (int i = 0; i < r.Length; i++) //{ // q = r[i][2].ToString(); // d = r[i][0].ToString(); //} //Double sum = 0; //foreach( DataGridViewRow row in dataGridView2.Rows ){ // if (d == row.Cells["Mid"].Value.ToString() && row.Cells["ProductID"].Value.ToString() != ID) // { // sum += (row.Cells["Quantity"].Value.ToString() == "") ? 0 : Convert.ToDouble(row.Cells["Quantity"].Value); // } //} Requisition.frmAddReq FrmAddReq = new Requisition.frmAddReq(type, ID, tw, qtyp, qty);//เรียก Dialog เพิ่มข้อมูลน้ำหนัก FrmAddReq.ShowDialog(); if (FrmAddReq.DialogResult == DialogResult.Yes) { foreach (DataGridViewRow row in dataGridView2.Rows) { if (row.Cells["ProductID"].Value.ToString() == ID)//ตรวจสอบรหัสสินค้า { row.Cells["QuantityPack"].Value = ""; row.Cells["QuantityPack"].Value = FrmAddReq.txtPack.Text;//เก็บจำนวนแพ็ค row.Cells["Quantity"].Value = ""; row.Cells["Quantity"].Value = FrmAddReq.txtSale.Text;//เก็บจำนวน row.Cells["Weight"].Value = ""; row.Cells["Weight"].Value = FrmAddReq.txtWeight.Text;//เก็บน้ำหนัก row.Cells["Type"].Value = type;//เก็บประเภท row.Cells["Detail"].Value = ""; row.Cells["Note"].Value = FrmAddReq.txtNote.Text;//เก็บหมายเหตุ row.Cells["Total"].Value = (Convert.ToDouble(row.Cells["Quantity"].Value) * Convert.ToDouble(row.Cells["CostPrice"].Value)).ToString();//เก็บต้นทุน foreach (DataGridViewRow roww in FrmAddReq.dgvWeight.Rows) { foreach (DataGridViewCell cell in roww.Cells) { if (roww.Index < FrmAddReq.dgvWeight.RowCount - 1) if (!cell.Size.IsEmpty) row.Cells["Detail"].Value += cell.Value + "#";//เก็บข้อมูลน้ำหนัก } } SetDgvWeightH(row.Cells["Detail"].Value.ToString(), dataGridView3, type);//แสดงข้อมูลน้ำหนักสินค้า textBox11.Text = sumTotal("Total");//เก็บค่าต้นทุนรวม } } } }