//removes text entered from the newTestPanel textboxes and restores their watermarks private void clearNewTestInputs() { NewTestPanel panel = form.NewTestPanel; TextPanel[] textpanels = new TextPanel[] { panel.PatientFirstTextbox, panel.PatientLastTextbox, panel.PatientDOBTextbox, panel.AdminFirstTextbox, panel.AdminLastTextbox, panel.TestTimeTextbox, panel.TestDateTextbox }; for (int i = 0; i < textpanels.Length; i++) { textpanels[i].clearText(); } panel.NotesTextbox.Clear(); }
//checks if inputs are valid and if they are not, shows message to the user which input is invalid and why private bool newTestInputsAreValid() { string inputText = ""; TextPanel[] nameTextboxes = new TextPanel[] { //to be checked using the nameFormat form.NewTestPanel.PatientFirstTextbox, form.NewTestPanel.PatientLastTextbox, form.NewTestPanel.AdminFirstTextbox, form.NewTestPanel.AdminLastTextbox }; TextPanel[] dateTextboxes = new TextPanel[] //to be checked using the dateFormat { form.NewTestPanel.PatientDOBTextbox, form.NewTestPanel.TestDateTextbox }; TextPanel[] timeTextboxes = new TextPanel[] //to be checked using the timeFormat { form.NewTestPanel.TestTimeTextbox //useful if there are multiple boxes to check }; TextBox notesTextbox = form.NewTestPanel.NotesTextbox; //validate name fields for (int i = 0; i < nameTextboxes.Length; i++) { inputText = nameTextboxes[i].Text; if (ValidationManager.inputIsValid(inputText, ValidationManager.ValidationTypes.Name) == false) { nameTextboxes[i].Focus(); return(false); } } //validate date fields for (int i = 0; i < dateTextboxes.Length; i++) { inputText = dateTextboxes[i].Text; if (ValidationManager.inputIsValid(inputText, ValidationManager.ValidationTypes.Date) == false) { dateTextboxes[i].Focus(); return(false); } } //validate time fields for (int i = 0; i < timeTextboxes.Length; i++) { inputText = timeTextboxes[i].Text; if (ValidationManager.inputIsValid(inputText, ValidationManager.ValidationTypes.Time) == false) { timeTextboxes[i].Focus(); return(false); } } //validate the notes entered inputText = notesTextbox.Text; if (ValidationManager.inputIsValid(inputText, ValidationManager.ValidationTypes.Notes) == false) { notesTextbox.Focus(); return(false); } return(true); }