// Selected Batch to DO. private void dgvView_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if ((sender as DataGridView).RowCount == 0) { return; } NP_Cls.autoIDDO = (sender as DataGridView).SelectedRows[0].Cells["clnAutoID"].Value.ToString(); NP_Cls.SONumberForDO = (sender as DataGridView).SelectedRows[0].Cells["clnSONumber"].Value.ToString(); NP_Cls.MatCodeForDO = (sender as DataGridView).SelectedRows[0].Cells["clnMaterialCode"].Value.ToString(); SaleTranSac.AddBatchDO frm = new WMS.SaleTranSac.AddBatchDO(); frm.StartPosition = FormStartPosition.CenterParent; frm.FormBorderStyle = FormBorderStyle.Sizable; frm.ControlBox = true; if (this.dsBatch.Tables.Count == 0) { dsBatch = MyGrid().Clone(); } frm.dsOverview = this.dsBatch.Copy(); frm.ShowDialog(); this.dsBatch = new DataSet(); this.dsBatch = frm.dsOverview.Copy(); if (this.dsBatch.Tables[0].Rows.Count > 0) { decimal SumQty = 0M; for (int i = 0; i < this.dsBatch.Tables[0].Rows.Count; i++) { if (this.dsBatch.Tables[0].Rows[i]["SOAutoID"].ToString() == NP_Cls.autoIDDO) { SumQty = SumQty + Convert.ToDecimal(this.dsBatch.Tables[0].Rows[i]["Qty"]); } } for (int i = 0; i < dsPR.Tables[0].Rows.Count; i++) { if (dsPR.Tables[0].Rows[i]["AutoID"].ToString() == NP_Cls.autoIDDO) { dsPR.Tables[0].Rows[i]["Qty"] = SumQty.ToString("#.###"); dsPR.Tables[0].Rows[i]["BatchNumber"] = "Already Selected"; break; } } //cloneDataSetFormAddBatch = this.dsBatch.Clone(); //foreach (DataRow item in frm.dsOverview.Tables[0].Rows) //{ // this.cloneDataSetFormAddBatch.Tables[0].ImportRow(item); //} dsPR.AcceptChanges(); this.dgvView.DataSource = dsPR.Tables[0]; this.dgvView.ClearSelection(); } }