public void SalesReturnMasterEdit(SalesReturnMasterInfo infoSalesReturnMaster)
        {
            try
             {
                 spSalesReturnMaster.SalesReturnMasterEdit(infoSalesReturnMaster);
             }
             catch (Exception ex)
             {
                 MessageBox.Show("AG1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);

             }
        }
 /// <summary>
 /// Function to get particular values from SalesReturnMaster Table based on the parameter
 /// </summary>
 /// <param name="salesReturnMasterId"></param>
 /// <returns></returns>
 public SalesReturnMasterInfo SalesReturnMasterView(decimal salesReturnMasterId)
 {
     SalesReturnMasterInfo salesreturnmasterinfo = new SalesReturnMasterInfo();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("SalesReturnMasterView", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@salesReturnMasterId", SqlDbType.Decimal);
         sprmparam.Value = salesReturnMasterId;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             salesreturnmasterinfo.SalesReturnMasterId = decimal.Parse(sdrreader["salesReturnMasterId"].ToString());
             salesreturnmasterinfo.VoucherNo = sdrreader["voucherNo"].ToString();
             salesreturnmasterinfo.InvoiceNo = sdrreader[2].ToString();
             salesreturnmasterinfo.VoucherTypeId = decimal.Parse(sdrreader["voucherTypeId"].ToString());
             salesreturnmasterinfo.SuffixPrefixId = decimal.Parse(sdrreader["suffixPrefixId"].ToString());
             salesreturnmasterinfo.LedgerId = decimal.Parse(sdrreader["ledgerId"].ToString());
             salesreturnmasterinfo.SalesAccount = decimal.Parse(sdrreader[6].ToString());
             salesreturnmasterinfo.PricinglevelId = decimal.Parse(sdrreader["pricinglevelId"].ToString());
             salesreturnmasterinfo.EmployeeId = decimal.Parse(sdrreader["employeeId"].ToString());
             salesreturnmasterinfo.Narration = sdrreader[9].ToString();
             salesreturnmasterinfo.ExchangeRateId = decimal.Parse(sdrreader["exchangeRateId"].ToString());
             salesreturnmasterinfo.TaxAmount = decimal.Parse(sdrreader["taxAmount"].ToString());
             salesreturnmasterinfo.UserId = decimal.Parse(sdrreader["userId"].ToString());
             salesreturnmasterinfo.LrNo = sdrreader[13].ToString();
             salesreturnmasterinfo.TransportationCompany = sdrreader[14].ToString();
             salesreturnmasterinfo.Date = DateTime.Parse(sdrreader["date"].ToString());
             salesreturnmasterinfo.TotalAmount = decimal.Parse(sdrreader["totalAmount"].ToString());
             salesreturnmasterinfo.grandTotal = decimal.Parse(sdrreader["grandTotal"].ToString());
             salesreturnmasterinfo.FinancialYearId = decimal.Parse(sdrreader["financialYearId"].ToString());
             salesreturnmasterinfo.ExtraDate = DateTime.Parse(sdrreader["extraDate"].ToString());
             salesreturnmasterinfo.Extra1 = sdrreader["extra1"].ToString();
             salesreturnmasterinfo.Extra2 = sdrreader[20].ToString();
             salesreturnmasterinfo.Discount = decimal.Parse(sdrreader["discount"].ToString());
             salesreturnmasterinfo.SalesMasterId = decimal.Parse(sdrreader["salesMasterId"].ToString());
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sdrreader.Close();
         sqlcon.Close();
     }
     return salesreturnmasterinfo;
 }
 public decimal SalesReturnMasterAdd(SalesReturnMasterInfo infoSalesReturnMaster)
 {
     decimal decIdentity = 0;
      try
      {
          decIdentity = spSalesReturnMaster.SalesReturnMasterAdd(infoSalesReturnMaster);
      }
      catch (Exception ex)
      {
          MessageBox.Show("AG1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
      }
      return decIdentity;
 }
 /// <summary>
 /// Function to Update values in SalesReturnMaster Table
 /// </summary>
 /// <param name="salesreturnmasterinfo"></param>
 public void SalesReturnMasterEdit(SalesReturnMasterInfo salesreturnmasterinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("SalesReturnMasterEdit", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@salesReturnMasterId", SqlDbType.Decimal);
         sprmparam.Value = salesreturnmasterinfo.SalesReturnMasterId;
         sprmparam = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar);
         sprmparam.Value = salesreturnmasterinfo.VoucherNo;
         sprmparam = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar);
         sprmparam.Value = salesreturnmasterinfo.InvoiceNo;
         sprmparam = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
         sprmparam.Value = salesreturnmasterinfo.VoucherTypeId;
         sprmparam = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal);
         sprmparam.Value = salesreturnmasterinfo.SuffixPrefixId;
         sprmparam = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
         sprmparam.Value = salesreturnmasterinfo.LedgerId;
         sprmparam = sccmd.Parameters.Add("@salesMasterId", SqlDbType.Decimal);
         sprmparam.Value = salesreturnmasterinfo.SalesMasterId;
         sprmparam = sccmd.Parameters.Add("@salesAccount", SqlDbType.Decimal);
         sprmparam.Value = salesreturnmasterinfo.SalesAccount;
         sprmparam = sccmd.Parameters.Add("@pricinglevelId", SqlDbType.Decimal);
         sprmparam.Value = salesreturnmasterinfo.PricinglevelId;
         sprmparam = sccmd.Parameters.Add("@employeeId", SqlDbType.Decimal);
         sprmparam.Value = salesreturnmasterinfo.EmployeeId;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = salesreturnmasterinfo.Narration;
         sprmparam = sccmd.Parameters.Add("@exchangeRateId", SqlDbType.Decimal);
         sprmparam.Value = salesreturnmasterinfo.ExchangeRateId;
         sprmparam = sccmd.Parameters.Add("@discount", SqlDbType.Decimal);
         sprmparam.Value = salesreturnmasterinfo.Discount;
         sprmparam = sccmd.Parameters.Add("@taxAmount", SqlDbType.Decimal);
         sprmparam.Value = salesreturnmasterinfo.TaxAmount;
         sprmparam = sccmd.Parameters.Add("@userId", SqlDbType.Decimal);
         sprmparam.Value = salesreturnmasterinfo.UserId;
         sprmparam = sccmd.Parameters.Add("@lrNo", SqlDbType.VarChar);
         sprmparam.Value = salesreturnmasterinfo.LrNo;
         sprmparam = sccmd.Parameters.Add("@transportationCompany", SqlDbType.VarChar);
         sprmparam.Value = salesreturnmasterinfo.TransportationCompany;
         sprmparam = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
         sprmparam.Value = salesreturnmasterinfo.Date;
         sprmparam = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal);
         sprmparam.Value = salesreturnmasterinfo.TotalAmount;
         sprmparam = sccmd.Parameters.Add("@grandTotal", SqlDbType.Decimal);
         sprmparam.Value = salesreturnmasterinfo.grandTotal;
         sprmparam = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal);
         sprmparam.Value = salesreturnmasterinfo.FinancialYearId;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = salesreturnmasterinfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = salesreturnmasterinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }