예제 #1
0
파일: Menu.cs 프로젝트: AdreN167/ADONETExam
        public void MainMenu()
        {
            var isEnd = false;

            Console.Write("Введите ваше полное имя (И.В.Петров): ");
            var fullName = Console.ReadLine();

            Console.Write("Введите вашу дату рождения (2020-12-31): ");
            var birthDate = DateTime.Parse(Console.ReadLine());

            _patient = new Patient
            {
                FullName  = fullName,
                BirthDate = birthDate
            };

            if (_patientDataAccess.Select().Where(patient => patient.FullName == fullName && patient.BirthDate == birthDate).ToList().Count == 0)
            {
                _patientDataAccess.Insert(_patient);
            }

            while (!isEnd)
            {
                Console.Clear();

                ShowMenu("-------------Главное меню------------", "Посмотреть свои записи", "Записаться на прием", "Закрыть");
                Console.Write("Ваш выбор: ");

                if (!int.TryParse(Console.ReadLine(), out int choice))
                {
                    ThrowError("Некорректный ввод!");
                }

                switch (choice)
                {
                case 1:
                    ShowOwnAppointments();
                    break;

                case 2:
                    ShowDoctors();
                    break;

                case 3:
                    isEnd = true;
                    break;

                default:
                    ThrowError("Такого пункта нет!");
                    break;
                }
            }
        }
예제 #2
0
파일: Menu.cs 프로젝트: IgorPolivni/DamuMed
        public void RegistrationMenu()
        {
            Patient newPatient = new Patient();
            var     isEnd      = false;

            while (!isEnd)
            {
                Console.Clear();
                Console.WriteLine("----------Меню регистрации----------");
                var patient = MenuGetPatientInfo();

                if (patient["name"].Length == 0 || patient["IIN"].Length == 0)
                {
                    Console.WriteLine("Вы ввели неправильно количество символов!");
                    Console.ReadLine();
                    isEnd = true;
                }

                else
                {
                    newPatient.Name = patient["name"];
                    newPatient.IIN  = patient["IIN"];

                    var patients = _patientDataAccess.SelectBy(newPatient.Name, newPatient.IIN);
                    if (patients.Count == 0)
                    {
                        _patientDataAccess.Insert(newPatient);
                        isEnd = true;
                    }
                    else
                    {
                        Console.WriteLine("Пользователь с такими данными уже существует!");
                        Console.ReadLine();
                        isEnd = true;
                    }
                }
            }
        }
예제 #3
0
        static void Main(string[] args)
        {
            ConfigurationService.Init();
            ICollection <Doctor>       doctors;
            ICollection <VisitHistory> visitTime;

            using (var doctorDataAccess = new DoctorDataAccess())
            {
                doctors = doctorDataAccess.Select();
            }
            Console.WriteLine(@"                                *********************************************
                                *			                    *
                                *			                    *
                                *       Welcome to the Hospital System!     *
                                *			                    *
                                *			                    *
                                *********************************************");
            var patient = new Patient();

            while (true)
            {
                Console.Write("Enter your Full name:\n");
                using (var patientDataAccess = new PatientDataAccess())
                {
                    patient.FullName = Console.ReadLine();
                    patientDataAccess.Insert(patient);
                    visitTime = patientDataAccess.SelectVisitTime();
                }
                Console.Clear();

                Console.Write("\n1. Sign up for an appointment\n\n0. Exit\nChoose: ");
                switch (Console.ReadLine())
                {
                case "1":
                    Console.Write("Choose doctor's direction: \n");
                    var direction = Console.ReadLine();
                    foreach (var doctor in doctors)
                    {
                        if (doctor.Direction.Name.Contains(direction))
                        {
                            using (var patientDataAccess = new PatientDataAccess())
                            {
                                foreach (var date in visitTime)
                                {
                                    if (date.DoctorId == doctor.Id && date.VisitDate.Hour <= DateTime.Now.Hour)
                                    {
                                        doctor.IsFree = true;
                                    }
                                }
                                if (doctor.Schedule.StartTime.Hour >= DateTime.Now.Hour &&
                                    (doctor.Schedule.EndTime.Hour - 1) <= DateTime.Now.Hour &&
                                    doctor.IsFree == true)
                                {
                                    patientDataAccess.InsertHistory(doctor, patient);
                                }
                            }
                        }
                    }
                    break;

                case "0":
                    return;
                }
            }
        }