Ejemplo n.º 1
0
        protected void createroombtn_Click(object sender, EventArgs e)
        {
            Room r = new Room();
            r.Roomnum = rnotbx.Text;
            r.Roomtype = rttbx.Text;
            r.Roomclass = rctbx.Text;
            r.Numofbed = Convert.ToInt32(nobtbx.Text);
            r.Bedtype = tobtbx.Text;
            r.Roomstatus = rstbx.Text;
            r.Roomrate = rrtbx.Text;

            if (SWENDbmanager.InsertRoom(r) == 1)
            {
                lblSuccessful.Text = "Room Creation Completed..";
            }
            else
            {
                lblSuccessful.Text = "Room Creation Failed..";
            }
        }
Ejemplo n.º 2
0
        public static int InsertRoom(Room r)
        {
            int rowsinserted = 0;

            SqlConnection conn = null;
            try
            {
                conn = new SqlConnection();
                conn.ConnectionString = ConfigurationManager.ConnectionStrings["SWENConnectionString"].ConnectionString;
                conn.Open();
                SqlCommand comm = new SqlCommand();
                comm.Connection = conn;
                comm.CommandText = "INSERT INTO Room(roomnum,roomtype,roomclass,numofbed,bedtype,roomrate,roomstatus)" +
                    " VALUES (@roomnum,@roomtype,@roomclass,@numofbed,@bedtype,@roomrate,@roomstatus)";
                comm.Parameters.AddWithValue("@roomnum", r.Roomnum);
                comm.Parameters.AddWithValue("@roomtype", r.Roomtype);
                comm.Parameters.AddWithValue("@roomclass", r.Roomclass);
                comm.Parameters.AddWithValue("@numofbed", r.Numofbed);
                comm.Parameters.AddWithValue("@bedtype", r.Bedtype);
                comm.Parameters.AddWithValue("@roomrate", r.Roomrate);
                comm.Parameters.AddWithValue("@roomstatus",r.Roomstatus);

                rowsinserted = comm.ExecuteNonQuery();

                conn.Close();
            }
            catch (SqlException e)
            {
                throw e;
            }
            return rowsinserted;
        }
Ejemplo n.º 3
0
        public static int UpdateRoomStatus(Room r)
        {
            int rowsupdated = 0;

            SqlConnection conn = null;
            try
            {
                conn = new SqlConnection();
                conn.ConnectionString = ConfigurationManager.ConnectionStrings["SWENConnectionString"].ConnectionString;
                conn.Open();
                SqlCommand comm = new SqlCommand();
                comm.Connection = conn;
                comm.CommandText = "UPDATE Room SET  roomstatus=@roomstatus WHERE roomnum=@roomnum";
                comm.Parameters.AddWithValue("@roomnum",r.Roomnum);
                comm.Parameters.AddWithValue("@roomstatus",r.Roomstatus);

                rowsupdated = comm.ExecuteNonQuery();
                conn.Close();
            }
            catch (SqlException e)
            {
                throw e;
            }
            return rowsupdated;
        }
Ejemplo n.º 4
0
        public static Room GetRoomByNum(string roomnum)
        {
            Room r = new Room();
            SqlConnection conn = null;
            try
            {
                conn = new SqlConnection();
                conn.ConnectionString = ConfigurationManager.ConnectionStrings["SWENConnectionString"].ConnectionString;
                conn.Open();
                SqlCommand comm = new SqlCommand();
                comm.Connection = conn;
                comm.CommandText = "SELECT * FROM Room WHERE roomnum=@roomnum";
                comm.Parameters.AddWithValue("@roomnum", roomnum);
                SqlDataReader dr = comm.ExecuteReader();
                if (dr.Read())
                {

                    r.Roomnum = (string)dr["roomnum"];
                    r.Roomtype = (string)dr["roomtype"];
                    r.Roomclass = (string)dr["roomclass"];
                    r.Numofbed = (int)dr["numofbed"];
                    r.Bedtype = (string)dr["bedtype"];
                    r.Roomrate = (string)dr["roomrate"];
                    r.Roomstatus = (string)dr["roomstatus"];
                    r.Roomid = (int)dr["roomid"];

                }
                dr.Close();
            }

            catch (SqlException e)
            {
                throw e;
            }

            return r;
        }