private void btn_appointment_insert_click(object sender, RoutedEventArgs e) { Appointments appointment = new Appointments(); appointment.AppointmentHour = Int32.Parse(textbox_appointmentHour.Text); appointment.AppointmentSubjectId = Int32.Parse(textbox_appointmentSubjectId.Text); appointment.AppointmentDate = datePicker_appointmentDate.SelectedDate.Value; appointment.DoctorId = Int32.Parse(textbox_appointmentDoctorID.Text); appointment.PatientId = Int32.Parse(textbox_appointmentPatientID.Text); appointment.DoctorNotes = textbox_appointmentDoctorNotes.Text; HospitalDB db = new HospitalDB(); db.Appointments.Add(appointment); db.SaveChanges(); MessageBox.Show("Appointment is saved..."); textbox_appointmentHour.Text = ""; textbox_appointmentSubjectId.Text = ""; textbox_appointmentDoctorID.Text = ""; textbox_appointmentPatientID.Text = ""; textbox_appointmentDoctorNotes.Text = ""; datePicker_appointmentDate.SelectedDate = DateTime.Now; LoadAppointments(); }
private void LoadAppointments() { HospitalDB db = new HospitalDB(); List <Appointments> appointmentList = db.Appointments.ToList(); grid_appointments.ItemsSource = appointmentList; }
private void LoadSubjects() { HospitalDB db = new HospitalDB(); List <Subjects> subjectList = db.Subjects.ToList(); data_grid_take_appo_subject_list.ItemsSource = subjectList; }
private void btn_doctor_insert_click(object sender, RoutedEventArgs e) { HospitalDB db1 = new HospitalDB(); List <Subjects> subjectList = db1.Subjects.ToList(); Doctors doctor = new Doctors(); doctor.Name = textbox_doctorName.Text; doctor.Surname = textbox_doctorSurname.Text; doctor.SubjectName = (string)combobox_doctorSubject.SelectedItem; doctor.BirthDate = datePicker_doctor_birthDate.SelectedDate.Value; doctor.username = textbox_doctor_username.Text; doctor.password = textbox_doctor_password.Text; HospitalDB db = new HospitalDB(); db.Doctors.Add(doctor); db.SaveChanges(); MessageBox.Show("Doctor is saved..."); textbox_doctorName.Text = ""; textbox_doctorSurname.Text = ""; textbox_doctor_username.Text = ""; textbox_doctor_password.Text = ""; datePicker_doctor_birthDate.SelectedDate = DateTime.Now; LoadDoctors(); }
private void LoadDoctors() { HospitalDB db = new HospitalDB(); List <Doctors> doctorList = db.Doctors.ToList(); datagrid_doctor_list.ItemsSource = doctorList; }
private void LoadSubjects() { HospitalDB db = new HospitalDB(); List <Subjects> subjectList = db.Subjects.ToList(); grid_subjects.ItemsSource = subjectList; fillSubjectCombobox(); }
private void fillSubjectCombobox() { HospitalDB db = new HospitalDB(); List <Subjects> subjectList = db.Subjects.ToList(); foreach (Subjects subject in subjectList) { combobox_doctorSubject.Items.Add(subject.Name); } combobox_doctorSubject.SelectedIndex = 0; }
private void btn_subject_insert_click(object sender, RoutedEventArgs e) { Subjects subject = new Subjects(); subject.Name = textbox_subjectName.Text; HospitalDB db = new HospitalDB(); db.Subjects.Add(subject); db.SaveChanges(); MessageBox.Show("Subject is saved..."); textbox_subjectName.Text = ""; LoadSubjects(); }
private void LoadAppointments() { HospitalDB db = new HospitalDB(); List <Appointments> appointmentList = db.Appointments.ToList(); List <Appointments> newAppointmentList = new List <Appointments>(); foreach (Appointments appo in appointmentList) { if (appo.DoctorId == doc.Id) { newAppointmentList.Add(appo); } } data_grid_doctorpage_appointmentList.ItemsSource = newAppointmentList; }
private void btn_appointment_delete_Click(object sender, RoutedEventArgs e) { Appointments appointment = grid_appointments.SelectedItem as Appointments; if (appointment != null) { HospitalDB db = new HospitalDB(); db.Appointments.Remove(appointment); db.SaveChanges(); MessageBox.Show("appointment is deleted!!"); LoadAppointments(); } else { MessageBox.Show("to delete. You should select a appointment"); } }
private void btn_subject_delete_Click(object sender, RoutedEventArgs e) { Subjects subject = grid_subjects.SelectedItem as Subjects; if (subject != null) { HospitalDB db = new HospitalDB(); db.Subjects.Remove(subject); db.SaveChanges(); MessageBox.Show("subject is deleted!!"); LoadSubjects(); } else { MessageBox.Show("to delete. You should select a subject"); } }
private void btn_PatientAdd_Click(object sender, RoutedEventArgs e) { Patients pat = new Patients(); pat.Name = textBox_PatientName.Text; pat.Surname = textBox_PatientSurname.Text; PatientID = pat.Id; HospitalDB db = new HospitalDB(); db.Patients.Add(pat); db.SaveChanges(); MessageBox.Show("Patient is saved..."); textBox_PatientName.Text = ""; textBox_PatientSurname.Text = ""; }
private void btn_doctor_delete_Click(object sender, RoutedEventArgs e) { Doctors doctor = grid_doctors.SelectedItem as Doctors; if (doctor != null) { HospitalDB db = new HospitalDB(); db.Doctors.Remove(doctor); db.SaveChanges(); MessageBox.Show("Doctor is deleted!!"); LoadDoctors(); } else { MessageBox.Show("to delete. You should select a doctor"); } }
private void btn_update_doctor_notes_click(object sender, RoutedEventArgs e) { Appointments appointment = data_grid_doctorpage_appointmentList.SelectedItem as Appointments; if (appointment != null) { HospitalDB db = new HospitalDB(); var appointmentnew = db.Appointments.Find(appointment.Id); appointmentnew.DoctorNotes = textbox_doctor_notes.Text; db.SaveChanges(); LoadAppointments(); MessageBox.Show("Updated."); } else { MessageBox.Show("to update. You should select an appointment."); } }
private void btn_subject_update_click(object sender, RoutedEventArgs e) { Subjects subject = grid_subjects.SelectedItem as Subjects; if (subject != null) { HospitalDB db = new HospitalDB(); var subjectnew = db.Subjects.Find(subject.Id); subjectnew.Name = textbox_subjectName.Text; db.SaveChanges(); LoadSubjects(); MessageBox.Show("Updated."); } else { MessageBox.Show("to update. You should select a doctor."); } }
private void btn_take_appo_Click(object sender, RoutedEventArgs e) { if (PatientID == -1) { MessageBox.Show("Before taking appointment. You should add a patient."); return; } Appointments appointment = new Appointments(); appointment.AppointmentHour = Int32.Parse(textbox_take_appo_hour.Text); appointment.AppointmentSubjectId = Int32.Parse(textBox_take_appo_subject_id.Text); appointment.AppointmentDate = date_picker_take_appointment.SelectedDate.Value; appointment.DoctorId = Int32.Parse(textbox_take_appo_doctor_id.Text); appointment.PatientId = PatientID; appointment.DoctorNotes = ""; HospitalDB db = new HospitalDB(); List <Appointments> appointmentList = db.Appointments.ToList(); foreach (Appointments appo in appointmentList) { if (appo.AppointmentDate == appointment.AppointmentDate) { if (appo.AppointmentHour == appointment.AppointmentHour) { MessageBox.Show("Selected date is reserved. Try different time"); return; } } } db.Appointments.Add(appointment); db.SaveChanges(); MessageBox.Show("Appointment is saved..."); textbox_take_appo_hour.Text = ""; textBox_take_appo_subject_id.Text = ""; textbox_take_appo_doctor_id.Text = ""; date_picker_take_appointment.SelectedDate = DateTime.Now; }
private void btn_doctor_update_click(object sender, RoutedEventArgs e) { Doctors doctor = grid_doctors.SelectedItem as Doctors; if (doctor != null) { HospitalDB db = new HospitalDB(); var doctornew = db.Doctors.Find(doctor.Id); doctornew.Name = textbox_doctorName.Text; doctornew.Surname = textbox_doctorSurname.Text; doctornew.BirthDate = datePicker_doctor_birthDate.SelectedDate.Value; doctornew.SubjectName = (string)combobox_doctorSubject.SelectedItem; doctornew.username = textbox_doctor_username.Text; doctornew.password = textbox_doctor_password.Text; db.SaveChanges(); LoadDoctors(); MessageBox.Show("Updated."); } else { MessageBox.Show("to update. You should select a doctor."); } }
private void btn_appointment_update_click(object sender, RoutedEventArgs e) { Appointments appointment = grid_appointments.SelectedItem as Appointments; if (appointment != null) { HospitalDB db = new HospitalDB(); var appointmentnew = db.Appointments.Find(appointment.Id); appointmentnew.AppointmentHour = Int32.Parse(textbox_appointmentHour.Text); appointmentnew.AppointmentSubjectId = Int32.Parse(textbox_appointmentSubjectId.Text); appointmentnew.AppointmentDate = datePicker_appointmentDate.SelectedDate.Value; appointmentnew.DoctorId = Int32.Parse(textbox_appointmentDoctorID.Text); appointmentnew.PatientId = Int32.Parse(textbox_appointmentPatientID.Text); appointmentnew.DoctorNotes = textbox_appointmentDoctorNotes.Text; db.SaveChanges(); LoadAppointments(); MessageBox.Show("Updated."); } else { MessageBox.Show("to update. You should select a doctor."); } }
private void btn_doctor_login_bottom_Click(object sender, RoutedEventArgs e) { image_welcome.Visibility = Visibility.Visible; label_password.Visibility = Visibility.Hidden; label_username.Visibility = Visibility.Hidden; textbox_username.Visibility = Visibility.Hidden; textbox_password.Visibility = Visibility.Hidden; btn_doctor_login_bottom.Visibility = Visibility.Hidden; HospitalDB db = new HospitalDB(); List <Doctors> doctorList = db.Doctors.ToList(); int usernameCount = 0; foreach (Doctors doctor in doctorList) { if (doctor.username == textbox_username.Text) { if (doctor.password == textbox_password.Text) { DoctorHomePage doctorPage = new DoctorHomePage(doctor); doctorPage.Show(); } else { MessageBox.Show("Password is wrong. Try again."); } usernameCount++; break; } } if (usernameCount == 0) { MessageBox.Show("User cannot be found. Try again."); } textbox_username.Text = ""; textbox_password.Text = ""; }
private void LoadDoctors() { HospitalDB db = new HospitalDB(); List <Doctors> doctorList = db.Doctors.ToList(); }