private void SubmitButton_Click(object sender, EventArgs e) { if (this.selectedTestNameListBox.Items.Count > 0) { foreach (string s in this.selectedTestNameListBox.Items) { labTestList.ForEach(x => { if (x.Name.Equals(s)) { selectedLabTestList.Add(x); } }); } Lab_Order labOrder = new Lab_Order(this.visitDTO.ID, DateTime.Now); this.labOrderController.OrderLabs(labOrder, selectedLabTestList.ToArray()); this.selectedTestNameListBox.Items.Clear(); Form successfullPersistDialog = new SuccessfullPersistDialog("Lab Order Submitted Successfully!!"); DialogResult result = successfullPersistDialog.ShowDialog(); if (result == DialogResult.OK) { this.ParentForm.DialogResult = DialogResult.Cancel; } } else { this.messageLabel.Visible = true; this.messageLabel.Text = "Please select atlease one test to proceed!!"; } }
private void UpdateLabTestButton_Click(object sender, EventArgs e) { try { this.testResultError.Visible = false; this.testResultError.Text = ""; this.testDateError.Visible = false; this.testDateError.Text = ""; this.messageLabel.Visible = false; this.testDateError.Text = ""; this.testResultStatusErrorlabel.Visible = false; this.testResultStatusErrorlabel.Text = ""; bool isTestResultsEmptyOrNull = String.IsNullOrWhiteSpace(this.testResultTextBox.Text); bool isTestDateInvalid = this.testPerformedDateTimePicker.Value < selectedLabOrderTestDTO.OrderedDate; bool isTestResultRadioBtnSelected = this.CheckIfTestResultRadioButtonSelected(); bool isSelectedTestDateTimeInValid = (selectedAppointmentDateTime == null || this.testTime.SelectedIndex <= 0); if (isTestResultsEmptyOrNull || isTestDateInvalid || !isTestResultRadioBtnSelected || isSelectedTestDateTimeInValid) { if (isTestResultsEmptyOrNull) { this.testResultError.Visible = true; this.testResultError.Text = "The Test Result is mandatory!!"; } if (isTestDateInvalid) { this.testDateError.Visible = true; this.testDateError.Text = "The Test Date cannot be before test order date!!"; } if (!isTestResultRadioBtnSelected) { this.testResultStatusErrorlabel.Visible = true; this.testResultStatusErrorlabel.Text = "The Test Result Status Must be seleced!!"; } if (isSelectedTestDateTimeInValid) { this.testDateError.Visible = true; this.testDateError.Text = "The Test time is must to be selected!!"; } } else { List <Lab_Orders_have_Lab_Tests> labOrderHaveLabTestLst = new List <Lab_Orders_have_Lab_Tests>(); labOrderHaveLabTestLst.Add(new Lab_Orders_have_Lab_Tests(selectedLabOrderTestDTO.OrderId, this.selectedLabOrderTestDTO.TestCode, selectedAppointmentDateTime, this.testResultTextBox.Text, this.normalRadioButton.Checked?true:false)); if (this.labOrdersTestController.EnterTestResults(labOrderHaveLabTestLst.ToArray())) { Form successfullPersistDialog = new SuccessfullPersistDialog("Lab Test Updated Successfully!!."); DialogResult result = successfullPersistDialog.ShowDialog(); if (result == DialogResult.OK) { this.ParentForm.DialogResult = DialogResult.Cancel; } } else { this.messageLabel.Text = "Input Data inconsistent!!"; this.messageLabel.Visible = true; } } } catch (Exception ex) { this.messageLabel.Text = "Input Data inconsistent." + Environment.NewLine + "Please verify all data entered for the input fields and try again!!"; var message = ex.Message; this.messageLabel.Visible = true; } }