private void buttonSubmit_Click(object sender, System.EventArgs e) { PatientTests patientTest = new PatientTests(); patientTest.VisitId = this.visitID; patientTest.TestId = Int32.Parse(comboBoxTest.SelectedValue.ToString()); patientTest.TestOrdered = DateTime.Now; try { _controller.OrderTest(patientTest); MessageBox.Show(@"Test Added."); Close(); } catch (Exception exception) { MessageBox.Show(@"There was a problem adding the test." + exception); } }
private void saveButton_Click(object sender, EventArgs e) { PatientTests patientTests = new PatientTests(); patientTests.PatientTestsId = oldPatientTests.PatientTestsId; patientTests.TestId = oldPatientTests.TestId; patientTests.VisitId = oldPatientTests.VisitId; Boolean saveTest = false; if (string.IsNullOrEmpty(resultTextBox.Text)) { resultsAdded = false; } else { resultsAdded = true; } if (takenCheckBox.Checked) { patientTests.TestTaken = dateTimePickerTaken.Value; saveTest = true; } else if (resultsAdded) { MessageBox.Show(@"You need set the date test was taken before entering results.."); } if ((completedCheckBox.Checked) & (resultsAdded)) { patientTests.TestCompleted = dateTimePickerCompleted.Value; patientTests.Results = resultTextBox.Text.Trim(); saveTest = true; } else if ((completedCheckBox.Checked == false) & (resultsAdded)) { MessageBox.Show(@"You need to Set Completion date if your setting results."); saveTest = false; } else if ((completedCheckBox.Checked == true) & (!resultsAdded)) { MessageBox.Show(@"You need to Set Results if your setting Completion date."); saveTest = false; } if (saveTest){ try { if (NorthwindController.UpdatePatientTest(this.oldPatientTests, patientTests)) { MessageBox.Show("The test has been updated."); this.Close(); } else { MessageBox.Show("Something went wrong. The test data was not saved."); } } catch (SqlException ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } } }
public NwUpdatePatientTest(PatientTests patientTestParam) { this.oldPatientTests = patientTestParam; InitializeComponent(); }
private void patient_testsDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 7) //Update patient test button is clicked { //Get the ID of the selected visit int i = e.RowIndex; DataGridViewRow row = patient_testsDataGridView.Rows[i]; DataGridViewCell cell = row.Cells[1]; int patientTestID = (int) cell.Value; PatientTests test = new PatientTests(); test = _controller.GetPatientTest(patientTestID); //Display the visit info form NwUpdatePatientTest testForm = new NwUpdatePatientTest(test); testForm.ShowDialog(); } if (e.ColumnIndex == 8) //Delete patient test button is clicked { //Get the ID of the selected test int i = e.RowIndex; DataGridViewRow row = patient_testsDataGridView.Rows[i]; DataGridViewCell cell = row.Cells[1]; int patientTestID = (int)cell.Value; DialogResult confirmDeleteReturn = MessageBox.Show(@" Are you sure you want to delete " + row.Cells[2].Value.ToString().Trim() + @" test ordered on " + row.Cells[3].Value + @" ?", @"Confirm Delete", MessageBoxButtons.YesNo); String completed = this.patient_testsDataGridView[5, i].Value.ToString(); if (completed == "") { if (confirmDeleteReturn == DialogResult.Yes) { int success = _controller.DeletePatientTest(patientTestID); if (success == 1) { MessageBox.Show("Ordered test deleted succesfully!"); } else { MessageBox.Show("Ordered test could not be deleted!"); } } } else { MessageBox.Show("This test has been completed and may not be deleted."); } } }
public static bool UpdatePatientTest(PatientTests oldPatientTest, PatientTests newPatientTest) { return PatientTestsDal.UpdatePatientTest(oldPatientTest, newPatientTest); }
internal void OrderTest(PatientTests patientTest) { PatientTestsDal.OrderTest(patientTest); }