private bool DataIsValid() { if (string.IsNullOrEmpty(txtStudNum.Text.Trim())) { MessageDialog.ShowValidationError(txtStudNum, "Student Number must NOT be blank"); return(false); } int studnum; if (!int.TryParse(txtStudNum.Text, out studnum)) { txtStudNum.Focus(); MessageDialog.ShowValidationError(txtStudNum, "Invalid Student Number"); return(false); } if (string.IsNullOrWhiteSpace(txtSection.Text)) { MessageDialog.ShowValidationError(txtSection, "Section is Required. Specify Section"); return(false); } var reader = new StudentDataReader(); if (reader.HasExistingStudentNumber(Convert.ToInt32(txtStudNum.Text), ItemData.Id)) { MessageDialog.ShowValidationError(txtStudNum, "Student Number already exists!"); return(false); } return(true); }
private bool ExistingPersonId(int personId) { var reader = new StudentDataReader(); return(reader.HasExistingPersonId(personId)); }