Example #1
0
        /// <summary>
        /// Function to insert values to Holiday table and return Id
        /// </summary>
        /// <param name="holidayinfo"></param>
        /// <returns></returns>
        public bool HolidayAddWithIdentity(HolidayInfo holidayinfo)
        {
            bool isSave = true;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("HolidayAddWithIdentity", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
                sprmparam.Value = holidayinfo.Date;
                sprmparam       = sccmd.Parameters.Add("@holidayName", SqlDbType.VarChar);
                sprmparam.Value = holidayinfo.HolidayName;
                sprmparam       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
                sprmparam.Value = holidayinfo.Narration;
                sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
                sprmparam.Value = holidayinfo.Extra1;
                sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
                sprmparam.Value = holidayinfo.Extra2;
                int inAffected = sccmd.ExecuteNonQuery();
                if (inAffected > 0)
                {
                    isSave = true;
                }
                else
                {
                    isSave = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sqlcon.Close();
            }
            return(isSave);
        }
Example #2
0
        /// <summary>
        /// Function to get particular values from Holiday table based on the parameter
        /// </summary>
        /// <param name="holidayId"></param>
        /// <returns></returns>
        public HolidayInfo HolidayView(decimal holidayId)
        {
            HolidayInfo   holidayinfo = new HolidayInfo();
            SqlDataReader sdrreader   = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("HolidayView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@holidayId", SqlDbType.Decimal);
                sprmparam.Value = holidayId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    holidayinfo.HolidayId   = decimal.Parse(sdrreader[0].ToString());
                    holidayinfo.Date        = DateTime.Parse(sdrreader[1].ToString());
                    holidayinfo.HolidayName = sdrreader[2].ToString();
                    holidayinfo.Narration   = sdrreader[3].ToString();
                    holidayinfo.ExtraDate   = DateTime.Parse(sdrreader[4].ToString());
                    holidayinfo.Extra1      = sdrreader[5].ToString();
                    holidayinfo.Extra2      = sdrreader[6].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(holidayinfo);
        }
Example #3
0
 /// <summary>
 /// Function to Update values in Holiday Table
 /// </summary>
 /// <param name="holidayinfo"></param>
 public void HolidayEdit(HolidayInfo holidayinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("HolidayEdit", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam       = sccmd.Parameters.Add("@holidayId", SqlDbType.Decimal);
         sprmparam.Value = holidayinfo.HolidayId;
         sprmparam       = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
         sprmparam.Value = holidayinfo.Date;
         sprmparam       = sccmd.Parameters.Add("@holidayName", SqlDbType.VarChar);
         sprmparam.Value = holidayinfo.HolidayName;
         sprmparam       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = holidayinfo.Narration;
         sprmparam       = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         sprmparam.Value = holidayinfo.ExtraDate;
         sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = holidayinfo.Extra1;
         sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = holidayinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }