private void buttonDelete_Click(object sender, RoutedEventArgs e) { var row = this.dataGridViewResult.SelectedItem;//currentrow было вместо колумна if (row == null) { return; } if (MessageBox.Show("Вы действительно хотите удалить эту консультацию ? ", "Подтверждение удаления", MessageBoxButton.OKCancel) != MessageBoxResult.OK)//messageboxresult System.Windows.Forms.DialogResult { return; } try { var patient = (Patient)row;//row.DataBoundItem; int patientId = patient.PatientId; PatientsDataAccess.DeletePatientById(patientId); this.Presenter.LoadAllPatients(); } catch (Exception ex) { string errorMessage = string.Format("При удалении объекта произошла ошибка!\n {0}", ex.Message); this.Message = errorMessage; } }
private void buttonDelete_Click(object sender, EventArgs e) { var row = this.dataGridViewResults.CurrentRow; if (row == null) { return; } if (MessageBox.Show("Сигурни ли сте, че искате да изтриете този пациент?", "Потвърждение за изтриване", MessageBoxButtons.OKCancel) != System.Windows.Forms.DialogResult.OK) { return; } try { var patient = (Patient)row.DataBoundItem; int patientId = patient.PatientId; PatientsDataAccess.DeletePatientById(patientId); this.Presenter.LoadAllPatients(); } catch (Exception ex) { string errorMessage = string.Format("Възникна грешка при изтриване на обект!\n {0}", ex.Message); this.Message = errorMessage; } }
private void buttonDelete_Click(object sender, RoutedEventArgs e) { var row = (Patient)dataGridViewResult.SelectedItem; if (row == null) { return; } if (MessageBox.Show("Вы действительно хотите удалить этого пациента ? ", "Подтверждение удаления", MessageBoxButton.OKCancel) != MessageBoxResult.OK)//messageboxresult System.Windows.Forms.DialogResult { return; } try { //var patient = (Patient)row; //int patientId = patient.Id; UsersDataAccess.DeleteUserByPatientId(row.Id); dataGridViewResult.ItemsSource = PatientsDataAccess.GetPatients(); } catch (Exception ex) { string errorMessage = string.Format("При удалении объекта произошла ошибка!\n {0}", ex.Message); //this.Message = errorMessage; MessageBox.Show(errorMessage); } }
private void SaveModel(Patient model) { try { if (model.Id == 0) { Patient patient = PatientsDataAccess.InsertPatient(model); if (patient != null) { EditUser editUser = new EditUser(patient, true); editUser.Show(); } } else { PatientsDataAccess.UpdatePatient(model); } //View.Message = "Успешная запись!"; } catch (Exception e) { var message = String.Format("Ошибка хранилища"); MessageBox.Show(message); } }
public Patients() { InitializeComponent(); dataGridViewResult.ItemsSource = PatientsDataAccess.GetPatients(); if (Membership.CurrentUser.RoleID == 2) { buttonAdd.Visibility = Visibility.Collapsed; buttonDelete.Visibility = Visibility.Collapsed; } }
private void buttonLoadPatient_Click(object sender, RoutedEventArgs e) { Visit.Patient = PatientsDataAccess.GetPatientByName(textBoxPatientName.Text); if (Visit.Patient != null) { MessageBox.Show("Пациент найден"); } else { MessageBox.Show("Пациент не найден, попробуйте еще раз"); } }
public void Load(int patientId) { try { if (patientId == 0) { throw new ArgumentNullException("patientId трябва да е различно от 0!"); } var patient = PatientsDataAccess.GetPatientWithConsultationsAndDiagnosesById(patientId); this.Patient = patient; this.FillView(); this.LoadConsultations(); } catch (Exception e) { string message = "Грешка!:" + e.Message; View.Message = message; } }
protected void FillView() { int doctorId = Diagnosis.DoctorId.HasValue ? Diagnosis.DoctorId.Value : 0; View.DoctorId = doctorId; var consultationDoctor = DoctorsDataAccess.GetDoctorById(doctorId); if (consultationDoctor != null) { View.DoctorName = consultationDoctor.Name; } else { View.DoctorName = "Не е избран лекар"; } int patientId = Diagnosis.PatientId.HasValue ? Diagnosis.PatientId.Value : 0; View.PatientId = patientId; var consultationPatient = PatientsDataAccess.GetPatientById(patientId); if (consultationPatient != null) { View.PatientName = consultationPatient.Name; View.PatientNumber = consultationPatient.Number; } else { View.PatientName = "Не е избран пациент"; View.PatientNumber = string.Empty; } DateTime scheduleDate = Diagnosis.DiagnosticationDate.HasValue ? Diagnosis.DiagnosticationDate.Value : DateTime.Now; View.DiagnosticationDate = scheduleDate; View.Notes = Diagnosis.Notes; View.Subject = Diagnosis.Subect; View.Prescription = Diagnosis.Prescription; View.DiagnoseId = Diagnosis.DiagnoseId; }
protected void FillView() { int doctorId = Consultation.DoctorId.HasValue ? Consultation.DoctorId.Value : 0; View.DoctorId = doctorId; var consultationDoctor = DoctorsDataAccess.GetDoctorById(doctorId); if (consultationDoctor != null) { View.DoctorName = consultationDoctor.Name; } else { View.DoctorName = "Не е избран лекар"; } int patientId = Consultation.PatientId.HasValue ? Consultation.PatientId.Value : 0; View.PatientId = patientId; var consultationPatient = PatientsDataAccess.GetPatientById(patientId); if (consultationPatient != null) { View.PatientName = consultationPatient.Name; View.PatientNumber = consultationPatient.Number; } else { View.PatientName = "Не е избран пациент"; View.PatientNumber = string.Empty; } DateTime scheduleDate = Consultation.ScheduleDate.HasValue ? Consultation.ScheduleDate.Value : DateTime.Now; View.ScheduleDate = scheduleDate; View.Notes = Consultation.Notes; View.Reason = Consultation.Reason; View.Conclusion = Consultation.Conclusion; View.ConsultationId = Consultation.ConsultationId; }
private void SaveModel(Patient model) { try { if (Patient.PatientId == 0) { PatientsDataAccess.InsertPatient(Patient); } else { PatientsDataAccess.UpdatePatient(Patient); } View.Message = "Успешен запис!"; } catch (Exception e) { var message = String.Format("Възникна грешка при съхраняване! Обадете се на администратор!/n [0] ", e.Message); View.Message = message; } }
private void SaveModel(Patient model) { try { if (Patient.PatientId == 0) { PatientsDataAccess.InsertPatient(Patient); } else { PatientsDataAccess.UpdatePatient(Patient); } View.Message = "Успешная запись!"; } catch (Exception e) { var message = String.Format("Ошибка хранилища!Позвоните администратору!/ n [0] ", e.Message); View.Message = message; } }
/// <summary> /// Filters patients by name and number and sets the datagrdview source /// </summary> /// <param name="name"></param> /// <param name="number"></param> public void LoadPatientsByCriterias(string name, string number) { try { IQueryable <Patient> patientsQuery; patientsQuery = PatientsDataAccess.GetPatients(); if (!string.IsNullOrEmpty(name)) { patientsQuery = patientsQuery.Where(p => p.Name.Contains(name)); } if (!string.IsNullOrEmpty(number)) { patientsQuery = patientsQuery.Where(p => p.Number.Contains(number)); } this.Patients = patientsQuery.ToList(); } catch (Exception e) { this.Message = "Ошибка при запросе базы данных!Вызовите администратора!"; } }
/// <summary> /// Filters patients by name and number and sets the datagrdview source /// </summary> /// <param name="name"></param> /// <param name="number"></param> public void LoadPatientsByCriterias(string name, string number) { try { IQueryable <Patient> patientsQuery; patientsQuery = PatientsDataAccess.GetPatients(); if (!string.IsNullOrEmpty(name)) { patientsQuery = patientsQuery.Where(p => p.Name.Contains(name)); } if (!string.IsNullOrEmpty(number)) { patientsQuery = patientsQuery.Where(p => p.Number.Contains(number)); } this.Patients = patientsQuery.ToList(); } catch (Exception e) { this.Message = "Грешка при заявка към базатa от данни!Обадете се на администратор!"; } }
private void buttonSearch_Click(object sender, RoutedEventArgs e) { collection = from t in PatientsDataAccess.GetPatients() select t; if (!String.IsNullOrEmpty(Name.Text)) { collection = from t in collection where t.Name.Contains(Name.Text) select t; } if (!String.IsNullOrEmpty(Address.Text)) { collection = from t in collection where t.Address.Contains(Address.Text) select t; } if (dateTimePickerFrom.SelectedDate != null) { collection = from t in collection where t.Birthdate > BirthdateSearchFrom select t; } if (dateTimePickerTo.SelectedDate != null) { collection = from t in collection where t.Birthdate < BirthdateSearchTo select t; } dataGridViewResult.ItemsSource = collection; return; }
public void Load(int patientId) { try { if (patientId == 0) { throw new ArgumentNullException("patientId должен отличаться от 0!"); } patient = PatientsDataAccess.GetPatientById(patientId); textBoxAddress.Text = patient.Address; textBoxName.Text = patient.Name; textBoxPhone.Text = patient.Phone; dateTimePickerBirthdate.SelectedDate = patient.Birthdate; dataGridViewVisits.ItemsSource = VisitsDataAccess.GetVisitsByPatientId(patientId); Flag = true; } catch (Exception e) { string message = "Ошибка!:" + e.Message; MessageBox.Show(message); } }
//public ConsultationsPresenter Presenter { get; set; } private void buttonSearch_Click(object sender, RoutedEventArgs e) { dataGridViewResult.Columns.Clear(); List <Visit> visits = new List <Visit>(); if (Membership.CurrentUser.RoleID == 1) { for (int i = 0; i < VisitsDataAccess.GetVisits().Count; i++) { var row = VisitsDataAccess.GetVisits()[i]; visits.Add(new Visit(Convert.ToInt32(row.Row.ItemArray[0]), DoctorDataAccess.GetDoctorByName(row.Row.ItemArray[1].ToString()), PatientsDataAccess.GetPatientByName(row.Row.ItemArray[2].ToString()), Convert.ToDateTime(row.Row.ItemArray[3]), VisitsDataAccess.GetTypeByName(row.Row.ItemArray[4].ToString()), row.Row.ItemArray[5].ToString(), row.Row.ItemArray[6].ToString(), row.Row.ItemArray[7].ToString(), row.Row.ItemArray[8].ToString(), new Room(row.Row.ItemArray[9].ToString(), null), (row.Row.ItemArray[10].ToString() == "") ? null : (byte[])row.Row.ItemArray[10] )); } } else if (Membership.CurrentUser.RoleID == 2) { for (int i = 0; i < VisitsDataAccess.GetVisitsByDoctorId(Membership.CurrentUser.Doctor.Id).Count; i++) { var row = VisitsDataAccess.GetVisitsByDoctorId(Membership.CurrentUser.Doctor.Id)[i]; visits.Add(new Visit(Convert.ToInt32(row.Row.ItemArray[0]), DoctorDataAccess.GetDoctorByName(row.Row.ItemArray[1].ToString()), PatientsDataAccess.GetPatientByName(row.Row.ItemArray[2].ToString()), Convert.ToDateTime(row.Row.ItemArray[3]), VisitsDataAccess.GetTypeByName(row.Row.ItemArray[4].ToString()), row.Row.ItemArray[5].ToString(), row.Row.ItemArray[6].ToString(), row.Row.ItemArray[7].ToString(), row.Row.ItemArray[8].ToString(), new Room(row.Row.ItemArray[9].ToString(), null), (row.Row.ItemArray[10].ToString() == "") ? null : (byte[])row.Row.ItemArray[10] )); } } dataGridViewResult.AutoGenerateColumns = false; DataGridTextColumn id = new DataGridTextColumn(); id.Header = "ID"; id.Binding = new Binding("ID"); dataGridViewResult.Columns.Add(id); DataGridTextColumn doctor = new DataGridTextColumn(); doctor.Header = "Доктор"; doctor.Binding = new Binding("Doctor.Name"); dataGridViewResult.Columns.Add(doctor); DataGridTextColumn patient = new DataGridTextColumn(); patient.Header = "Пациент"; patient.Binding = new Binding("Patient.Name"); dataGridViewResult.Columns.Add(patient); DataGridTextColumn datetime = new DataGridTextColumn(); datetime.Header = "Дата/время"; datetime.Binding = new Binding("DateTime"); dataGridViewResult.Columns.Add(datetime); DataGridTextColumn type = new DataGridTextColumn(); type.Header = "Тип"; type.Binding = new Binding("Type.Type"); dataGridViewResult.Columns.Add(type); DataGridTextColumn sympthoms = new DataGridTextColumn(); sympthoms.Header = "Симптомы"; sympthoms.Binding = new Binding("Symthoms"); dataGridViewResult.Columns.Add(sympthoms); DataGridTextColumn diagnosis = new DataGridTextColumn(); diagnosis.Header = "Диагноз"; diagnosis.Binding = new Binding("Diagnosis"); dataGridViewResult.Columns.Add(diagnosis); DataGridTextColumn prescription = new DataGridTextColumn(); prescription.Header = "Назначения"; prescription.Binding = new Binding("Prescription"); dataGridViewResult.Columns.Add(prescription); DataGridTextColumn notes = new DataGridTextColumn(); notes.Header = "Заметки"; notes.Binding = new Binding("Notes"); dataGridViewResult.Columns.Add(notes); DataGridTextColumn room = new DataGridTextColumn(); room.Header = "Кабинет"; room.Binding = new Binding("Room.Number"); dataGridViewResult.Columns.Add(room); IEnumerable <Visit> result = visits; if (dateTimePickerFrom.SelectedDate != null) { result = result.Where(el => (el.DateTime > dateTimePickerFrom.SelectedDate)).Select(el => el); } if (dateTimePickerTo.SelectedDate != null) { result = result.Where(el => (el.DateTime < dateTimePickerTo.SelectedDate)).Select(el => el); } if (!String.IsNullOrEmpty(Patient.Text)) { result = result.Where(el => (el.Patient.Name.Contains(Patient.Text))).Select(el => el); } if (!String.IsNullOrEmpty(Doctor.Text)) { result = result.Where(el => (el.Doctor.Name.Contains(Doctor.Text))).Select(el => el); } if (!String.IsNullOrEmpty(Diagnosis.Text)) { result = result.Where(el => (el.Diagnosis.Contains(Patient.Text))).Select(el => el); } if (VisitType.SelectedItem != null && VisitType.SelectedItem.ToString() != "") { result = result.Where(el => (el.Type.Type == VisitType.SelectedItem.ToString())).Select(el => el); } dataGridViewResult.ItemsSource = result; SelectFlag = true; }