// Button 'Check in' in the room section // Validation: Room is not marked as checked in already -> Date for checkin is today -> Room is clean // Checkin procedure: Create new folio or append existing -> Add folio items for room charge -> Mark room as checked in private void buttonCheckinRoom_Click(object sender, EventArgs e) { // Make sure datagridview has selection if (dataGridViewRoom.SelectedRows.Count > 0 && dataGridViewRoom.CurrentRow != null) { // Validation variables Boolean checkedin = false; Boolean checkindate = true; Boolean roomcleared = true; // Roomstatus values: 0 = deny checkin, 1 = warning, 2 = no flag int roomstatus = 2; // Reference variables string adminid = UserInfo.AdminID; int reservationid = Convert.ToInt32(dataGridViewRoom.CurrentRow.Cells[0].Value); int roomid = Convert.ToInt32(dataGridViewRoom.CurrentRow.Cells[3].Value); // Confirm checkin DialogResult confirmCheckin = MessageBox.Show("Checking in roomnumber " + roomid + "\nAre you sure you want to continue?", "Check in", MessageBoxButtons.YesNo); if (confirmCheckin == DialogResult.Yes) { // Check that reservation checkin date is today MySqlDataReader getRoomCheckinDate = DBGetData.GetRoomCheckinDate(reservationid); if (getRoomCheckinDate.Read()) { DateTime date = Convert.ToDateTime(getRoomCheckinDate[0]); if (date != DateTime.Today) { checkindate = false; } if (!checkindate) { new StatusMessage("Room reservation not marked for checkin today."); } } getRoomCheckinDate.Dispose(); // Check that reservation is not already checked in if (DBGetData.GetRoomCheckedin(reservationid) > 0) { checkedin = true; } if (checkedin) { new StatusMessage("Room reservation has already checked in."); } // Check if room is clean MySqlDataReader getHousekeepingCode = DBGetData.GetRoomHousekeeping(roomid); if (getHousekeepingCode.Read()) { int code = Convert.ToInt32(getHousekeepingCode[0]); switch (code) { case 0: roomstatus = 0; new StatusMessage("Room unavailable due to maintainance, " + "please change reservation or upgrade guest."); break; case 1: roomstatus = 1; new StatusMessage("Room needs inspection, " + "please change reservation or send staff immediately."); break; case 2: roomstatus = 1; new StatusMessage("Room needs cleaning, " + "please change reservation or send staff immediately."); break; } } getHousekeepingCode.Dispose(); // Check if room is cleared for checkin switch (roomstatus) { // Deny checkin of a room that is flagged as inactive case 0: roomcleared = false; break; // Option to continue if room has a warning code and other arrangements cant be made case 1: DialogResult continueCheckin = MessageBox.Show( "Room is flagged for cleaning or inspection" + "\nAre you sure you want to continue?", "Warning!", MessageBoxButtons.YesNo); if (continueCheckin == DialogResult.Yes) { roomcleared = true; } else if (continueCheckin == DialogResult.No) { roomcleared = false; } break; // No code on room case 2: roomcleared = true; break; } // Proceed with checkin if (!checkedin && checkindate && roomcleared) { DBSetData.RoomreservationCheckin(reservationid, adminid); DisplayDefaultRoom(); this.Refresh(); new StatusMessage("Room reservation for room " + roomid + " has been flagged as checked in and folio was added."); } } } }