protected override void Validate(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors) { //Check if this employee already has a record for the same year. if (new PTOVacationBankData().IsDuplicate(db, ID, ENTUserAccountId, VacationYear)) { validationErrors.Add("The vacation bank has already been entered for this user for " + VacationYear + "."); } }
protected override void Validate(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors) { if (HolidayName.Trim() == "") { validationErrors.Add("The name is required."); } if (HolidayDate == DateTime.MinValue) { validationErrors.Add("The date is required."); } else { if (new HolidayData().IsDuplicateHolidayDate(db, ID, HolidayDate)) { validationErrors.Add("The date must be unique."); } } }
protected void btnCopy_Click(object sender, EventArgs e) { ENTValidationErrors validationErrors = new ENTValidationErrors(); if (ddlFrom.Text == ddlTo.Text) { validationErrors.Add("The from and to years can not be the same."); ValidationErrorMessages1.ValidationErrors = validationErrors; } else { PTOVacationBankEO.CopyYear(Convert.ToInt16(ddlFrom.Text), Convert.ToInt16(ddlTo.Text), CurrentUser.ID); Response.Redirect("VacationBanks.aspx"); } }
public bool GetWhereClause(ref string whereClause, ref ENTValidationErrors validationErrors) { //The left and right parens must equal each other. int leftParenCount = 0; int rightParenCount = 0; whereClause = ""; //Append any required where clauses foreach (object attribute in QueryFields) { if (attribute is RequiredQueryFieldAttribute) { if (whereClause == "") { whereClause = " WHERE "; } whereClause += ((RequiredQueryFieldAttribute)attribute).Clause + " AND "; } } //If there were any required where clauses then the rest of the query must be surrounded by parens ( ) bool requiredWhereClauseExists = (whereClause != ""); if (requiredWhereClauseExists) { whereClause += "( "; } //Add a line for each item in the list box. if (_lstWhereClause.Items.Count > 0) { if (whereClause == "") { whereClause = " WHERE "; } foreach (ListItem li in _lstWhereClause.Items) { leftParenCount += CountParens('(', li.Value); rightParenCount += CountParens(')', li.Value); whereClause += li.Value; } } //Close out the parenthesis if a required where clause existed. if (requiredWhereClauseExists) { whereClause += ")"; } //Validate that the left and right parens were equal. if (leftParenCount == rightParenCount) { return(true); } validationErrors.Add("Error In Filter: The nubmer of left and right parenthesis must match"); return(false); }