Ejemplo n.º 1
0
        /// <summary>
        /// Function to Update values in ReceiptDetails Table
        /// </summary>
        /// <param name="receiptdetailsinfo"></param>
        /// <returns></returns>
        public decimal ReceiptDetailsEdit(ReceiptDetailsInfo receiptdetailsinfo)
        {
            decimal decReceiptDetailsId = 0;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("ReceiptDetailsEdit", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam           = sccmd.Parameters.Add("@receiptDetailsId", SqlDbType.Decimal);
                sprmparam.Value     = receiptdetailsinfo.ReceiptDetailsId;
                sprmparam           = sccmd.Parameters.Add("@receiptMasterId", SqlDbType.Decimal);
                sprmparam.Value     = receiptdetailsinfo.ReceiptMasterId;
                sprmparam           = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
                sprmparam.Value     = receiptdetailsinfo.LedgerId;
                sprmparam           = sccmd.Parameters.Add("@amount", SqlDbType.Decimal);
                sprmparam.Value     = receiptdetailsinfo.Amount;
                sprmparam           = sccmd.Parameters.Add("@exchangeRateId", SqlDbType.Decimal);
                sprmparam.Value     = receiptdetailsinfo.ExchangeRateId;
                sprmparam           = sccmd.Parameters.Add("@chequeNo", SqlDbType.VarChar);
                sprmparam.Value     = receiptdetailsinfo.ChequeNo;
                sprmparam           = sccmd.Parameters.Add("@chequeDate", SqlDbType.DateTime);
                sprmparam.Value     = receiptdetailsinfo.ChequeDate;
                sprmparam           = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
                sprmparam.Value     = receiptdetailsinfo.Extra1;
                sprmparam           = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
                sprmparam.Value     = receiptdetailsinfo.Extra2;
                decReceiptDetailsId = sccmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sqlcon.Close();
            }
            return(decReceiptDetailsId);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Function to get particular values from ReceiptDetails Table based on the parameter
        /// </summary>
        /// <param name="receiptDetailsId"></param>
        /// <returns></returns>
        public ReceiptDetailsInfo ReceiptDetailsView(decimal receiptDetailsId)
        {
            ReceiptDetailsInfo receiptdetailsinfo = new ReceiptDetailsInfo();
            SqlDataReader      sdrreader          = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("ReceiptDetailsView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@receiptDetailsId", SqlDbType.Decimal);
                sprmparam.Value = receiptDetailsId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    receiptdetailsinfo.ReceiptDetailsId = decimal.Parse(sdrreader[0].ToString());
                    receiptdetailsinfo.ReceiptMasterId  = decimal.Parse(sdrreader[1].ToString());
                    receiptdetailsinfo.LedgerId         = decimal.Parse(sdrreader[2].ToString());
                    receiptdetailsinfo.Amount           = decimal.Parse(sdrreader[3].ToString());
                    receiptdetailsinfo.ChequeNo         = sdrreader[4].ToString();
                    receiptdetailsinfo.ChequeDate       = DateTime.Parse(sdrreader[5].ToString());
                    receiptdetailsinfo.ExtraDate        = DateTime.Parse(sdrreader[6].ToString());
                    receiptdetailsinfo.Extra1           = sdrreader[7].ToString();
                    receiptdetailsinfo.Extra2           = sdrreader[8].ToString();
                    receiptdetailsinfo.ExchangeRateId   = decimal.Parse(sdrreader[9].ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(receiptdetailsinfo);
        }