Exemple #1
0
        public WPF_9_RelationalDB()
        {
            InitializeComponent();

            HospitalManagementDBEntities db = new HospitalManagementDBEntities();

            var result = from a in db.Appointments
                         select new
            {
                a.DoctorID,
                DoctorName = a.Doctor.Name,
                a.Doctor.Specialization,
                a.PatientID,
                Patient = a.Patient.Name,
                a.Patient.ContactNo,
                a.AppointmentDate
            };

            var resultOuterDoctor = from d in db.Doctors
                                    from a in d.Appointments.DefaultIfEmpty()
                                    select new
            {
                d.Name,
                ApptID = a.Id.ToString(),
                a.AppointmentDate,
                Patient = a.Patient.Name
            };

            this.gridAppointments.ItemsSource = result.ToList();
        }
Exemple #2
0
        private void BtnDeleteDoctor_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult msgBoxResult = MessageBox.Show("Are you sure you want to Delete?",
                                                            "Delete Doctor",
                                                            MessageBoxButton.YesNo,
                                                            MessageBoxImage.Warning,
                                                            MessageBoxResult.No
                                                            );

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

                var r = from d in db.Doctors
                        where d.Id == this.updatingDoctorID
                        select d;

                Doctor obj = r.SingleOrDefault();

                if (obj != null)
                {
                    db.Doctors.Remove(obj);
                    db.SaveChanges();
                }
            }
        }
Exemple #3
0
        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
            };

            db.Doctors.Add(doctorObject);
            db.SaveChanges();
        }
Exemple #4
0
        private void BtnUpdateDoctor_Click(object sender, RoutedEventArgs e)
        {
            HospitalManagementDBEntities db = new HospitalManagementDBEntities();

            var r = from d in db.Doctors
                    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.txtAge.Text);

                db.SaveChanges();
            }
        }
Exemple #5
0
        public WPF_8_EF_HMS()
        {
            InitializeComponent();

            HospitalManagementDBEntities db = new HospitalManagementDBEntities();
            var docs = from d in db.Doctors
                       select new
            {
                DoctorName = d.Name,
                Speciality = d.Specialization
            };

            foreach (var item in docs)
            {
                Console.WriteLine(item.DoctorName);
                Console.WriteLine(item.Speciality);
            }

            this.gridDoctors.ItemsSource = docs.ToList();
        }
Exemple #6
0
        private void BtnLoadDoctors_Click(object sender, RoutedEventArgs e)
        {
            HospitalManagementDBEntities db = new HospitalManagementDBEntities();

            this.gridDoctors.ItemsSource = db.Doctors.ToList();
        }