/// <summary>
 /// Delete Function, Checking the References and Check other forms are opend or not
 /// </summary>
 /// <param name="decPDCReceivableMasterId"></param>
 public void DeleteFunction(decimal decPDCReceivableMasterId)
 {
     try
     {
         PDCRecivebleBll BllPdcRecieveble = new PDCRecivebleBll();
         PartyBalanceBll BllPartyBalance = new PartyBalanceBll();
         AccountLedgerBll bllAccountLedger = new AccountLedgerBll();
         if (!BllPartyBalance.PartyBalanceCheckReference(decPDCReceivableVoucherTypeId, strVoucherNo))
         {
             BllPdcRecieveble.PDCReceivableDeleteMaster(decPDCReceivableMasterId, decPDCReceivableVoucherTypeId, strVoucherNo);
             Messages.DeletedMessage();
         }
         else
         {
             Messages.InformationMessage("Reference exist. Cannot delete");
             txtVoucherDate.Focus();
         }
         if (PDCReceivableRegisterObj != null)
         {
             this.Close();
             PDCReceivableRegisterObj.Show();
         }
         else if (PDCReceivableReportObj != null)
         {
             this.Close();
             PDCReceivableReportObj.Show();
         }
         else if (frmLedgerDetailsObj != null)
         {
             this.Close();
             frmLedgerDetailsObj.Show();
         }
         else if (objVoucherSearch != null)
         {
             this.Close();
             objVoucherSearch.GridFill();
         }
         else
         {
             ClearFunction();
         }
         if (frmDayBookObj != null)
         {
             this.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PR20:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Delete function, deleting all are the details here
 /// </summary>
 /// <param name="SalesMasterId"></param>
 public void DeleteFunction(decimal SalesMasterId)
 {
     //SalesMasterSP spSalesMaster = new SalesMasterSP();
     SalesInvoiceBll BllSalesInvoice = new SalesInvoiceBll();
     try
     {
         PartyBalanceBll BllPartyBalance = new PartyBalanceBll();
         if (!BllSalesInvoice.SalesReturnCheckReferenceForSIDelete(decSalesInvoiceIdToEdit))
         {
             if (!BllPartyBalance.PartyBalanceCheckReference(DecSalesInvoiceVoucherTypeId, strVoucherNo))
             {
                 BllSalesInvoice.SalesInvoiceDelete(decSalesInvoiceIdToEdit, DecSalesInvoiceVoucherTypeId, strVoucherNo);
                 Messages.DeletedMessage();
                 if (frmSalesinvoiceRegisterObj != null)
                 {
                     this.Close();
                     frmSalesinvoiceRegisterObj.Enabled = true;
                 }
                 else if (frmSalesReportObj != null)
                 {
                     this.Close();
                     frmSalesReportObj.Enabled = true;
                 }
                 else if (objVoucherSearch != null)
                 {
                     this.Close();
                     objVoucherSearch.GridFill();
                 }
                 else if (frmDayBookObj != null)
                 {
                     this.Close();
                 }
                 else if (frmledgerDetailsObj != null)
                 {
                     this.Close();
                 }
                 else
                 {
                     Clear();
                 }
             }
             else
             {
                 Messages.InformationMessage("Reference exist. Cannot delete");
                 txtDate.Focus();
             }
         }
         else
         {
             Messages.InformationMessage("Reference exist. Cannot delete");
             txtDate.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SI: 85" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// function to delete voucher
        /// </summary>
        /// <param name="decJournalMasterId"></param>
        public void DeleteFunction(decimal decJournalMasterId)
        {
            try
            {
                JournalVoucherBll bllJournalMaster = new JournalVoucherBll();
                PartyBalanceBll BllPartyBalance = new PartyBalanceBll();

                if (!BllPartyBalance.PartyBalanceCheckReference(decJournalVoucherTypeId, strVoucherNo))
                {
                    bllJournalMaster.JournalVoucherDelete(decJournalMasterId, decJournalVoucherTypeId, strVoucherNo);

                    Messages.DeletedMessage();
                    if (journalRegisterObj != null)
                    {
                        this.Close();
                        journalRegisterObj.Enabled = true;
                    }
                    else if (frmJournalReportObj != null)
                    {
                        this.Close();
                        frmJournalReportObj.Enabled = true;
                    }
                    else if (frmLedgerDetailsObj != null)
                    {
                        this.Close();
                    }
                    else if (objVoucherSearch != null)
                    {
                        this.Close();
                        objVoucherSearch.GridFill();
                    }
                    else if (frmDayBookObj != null)
                    {
                        this.Close();
                    }
                    else if (frmBillallocationObj != null)
                    {
                        this.Close();
                    }
                    else
                    {
                        clear();
                    }
                }
                else
                {
                    Messages.InformationMessage("Reference exist. Cannot delete");
                    txtDate.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("JV19:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Delete Function
        /// </summary>
        /// <param name="decMasterId"></param>
        public void Delete(decimal decMasterId)
        {
            try
            {
                //PaymentMasterSP SpPaymentMaster = new PaymentMasterSP();
                PartyBalanceBll BllPartyBalance = new PartyBalanceBll();
                PaymentVoucherBll BllPaymentVoucher = new PaymentVoucherBll();
                if (!BllPartyBalance.PartyBalanceCheckReference(decPaymentVoucherTypeId, strVoucherNo))
                {
                    BllPaymentVoucher.PaymentVoucherDelete(decPaymentmasterId, decPaymentVoucherTypeId, strVoucherNo);
                    Messages.DeletedMessage();
                    if (frmPaymentRegisterObj != null)
                    {
                        this.Close();
                        frmPaymentRegisterObj.CallFromPaymentVoucher(this);
                    }
                    else if (frmPaymentReportObj != null)
                    {
                        this.Close();
                        frmPaymentReportObj.CallFromPaymentVoucher(this);
                    }
                    else if (frmLedgerDetailsObj != null)
                    {
                        this.Close();
                    }
                    if (_frmVoucherSearch != null)
                    {
                        this.Close();
                        _frmVoucherSearch.GridFill();
                    }
                    if (frmDayBookObj != null)
                    {
                        this.Close();
                    }
                    if (frmBillallocationObj != null)
                    {
                        this.Close();
                    }

                }
                else
                {
                    Messages.InformationMessage("Reference exist. Cannot delete");
                    txtDate.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PV19:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// function to delete voucher
        /// </summary>
        /// <param name="decDebitNoteMasterId"></param>
        public void DeleteFunction(decimal decDebitNoteMasterId)
        {
            try
            {
                //DebitNoteMasterSP spDebitNoteMaster = new DebitNoteMasterSP();
                DebitNoteBll bllDebitNote = new DebitNoteBll();
                PartyBalanceBll BllPartyBalance = new PartyBalanceBll();
                if (!BllPartyBalance.PartyBalanceCheckReference(decDebitNoteVoucherTypeId, strVoucherNo))
                {
                    bllDebitNote.DebitNoteVoucherDelete(decDebitNoteMasterId, decDebitNoteVoucherTypeId, strVoucherNo);

                    Messages.DeletedMessage();
                    if (frmDebitNoteRegisterObj != null)
                    {
                        this.Close();
                        frmDebitNoteRegisterObj.Enabled = true;
                    }
                    else if (frmDebitNoteReportObj != null)
                    {
                        this.Close();
                        frmDebitNoteReportObj.Enabled = true;
                    }
                    else if (objVoucherSearch != null)
                    {
                        this.Close();
                        objVoucherSearch.GridFill();
                    }
                    else if (frmLedgerDetailsObj != null)
                    {
                        this.Close();
                    }
                    else
                    {
                        Clear();
                    }
                }
                else
                {
                    Messages.InformationMessage("Reference exist. Cannot delete");
                    txtDate.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("DRNT25:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }