public decimal CreditNoteDetailsEdit(CreditNoteDetailsInfo creditnotedetailsinfo)
 {
     decimal decId = 0;
     try
     {
         decId = SpCreditNoteDetails.CreditNoteDetailsEdit(creditnotedetailsinfo);
     }
     catch (Exception ex)
     {
         MessageBox.Show("CNDB:3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     return decId;
 }
 /// <summary>
 /// Function to insert values to CreditNoteDetails Table
 /// </summary>
 /// <param name="creditnotedetailsinfo"></param>
 /// <returns></returns>
 public decimal CreditNoteDetailsAdd(CreditNoteDetailsInfo creditnotedetailsinfo)
 {
     decimal decId = 0;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("CreditNoteDetailsAdd", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@creditNoteMasterId", SqlDbType.Decimal);
         sprmparam.Value = creditnotedetailsinfo.CreditNoteMasterId;
         sprmparam = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
         sprmparam.Value = creditnotedetailsinfo.LedgerId;
         sprmparam = sccmd.Parameters.Add("@credit", SqlDbType.Decimal);
         sprmparam.Value = creditnotedetailsinfo.Credit;
         sprmparam = sccmd.Parameters.Add("@debit", SqlDbType.Decimal);
         sprmparam.Value = creditnotedetailsinfo.Debit;
         sprmparam = sccmd.Parameters.Add("@exchangeRateId", SqlDbType.Decimal);
         sprmparam.Value = creditnotedetailsinfo.ExchangeRateId;
         sprmparam = sccmd.Parameters.Add("@chequeNo", SqlDbType.VarChar);
         sprmparam.Value = creditnotedetailsinfo.ChequeNo;
         sprmparam = sccmd.Parameters.Add("@chequeDate", SqlDbType.DateTime);
         sprmparam.Value = creditnotedetailsinfo.ChequeDate;
         sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         sprmparam.Value = creditnotedetailsinfo.ExtraDate;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = creditnotedetailsinfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = creditnotedetailsinfo.Extra2;
         decId = Convert.ToDecimal(sccmd.ExecuteScalar());
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
     return decId;
 }
 /// <summary>
 /// Function to get particular values from creditNoteDetails Table based on the parameter
 /// </summary>
 /// <param name="creditNoteDetailsId"></param>
 /// <returns></returns>
 public CreditNoteDetailsInfo CreditNoteDetailsView(decimal creditNoteDetailsId)
 {
     CreditNoteDetailsInfo infoCreditNoteDetails = new CreditNoteDetailsInfo();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("CreditNoteDetailsView", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@creditNoteDetailsId", SqlDbType.Decimal);
         sprmparam.Value = creditNoteDetailsId;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             infoCreditNoteDetails.CreditNoteDetailsId = Convert.ToDecimal(sdrreader[0].ToString());
             infoCreditNoteDetails.CreditNoteMasterId = Convert.ToDecimal(sdrreader[1].ToString());
             infoCreditNoteDetails.LedgerId = Convert.ToDecimal(sdrreader[2].ToString());
             infoCreditNoteDetails.Credit = Convert.ToDecimal(sdrreader[3].ToString());
             infoCreditNoteDetails.Debit = Convert.ToDecimal(sdrreader[4].ToString());
             infoCreditNoteDetails.ExchangeRateId = Convert.ToDecimal(sdrreader[5].ToString());
             infoCreditNoteDetails.ChequeNo = sdrreader[6].ToString();
             infoCreditNoteDetails.ChequeDate = Convert.ToDateTime(sdrreader[7].ToString());
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
     return infoCreditNoteDetails;
 }