private Boolean AddBOMDetailRow() { Boolean status = true; try { if (grdBOMDetail.Rows.Count > 0) { verifyAndReworkBOMDetailGridRows(); } grdBOMDetail.Rows.Add(); int kount = grdBOMDetail.RowCount; grdBOMDetail.Rows[kount - 1].Cells[0].Value = kount; DataGridViewComboBoxCell ComboColumn1 = (DataGridViewComboBoxCell)(grdBOMDetail.Rows[kount - 1].Cells[1]); StockItemDB.fillStockItemGridViewCombo(ComboColumn1, ""); ComboColumn1.DropDownWidth = 300; grdBOMDetail.Rows[kount - 1].Cells[2].Value = 0; grdBOMDetail.Rows[kount - 1].Cells[3].Value = 0; grdBOMDetail.Rows[kount - 1].Cells[4].Value = 0; grdBOMDetail.Rows[kount - 1].Cells[5].Value = 0; grdBOMDetail.Rows[kount - 1].Cells[7].Value = 0; var BtnCell = (DataGridViewButtonCell)grdBOMDetail.Rows[kount - 1].Cells[6]; BtnCell.Value = "Del"; grdBOMDetail.Rows[kount - 1].Cells[0].ReadOnly = true; grdBOMDetail.Rows[kount - 1].Cells[3].ReadOnly = true; grdBOMDetail.Rows[kount - 1].Cells[5].ReadOnly = true; } catch (Exception ex) { MessageBox.Show("AddBOMDetailRow() : Error"); } return(status); }
private void grdList_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex < 0) { return; } if (e.ColumnIndex == 5) { captureChange = false; int rowID = e.RowIndex; btnSave.Text = "Update"; cmbProduct.SelectedIndex = cmbProduct.FindStringExact(grdList.Rows[e.RowIndex].Cells[0].Value.ToString()); txtDetails.Text = grdList.Rows[e.RowIndex].Cells[2].Value.ToString(); txtCost.Text = grdList.Rows[e.RowIndex].Cells[3].Value.ToString(); cmbStatus.SelectedIndex = cmbStatus.FindStringExact(grdList.Rows[e.RowIndex].Cells[4].Value.ToString()); DataGridViewRow row = grdList.Rows[rowID]; //get customer bank details BOMDB bomdb = new BOMDB(); List <bomdetail> bomdetails = bomdb.getBOMDetail(grdList.Rows[e.RowIndex].Cells[0].Value.ToString()); grdBOMDetail.Rows.Clear(); int i = 0; foreach (bomdetail bd in bomdetails) { AddBOMDetailRow(); grdBOMDetail.Rows[i].Cells[0].Value = i + 1; //DataGridViewComboBoxCell ComboColumn1 = new DataGridViewComboBoxCell(); //StockItemDB.fillTaxItemGridViewCombo(ComboColumn1,""); //grdBOMDetail.Rows[i].Cells[1] = ComboColumn1; //grdBOMDetail.Rows[i].Cells[1].Value = bd.Name; DataGridViewComboBoxCell ComboColumn1 = new DataGridViewComboBoxCell(); StockItemDB.fillStockItemGridViewCombo(ComboColumn1, ""); grdBOMDetail.Rows[i].Cells[1].Value = bd.StockItemID + "-" + bd.Name; grdBOMDetail.Rows[i].Cells[2].Value = bd.Quantity; grdBOMDetail.Rows[i].Cells[3].Value = bd.PurchasePrice; grdBOMDetail.Rows[i].Cells[4].Value = bd.CustomPrice; i++; } cmbProduct.SelectedIndex = cmbProduct.FindString(grdList.Rows[e.RowIndex].Cells[0].Value.ToString()); cmbProduct.Enabled = false; verifyAndReworkBOMDetailGridRows(); btnSave.Text = "Update"; pnlBOMDetails.Visible = true; pnlBottomActions.Visible = false; captureChange = true; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }