Beispiel #1
0
        private void UpdateRecord()
        {
            string        header = "UPDATING RECORD\n" + breaker;
            int           id;
            PatientRecord h = null;

            while (true)
            {
                Console.ForegroundColor = ConsoleColor.White;
                Console.Clear();
                Console.WriteLine(header);
                controller.ViewRecord();
                Console.Write("Please choose a record by entering it's ID: ");
                try
                {
                    id = Convert.ToInt32(Console.ReadLine());
                }
                catch (Exception)
                {
                    controller.ErrorMsg("Invalid ID. ID should be integer only");
                    continue;
                }
                if ((h = controller.findRecord(id)) == null)
                {
                    controller.ErrorMsg("This record id does not exist");
                    continue;
                }
                break;
            }
            if (h == null)
            {
                return;
            }
            header += "\n" + h.ToString();
            int choice = 0;

            while (true)
            {
                Console.ForegroundColor = ConsoleColor.White;
                Console.Clear();
                Console.WriteLine(header);
                Console.WriteLine(editHospital);
                Console.Write("Please choose an option: ");
                try
                {
                    choice = Convert.ToInt32(Console.ReadLine());
                }
                catch (Exception)
                {
                    controller.ErrorMsg("Invalid Input");
                    continue;
                }
                if (choice != 1)
                {
                    controller.ErrorMsg("Invalid Input");
                    continue;
                }
                break;
            }
            switch (choice)
            {
            case 1: Console.Write("Enter new diagnosis:");
                string diagnosis = Console.ReadLine();
                if (controller.DiagnosisChecker(diagnosis))
                {
                    h.Diagnosis = diagnosis;
                    Console.WriteLine("Diagnosis edited to " + h.Diagnosis);
                }
                break;
            }
        }