private void btnCopyUserSpecified_Click(object sender, EventArgs e) { DataTable dtMR = new DataTable(); dtMR.Columns.Add("Sr"); dtMR.Columns.Add("PartNo"); dtMR.Columns.Add("Description"); dtMR.Columns.Add("Manufacturer"); dtMR.Columns.Add("Qty"); dtMR.Columns.Add("UnitCost"); dtMR.Columns.Add("ExtCost"); dtMR.Columns.Add("UnitPrice"); dtMR.Columns.Add("ExtPrice"); FrmGetQty frmGetQty = new FrmGetQty(); foreach (DataGridViewRow gvr in dataGridView2.Rows) { if (gvr.Cells["Select2"].Value != null && (bool)gvr.Cells["Select2"].Value == true) { DataRow newRow = dtMR.NewRow(); newRow["Sr"] = gvr.Cells["Sr2"].Value; newRow["PartNo"] = gvr.Cells["PartNo2"].Value; frmGetQty.gPartNo = gvr.Cells["PartNo2"].Value.ToString(); newRow["Description"] = gvr.Cells["Description2"].Value; newRow["Manufacturer"] = gvr.Cells["Manufacturer2"].Value; var result = frmGetQty.ShowDialog(); if (result == DialogResult.OK) { //newRow["Qty"] = gvr.Cells["Qty2"].Value; newRow["Qty"] = frmGetQty.gQty; } else { dataGridView4.DataSource = dtMR; continue; } decimal unitCost = decimal.Parse(string.IsNullOrEmpty(gvr.Cells["UnitCost2"].Value.ToString()) ? "0" : gvr.Cells["UnitCost2"].Value.ToString()); //decimal qty = decimal.Parse ( frmGetQty.gQty); decimal qty = Convert.ToDecimal(string.IsNullOrEmpty(frmGetQty.gQty) ? "0" : frmGetQty.gQty); newRow["UnitCost"] = gvr.Cells["UnitCost2"].Value; newRow["ExtCost"] = unitCost * qty; //gvr.Cells["ExtCost2"].Value; newRow["UnitPrice"] = gvr.Cells["UnitPrice2"].Value; newRow["ExtPrice"] = gvr.Cells["ExtPrice2"].Value; dtMR.Rows.Add(newRow); } dataGridView4.DataSource = dtMR; } _dtExportMRtoExcel = dtMR.Copy(); }
private void InputQty_ButtonCustomClick(object sender, EventArgs e) { try { var frm = new FrmGetQty(Part.dStdBoxQty); frm.ShowDialog(); if (frm.DialogResult != DialogResult.OK) { return; } InputQty.Text = frm.Qty.ToString(); } catch (Exception ex) { BLMUtils.ShowError(ex.Message); } }