Пример #1
0
        public static int AddRoom(Room room)
        {
            int roomID = -1;

            // Setup Connection
            using (DatabaseConnection db = new DatabaseConnection("dbo.AddRoom"))
            {
                // Set Parameters
                AddParameters(room, db.comm);

                // Open Connection
                db.conn.Open();

                // Execute Command and Read Response
                roomID = Convert.ToInt32(db.comm.ExecuteScalar());
            }

            return roomID;
        }
Пример #2
0
 private static void AddParameters(Room room, SqlCommand comm)
 {
     comm.Parameters.AddWithValue("RoomName", room.RoomName);
     comm.Parameters.AddWithValue("Seats", room.RoomSeats);
 }
Пример #3
0
 public static Room ReadRoom(SqlDataReader reader)
 {
     Room room = new Room();
     room.RoomID = (int)reader["RoomID"];
     room.RoomName = (string)reader["RoomName"];
     room.RoomSeats = (int)reader["RoomSeats"];
     return room;
 }
Пример #4
0
        public static int UpdateRoom(Room room, Room oldRoom)
        {
            int rowsAffected = 0;

            // Setup Connection
            DatabaseConnection db = new DatabaseConnection("dbo.UpdateRoom");
            {
                // Set Parameters
                AddParameters(room, db.comm);
                AddOldParameters(oldRoom, db.comm);

                // Open Connection
                db.conn.Open();

                // Execute Command and Read Response
                rowsAffected = db.comm.ExecuteNonQuery();
            }

            return rowsAffected;
        }
Пример #5
0
 public Session()
 {
     course = new Course();
     instructor = new Instructor();
     room = new Room();
 }