示例#1
0
 public static void ImportExams()
 {
     using (var context = new HospitalAppEntities())
     {
         var exam = new Exam()
         {
             ExamDate  = new DateTime(2012, 02, 02),
             RoomId    = 2,
             PatientId = 1,
             DiseaseId = 3,
             DoctorId  = 1
         };
         var exam2 = new Exam()
         {
             ExamDate  = new DateTime(2012, 02, 02),
             RoomId    = 4,
             PatientId = 3,
             DiseaseId = 1,
             DoctorId  = 1
         };
         var exam3 = new Exam()
         {
             ExamDate  = new DateTime(2012, 02, 02),
             RoomId    = 6,
             PatientId = 2,
             DiseaseId = 1,
             DoctorId  = 2
         };
         context.Exams.Add(exam);
         context.Exams.Add(exam2);
         context.Exams.Add(exam3);
         Console.WriteLine("Succesfuly added new exam");
         context.SaveChanges();
     }
 }
示例#2
0
        private void yes_click(object sender, RoutedEventArgs e)
        {
            using (var context = new HospitalAppEntities())

            {
                var id1      = Convert.ToInt32(this.id.Text);
                var ida      = context.Patients.Where(x => x.Id == id1).FirstOrDefault();
                var fullname =
                    context.Patients.Where(x => x.Id == id1)
                    .Select(x => new { FullName = x.FirstName + " " + " " + x.LastName })
                    .FirstOrDefault();
                context.Patients.Remove(ida);
                context.SaveChanges();

                id.Visibility             = Visibility.Visible;
                label.Visibility          = Visibility.Visible;
                label_delete.Visibility   = Visibility.Visible;
                Yes.Visibility            = Visibility.Hidden;
                No.Visibility             = Visibility.Hidden;
                button.Visibility         = Visibility.Visible;
                Yes.Visibility            = Visibility.Hidden;
                No.Visibility             = Visibility.Hidden;
                _delete.Visibility        = Visibility.Hidden;
                deletedmessage.Visibility = Visibility.Visible;
                deletedmessage.Content    = $"{fullname.FullName} removed";
            }
        }
示例#3
0
        private async void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            Global.password          = passBxPassword.Password;
            lblfrgtPass.Visibility   = Visibility.Hidden;
            Mouse.OverrideCursor     = Cursors.Wait;
            passBxPassword.IsEnabled = false;
            btnLogin.IsEnabled       = false;
            using (var context = new HospitalAppEntities())
            {
                var pass = context.Doctors
                           .Select(p => p.Password)
                           .ToList();

                foreach (var pas in pass)
                {
                    if (Global.password == pas)
                    {
                        loadingGif.Visibility = Visibility.Visible;
                        await Task.Delay(3000);

                        Home home = new Home();
                        home.Show();
                        Close();
                        Mouse.OverrideCursor = Cursors.Arrow;
                    }
                }

                lblfrgtPass.Visibility     = Visibility.Visible;
                lblfrgtPass.Content        = "Forgot Password ?";
                passBxPassword.IsEnabled   = true;
                passBxPassword.BorderBrush = Brushes.Red;
                btnLogin.IsEnabled         = true;
                Mouse.OverrideCursor       = null;
            }
        }
示例#4
0
        public newRehabilitation()
        {
            InitializeComponent();

            var context = new HospitalAppEntities();

            var rehabilitations = context.Rehabilitations.ToList();

            this.DataContext = rehabilitations;
        }
示例#5
0
        public NewSurgery()
        {
            InitializeComponent();

            var context = new HospitalAppEntities();

            var sugery = context.Surgeries.ToList();

            this.DataContext = sugery;
        }
示例#6
0
        public Patients()
        {
            InitializeComponent();

            var context = new HospitalAppEntities();

            var patians = context.Patients.ToList();

            this.DataContext = patians;
            //xmlns:data="clr-namespace:Models;assembly=Models"
            // xmlns:local="clr-namespace:Hospital.App.Pages"
        }
示例#7
0
 public static void AddRooms(IEnumerable <RoomDto> rooms)
 {
     using (var context = new HospitalAppEntities())
     {
         foreach (var room in rooms)
         {
             context.Rooms.Add(new Room {
                 Number = room.Number
             });
             Console.WriteLine($"Imported room { room.Number}!");
         }
         context.SaveChanges();
     }
 }
示例#8
0
 public static void ImportSurgery()
 {
     using (var context = new HospitalAppEntities())
     {
         var surgery = new Surgery()
         {
             SurgeryDate = new DateTime(2011, 03, 06),
             RoomId      = 11,
             PatientId   = 1,
             DiseaseId   = 2,
             DoctorId    = 3
         };
         context.Surgeries.Add(surgery);
         Console.WriteLine("Succesfuly added new surgery");
         context.SaveChanges();
     }
 }
 public static void ImportRehabilitation()
 {
     using (var context = new HospitalAppEntities())
     {
         var rehabilitation = new Rehabilitation()
         {
             RehabilitationStartDate = new DateTime(2012, 02, 03),
             RehabilitationEndDate   = new DateTime(2012, 03, 04),
             RoomId    = 10,
             PatientId = 3,
             DiseaseId = 1,
             DoctorId  = 2
         };
         context.Rehabilitations.Add(rehabilitation);
         Console.WriteLine("Succesfuly added new rehabilitation");
         context.SaveChanges();
     }
 }
示例#10
0
        public static void AddDiseases(IEnumerable <DiseaseDto> diseases)
        {
            using (var context = new HospitalAppEntities())
            {
                foreach (var disease in diseases)
                {
                    context.Diseases.Add(new Disease
                    {
                        Name        = disease.Name,
                        Description = disease.Description,
                        Complexity  = disease.Complexity
                    });

                    Console.WriteLine($"Added new disease : {disease.Name}");
                }
                context.SaveChanges();
            }
        }
示例#11
0
        public myPatients()
        {
            InitializeComponent();
            using (var context = new HospitalAppEntities())
            {
                var doc = context.Doctors
                          .Where(x => x.Password == Global.password)
                          .Select(d => d.Id)
                          .FirstOrDefault();
                var patientsFromExam = context.Exams
                                       .Where(d => d.DoctorId == doc)
                                       .Select(x => x.PatientId)
                                       .FirstOrDefault();
                var patients = context.Patients
                               .Where(p => p.Id == patientsFromExam).ToList();

                this.DataContext = patients;
            }
        }
示例#12
0
 public static void AddPatients(IEnumerable <PatientDto> patients)
 {
     using (var context = new HospitalAppEntities())
     {
         foreach (var patient in patients)
         {
             context.Patients.Add(new Patient
             {
                 FirstName   = patient.FirstName,
                 LastName    = patient.LastName,
                 Gender      = patient.Gender,
                 BirthDay    = patient.BirthDay,
                 Address     = patient.Address,
                 PhoneNumber = patient.PhoneNumber
             });
             Console.WriteLine($"Added new patient :{patient.FirstName} {patient.LastName}");
         }
         context.SaveChanges();
     }
 }
示例#13
0
        private void delete_check_click(object sender, RoutedEventArgs e)
        {
            using (var context = new HospitalAppEntities())
            {
                var id1      = Convert.ToInt32(id.Text);
                var fullname =
                    context.Patients.Where(x => x.Id == id1)
                    .Select(x => new { FullName = x.FirstName + " " + " " + x.LastName })
                    .FirstOrDefault();
                _delete.Visibility = Visibility.Visible;
                _delete.Content    = $"Are you sure you want to remove {fullname.FullName}";

                id.Visibility             = Visibility.Hidden;
                button.Visibility         = Visibility.Hidden;
                label.Visibility          = Visibility.Hidden;
                label_delete.Visibility   = Visibility.Hidden;
                Yes.Visibility            = Visibility.Visible;
                No.Visibility             = Visibility.Visible;
                deletedmessage.Visibility = Visibility.Hidden;
            }
        }
示例#14
0
        public static void AddDoctors(IEnumerable <DoctorDto> doctors)
        {
            using (var context = new HospitalAppEntities())
            {
                foreach (var doctor in doctors)
                {
                    context.Doctors.Add(new Doctor {
                        FirstName = doctor.FirstName,
                        LastName  = doctor.LastName,
                        Gender    = doctor.Gender,
                        HireDate  = doctor.HireDate,
                        Salary    = doctor.Salary,
                        Specialty = doctor.Specialty,
                        Password  = doctor.Password
                    });
                    Console.WriteLine($"Added {doctor.FirstName} {doctor.LastName} in table Doctors!");
                }


                context.SaveChanges();
            }
        }
示例#15
0
        public MyInfo()
        {
            InitializeComponent();
            using (var context = new HospitalAppEntities())
            {
                var firstName = context.Doctors.
                                Where(p => p.Password == Global.password)
                                .Select(f => f.FirstName).First().ToString();

                var lastName = context.Doctors.
                               Where(p => p.Password == Global.password)
                               .Select(f => f.LastName).First().ToString();

                var gender = context.Doctors.
                             Where(p => p.Password == Global.password)
                             .Select(f => f.Gender).First().ToUpper();

                var birthday = context.Doctors.
                               Where(p => p.Password == Global.password)
                               .Select(f => f.HireDate).First().ToString();

                var salary = context.Doctors.
                             Where(p => p.Password == Global.password)
                             .Select(f => f.Salary).First().ToString();

                var speciality = context.Doctors.
                                 Where(p => p.Password == Global.password)
                                 .Select(f => f.Specialty).First().ToString();


                FirstName.Text  = firstName;
                LastName.Text   = lastName;
                Gender.Text     = gender;
                Birthdate.Text  = birthday;
                Salary.Text     = salary;
                Speciality.Text = speciality;
            }
        }
示例#16
0
 private void newSurgery_Save_click(object sender, RoutedEventArgs e)
 {
     using (var context = new HospitalAppEntities())
     {
         var surgery = new Surgery();
         surgery.SurgeryDate = Convert.ToDateTime(SurgeryDate.Text);
         surgery.RoomId      = Convert.ToInt32(RoomId.Text);
         surgery.PatientId   = Convert.ToInt32(PatientId.Text);
         surgery.DiseaseId   = Convert.ToInt32(DiseaseId.Text);
         surgery.DoctorId    = Convert.ToInt32(DoctorId.Text);
         if (surgery.RoomId == 0 || surgery.PatientId == 0 || surgery.DiseaseId == 0 || surgery.DoctorId == 0)
         {
             MessageBox.Show("Error: Check if there is any missing proparties or 0 values of Ids");
         }
         else
         {
             context.Surgeries.Add(surgery);
             added.Content    = $"Surgeries added successfully!";
             added.Visibility = Visibility.Visible;
             context.SaveChanges();
         }
     }
 }
示例#17
0
 private void newPatient_Save_click(object sender, RoutedEventArgs e)
 {
     using (var context = new HospitalAppEntities())
     {
         var patient = new Patient();
         patient.FirstName   = FirstName.Text;
         patient.LastName    = LastName.Text;
         patient.Address     = Address.Text;
         patient.PhoneNumber = PhoneNumber.Text;
         patient.Gender      = Gender.Text;
         if (patient.FirstName == string.Empty || patient.LastName == string.Empty || patient.Address == string.Empty || patient.PhoneNumber == string.Empty || patient.Gender == string.Empty)
         {
             MessageBox.Show("Error: Check if there is any missing proparties");
         }
         else
         {
             context.Patients.Add(patient);
             added.Content    = $"Patient {patient.FirstName} {patient.LastName} added !";
             added.Visibility = Visibility.Visible;
             context.SaveChanges();
         }
     }
 }
示例#18
0
 private void newRehabilitation_Save_click(object sender, RoutedEventArgs e)
 {
     using (var context = new HospitalAppEntities())
     {
         var rehabilitation = new Rehabilitation();
         rehabilitation.RehabilitationStartDate = Convert.ToDateTime(RehabilitationStartDate.Text);
         rehabilitation.RehabilitationEndDate   = Convert.ToDateTime(RehabilitationEndDate.Text);
         rehabilitation.RoomId    = Convert.ToInt32(RoomId.Text);
         rehabilitation.PatientId = Convert.ToInt32(PatientId.Text);
         rehabilitation.DiseaseId = Convert.ToInt32(DiseaseId.Text);
         rehabilitation.DoctorId  = Convert.ToInt32(DoctorId.Text);
         if (rehabilitation.RoomId == 0 || rehabilitation.PatientId == 0 || rehabilitation.DiseaseId == 0 || rehabilitation.DoctorId == 0)
         {
             MessageBox.Show("Error: Check if there is any missing proparties or 0 values of Ids");
         }
         else
         {
             context.Rehabilitations.Add(rehabilitation);
             added.Content    = $"Rehabilitation added successfully!";
             added.Visibility = Visibility.Visible;
             context.SaveChanges();
         }
     }
 }
示例#19
0
        public static void InitDb()
        {
            var context = new HospitalAppEntities();

            context.Database.Initialize(true);
        }