Exemplo n.º 1
0
        public bool Insert(NoOfWorkingDays c)
        {
            bool          isSucces = false;
            SqlConnection conn     = new SqlConnection(myconnstring);

            try
            {
                conn.Open();
                string     sql = "INSERT INTO NoWorkingDays(Number_Of_Working_Days) VALUES(@Number_Of_Working_Days)";
                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.AddWithValue("@Number_Of_Working_Days", c.Number_Of_Working_Days);


                int rows = cmd.ExecuteNonQuery();
                if (rows > 0)
                {
                    isSucces = true;
                }
                else
                {
                    isSucces = false;
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                conn.Close();
            }
            return(isSucces);
        }
Exemplo n.º 2
0
        public String Update(NoOfWorkingDays c, int id)
        {
            String        isSuccess = "false";
            SqlConnection conn      = new SqlConnection(myconnstring);

            try
            {
                conn.Open();
                String     sql = "UPDATE NoWorkingDays SET Number_Of_Working_days=@Number_Of_Working_Days WHERE EntryID=@EntryID";
                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.AddWithValue("@Number_Of_Working_Days", c.Number_Of_Working_Days);
                cmd.Parameters.AddWithValue("@EntryID", id);

                cmd.ExecuteNonQuery();
                isSuccess = "true";
            }
            catch (Exception ex)
            {
                isSuccess = ex.Message;
            }
            finally
            {
                conn.Close();
            }
            return(isSuccess);
        }
Exemplo n.º 3
0
        public bool Delete(NoOfWorkingDays c, int id)
        {
            bool          isSuccess = false;
            SqlConnection conn      = new SqlConnection(myconnstring);

            try
            {
                String     sql = "DELETE FROM NoWorkingDays WHERE EntryID=@EntryID";
                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.AddWithValue("@EntryID", id);

                conn.Open();

                cmd.ExecuteNonQuery();

                isSuccess = true;
            }
            catch (Exception ex)
            {
            }
            finally
            {
                conn.Close();
            }
            return(isSuccess);
        }