예제 #1
0
        /// <summary>
        /// Function to get particular values from ServiceDetails Table based on the parameter
        /// </summary>
        /// <param name="serviceDetailsId"></param>
        /// <returns></returns>
        public ServiceDetailsInfo ServiceDetailsView(decimal serviceDetailsId)
        {
            ServiceDetailsInfo servicedetailsinfo = new ServiceDetailsInfo();
            SqlDataReader      sdrreader          = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("ServiceDetailsView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@serviceDetailsId", SqlDbType.Decimal);
                sprmparam.Value = serviceDetailsId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    servicedetailsinfo.ServiceDetailsId = decimal.Parse(sdrreader[0].ToString());
                    servicedetailsinfo.ServiceMasterId  = decimal.Parse(sdrreader[1].ToString());
                    servicedetailsinfo.ServiceId        = decimal.Parse(sdrreader[2].ToString());
                    servicedetailsinfo.Measure          = sdrreader[3].ToString();
                    servicedetailsinfo.Amount           = decimal.Parse(sdrreader[4].ToString());
                    servicedetailsinfo.ExtraDate        = DateTime.Parse(sdrreader[5].ToString());
                    servicedetailsinfo.Extra1           = sdrreader[6].ToString();
                    servicedetailsinfo.Extra2           = sdrreader[7].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(servicedetailsinfo);
        }
예제 #2
0
        /// <summary>
        /// Function to insert values to ServiceDetails Table and return corresponding row's id
        /// </summary>
        /// <param name="servicedetailsinfo"></param>
        /// <returns></returns>
        public decimal ServiceDetailsAddReturnWithIdentity(ServiceDetailsInfo servicedetailsinfo)
        {
            decimal decIdentity = 0;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("ServiceDetailsAddReturnWithIdentity", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@serviceMasterId", SqlDbType.Decimal);
                sprmparam.Value = servicedetailsinfo.ServiceMasterId;
                sprmparam       = sccmd.Parameters.Add("@serviceId", SqlDbType.Decimal);
                sprmparam.Value = servicedetailsinfo.ServiceId;
                sprmparam       = sccmd.Parameters.Add("@measure", SqlDbType.VarChar);
                sprmparam.Value = servicedetailsinfo.Measure;
                sprmparam       = sccmd.Parameters.Add("@amount", SqlDbType.Decimal);
                sprmparam.Value = servicedetailsinfo.Amount;
                sprmparam       = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
                sprmparam.Value = servicedetailsinfo.ExtraDate;
                sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
                sprmparam.Value = servicedetailsinfo.Extra1;
                sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
                sprmparam.Value = servicedetailsinfo.Extra2;
                decIdentity     = Convert.ToDecimal(sccmd.ExecuteScalar().ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sqlcon.Close();
            }
            return(decIdentity);
        }
예제 #3
0
 /// <summary>
 /// Function to insert values to ServiceDetails Table
 /// </summary>
 /// <param name="servicedetailsinfo"></param>
 public void ServiceDetailsAdd(ServiceDetailsInfo servicedetailsinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("ServiceDetailsAdd", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam       = sccmd.Parameters.Add("@serviceDetailsId", SqlDbType.Decimal);
         sprmparam.Value = servicedetailsinfo.ServiceDetailsId;
         sprmparam       = sccmd.Parameters.Add("@serviceMasterId", SqlDbType.Decimal);
         sprmparam.Value = servicedetailsinfo.ServiceMasterId;
         sprmparam       = sccmd.Parameters.Add("@serviceId", SqlDbType.Decimal);
         sprmparam.Value = servicedetailsinfo.ServiceId;
         sprmparam       = sccmd.Parameters.Add("@measure", SqlDbType.VarChar);
         sprmparam.Value = servicedetailsinfo.Measure;
         sprmparam       = sccmd.Parameters.Add("@amount", SqlDbType.Decimal);
         sprmparam.Value = servicedetailsinfo.Amount;
         sprmparam       = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         sprmparam.Value = servicedetailsinfo.ExtraDate;
         sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = servicedetailsinfo.Extra1;
         sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = servicedetailsinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }