private string WriteMessage(ISamplingObject s) { string result = string.Empty; string analyteCode = string.Empty; if (s is Result) { result = "Result "; analyteCode = string.Format("Analyte: {0}\r\n", ((Result)s).AnalyteCode); } string message = string.Format("SC Drinking Water Sample {0}Validation Error\r\n" + "PWSID: {1}\r\n" + "PWS Name: {2}\r\n" + "Sample Job Id: {3}\r\n" + "Sample Id: {4}\r\n{5}{6}", result, s.PWSIdentifier, s is Sample ? ((Sample)s).PWSName : string.Empty, s is Sample ? ((Sample)s).cmdpJobId : string.Empty, s.LabSampleIdentifier, analyteCode, s.Errors); return(message); }
public LabEmailForm(ISamplingObject s) { InitializeComponent(); emailSent = false; string subject = string.Format("SC Drinking Water Sample Validation Error for {0}{1}", s.LabSampleIdentifier, s is Result ? ", " + ((Result)s).AnalyteCode : ""); FillForm(s.LabAccredidationIdentifier, subject, WriteMessage(s)); }
public static bool SetStaffValidation(ISamplingObject item, bool validationResult) { if (item is Sample) { return(SetSampleStaffValidation((Sample)item, validationResult)); } else if (item is Result) { return(SetResultStaffValidation((Result)item, validationResult)); } else { return(false); } }
private void btnValidRejection_Click(object sender, EventArgs e) { LabEmailForm email = null; try { ISamplingObject sample = (ISamplingObject)lbxErrors.SelectedItem; email = new LabEmailForm(sample); email.ShowDialog(this); } catch (Exception ex) { if (email != null) { email.Close(); } MessageBox.Show("An error occurred while preparing lab message"); } if (email.emailSent) { ISamplingObject selectedItem; bool updateSuccess = false; try { selectedItem = (ISamplingObject)lbxErrors.SelectedItem; updateSuccess = DbHelper.SetStaffValidation(selectedItem, false); } catch (Exception) { } if (!updateSuccess) { MessageBox.Show("An error occurred while updating staff validation"); } else { UpdateErrorList(); } } }