/**
         * Adds a room to the provided practice.
         */
        private void addRoomToPractice(DentalPractice practice)
        {
            TreatmentRoom newTreatmentRoom;
            int           roomNo;

            try
            {
                roomNo = practice.getRooms().Count + 1;                         //Adds +1 to current room no.

                newTreatmentRoom = new TreatmentRoom(roomNo, practice, "", ""); //"", "" are for the dentist & nurse
                manageRoom(newTreatmentRoom);                                   //Runs manageRoom to set up new treatment room
                practice.getRooms().Add(newTreatmentRoom);                      //Adds the treatment room to practice.
                DataIO.saveAllRooms(practice);                                  //writes to file
            }
            catch (Exception e)
            {
                GeneralFunctions.errorHandler(e);
            }
        }
Esempio n. 2
0
        /**
         * Views a practice
         */
        public static void viewPractice(DentalPractice practice)
        {
            List <TreatmentRoom> rooms = practice.getRooms(); //geta all rooms at practice

            try
            {
                Console.Clear();
                Console.WriteLine(practice.getLocation());              //writes the name of specific pratice
                Console.WriteLine($"Address: {practice.getAddress()}"); //writes the address of the practice

                Console.Write("Receptionist: ");
                if (practice.getReceptionist() is Receptionist)              //Checks if receptionist is assigned
                {
                    Console.WriteLine(practice.getReceptionist().getName()); //writes the name of receptionist
                }
                else
                {
                    Console.WriteLine("Unassigned"); //if not
                }

                Console.WriteLine("\nRooms\n=====");

                for (int i = 0; i < rooms.Count; i++)    //iterates over room no.
                {
                    Console.WriteLine($"Room {i + 1}:"); //writes room no. adding +1 to index so more human friendly

                    Console.Write("Dentist: ");
                    if (rooms[i].getDentist() is DentistNurse)              //checks if dentist is assigned
                    {
                        Console.WriteLine(rooms[i].getDentist().getName()); //gets the assigned name of the dentist
                    }
                    else
                    {
                        Console.WriteLine("Unassigned");
                    }

                    Console.Write("Nurse: ");
                    if (rooms[i].getNurse() is DentistNurse)              //checks if nurse is assigned
                    {
                        Console.WriteLine(rooms[i].getNurse().getName()); //writes the name of the assigned nurse.
                    }
                    else
                    {
                        Console.WriteLine("Unassigned");
                    }
                }
                Console.ReadLine();
                Console.Clear();
            }
            catch (Exception e)
            {
                GeneralFunctions.errorHandler(e);
            }
        }
Esempio n. 3
0
        /**
         * Prints rooms in a given practice.
         */
        public static void printRoomsAtPractice(DentalPractice practice)
        {
            List <TreatmentRoom> rooms = practice.getRooms();

            try
            {
                for (int i = 0; i < rooms.Count; i++)                         //iterates over room no.
                {
                    Console.WriteLine("Room: {0}", rooms[i].getRoomNumber()); //Writes rooms
                }
            }
            catch (Exception e)
            {
                GeneralFunctions.errorHandler(e);
            }
        }
        /**
         * Reorgasnises the rooms. Usually occurs following the removal of a room.
         */
        private void restructureRooms(DentalPractice practice)
        {
            List <TreatmentRoom> rooms = practice.getRooms();

            try
            {
                for (int i = 0; i < rooms.Count; i++)
                {
                    rooms[i].setRoomNumber(i + 1); //Sets the room number, and converts indext to a more human friendly number (room 1 = 1 instead 0)
                }
                DataIO.saveAllRooms(practice);     //Saves all rooms to files
            }
            catch (Exception e)
            {
                GeneralFunctions.errorHandler(e);
            }
        }