/// <summary> /// RawMaterialComboFill function /// </summary> public void RawMaterialComboFill() { try { List<DataTable> listObj = new List<DataTable>(); ProductCreationBll BllProductCreation = new ProductCreationBll(); if (isCallFromProductCreation) { listObj = BllProductCreation.ProductViewAllWithoutOneProduct(decProductIdForEdit); dgvcmbRawMaterial.DataSource = listObj[0]; DataRow drow = listObj[0].NewRow(); drow["productName"] = string.Empty; drow["productId"] = 0; listObj[0].Rows.InsertAt(drow, 0); dgvcmbRawMaterial.DisplayMember = "productName"; dgvcmbRawMaterial.ValueMember = "productId"; } else { listObj = BllProductCreation.ProductViewAll(); DataRow drow = listObj[0].NewRow(); drow["productName"] = string.Empty; drow["productId"] = 0; listObj[0].Rows.InsertAt(drow, 0); dgvcmbRawMaterial.DataSource = listObj[0]; dgvcmbRawMaterial.DisplayMember = "productName"; dgvcmbRawMaterial.ValueMember = "productId"; } } catch (Exception ex) { MessageBox.Show("PB:3" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// To remove the selected product from the list in combo box /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvProductBOM_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) { try { List<DataTable> listObj = new List<DataTable>(); ProductCreationBll BllProductCreation = new ProductCreationBll(); if (dgvProductBOM.CurrentCell.ColumnIndex == dgvProductBOM.Columns["dgvcmbRawMaterial"].Index) { if (isCallFromProductCreation) { listObj = BllProductCreation.ProductViewAllWithoutOneProduct(decProductIdForEdit); } else { listObj = BllProductCreation.ProductViewAll(); } if (listObj[0].Rows.Count > 0) { if (dgvProductBOM.RowCount > 1) { int inGridRowCount = dgvProductBOM.RowCount; for (int inI = 0; inI < inGridRowCount - 1; inI++) { if (inI != e.RowIndex) { int inTableRowcount = listObj[0].Rows.Count; for (int inJ = 0; inJ < inTableRowcount; inJ++) { if (dgvProductBOM.Rows[inI].Cells["dgvcmbRawMaterial"].Value != null && dgvProductBOM.Rows[inI].Cells["dgvcmbRawMaterial"].Value.ToString() != "") { if (listObj[0].Rows[inJ]["productId"].ToString() == dgvProductBOM.Rows[inI].Cells["dgvcmbRawMaterial"].Value.ToString()) { listObj[0].Rows.RemoveAt(inJ); break; } } } } } } DataGridViewComboBoxCell dgvccProductBom = (DataGridViewComboBoxCell)dgvProductBOM[dgvProductBOM.Columns["dgvcmbRawMaterial"].Index, e.RowIndex]; dgvccProductBom.DataSource = listObj[0]; DataRow drow = listObj[0].NewRow(); drow["productName"] = string.Empty; drow["productId"] = 0; listObj[0].Rows.InsertAt(drow, 0); dgvccProductBom.ValueMember = "productId"; dgvccProductBom.DisplayMember = "productName"; } } } catch (Exception ex) { MessageBox.Show("PB:28" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill the product combobox /// </summary> public void ProductComboFill() { try { List <DataTable> listObj = BllProductCreation.ProductViewAll(); DataRow dr = listObj[0].NewRow(); dr["productId"] = 0; dr["productName"] = "All"; listObj[0].Rows.InsertAt(dr, 0); cmbProduct.DataSource = listObj[0]; cmbProduct.DisplayMember = "productName"; cmbProduct.ValueMember = "productId"; cmbProduct.SelectedIndex = 0; } catch (Exception ex) { MessageBox.Show(" RPL4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }