/// <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);
     }
 }