/// <summary> /// checks the ensure that the combo boxes options are not null /// </summary> /// <returns></returns> private bool CheckTB() { bool result = true; if (String.IsNullOrEmpty(newsubjCB.Text)) { errorMsg.SetError(newsubjCB, "Subject is missing."); result = false; newsubjCB.Focus(); } else { errorMsg.SetError(newsubjCB, ""); } if (String.IsNullOrEmpty(lecCB.Text)) { errorMsg.SetError(lecCB, "Teacher is missing."); result = false; lecCB.Focus(); } else { errorMsg.SetError(lecCB, ""); } if (String.IsNullOrEmpty(acadyrCB.Text)) { errorMsg.SetError(acadyrCB, "Academic Year is missing."); result = false; acadyrCB.Focus(); } else { errorMsg.SetError(acadyrCB, ""); } if (String.IsNullOrEmpty(TermCB.Text)) { errorMsg.SetError(TermCB, "Term is missing."); result = false; TermCB.Focus(); } else { errorMsg.SetError(TermCB, ""); } if (String.IsNullOrEmpty(FormCB.Text)) { errorMsg.SetError(FormCB, "Form is missing."); result = false; FormCB.Focus(); } else { errorMsg.SetError(FormCB, ""); } return(result); }
/// <summary> /// check to see if the form exsists /// before calling the method to save a new form /// </summary> /// <param name="v"></param> private void Validate(string v) { var vill = db.SchoolForms.Where(x => x.FormName == v).Count(); if (vill == 0) { try { saveForm(); MessageBox.Show("Successful!"); FormCB.Focus(); } catch (Exception) { MessageBox.Show("Error - Cannot Be Saved"); } MessageBox.Show("Duplicate Error \n\n Subject Exists"); } }