private void btnAddRecord_Click(object sender, EventArgs e) { HealthRecordService service = new HealthRecordService(); if (!string.IsNullOrEmpty(txtDiagnose.Text) && healthDoctorRecord != null && healthPatientRecord != null) { HealthRecord record = new HealthRecord() { Patient = healthPatientRecord, Doctor = healthDoctorRecord, Diagnosis = txtDiagnose.Text, IsAmbulance = chAmbulance.CheckState == CheckState.Checked, IsDispencary = chDispancer.CheckState == CheckState.Checked, Notes = txtNotes.Text, Id = Guid.NewGuid().ToString() }; if (chCanWork.CheckState == CheckState.Checked) { record.IsCanContinueWork = true; if (!string.IsNullOrEmpty(txtDiagnose.Text)) { record.CountDayWithoutWork = 0; } } else { record.IsCanContinueWork = false; record.CountDayWithoutWork = Convert.ToInt32(txtWithoutWork.Text); } service.AddRecord(record); var records = service.GetAll(); dataGridView1.Rows.Clear(); if (records != null) { foreach (var p in records) { dataGridView1.Rows.Add(p.Patient.GetFullName, p.Doctor.GetFullName, p.Diagnosis, p.IsAmbulance, p.IsCanContinueWork, p.CountDayWithoutWork, p.IsDispencary, p.Notes, p.Id); } } } else { lbError.Text = "Filed can't be empty"; } }
private void btnGetAllRecord_Click(object sender, EventArgs e) { var records = new HealthRecordService().GetAll(); dataGridView1.Rows.Clear(); if (records?.Count > 0) { foreach (var p in records) { dataGridView1.Rows.Add(p.Patient.GetFullName, p.Doctor.GetFullName, p.Diagnosis, p.IsAmbulance, p.IsCanContinueWork, p.CountDayWithoutWork, p.IsDispencary, p.Notes, p.Id); } } }
private void button1_Click(object sender, EventArgs e) { HealthRecordService service = new HealthRecordService(); if (btnUpdateRecord.Text == "Confirm") { selectedHealthRecord = null; ClearRecordValues(); btnUpdateRecord.Text = "Update"; var records = service.GetAll(); dgDoctor.Rows.Clear(); if (records?.Count > 0) { foreach (var p in records) { dataGridView1.Rows.Add(p.Patient.GetFullName, p.Doctor.GetFullName, p.Diagnosis, p.IsAmbulance, p.IsCanContinueWork, p.CountDayWithoutWork, p.IsDispencary, p.Notes, p.Id); } } } }
private void btnUpdateRecord_Click(object sender, EventArgs e) { HealthRecordService service = new HealthRecordService(); if (btnUpdateRecord.Text == "Confirm") { HealthRecord record = new HealthRecord() { Patient = healthPatientRecord, Doctor = healthDoctorRecord, Diagnosis = txtDiagnose.Text, IsAmbulance = chAmbulance.CheckState == CheckState.Checked, IsDispencary = chDispancer.CheckState == CheckState.Checked, Notes = txtNotes.Text, Id = Guid.NewGuid().ToString() }; if (chCanWork.CheckState == CheckState.Checked) { record.IsCanContinueWork = true; record.CountDayWithoutWork = 0; } else { record.IsCanContinueWork = false; if (!string.IsNullOrEmpty(txtDiagnose.Text)) { record.CountDayWithoutWork = Convert.ToInt32(txtWithoutWork.Text); } } record.Id = selectedHealthRecord.Id; service.UpdateRecord(record); selectedHealthRecord = null; btnUpdateRecord.Text = "Update"; button1.Visible = false; ClearRecordValues(); var records = service.GetAll(); dataGridView1.Rows.Clear(); if (records?.Count > 0) { foreach (var p in records) { dataGridView1.Rows.Add(p.Patient.GetFullName, p.Doctor.GetFullName, p.Diagnosis, p.IsAmbulance, p.IsCanContinueWork, p.CountDayWithoutWork, p.IsDispencary, p.Notes, p.Id); } } } else { if (selectedHealthRecord != null) { btnUpdateRecord.Text = "Confirm"; txtDiagnose.Text = selectedHealthRecord.Diagnosis; chAmbulance.CheckState = selectedHealthRecord.IsAmbulance ? CheckState.Checked : CheckState.Unchecked; chDispancer.CheckState = selectedHealthRecord.IsDispencary ? CheckState.Checked : CheckState.Unchecked; chCanWork.CheckState = selectedHealthRecord.IsCanContinueWork ? CheckState.Checked : CheckState.Unchecked; txtWithoutWork.Text = selectedHealthRecord.CountDayWithoutWork.ToString(); txtNotes.Text = selectedHealthRecord.Notes; healthPatientRecord = selectedHealthRecord.Patient; healthDoctorRecord = selectedHealthRecord.Doctor; button1.Visible = true; } } }