/// <summary>
 /// Delete Function
 /// </summary>
 public void Delete()
 {
     try
     {
         //DeliveryNoteMasterSP spDeliveryNoteMaster = new DeliveryNoteMasterSP();
         //DeliveryNoteDetailsSP spDeliveryNoteDetails = new DeliveryNoteDetailsSP();
         DeliveryNoteBll bllDeliveryNote = new DeliveryNoteBll();
         StockPostingBll BllStockPosting = new StockPostingBll();
         //StockPostingSP spStockPosting = new StockPostingSP();
         if (!bllDeliveryNote.DeliveryNoteCheckReferenceInSalesInvoice(decDelivryNoteIdToEdit))
         {
             decimal decResult1 = 0;
             decimal decResult2 = bllDeliveryNote.DeliveryNoteMasterDelete(decDelivryNoteIdToEdit);
             for (int inI = 0; inI < dgvProduct.Rows.Count - 1; inI++)
             {
                 if (Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtDetailsId"].Value) != 0)
                 {
                     decResult1 = bllDeliveryNote.DeliveryNoteDetailsDelete(Convert.ToDecimal(dgvProduct.Rows[0].Cells["dgvtxtDetailsId"].Value.ToString()));
                 }
             }
             BllStockPosting.StockPostingDeleteByVoucherTypeAndVoucherNo(strVoucherNo, decDeliveryNoteVoucherTypeId);
             if (decResult2 > 0)
             {
                 Messages.DeletedMessage();
             }
             else
             {
                 Messages.ReferenceExistsMessage();
             }
             if (frmDeliveryNoteRegisterObj != null)
             {
                 this.Close();
                 frmDeliveryNoteRegisterObj.GridFill();
             }
             if (frmDeliveryNoteReportObj != null)
             {
                 this.Close();
                 frmDeliveryNoteReportObj.GridFill();
             }
             if (frmDayBookObj != null)
             {
                 this.Close();
             }
             if (objVoucherSearch != null)
             {
                 this.Close();
             }
             if (objVoucherProduct != null)
             {
                 this.Close();
             }
         }
         else
         {
             Messages.ReferenceExistsMessage();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("DN42:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// RemoveDeliveryNoteDetails If any row was removed at the time of update
 /// </summary>
 public void RemoveDeliveryNoteDetails()
 {
     try
     {
         //DeliveryNoteDetailsSP spDeliveryNoteDetails = new DeliveryNoteDetailsSP();
         DeliveryNoteBll bllDeliveryNote = new DeliveryNoteBll();
         foreach (string str in lstArrOfRemove)
         {
             decimal decDeleteId = Convert.ToDecimal(str);
             bllDeliveryNote.DeliveryNoteDetailsDelete(decDeleteId);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("DN37:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }