Esempio n. 1
0
        private static void AddPhysicianRecord()
        {
            try
            {
                Console.Clear();
                HospitalMenuHeader();
                Console.WriteLine("|              Add Physician Form                   |");
                Console.WriteLine("=====================================================");

                Physician physician = new Physician();
                physician.ContactInfo    = new ContactInfo();
                physician.Specialization = new List <Specialization>();

                Specialization specialization = new Specialization();

                if (physicians.Count > 0)
                {
                    physician.Id = physicians.Last().Id + 1;
                }
                else
                {
                    physician.Id = 1;
                }

                Console.WriteLine("|              Personal Information                 |");
                Console.WriteLine("-----------------------------------------------------");
                physician.FirstName = HospitalFormField("First Name ", "", false);
                while (!allowLettersOnly(physician.FirstName))
                {
                    physician.FirstName = HospitalFormField("First Name ", "", false);
                }
                physician.MiddleName = HospitalFormField("Middle Name ", "", false);
                while (!allowLettersOnly(physician.MiddleName))
                {
                    physician.MiddleName = HospitalFormField("Middle Name ", "", false);
                }
                physician.LastName = HospitalFormField("Last Name ", "", false);
                while (!allowLettersOnly(physician.LastName))
                {
                    physician.LastName = HospitalFormField("Last Name ", "", false);
                }
                physician.BirthDate = HospitalFormDateTimeField("Birthdate ", default(DateTime), false);
                physician.Gender    = HospitalFormField("Gender ", "", false);
                while (!allowLettersOnly(physician.Gender))
                {
                    physician.Gender = HospitalFormField("Gender ", "", false);
                }
                physician.Weight = HospitalFormDecimalField("Weight ", 0.00, false);
                physician.Height = HospitalFormDecimalField("Height ", 0.00, false);
                Console.WriteLine("-----------------------------------------------------");
                Console.WriteLine("|              Contact Information                  |");
                Console.WriteLine("-----------------------------------------------------");
                physician.ContactInfo.HomeAddress = HospitalFormField("Home Address ", "", false);
                physician.ContactInfo.HomePhone   = HospitalFormField("Home Phone ", "", false);
                while (!allowNumbersOnly(physician.ContactInfo.HomePhone, false))
                {
                    physician.ContactInfo.HomePhone = HospitalFormField("Home Phone ", "", false);
                }
                physician.ContactInfo.OfficeAddress = HospitalFormField("Office Address ", "", false);
                physician.ContactInfo.OfficePhone   = HospitalFormField("Office Phone ", "", false);
                while (!allowNumbersOnly(physician.ContactInfo.OfficePhone, false))
                {
                    physician.ContactInfo.OfficePhone = HospitalFormField("Office Phone ", "", false);
                }
                physician.ContactInfo.EmailAddress    = HospitalFormField("E-mail Address ", "", false);
                physician.ContactInfo.CellphoneNumber = HospitalFormField("Cellphone Number ", "", false);
                while (!allowNumbersOnly(physician.ContactInfo.CellphoneNumber, false))
                {
                    physician.ContactInfo.CellphoneNumber = HospitalFormField("Cellphone Number ", "", false);
                }
                Console.WriteLine("-----------------------------------------------------");
                Console.WriteLine("|              Specializations                      |");
                Console.WriteLine("-----------------------------------------------------");
                Console.Write("How many specializations? ");
                int specializationCount = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("");
                for (int i = 0; i < specializationCount; i++)
                {
                    specialization         = new Specialization();
                    specialization.Name    = HospitalFormField("Name ", "", false);
                    specialization.Remarks = HospitalFormField("Remarks ", "", false);
                    Console.WriteLine();
                    physician.Specialization.Add(specialization);
                }

                physicians.Add(physician);
                HospitalMenu();
            }
            catch (Exception e)
            {
                defaultError();
                goBackToMainMenu();
            }
        }
Esempio n. 2
0
        private static void UpdatePhysicianRecordById()
        {
            try
            {
                Console.Clear();
                HospitalMenuHeader();
                Console.Write("Please enter employee ID to update records : ");
                int id = Convert.ToInt32(Console.ReadLine());

                List <Physician> physicianRecords = new List <Physician>();
                physicianRecords = physicians.Where(x => x.Id == id).ToList();
                Physician newPhysicianRecord = new Physician();

                if (physicianRecords.Count > 0)
                {
                    foreach (var physician in physicianRecords)
                    {
                        Console.WriteLine("-----------------------------------------------------");
                        Console.WriteLine("                Personal Information                 ");
                        newPhysicianRecord.Id        = physician.Id;
                        newPhysicianRecord.FirstName = HospitalFormField("First Name ", physician.FirstName, true);
                        while (!allowLettersOnly(newPhysicianRecord.FirstName))
                        {
                            newPhysicianRecord.FirstName = HospitalFormField("First Name ", physician.FirstName, true);
                        }
                        newPhysicianRecord.MiddleName = HospitalFormField("Middle Name ", physician.MiddleName, true);
                        while (!allowLettersOnly(newPhysicianRecord.MiddleName))
                        {
                            newPhysicianRecord.MiddleName = HospitalFormField("Middle Name ", physician.MiddleName, true);
                        }
                        newPhysicianRecord.LastName = HospitalFormField("Last Name ", physician.LastName, true);
                        while (!allowLettersOnly(newPhysicianRecord.LastName))
                        {
                            newPhysicianRecord.LastName = HospitalFormField("Last Name ", physician.LastName, true);
                        }
                        newPhysicianRecord.BirthDate = HospitalFormDateTimeField("Birthdate ", physician.BirthDate, true);
                        newPhysicianRecord.Gender    = HospitalFormField("Gender ", physician.Gender, true);
                        while (!allowLettersOnly(newPhysicianRecord.Gender))
                        {
                            newPhysicianRecord.Gender = HospitalFormField("Gender ", physician.Gender, true);
                        }
                        newPhysicianRecord.Weight = HospitalFormDecimalField("Weight ", physician.Weight, true);
                        newPhysicianRecord.Height = HospitalFormDecimalField("Height ", physician.Height, true);
                        Console.WriteLine("                Contact Information                  ");
                        newPhysicianRecord.ContactInfo             = new ContactInfo();
                        newPhysicianRecord.ContactInfo.HomeAddress = HospitalFormField("Home Address ", physician.ContactInfo.HomeAddress, true);
                        newPhysicianRecord.ContactInfo.HomePhone   = HospitalFormField("Home Phone ", physician.ContactInfo.HomePhone, true);
                        while (!allowNumbersOnly(newPhysicianRecord.ContactInfo.HomePhone, false))
                        {
                            newPhysicianRecord.ContactInfo.HomePhone = HospitalFormField("Home Phone ", physician.ContactInfo.HomePhone, true);
                        }
                        newPhysicianRecord.ContactInfo.OfficeAddress = HospitalFormField("Office Address ", physician.ContactInfo.OfficeAddress, true);
                        newPhysicianRecord.ContactInfo.OfficePhone   = HospitalFormField("Office Phone ", physician.ContactInfo.OfficePhone, true);
                        while (!allowNumbersOnly(newPhysicianRecord.ContactInfo.OfficePhone, false))
                        {
                            newPhysicianRecord.ContactInfo.OfficePhone = HospitalFormField("Office Phone ", physician.ContactInfo.OfficePhone, true);
                        }
                        newPhysicianRecord.ContactInfo.EmailAddress    = HospitalFormField("E-mail Address ", physician.ContactInfo.EmailAddress, true);
                        newPhysicianRecord.ContactInfo.CellphoneNumber = HospitalFormField("Cellphone Number ", physician.ContactInfo.CellphoneNumber, true);
                        while (!allowNumbersOnly(newPhysicianRecord.ContactInfo.CellphoneNumber, false))
                        {
                            newPhysicianRecord.ContactInfo.CellphoneNumber = HospitalFormField("Cellphone Number ", physician.ContactInfo.CellphoneNumber, true);
                        }

                        Specialization newSpecializationRecord = new Specialization();
                        newPhysicianRecord.Specialization = new List <Specialization>();

                        Console.WriteLine("                Specializations                      ");
                        foreach (var specialization in physician.Specialization)
                        {
                            newSpecializationRecord         = new Specialization();
                            newSpecializationRecord.Name    = HospitalFormField("Name ", specialization.Name, true);
                            newSpecializationRecord.Remarks = HospitalFormField("Remarks ", specialization.Remarks, true);
                            newPhysicianRecord.Specialization.Add(newSpecializationRecord);
                        }

                        Console.Write("Are you sure you want to update employee records (Yes/No)? ");
                        var response = Console.ReadLine();
                        if (response.Trim().Equals("Yes", StringComparison.InvariantCultureIgnoreCase))
                        {
                            var  prevRecordToBeDeleted = physicians.Single(r => r.Id == id);
                            bool result = physicians.Remove(prevRecordToBeDeleted);

                            if (result)
                            {
                                physicians.Add(newPhysicianRecord);
                            }
                            Console.ForegroundColor = ConsoleColor.Green;
                            Console.WriteLine("Employee records successfully updated.");
                            Console.ResetColor();
                        }
                        else if (response.Trim().Equals("No", StringComparison.InvariantCultureIgnoreCase))
                        {
                            Console.ForegroundColor = ConsoleColor.Blue;
                            Console.WriteLine("Employee records not updated.");
                            Console.ResetColor();
                        }
                        else
                        {
                            Console.ForegroundColor = ConsoleColor.DarkRed;
                            Console.WriteLine("Invalid input, record not updated.");
                            Console.ResetColor();
                        }
                        Console.WriteLine("-----------------------------------------------------");
                    }
                }
                else
                {
                    Console.WriteLine("|             No Available Records                  |");
                }
                HospitalMenuFooter();
            }
            catch (Exception)
            {
                defaultError();
                goBackToMainMenu();
            }
        }