// Delete Patient record in database
        private void btnDeletePatient_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult msgBoxResult = MessageBox.Show("Are you sure you want to delete?",
                                                            "Delete Patient",
                                                            MessageBoxButton.YesNo,
                                                            MessageBoxImage.Warning,
                                                            MessageBoxResult.No
                                                            );

            if (msgBoxResult == MessageBoxResult.Yes)
            {
                HospitalManagementDBEntities db = new HospitalManagementDBEntities();

                var r = from d in db.Patient
                        where d.Id == this.updatingPatientId
                        select d;

                Patient obj = r.SingleOrDefault();

                if (obj != null)
                {
                    db.Patient.Remove(obj);
                    db.SaveChanges();
                }
            }
        }
        public MainWindow()
        {
            InitializeComponent();

            HospitalManagementDBEntities db = new HospitalManagementDBEntities();

            var docs = from d in db.Doctor
                       select new
            {
                DoctorName = d.Name,
                Speciality = d.Specialization,
            };

            this.gridDoctors.ItemsSource = docs.ToList();

            var patient = from d in db.Patient
                          select new
            {
                Name        = d.FirstName,
                Surname     = d.SecondName,
                PhoneNumber = d.PhoneNumber,
                Address     = d.Address,
                Age         = d.Age
            };

            this.PatientGrid.ItemsSource = patient.ToList();
        }
示例#3
0
        public AppointmentsWindow()
        {
            InitializeComponent();

            HospitalManagementDBEntities db = new HospitalManagementDBEntities();

            //Inner join
            var result = from a in db.Appointment
                         select new
            {
                a.DoctorID,
                a.Doctor.Name,
                a.Doctor.Specialization,
                a.PatientID,
                a.Patient.FirstName,
                a.Patient.SecondName,
                a.Patient.PhoneNumber,
                a.AppointmentDate
            };

            //Outer join
            var resultOuterDoctor = from d in db.Doctor
                                    from a in db.Appointment.DefaultIfEmpty()
                                    select new
            {
                d.Name,
                a.Id,
                a.AppointmentDate,
                Patient = a.Patient.FirstName
            };

            this.gridAppointments.ItemsSource = resultOuterDoctor.ToList();
        }
        // Add a new diagnosed disease
        private void btnAddDisease_Click(object sender, RoutedEventArgs e)
        {
            HospitalManagementDBEntities db = new HospitalManagementDBEntities();

            Diagnosis diagnosis = new Diagnosis()
            {
                DiseaseName   = txtNameDisease.Text,
                DiseaseCode   = txtCodeDisease.Text,
                DiagnosisDate = DateTime.Parse(txtDiagnosisDate.Text),
                Medicines     = txtMedicines.Text
            };

            db.Diagnosis.Add(diagnosis);
            db.SaveChanges();
        }
        // Add - do the insertion operation
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            HospitalManagementDBEntities db = new HospitalManagementDBEntities();

            Doctor doctorObject = new Doctor()
            {
                Name           = txtName.Text,
                Qualification  = txtQualification.Text,
                Specialization = txtSpecialization.Text,
                Age            = int.Parse(txtAge.Text)
            };

            db.Doctor.Add(doctorObject);
            db.SaveChanges();
        }
        // Patient ///////////////////////////////////////////


        // Add Patient to the database - do the insertion operation
        private void btnAddPatient_Click(object sender, RoutedEventArgs e)
        {
            HospitalManagementDBEntities db = new HospitalManagementDBEntities();

            Patient patientObject = new Patient()
            {
                FirstName   = txtPatientName.Text,
                SecondName  = txtPatientSurname.Text,
                PhoneNumber = txtPatientPhone.Text,
                Address     = txtPatientAddress.Text,
                Age         = int.Parse(txtPatientAge.Text)
            };

            db.Patient.Add(patientObject);
            db.SaveChanges();
        }
        public SubWindow()
        {
            InitializeComponent();

            HospitalManagementDBEntities db = new HospitalManagementDBEntities();

            var diagnosis = from d in db.Diagnosis
                            select new
            {
                Patient_ID        = d.Id,
                Disease_Name      = d.DiseaseName,
                Disease_Code      = d.DiseaseCode,
                Date_Of_Diagnosis = d.DiagnosisDate,
                Patient_Medicines = d.Medicines
            };

            this.gridDiagnosis.ItemsSource = diagnosis.ToList();
        }
        // Update the record
        private void btnUpdateDoctor_Click(object sender, RoutedEventArgs e)
        {
            HospitalManagementDBEntities db = new HospitalManagementDBEntities();

            var r = from d in db.Doctor
                    where d.Id == this.updatingDoctorId
                    select d;

            Doctor obj = r.SingleOrDefault();

            if (obj != null)
            {
                obj.Name           = this.txtName2.Text;
                obj.Specialization = this.txtSpecialization2.Text;
                obj.Qualification  = this.txtQualification2.Text;
                obj.Age            = int.Parse(this.txtAge2.Text);

                db.SaveChanges();
            }
        }
        private void btnUpdatePatient_Click(object sender, RoutedEventArgs e)
        {
            HospitalManagementDBEntities db = new HospitalManagementDBEntities();

            var r = from d in db.Patient
                    where d.Id == this.updatingPatientId
                    select d;

            Patient obj = r.SingleOrDefault();

            if (obj != null)
            {
                obj.FirstName   = this.txtPatientName2.Text;
                obj.SecondName  = this.txtPatientSurname2.Text;
                obj.PhoneNumber = this.txtPatientPhone2.Text;
                obj.Address     = this.txtPatientAddress2.Text;
                obj.Age         = int.Parse(this.txtPatientAge2.Text);

                db.SaveChanges();
            }
        }
        private void btnLoadHistory_Click(object sender, RoutedEventArgs e)
        {
            HospitalManagementDBEntities db = new HospitalManagementDBEntities();

            this.gridDiagnosis.ItemsSource = db.Diagnosis.ToList();
        }
        // Load, refresh the database
        private void btnLoadPatient_Click(object sender, RoutedEventArgs e)
        {
            HospitalManagementDBEntities db = new HospitalManagementDBEntities();

            this.PatientGrid.ItemsSource = db.Patient.ToList();
        }