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(); } } }
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(); }
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(); } }