/// <summary>
 /// Function to insert values to PurchaseReturnMaster Table
 /// </summary>
 /// <param name="purchasereturnmasterinfo"></param>
 public void PurchaseReturnMasterAdd(PurchaseReturnMasterInfo purchasereturnmasterinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("PurchaseReturnMasterAdd", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@purchaseReturnMasterId", SqlDbType.Decimal);
         sprmparam.Value = purchasereturnmasterinfo.PurchaseReturnMasterId;
         sprmparam = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar);
         sprmparam.Value = purchasereturnmasterinfo.VoucherNo;
         sprmparam = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar);
         sprmparam.Value = purchasereturnmasterinfo.InvoiceNo;
         sprmparam = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal);
         sprmparam.Value = purchasereturnmasterinfo.SuffixPrefixId;
         sprmparam = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
         sprmparam.Value = purchasereturnmasterinfo.VoucherTypeId;
         sprmparam = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
         sprmparam.Value = purchasereturnmasterinfo.Date;
         sprmparam = sccmd.Parameters.Add("@purchaseMasterId", SqlDbType.Decimal);
         sprmparam.Value = purchasereturnmasterinfo.PurchaseMasterId;
         sprmparam = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
         sprmparam.Value = purchasereturnmasterinfo.LedgerId;
         sprmparam = sccmd.Parameters.Add("@discount", SqlDbType.Decimal);
         sprmparam.Value = purchasereturnmasterinfo.Discount;
         sprmparam = sccmd.Parameters.Add("@exchangeRateId", SqlDbType.Decimal);
         sprmparam.Value = purchasereturnmasterinfo.ExchangeRateId;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = purchasereturnmasterinfo.Narration;
         sprmparam = sccmd.Parameters.Add("@purchaseAccount", SqlDbType.Decimal);
         sprmparam.Value = purchasereturnmasterinfo.PurchaseAccount;
         sprmparam = sccmd.Parameters.Add("@totalTax", SqlDbType.Decimal);
         sprmparam.Value = purchasereturnmasterinfo.TotalTax;
         sprmparam = sccmd.Parameters.Add("@grandTotal", SqlDbType.Decimal);
         sprmparam.Value = purchasereturnmasterinfo.GrandTotal;
         sprmparam = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal);
         sprmparam.Value = purchasereturnmasterinfo.TotalAmount;
         sprmparam = sccmd.Parameters.Add("@userId", SqlDbType.Decimal);
         sprmparam.Value = purchasereturnmasterinfo.UserId;
         sprmparam = sccmd.Parameters.Add("@lrNo", SqlDbType.VarChar);
         sprmparam.Value = purchasereturnmasterinfo.LrNo;
         sprmparam = sccmd.Parameters.Add("@transportationCompany", SqlDbType.VarChar);
         sprmparam.Value = purchasereturnmasterinfo.TransportationCompany;
         sprmparam = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal);
         sprmparam.Value = purchasereturnmasterinfo.FinancialYearId;
         sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         sprmparam.Value = purchasereturnmasterinfo.ExtraDate;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = purchasereturnmasterinfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = purchasereturnmasterinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
 /// <summary>
 /// Function to get particular values from PurchaseReturnMaster table based on the parameter
 /// </summary>
 /// <param name="purchaseReturnMasterId"></param>
 /// <returns></returns>
 public PurchaseReturnMasterInfo PurchaseReturnMasterView(decimal purchaseReturnMasterId)
 {
     PurchaseReturnMasterInfo purchasereturnmasterinfo = new PurchaseReturnMasterInfo();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("PurchaseReturnMasterView", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@purchaseReturnMasterId", SqlDbType.Decimal);
         sprmparam.Value = purchaseReturnMasterId;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             purchasereturnmasterinfo.PurchaseReturnMasterId = Convert.ToDecimal(sdrreader["purchaseReturnMasterId"].ToString());
             purchasereturnmasterinfo.VoucherNo = sdrreader["voucherNo"].ToString();
             purchasereturnmasterinfo.InvoiceNo = sdrreader["invoiceNo"].ToString();
             purchasereturnmasterinfo.SuffixPrefixId = Convert.ToDecimal(sdrreader["suffixPrefixId"].ToString());
             purchasereturnmasterinfo.VoucherTypeId = Convert.ToDecimal(sdrreader["voucherTypeId"].ToString());
             purchasereturnmasterinfo.Date = Convert.ToDateTime(sdrreader["date"].ToString());
             purchasereturnmasterinfo.LedgerId = Convert.ToDecimal(sdrreader["ledgerId"].ToString());
             purchasereturnmasterinfo.Discount = Convert.ToDecimal(sdrreader["discount"].ToString());
             purchasereturnmasterinfo.Narration = sdrreader["narration"].ToString();
             purchasereturnmasterinfo.PurchaseAccount = Convert.ToDecimal(sdrreader["purchaseAccount"].ToString());
             purchasereturnmasterinfo.TotalTax = Convert.ToDecimal(sdrreader["totalTax"].ToString());
             purchasereturnmasterinfo.TotalAmount = Convert.ToDecimal(sdrreader["totalAmount"].ToString());
             purchasereturnmasterinfo.GrandTotal = Convert.ToDecimal(sdrreader["grandTotal"].ToString());
             purchasereturnmasterinfo.UserId = Convert.ToDecimal(sdrreader["userId"].ToString());
             purchasereturnmasterinfo.LrNo = sdrreader["lrNo"].ToString();
             purchasereturnmasterinfo.TransportationCompany = sdrreader["transportationCompany"].ToString();
             purchasereturnmasterinfo.FinancialYearId = Convert.ToDecimal(sdrreader["financialYearId"].ToString());
             purchasereturnmasterinfo.PurchaseMasterId = Convert.ToDecimal(sdrreader["purchaseMasterId"].ToString());
             purchasereturnmasterinfo.ExchangeRateId = Convert.ToDecimal(sdrreader["exchangeRateId"].ToString());
             purchasereturnmasterinfo.ExtraDate = Convert.ToDateTime(sdrreader["extraDate"].ToString());
             purchasereturnmasterinfo.Extra1 = sdrreader["extra1"].ToString();
             purchasereturnmasterinfo.Extra2 = sdrreader["extra2"].ToString();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sdrreader.Close();
         sqlcon.Close();
     }
     return purchasereturnmasterinfo;
 }
        /// <summary>
        /// Function to insert values to PurchaseReturnMaster Table
        /// </summary>
        /// <param name="purchasereturnmasterinfo"></param>
        /// <returns></returns>
        public void PurchaseReturnMasterEdit(PurchaseReturnMasterInfo purchasereturnmasterinfo)
        {
            PurchaseReturnMasterSP SPPurchaseReturnMaster = new PurchaseReturnMasterSP();

               try
               {
               SPPurchaseReturnMaster.PurchaseReturnMasterEdit(purchasereturnmasterinfo);
               }
               catch (Exception ex)
               {
               MessageBox.Show("PrBll 8:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
               }
        }
 /// <summary>
 /// Function to get particular values from PurchaseReturnMaster table based on the parameter
 /// </summary>
 /// <param name="purchaseReturnMasterId"></param>
 /// <returns></returns>
 public PurchaseReturnMasterInfo PurchaseReturnMasterView(decimal purchaseReturnMasterId)
 {
     PurchaseReturnMasterSP SPPurchaseReturnMaster = new PurchaseReturnMasterSP();
        PurchaseReturnMasterInfo infopurchasereturnmaster = new PurchaseReturnMasterInfo();
        try
        {
        infopurchasereturnmaster = SPPurchaseReturnMaster.PurchaseReturnMasterView(purchaseReturnMasterId);
        }
        catch (Exception ex)
        {
        MessageBox.Show("PrBll 9:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        return infopurchasereturnmaster;
 }
 /// <summary>
 /// Function to insert values to PurchaseReturnMaster Table
 /// </summary>
 /// <param name="purchasereturnmasterinfo"></param>
 /// <returns></returns>
 public decimal PurchaseReturnMasterAddWithReturnIdentity(PurchaseReturnMasterInfo purchasereturnmasterinfo)
 {
     PurchaseReturnMasterSP SPPurchaseReturnMaster = new PurchaseReturnMasterSP();
        decimal decIdentity = 0;
        try
        {
        decIdentity = SPPurchaseReturnMaster.PurchaseReturnMasterAddWithReturnIdentity(purchasereturnmasterinfo);
        }
        catch (Exception ex)
        {
        MessageBox.Show("PrBll 7:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        return decIdentity;
 }