void compareRoom(Room & room1, Room & room2) { EXPECT_EQ(room1.getId(), room2.getId()); EXPECT_EQ(room1.getCapacity(), room2.getCapacity()); EXPECT_EQ(room1.getPrize(), room2.getPrize()); EXPECT_EQ(room1.getRoomLocation().getDoor(), room2.getRoomLocation().getDoor()); EXPECT_EQ(room1.getRoomLocation().getFloor(), room2.getRoomLocation().getFloor()); }
/** *Edits the fields from selected room in Room table *@param room is a room class item *@param fetchquery is an sql query *@param query is an sql query */ void RoomManagement::editRoom(Room room) { QSqlQuery query; QSqlQuery fetchquery; fetchquery = sqlMechanism.myQuery(); fetchquery.prepare("SELECT * FROM RoomsReservation WHERE fkRoomId= :rNum"); fetchquery.bindValue(":rNum",room.getRoomNumber()); fetchquery.exec(); fetchquery.next(); if(fetchquery.isValid()) { QMessageBox::information(0,"Input Data Error","This room can't be edited.Reservation in progress"); } else { query = sqlMechanism.myQuery(); query.prepare("update Rooms SET RoomFloor= :rFloor, Capacity= :capacity WHERE RoomNumber=:rNum"); query.bindValue(":rNum",room.getRoomNumber()); query.bindValue(":rFloor",room.getRoomFloor()); query.bindValue(":capacity",room.getCapacity()); query.exec(); } }
/** *Creates new entry in Room table *@param room is a room class item *@param fetchquery is an sql query *@param query is an sql query */ void RoomManagement::newRoom(Room room) { QSqlQuery fetchquery; fetchquery = sqlMechanism.myQuery(); fetchquery.prepare("SELECT * FROM Rooms WHERE RoomNumber= :rNum"); fetchquery.bindValue(":rNum",room.getRoomNumber()); fetchquery.exec(); while(fetchquery.next()) { QMessageBox::information(0,"Input Data Error","This Number exists"); } if(RoomManagement::checkInData(room)) { QSqlQuery query; query = sqlMechanism.myQuery(); query.prepare("insert into Rooms (RoomNumber,RoomFloor,Capacity,Extras)" "values(:rNum, :rFloor, :capacity, :extras)"); query.bindValue(":rNum",room.getRoomNumber()); query.bindValue(":rFloor",room.getRoomFloor()); query.bindValue(":capacity",room.getCapacity()); query.bindValue(":extras",""); query.exec(); } }
void MainWindow::on_pushButton_clicked() { if("" == ui->FindRoomNumber->text()) { QMessageBox::about(0,Title,NoRoomNumber); ui->FindRoomNumber->setFocus(); } else { Room room; room = RM.fetchRoom(ui->FindRoomNumber->text().toInt()); if(room.getCapacity()!=0) { ui->FindRoomFloor->setText(QString("%1").arg(room.getRoomFloor())); ui->FindRoomCapacity->setText(QString("%1").arg(room.getCapacity())); } else { QMessageBox::about(0,Title,NoRoomNumber); } ui->FindRoomFloor->setFocus(); } }
bool RoomManagement::checkInData(Room room) { int rNum=room.getRoomNumber(); int rFloor=room.getRoomFloor(); int cpct=room.getCapacity(); bool ret=false; if(0==rNum) { QMessageBox::warning(0,"Input Data Error","Check the Room Number"); ret = false; } else { ret = true; } if(0==rFloor) { QMessageBox::warning(0,"Input Data Error","Check the Room Floor"); ret = false; } else { ret = true; } if(0 == cpct) { QMessageBox::warning(0,"Input Data Error","Check the Capacity"); ret = false; } else{ ret= true; } return ret; }