public void DebitNoteDetailsEdit(DebitNoteDetailsInfo debitnotedetailsinfo)
 {
     try
        {
        spDebitNoteDetails.DebitNoteDetailsEdit(debitnotedetailsinfo);
        }
        catch (Exception ex)
        {
        MessageBox.Show("DNBLL:3" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
 }
 public decimal DebitNoteDetailsAdd(DebitNoteDetailsInfo debitnotedetailsinfo)
 {
     decimal decDebitNoteDetails = 0;
        try
        {
        decDebitNoteDetails = spDebitNoteDetails.DebitNoteDetailsAdd(debitnotedetailsinfo);
        }
        catch (Exception ex)
        {
        MessageBox.Show("DNBLL:1" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        return decDebitNoteDetails;
 }
        /// <summary>
        /// Function to insert values to DebitNoteDetails Table
        /// </summary>
        /// <param name="debitnotedetailsinfo"></param>
        /// <returns></returns>
        public decimal DebitNoteDetailsAdd(DebitNoteDetailsInfo debitnotedetailsinfo)
        {
            decimal decDebitNoteDetails = 0;
            try
            {
            if (sqlcon.State == ConnectionState.Closed)
            {
                sqlcon.Open();
            }
            SqlCommand sccmd = new SqlCommand("DebitNoteDetailsAdd", sqlcon);
            sccmd.CommandType = CommandType.StoredProcedure;
            SqlParameter sprmparam = new SqlParameter();

            sprmparam = sccmd.Parameters.Add("@debitNoteMasterId", SqlDbType.Decimal);
            sprmparam.Value = debitnotedetailsinfo.DebitNoteMasterId;
            sprmparam = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
            sprmparam.Value = debitnotedetailsinfo.LedgerId;
            sprmparam = sccmd.Parameters.Add("@credit", SqlDbType.Decimal);
            sprmparam.Value = debitnotedetailsinfo.Credit;
            sprmparam = sccmd.Parameters.Add("@debit", SqlDbType.Decimal);
            sprmparam.Value = debitnotedetailsinfo.Debit;
            sprmparam = sccmd.Parameters.Add("@exchangeRateId", SqlDbType.Decimal);
            sprmparam.Value = debitnotedetailsinfo.ExchangeRateId;
            sprmparam = sccmd.Parameters.Add("@chequeNo", SqlDbType.VarChar);
            sprmparam.Value = debitnotedetailsinfo.ChequeNo;
            sprmparam = sccmd.Parameters.Add("@chequeDate", SqlDbType.DateTime);
            sprmparam.Value = debitnotedetailsinfo.ChequeDate;
            sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
            sprmparam.Value = debitnotedetailsinfo.Extra1;
            sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
            sprmparam.Value = debitnotedetailsinfo.Extra2;
            sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
            sprmparam.Value = debitnotedetailsinfo.ExtraDate;
            decDebitNoteDetails = Convert.ToDecimal(sccmd.ExecuteScalar().ToString());
            }
            catch (Exception ex)
            {
            MessageBox.Show(ex.ToString());
            }
            finally
            {
            sqlcon.Close();
            }
            return decDebitNoteDetails;
        }
 /// <summary>
 /// Function to get particular values from DebitNoteDetails table based on the parameter
 /// </summary>
 /// <param name="debitNoteDetailsId"></param>
 /// <returns></returns>
 public DebitNoteDetailsInfo DebitNoteDetailsView(decimal debitNoteDetailsId )
 {
     DebitNoteDetailsInfo debitnotedetailsinfo =new DebitNoteDetailsInfo();
     SqlDataReader sdrreader =null;
     try
     {
     if (sqlcon.State == ConnectionState.Closed)
     {
         sqlcon.Open();
     }
     SqlCommand sccmd = new SqlCommand("DebitNoteDetailsView", sqlcon);
     sccmd.CommandType = CommandType.StoredProcedure;
     SqlParameter sprmparam = new SqlParameter();
     sprmparam = sccmd.Parameters.Add("@debitNoteDetailsId", SqlDbType.Decimal);
     sprmparam.Value = debitNoteDetailsId;
      sdrreader = sccmd.ExecuteReader();
     while (sdrreader.Read())
     {
         debitnotedetailsinfo.DebitNoteDetailsId=decimal.Parse(sdrreader[0].ToString());
         debitnotedetailsinfo.DebitNoteMasterId=decimal.Parse(sdrreader[1].ToString());
         debitnotedetailsinfo.LedgerId=decimal.Parse(sdrreader[2].ToString());
         debitnotedetailsinfo.Credit=decimal.Parse(sdrreader[3].ToString());
         debitnotedetailsinfo.Debit=decimal.Parse(sdrreader[4].ToString());
         debitnotedetailsinfo.ExchangeRateId=decimal.Parse(sdrreader[5].ToString());
         debitnotedetailsinfo.ChequeNo= sdrreader[6].ToString();
         debitnotedetailsinfo.ChequeDate=DateTime.Parse(sdrreader[7].ToString());
         debitnotedetailsinfo.Extra1= sdrreader[8].ToString();
         debitnotedetailsinfo.Extra2= sdrreader[9].ToString();
         debitnotedetailsinfo.ExtraDate=DateTime.Parse(sdrreader[10].ToString());
     }
     }
     catch (Exception ex)
     {
     MessageBox.Show(ex.ToString());
     }
     finally
     {           sdrreader.Close();
     sqlcon.Close();
     }
     return debitnotedetailsinfo;
 }