コード例 #1
0
 /// <summary>
 /// Function for update details in table
 /// </summary>
 public void EditFunction()
 {
     ProductCreationBll BllProductCreation = new ProductCreationBll();
     try
     {
         decimal decStatus = BllProductCreation.BatchReferenceCheckForProductEdit(decProductIdForEdit);
         if (decStatus != 0)
         {
             if (cmbOpeningStock.SelectedIndex == 1)
             {
                 if (isOpeningStockChanged)
                 {
                     DeleteOpeningStock();
                     DeleteBatchFromOpeningStock();
                 }
                 if (cmbAllowBatch.SelectedIndex == 0)
                 {
                     if (RemoveIncompleteRowsFromGrid())
                     {
                         if (!GridCheckWeatherSameRackAndGodownExisting())
                         {
                             ProductEditFill();
                             if (isUpdated)
                             {
                                 CheckWetherSaveOrEdit();
                                 RemoveRows();
                                 if (isBatchForUpdate)
                                 {
                                     DeleteBatchFromOpeningStock();
                                 }
                                 if (!isOpeningStockForUpdate)
                                 {
                                     StockPostingTableFillWhileUpdating();
                                 }
                                 else
                                 {
                                     NewRowAdded();
                                     StockPostingTableEditFill();
                                 }
                                 if (isStpUpdated || decCheck > 0 || isRowRemoved)
                                 {
                                     Messages.UpdatedMessage();
                                     this.Close();
                                 }
                             }
                         }
                     }
                     else
                     {
                         if (dgvProductCreation.Rows.Count == 1)
                         {
                             Messages.InformationMessage("Cant save without atleast one row");
                             dgvProductCreation.Focus();
                         }
                     }
                 }
                 else
                 {
                     if (RemoveIncompleteRowsFromGrid())
                     {
                         if (!GridCheckWeatherSameRackAndGodownExisting())
                         {
                             ProductEditFill();
                             if (isUpdated)
                             {
                                 CheckWetherSaveOrEdit();
                                 RemoveRows();
                                 if (!isBatchForUpdate)
                                 {
                                     BatchTableFill();
                                 }
                                 else
                                 {
                                     RowsAddInBatchTable();
                                     BatchTableEditFill();
                                 }
                                 if (!isOpeningStockForUpdate)
                                 {
                                     StockPostingTableFillWhileUpdating();
                                 }
                                 else
                                 {
                                     NewRowAdded();
                                     StockPostingTableEditFill();
                                 }
                                 if (isStpUpdated || isBatchUpdated || decBatchId > 0 || decCheck > 0)
                                 {
                                     Messages.UpdatedMessage();
                                     this.Close();
                                 }
                             }
                         }
                     }
                     else
                     {
                         if (dgvProductCreation.Rows.Count == 1)
                         {
                             Messages.InformationMessage("Cant save without atleast one row");
                             dgvProductCreation.Focus();
                         }
                     }
                 }
             }
             else
             {
                 ProductEditFill();
                 CheckWetherSaveOrEdit();
                 if (cmbOpeningStock.SelectedIndex == 0 && isOpeningStockForUpdate == true)
                 {
                     DeleteOpeningStock();
                     if (isBatchForUpdate)
                     {
                         isBatchForUpdate = false;
                         DeleteBatchFromOpeningStock();
                     }
                 }
                 if (cmbAllowBatch.SelectedIndex == 1 && (isBatchForUpdate == true))
                 {
                     DeleteBatchFromOpeningStock();
                 }
                 if (isUpdated)
                 {
                     Messages.UpdatedMessage();
                     this.Close();
                 }
             }
         }
         else
         {
             Messages.ReferenceExistsMessageForUpdate();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PC:61" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }