/// <summary>
 /// Function to delete material receipt
 /// </summary>
 public void Delete()
 {
     MaterialReceiptBll bllMaterialReceiptMaster = new MaterialReceiptBll();
     //StockPostingSP spstockposting = new StockPostingSP();
     StockPostingBll BllStockPosting = new StockPostingBll();
     try
     {
         decimal decResult1 = 0;
         decimal decReference = bllMaterialReceiptMaster.MaterialReceiptMasterReferenceCheck(decMaterialReceiptMasterId);
         if (decReference == 1)
         {
             decResult1 = bllMaterialReceiptMaster.MaterialReceiptDelete(decMaterialReceiptMasterId);
             if (decResult1 > 0)
             {
                 if (Convert.ToDecimal(dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtvouchertypeId"].Value) == 0)
                 {
                     decimal decResult3 = BllStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType(0, "NA", strVoucherNo, decMaterialReceiptVoucherTypeId);
                 }
                 else
                 {
                     decimal decResult3 = BllStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType(decMaterialReceiptVoucherTypeId, strVoucherNo, strAgainstVoucherNo, decAgainstVoucherTypeId);
                 }
                 Messages.DeletedMessage();
                 if (frmMaterialReceiptRegisterObj != null)
                 {
                     this.Close();
                     frmMaterialReceiptRegisterObj.GridFill();
                 }
                 if (frmMaterialReceiptReportObj != null)
                 {
                     this.Close();
                     frmMaterialReceiptReportObj.GridFill();
                 }
                 if (objVoucherSearch != null)
                 {
                     this.Close();
                     objVoucherSearch.GridFill();
                 }
                 if (frmDayBookObj != null)
                 {
                     this.Close();
                     frmDayBookObj.dayBookGridFill();
                 }
             }
         }
         else
         {
             Messages.ReferenceExistsMessage();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("MR50:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }