private void buttonDelete_Click(object sender, EventArgs e) { var selectedDoctor = this.GetSelectedDoctor(); if (selectedDoctor == null) { return; } if (MessageBox.Show("Сигурни ли сте, че искате да изтриете тази консултация?", "Потвърждение за изтриване", MessageBoxButtons.OKCancel) != System.Windows.Forms.DialogResult.OK) { return; } try { int doctorId = selectedDoctor.DoctorId; DoctorsDataAccess.DeleteDoctorById(doctorId); this.Presenter.LoadAllDoctors(); } catch (Exception ex) { string errorMessage = string.Format("Възникна грешка при изтриване на обект!\n {0}", ex.Message); this.Message = errorMessage; } }
public void Load(int doctorId) { try { if (doctorId == 0) { throw new ArgumentNullException("doctorId трябва да е различно от 0!"); } var doctor = DoctorsDataAccess.GetDoctorById(doctorId); this.Doctor = doctor; this.FillView(); } catch (Exception e) { string message = "Грешка!:" + e.Message; View.Message = message; } }
/// <summary> /// Filters doctors by name and number and sets the datagrdview source /// </summary> /// <param name="name"></param> /// <param name="number"></param> public void LoadDoctorsByCriterias(string name) { try { IQueryable <Doctor> doctorsQuery; doctorsQuery = DoctorsDataAccess.GetDoctors(); if (!string.IsNullOrEmpty(name)) { doctorsQuery = doctorsQuery.Where(d => d.Name.Contains(name)); } this.Doctors = doctorsQuery.ToList(); } catch (Exception e) { this.Message = "Грешка при заявка към базатa от данни!Обадете се на администратор!\n" + e.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(Doctor model) { try { if (Doctor.DoctorId == 0) { DoctorsDataAccess.InsertDoctor(Doctor); } else { DoctorsDataAccess.UpdateDoctor(Doctor); } View.Message = "Успешен запис!"; } catch (Exception e) { var message = String.Format("Възникна грешка при съхраняване! Обадете се на администратор!/n [0] ", e.Message); View.Message = message; } }