/// <summary> /// Function to Remove Row from StockJournalAdditionalCostDetails /// </summary> public void RemoveRowStockJournalAdditionalCostDetails() { AdditionalCostSP spAdditionalCost = new AdditionalCostSP(); try { foreach (var strDetailsId in ArrlstOfAdditionalCostRemove) { decimal decDeleteId = Convert.ToDecimal(strDetailsId); spAdditionalCost.AdditionalCostDelete(decDeleteId); } } catch (Exception ex) { MessageBox.Show("SJ:3" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void Delete() { PurchaseMasterSP spPurchaseMaster = new PurchaseMasterSP(); PurchaseDetailsSP spPurchaseDetails = new PurchaseDetailsSP(); PurchaseBillTaxSP spPurchaseBillTax = new PurchaseBillTaxSP(); AdditionalCostSP spAdditionalCost = new AdditionalCostSP(); AccountLedgerSP spAccountLedger = new AccountLedgerSP(); StockPostingSP spStockPosting = new StockPostingSP(); LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); PurchaseOrderMasterSP spPurchaseOrderMaster = new PurchaseOrderMasterSP(); MaterialReceiptMasterSP spMaterialReceiptMaster = new MaterialReceiptMasterSP(); PurchaseOrderMasterInfo infoPurchaseOrderMaster = new PurchaseOrderMasterInfo(); MaterialReceiptMasterInfo infoMaterialReceiptMaster = new MaterialReceiptMasterInfo(); PurchaseMasterInfo infoPurchaseMaster = new PurchaseMasterInfo(); /*---------------------------------Deleting previous stock posting, Ledger posting, partybalanceposting---------------------------------------*/ infoPurchaseMaster = spPurchaseMaster.PurchaseMasterView(decPurchaseMasterId); if (infoPurchaseMaster.MaterialReceiptMasterId != 0) { infoMaterialReceiptMaster = spMaterialReceiptMaster.MaterialReceiptMasterView(infoPurchaseMaster.MaterialReceiptMasterId); spStockPosting.StockPostingDeleteForSalesInvoiceAgainstDeliveryNote (infoPurchaseMaster.VoucherTypeId, infoPurchaseMaster.VoucherNo, infoMaterialReceiptMaster.VoucherNo, infoMaterialReceiptMaster.VoucherTypeId); } spStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType (0, "NA", infoPurchaseMaster.VoucherNo, infoPurchaseMaster.VoucherTypeId); //------------------------------------------------- decimal decPurchaseDetailsId = 0; decimal decPurchaseOrderMasterId = 0; decimal decMaterialReceiptMasterId = 0; decimal decAdditionalCostId = 0; decimal decPurchaseBillTaxId = 0; int inRef = 0; bool isRef = false; try { foreach (DataGridViewRow dgvrow in dgvProductDetails.Rows) { if (dgvrow.Cells["dgvtxtPurchaseDetailsId"].Value != null) { if (dgvrow.Cells["dgvtxtPurchaseDetailsId"].Value.ToString() != string.Empty && dgvrow.Cells["dgvtxtPurchaseDetailsId"].Value.ToString() != "0") { decPurchaseDetailsId = Convert.ToDecimal(dgvrow.Cells["dgvtxtPurchaseDetailsId"].Value.ToString()); inRef = spPurchaseMaster.PurchaseMasterReferenceCheck(decPurchaseMasterId, decPurchaseDetailsId); if (inRef > 0 && !isRef) { isRef = true; } } } } if (!isRef) { isRef = spAccountLedger.PartyBalanceAgainstReferenceCheck(strVoucherNo, decPurchaseInvoiceVoucherTypeId); if (!isRef) { spPurchaseMaster.PurchaseMasterDelete(decPurchaseMasterId); spPurchaseDetails.PurchaseDetailsDeleteByPurchaseMasterId(decPurchaseMasterId); foreach (DataGridViewRow dgvrow in dgvAdditionalCost.Rows) { if (dgvrow.Cells["dgvtxtAdditionalCostId"].Value != null) { if (dgvrow.Cells["dgvtxtAdditionalCostId"].Value.ToString() != string.Empty && dgvrow.Cells["dgvtxtAdditionalCostId"].Value.ToString() != "0") { decAdditionalCostId = Convert.ToDecimal(dgvrow.Cells["dgvtxtAdditionalCostId"].Value.ToString()); spAdditionalCost.AdditionalCostDelete(decAdditionalCostId); } } } if (dgvTax.Visible) { foreach (DataGridViewRow dgvrow in dgvTax.Rows) { if (dgvrow.Cells["dgvtxtPurchaseBillTaxId"].Value != null) { if (dgvrow.Cells["dgvtxtPurchaseBillTaxId"].Value.ToString() != string.Empty && dgvrow.Cells["dgvtxtPurchaseBillTaxId"].Value.ToString() != "0") { decPurchaseBillTaxId = Convert.ToDecimal(dgvrow.Cells["dgvtxtPurchaseBillTaxId"].Value.ToString()); spPurchaseBillTax.PurchaseBillTaxDelete(decPurchaseBillTaxId); } } } } if (cmbPurchaseMode.Text == "Against PurchaseOrder") { decPurchaseOrderMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()); infoPurchaseOrderMaster = spPurchaseOrderMaster.PurchaseOrderMasterView(decPurchaseOrderMasterId); } else if (cmbPurchaseMode.Text == "Against MaterialReceipt") { decMaterialReceiptMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()); infoMaterialReceiptMaster = spMaterialReceiptMaster.MaterialReceiptMasterView(decMaterialReceiptMasterId); } spLedgerPosting.LedgerPostDelete(strVoucherNo, decPurchaseInvoiceVoucherTypeId); if (infoPurchaseOrderMaster.PurchaseOrderMasterId != 0) { spStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType (decPurchaseInvoiceVoucherTypeId, strVoucherNo, infoPurchaseOrderMaster.VoucherNo, infoPurchaseOrderMaster.VoucherTypeId); } else if (infoMaterialReceiptMaster.MaterialReceiptMasterId != 0) { spStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType (decPurchaseInvoiceVoucherTypeId, strVoucherNo, infoMaterialReceiptMaster.VoucherNo, infoMaterialReceiptMaster.VoucherTypeId); } spStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType (0, "NA", strVoucherNo, decPurchaseInvoiceVoucherTypeId); spAccountLedger.PartyBalanceDeleteByVoucherTypeVoucherNoAndReferenceType(strVoucherNo, decPurchaseInvoiceVoucherTypeId); Messages.DeletedMessage(); Clear(); this.Close(); } else { Messages.InformationMessage("Cannot delete purchase invoice because there is a payment voucher against this invoice"); } } else { Messages.InformationMessage("Cannot delete purchase invoice because reference exists"); } } catch (Exception ex) { MessageBox.Show("PI41:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Remove all sales invoice additional cost details here /// </summary> public void removeSalesInvoiceAdditionalDetails() { AdditionalCostSP spAdditionalCost = new AdditionalCostSP(); try { foreach (var strId in lstArrOfRemoveLedger) { decimal decDeleteId = Convert.ToDecimal(strId); spAdditionalCost.AdditionalCostDelete(decDeleteId); } } catch (Exception ex) { MessageBox.Show("SI: 80" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// deleting the rows from tbl_PurchaseDetails removed by user from the grid while updating after reference check /// </summary> public void RemoveDelete() { PurchaseMasterSP spPurchaseMaster = new PurchaseMasterSP(); PurchaseDetailsSP spPurchaseDetails = new PurchaseDetailsSP(); AdditionalCostSP spAdditionalCost = new AdditionalCostSP(); decimal decPurchaseDetailsId = 0; decimal decAdditionalCostId = 0; int inRef = 0; try { foreach (var item in arrlstRemove) { decPurchaseDetailsId = Convert.ToDecimal(item); inRef = spPurchaseMaster.PurchaseMasterReferenceCheck(decPurchaseMasterId, decPurchaseDetailsId); if (inRef == 0) { spPurchaseDetails.PurchaseDetailsDelete(decPurchaseDetailsId); } } foreach (var item1 in arrlstRemoveAdditionalCost) { decAdditionalCostId = Convert.ToDecimal(item1); spAdditionalCost.AdditionalCostDelete(decAdditionalCostId); } } catch (Exception ex) { MessageBox.Show("PI40:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }