Exemple #1
0
        //Updating RoomNonReservableTime data in db
        public bool updateRoomNonReservableTime(NonReservableTimeRoom nrtr)
        {
            bool isSuccess = false;

            //database connection
            SqlConnection conn = new SqlConnection(myconnstring);

            try
            {
                //sql query
                string sql = "UPDATE RoomNonReservableTime SET Room_name=@Room_name, StartTime=@StartTime, EndTime=@EndTime, Day=@Day WHERE NonReservableID=@NonReservableID";

                //creating cmd using sql and conn
                SqlCommand cmd = new SqlCommand(sql, conn);

                //Creating parameters to add data
                cmd.Parameters.AddWithValue("@NonReservableID", nrtr.NonReservableID);
                cmd.Parameters.AddWithValue("@Room_name", nrtr.Room_name);
                cmd.Parameters.AddWithValue("@StartTime", nrtr.StartTime);
                cmd.Parameters.AddWithValue("@EndTime", nrtr.EndTime);
                cmd.Parameters.AddWithValue("@Day", nrtr.Day);

                //Open connection
                conn.Open();
                int rows = cmd.ExecuteNonQuery();

                if (rows > 0)
                {
                    isSuccess = true;
                }
                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                conn.Close();
            }
            return(isSuccess);
        }
Exemple #2
0
        //Deleting RoomNonReservableTime data in db
        public bool deleteRoomNonReservableTime(NonReservableTimeRoom nrtr)
        {
            bool isSuccess = false;

            //database connection
            SqlConnection conn = new SqlConnection(myconnstring);

            try
            {
                //sql query
                string sql = "DELETE FROM RoomNonReservableTime WHERE NonReservableID=@NonReservableID";

                //creating cmd using sql and conn
                SqlCommand cmd = new SqlCommand(sql, conn);

                //Creating parameters to add data
                cmd.Parameters.AddWithValue("@NonReservableID", nrtr.NonReservableID);

                //Open connection
                conn.Open();
                int rows = cmd.ExecuteNonQuery();

                if (rows > 0)
                {
                    isSuccess = true;
                }
                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                conn.Close();
            }
            return(isSuccess);
        }
Exemple #3
0
        //Inserting RoomNonReservableTime data into db
        public int insertRoomNonReservableTime(NonReservableTimeRoom nrtr)
        {
            //database connection
            SqlConnection conn = new SqlConnection(myconnstring);

            try
            {
                //sql query
                string sql = "INSERT INTO RoomNonReservableTime (Room_name, StartTime, EndTime, Day) VALUES (@Room_name, @StartTime, @EndTime, @Day); SELECT SCOPE_IDENTITY()";

                //creating cmd using sql and conn
                SqlCommand cmd = new SqlCommand(sql, conn);


                cmd.CommandType = CommandType.Text;


                //Creating parameters to add data
                cmd.Parameters.AddWithValue("@Room_name", nrtr.Room_name);
                cmd.Parameters.AddWithValue("@StartTime", nrtr.StartTime);
                cmd.Parameters.AddWithValue("@EndTime", nrtr.EndTime);
                cmd.Parameters.AddWithValue("@Day", nrtr.Day);

                //Open connection
                conn.Open();
                ID = Convert.ToInt32(cmd.ExecuteScalar());
            }
            catch (Exception ex)
            {
            }
            finally
            {
                conn.Close();
            }
            return(ID);
        }