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; }
private static void AddParameters(Room room, SqlCommand comm) { comm.Parameters.AddWithValue("RoomName", room.RoomName); comm.Parameters.AddWithValue("Seats", room.RoomSeats); }
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; }
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; }
public Session() { course = new Course(); instructor = new Instructor(); room = new Room(); }