예제 #1
0
        /// <summary>
        /// Function to insert values to ContraDetails Table
        /// </summary>
        /// <param name="contradetailsinfo"></param>
        /// <returns></returns>
        public decimal ContraDetailsAdd(ContraDetailsInfo contradetailsinfo)
        {
            decimal deceffect = 0;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("ContraDetailsAdd", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@contraMasterId", SqlDbType.Decimal);
                sprmparam.Value = contradetailsinfo.ContraMasterId;
                sprmparam       = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
                sprmparam.Value = contradetailsinfo.LedgerId;
                sprmparam       = sccmd.Parameters.Add("@amount", SqlDbType.Decimal);
                sprmparam.Value = contradetailsinfo.Amount;
                sprmparam       = sccmd.Parameters.Add("@chequeNo", SqlDbType.VarChar);
                sprmparam.Value = contradetailsinfo.ChequeNo;
                sprmparam       = sccmd.Parameters.Add("@chequeDate", SqlDbType.DateTime);
                sprmparam.Value = contradetailsinfo.ChequeDate;
                sprmparam       = sccmd.Parameters.Add("@exchangeRateId", SqlDbType.Decimal);
                sprmparam.Value = contradetailsinfo.ExchangeRateId;
                sprmparam       = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
                sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
                sprmparam.Value = contradetailsinfo.Extra1;
                sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
                sprmparam.Value = contradetailsinfo.Extra2;
                deceffect       = Convert.ToDecimal(sccmd.ExecuteNonQuery().ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sqlcon.Close();
            }
            return(deceffect);
        }
예제 #2
0
        /// <summary>
        /// Function to get particular values from ContraDetails Table based on the parameter
        /// </summary>
        /// <param name="contraDetailsId"></param>
        /// <returns></returns>
        public ContraDetailsInfo ContraDetailsView(decimal contraDetailsId)
        {
            ContraDetailsInfo contradetailsinfo = new ContraDetailsInfo();
            SqlDataReader     sdrreader         = null;

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