/** * Deletes a treatment room. */ private void deleteRoom(TreatmentRoom room, bool singleRoom) { DentalPractice parentPractice; List <TreatmentRoom> rooms; string roomPath; try { parentPractice = room.getPractice(); //practice that room belongs to roomPath = DataIO.practicePath + "\\" + parentPractice.getLocation() + "\\Rooms\\" + room.getRoomNumber() + ".txt"; //Find the file path to the room, to be deleted File.Delete(roomPath); //Deletes the file rooms = parentPractice.getRooms(); //Gets practice associated to room rooms.Remove(room); //Remove the room from the practice. if (singleRoom) { restructureRooms(parentPractice); //No point running this when all rooms are being removed but just in case. } } catch (Exception e) { GeneralFunctions.errorHandler(e); } }
/** * Shows the interface to manage a room. */ private void manageRoom(TreatmentRoom room) { string response; bool invalidResponse; Staff userToCheck; DentistNurse userToAssign; try { invalidResponse = true; while (invalidResponse) // Prints all staff at practice. { DataPrinting.printStaffAtPractice(room.getPractice()); Console.Write("Dentist to assign: (Enter nothing to skip)"); response = Console.ReadLine(); Console.Clear(); if (response != "") { if (DataSearching.userExists(response)) //Validates the response { userToCheck = (Staff)DataSearching.findUser(response); //Find staff users with the given username response. if (userToCheck is DentistNurse) { userToAssign = (DentistNurse)DataSearching.findUser(response); //Checks wether they are dentist or nurse and find them usign findUser method if (userToAssign.getPractitionerType() != "Dentist") //if not equal to dentist { Console.WriteLine("Selected staff is not dentist."); } else { room.setDentist(userToAssign); // sets the given room to the dentist user. invalidResponse = false; } } else { Console.WriteLine("Selected staff is not dentist."); } } else { Console.WriteLine("user does not exist."); } } else { invalidResponse = false; } } invalidResponse = true; while (invalidResponse) // Selecting the Nurse. works the same as Dentist { DataPrinting.printStaffAtPractice(room.getPractice()); Console.Write("Nurse to assign: (Enter nothing to skip)"); response = Console.ReadLine(); Console.Clear(); if (response != "") { if (DataSearching.userExists(response)) { userToCheck = (Staff)DataSearching.findUser(response); if (userToCheck is DentistNurse) { userToAssign = (DentistNurse)DataSearching.findUser(response); if (userToAssign.getPractitionerType() != "Nurse") { Console.WriteLine("Selected staff is not nurse."); } else { room.setNurse(userToAssign); invalidResponse = false; } } else { Console.WriteLine("Selected staff is not nurse."); } } else { Console.WriteLine("user does not exist."); } } else { invalidResponse = false; } } } catch (Exception e) { GeneralFunctions.errorHandler(e); } }