Beispiel #1
0
 /// <summary>
 /// RawMaterialComboFill function
 /// </summary>
 public void RawMaterialComboFill()
 {
     try
     {
         DataTable dtbl = new DataTable();
         ProductSP spProduct = new ProductSP();
         if (isCallFromProductCreation)
         {
             dtbl = spProduct.ProductViewAllWithoutOneProduct(decProductIdForEdit);
             dgvcmbRawMaterial.DataSource = dtbl;
             DataRow drow = dtbl.NewRow();
             drow["productName"] = string.Empty;
             drow["productId"] = 0;
             dtbl.Rows.InsertAt(drow, 0);
             dgvcmbRawMaterial.DisplayMember = "productName";
             dgvcmbRawMaterial.ValueMember = "productId";
         }
         else
         {
             dtbl = spProduct.ProductViewAll();
             DataRow drow = dtbl.NewRow();
             drow["productName"] = string.Empty;
             drow["productId"] = 0;
             dtbl.Rows.InsertAt(drow, 0);
             dgvcmbRawMaterial.DataSource = dtbl;
             dgvcmbRawMaterial.DisplayMember = "productName";
             dgvcmbRawMaterial.ValueMember = "productId";
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PB:3" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Beispiel #2
0
 /// <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
     {
         DataTable dtbl = new DataTable();
         ProductSP spProduct = new ProductSP();
         if (dgvProductBOM.CurrentCell.ColumnIndex == dgvProductBOM.Columns["dgvcmbRawMaterial"].Index)
         {
             if (isCallFromProductCreation)
             {
                 dtbl = spProduct.ProductViewAllWithoutOneProduct(decProductIdForEdit);
             }
             else
             {
                 dtbl = spProduct.ProductViewAll();
             }
             if (dtbl.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 = dtbl.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 (dtbl.Rows[inJ]["productId"].ToString() == dgvProductBOM.Rows[inI].Cells["dgvcmbRawMaterial"].Value.ToString())
                                     {
                                         dtbl.Rows.RemoveAt(inJ);
                                         break;
                                     }
                                 }
                             }
                         }
                     }
                 }
                 DataGridViewComboBoxCell dgvccProductBom = (DataGridViewComboBoxCell)dgvProductBOM[dgvProductBOM.Columns["dgvcmbRawMaterial"].Index, e.RowIndex];
                 dgvccProductBom.DataSource = dtbl;
                 DataRow drow = dtbl.NewRow();
                 drow["productName"] = string.Empty;
                 drow["productId"] = 0;
                 dtbl.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);
     }
 }