private void checkType(string type) { switch (type) { case "2": { Dialog.DialogAmnt p = new Dialog.DialogAmnt(); p.ShowDialog(); if (p.DialogResult == System.Windows.Forms.DialogResult.OK) { int value = Convert.ToInt32(p.txtAmnt.Text); dataGridView2.CurrentRow.Cells["WaitDetailQuantity"].Value = value; Calculate(value); } break; } case "3": { var item = (from i in qty where Convert.ToInt32(i.ProductionWaitDetailId) == Convert.ToInt32(dataGridView2.CurrentRow.Cells["WaitDetailId"].Value) select i).ToList(); DialogReceiveQtyOnPalet f = new DialogReceiveQtyOnPalet(dataGridView2.CurrentRow.Cells["FmName"].Value.ToString(), dataGridView2.CurrentRow.Cells["WaitDetailPallet"].Value.ToString(), item); f.StartPosition = FormStartPosition.CenterScreen; f.ShowDialog(); if (f.DialogResult == System.Windows.Forms.DialogResult.OK) { item = (from i in qty where Convert.ToInt32(i.ProductionWaitDetailId) == Convert.ToInt32(dataGridView2.CurrentRow.Cells["WaitDetailId"].Value) select i).ToList(); foreach (var i in item) { qty.Remove(i); } int qtyall = 0; for (int i = 0; i < f.dgvQty.Rows.Count - 1; ++i) { qtyall += Convert.ToInt32(f.dgvQty.Rows[i].Cells[1].Value); QtyOnPalet q = new QtyOnPalet(Convert.ToInt32(dataGridView2.CurrentRow.Cells["WaitDetailId"].Value), Convert.ToInt32(f.dgvQty.Rows[i].Cells[0].Value), Convert.ToInt32(f.dgvQty.Rows[i].Cells[1].Value)); qty.Add(q); } dataGridView2.CurrentRow.Cells["WaitDetailQuantity"].Value = qtyall; Calculate(qtyall); } break; } } }
/*เก็บค่าจำนวนจาก Dialog*/ private void CheckType(string type,int row) { switch (type) { case "2": { Dialog.DialogAmnt amnt = new Dialog.DialogAmnt(); amnt.txtAmnt.Text = DgvProduct.Rows[row].Cells["Quantity"].Value.ToString(); amnt.ShowDialog(); if (amnt.DialogResult == System.Windows.Forms.DialogResult.OK) { DgvProduct.Rows[row].Cells["Quantity"].Value = Convert.ToDecimal(amnt.txtAmnt.Text); } break; } case "3": { string ProductId = DgvProduct.Rows[row].Cells["ProductId"].Value.ToString(); ProductionNew.DialogReceiveQtyOnPalet qty = new ProductionNew.DialogReceiveQtyOnPalet("จำนวนสั่งซื่อจำนวนย่อย", iQty.Where(q=>q.ProductionWaitDetailId.ToString() == ProductId).ToList()); qty.ShowDialog(); if (qty.DialogResult == System.Windows.Forms.DialogResult.OK) { RemoveiQty(ProductId); PuseiQty(ref qty.dgvQty, ProductId); DgvProduct.Rows[row].Cells["Quantity"].Value = PuseToDGVQty(ProductId); } break; } } }