Exemple #1
0
        /// <summary>
        /// Function to get particular values from AdditionalCost table based on the parameter
        /// </summary>
        /// <param name="additionalCostId"></param>
        /// <returns></returns>
        public AdditionalCostInfo AdditionalCostView(decimal additionalCostId)
        {
            AdditionalCostInfo additionalcostinfo = new AdditionalCostInfo();
            SqlDataReader      sdrreader          = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("AdditionalCostView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@additionalCostId", SqlDbType.Decimal);
                sprmparam.Value = additionalCostId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    additionalcostinfo.AdditionalCostId = decimal.Parse(sdrreader[0].ToString());
                    additionalcostinfo.VoucherTypeId    = decimal.Parse(sdrreader[1].ToString());
                    additionalcostinfo.VoucherNo        = sdrreader[2].ToString();
                    additionalcostinfo.LedgerId         = decimal.Parse(sdrreader[3].ToString());
                    additionalcostinfo.Debit            = decimal.Parse(sdrreader[4].ToString());
                    additionalcostinfo.Credit           = decimal.Parse(sdrreader[5].ToString());
                    additionalcostinfo.ExtraDate        = DateTime.Parse(sdrreader[6].ToString());
                    additionalcostinfo.Extra1           = sdrreader[7].ToString();
                    additionalcostinfo.Extra2           = sdrreader[8].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(additionalcostinfo);
        }
Exemple #2
0
 /// <summary>
 /// Function to Update values in AdditionCost table
 /// </summary>
 /// <param name="additionalcostinfo"></param>
 public void AdditionalCostEdit(AdditionalCostInfo additionalcostinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("AdditionalCostEdit", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam       = sccmd.Parameters.Add("@additionalCostId", SqlDbType.Decimal);
         sprmparam.Value = additionalcostinfo.AdditionalCostId;
         sprmparam       = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
         sprmparam.Value = additionalcostinfo.VoucherTypeId;
         sprmparam       = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar);
         sprmparam.Value = additionalcostinfo.VoucherNo;
         sprmparam       = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
         sprmparam.Value = additionalcostinfo.LedgerId;
         sprmparam       = sccmd.Parameters.Add("@debit", SqlDbType.Decimal);
         sprmparam.Value = additionalcostinfo.Debit;
         sprmparam       = sccmd.Parameters.Add("@credit", SqlDbType.Decimal);
         sprmparam.Value = additionalcostinfo.Credit;
         sprmparam       = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         sprmparam.Value = additionalcostinfo.ExtraDate;
         sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = additionalcostinfo.Extra1;
         sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = additionalcostinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }