public override bool Save(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors, int userAccountId) { if (DBAction == DBActionEnum.Save) { //Validate the object Validate(db, ref validationErrors); //Check if there were any validation errors if (validationErrors.Count == 0) { if (IsNewRecord()) { //Add ID = new ENTRoleData().Insert(db, RoleName, userAccountId); } else { //Update if (!new ENTRoleData().Update(db, ID, RoleName, userAccountId, Version)) { UpdateFailed(ref validationErrors); return(false); } } return(true); } //Didn't pass validation. return(false); } throw new Exception("DBAction not Save."); }
void Master_SaveButton_Click(object sender, EventArgs e) { ENTValidationErrors validationErrors = new ENTValidationErrors(); PTORequestEO ptoRequest = (PTORequestEO)ViewState[VIEW_STATE_KEY_PTOREQUEST]; //Get the original state of the object. PTORequestEO originalPTORequest = new PTORequestEO(); originalPTORequest.Load(ptoRequest.ID); ptoRequest.OriginalItem = (ENTBaseEO)originalPTORequest; LoadObjectFromScreen(ptoRequest); if (!ptoRequest.Save(ref validationErrors, CurrentUser.ID)) { //Reload the object. If any validation errors occurred after a property was changed then //the object would retain that changed property. You want to revert back to what it was //originally. if ((ptoRequest == null) || (ptoRequest.ID == 0)) { CreateNew(ref ptoRequest); } else { ptoRequest = originalPTORequest; } ViewState[VIEW_STATE_KEY_PTOREQUEST] = ptoRequest; Master.ValidationErrors = validationErrors; } else { GoToGridPage(); } }
protected void btnPreview_Click(object sender, EventArgs e) { string whereClause = ""; var validationErrors = new ENTValidationErrors(); if (QueryBuilder1.GetWhereClause(ref whereClause, ref validationErrors)) { var currentReport = CurrentReport; var report = new ReportDocument(); report.Load(Server.MapPath(currentReport.FileName)); var objectType = Type.GetType(currentReport.ObjectName); object listObject = Activator.CreateInstance(objectType); if (objectType != null) { var data = (object[])objectType.InvokeMember("Select", BindingFlags.InvokeMethod, null, listObject, new object[] { whereClause }); //TODO: added length check after chapter was written. if (data.Length > 0) { //Get the data report.SetDataSource(data); //Check if there is a sub report if (report.Subreports.Count > 0) { //Only support 1 subreport //Get the object that can retrieve the data for the subreport Type objectType1 = Type.GetType(currentReport.SubReportObjectName); //The methods must be static for this data. if (objectType1 != null) { var subreportData = (object[])objectType1.InvokeMember(currentReport.SubReportMethodName, BindingFlags.InvokeMethod, null, objectType1, new object[] { }); report.Subreports[0].SetDataSource(subreportData); } } report.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, ""); } else { Response.Clear(); Response.Write("No data matches your criteria for this report."); Response.End(); } } } else { Response.Clear(); foreach (var ve in validationErrors) { Response.Write(ve.ErrorMessage + "<br>" + Environment.NewLine); } Response.End(); } }
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 + "."); } }
void _emailTimer_Elapsed(object sender, ElapsedEventArgs e) { if (!_processing) { _processing = true; try { //Check if there are any emails that need to be sent var emails = new ENTEmailEOList(); emails.LoadUnsent(); if (emails.Count != 0) { var validationErrors = new ENTValidationErrors(); //if there are then send one at a time var client = new SmtpClient(); foreach (ENTEmailEO email in emails) { var message = new MailMessage(); message.From = new MailAddress(email.FromEmailAddress); AddAddresses(email.ToEmailAddress, message.To); AddAddresses(email.CCEmailAddress, message.CC); AddAddresses(email.BCCEmailAddress, message.Bcc); message.Subject = email.Subject; message.Body = email.Body; message.IsBodyHtml = true; client.Send(message); //Update record after the email is sent email.EmailStatusFlag = ENTEmailEO.EmailStatusFlagEnum.Sent; if (!email.Save(ref validationErrors, _entUserAccountId)) { foreach (ENTValidationError ve in validationErrors) { var ev = new EventLog(); ev.Source = "EmailService"; ev.WriteEntry(ve.ErrorMessage, EventLogEntryType.Error); } } } } _processing = false; } catch (Exception exception) { _processing = false; var ev = new EventLog(); ev.Source = "EmailService"; ev.WriteEntry(exception.Message, EventLogEntryType.Error); } } }
void lbtnDelete_Command(object sender, CommandEventArgs e) { var validationErrors = new ENTValidationErrors(); var role = new ENTRoleEO(); role.DBAction = ENTBaseEO.DBActionEnum.Delete; role.ID = Convert.ToInt32(e.CommandArgument); role.Delete(ref validationErrors, CurrentUser.ID); Master.ValidationErrors = validationErrors; cgvRoles.DataBind(); }
void lbtnDelete_Command(object sender, CommandEventArgs e) { var validationErrors = new ENTValidationErrors(); var user = new ENTUserAccountEO(Convert.ToInt32(e.CommandArgument)); user.DBAction = ENTBaseEO.DBActionEnum.Delete; //user.ID = Convert.ToInt32(e.CommandArgument); user.Delete(ref validationErrors, CurrentUser.ID); Master.ValidationErrors = validationErrors; cgvUsers.DataBind(); }
void lbtnDelete_Command(object sender, CommandEventArgs e) { ENTValidationErrors validationErrors = new ENTValidationErrors(); ENTAuditObjectEO auditObject = new ENTAuditObjectEO(); auditObject.DBAction = ENTBaseEO.DBActionEnum.Delete; auditObject.ID = Convert.ToInt32(e.CommandArgument); auditObject.Delete(ref validationErrors, CurrentUser.ID); Master.ValidationErrors = validationErrors; cgvAuditObjects.DataBind(); }
void lbtnDelete_Command(object sender, CommandEventArgs e) { ENTValidationErrors validationErrors = new ENTValidationErrors(); ENTWFOwnerGroupEO workflowOwnerGroup = new ENTWFOwnerGroupEO(); workflowOwnerGroup.DBAction = ENTBaseEO.DBActionEnum.Delete; workflowOwnerGroup.ID = Convert.ToInt32(e.CommandArgument); workflowOwnerGroup.Delete(ref validationErrors, CurrentUser.ID); Master.ValidationErrors = validationErrors; cgvWorkflow.DataBind(); }
private void Master_SaveButton_Click(object sender, EventArgs e) { var validationErrors = new ENTValidationErrors(); var userAccount = (ENTUserAccountEO)ViewState[VIEW_STATE_KEY_USER]; LoadObjectFromScreen(userAccount); if (!userAccount.Save(ref validationErrors, 1)) { Master.ValidationErrors = validationErrors; } else { GoToGridPage(); } }
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"); } }
void Master_SaveButton_Click(object sender, EventArgs e) { var validationErrors = new ENTValidationErrors(); var myNotifications = (MyNotificationsEO)ViewState[VIEW_STATE_KEY_MYNOTIFICATIONS]; LoadObjectFromScreen(myNotifications); if (!myNotifications.Save(ref validationErrors, CurrentUser.ID)) { Master.ValidationErrors = validationErrors; } else { GoToGridPage(); } }
void Master_SaveButton_Click(object sender, EventArgs e) { var validationErrors = new ENTValidationErrors(); var ptoVacationBank = (PTOVacationBankEO)ViewState[VIEW_STATE_KEY_VACATION_BANK]; LoadObjectFromScreen(ptoVacationBank); if (!ptoVacationBank.Save(ref validationErrors, CurrentUser.ID)) { Master.ValidationErrors = validationErrors; } else { GoToGridPage(); } }
void Master_SaveButton_Click(object sender, EventArgs e) { var validationErrors = new ENTValidationErrors(); var workflow = (ENTWorkflowEO)ViewState[VIEW_STATE_KEY_WORKFLOW]; LoadObjectFromScreen(workflow); if (!workflow.Save(ref validationErrors, CurrentUser.ID)) { Master.ValidationErrors = validationErrors; } else { GoToGridPage(); } }
internal static void AddWinUserToDB(System.Security.Principal.WindowsIdentity idWindows) { var dbUser = UsersList.Find((a) => a.WindowsAccountName == idWindows.Name); var adminUser = UsersList.Find((a) => a.WindowsAccountName == "admin"); if (dbUser != null) { MessageBox.Show("The windows user " + idWindows.Name + " already exists in DB"); } else { var cloneAdminUser = UsersList.Find((a) => a.WindowsAccountName == "LANA-PC\\Lana"); dbUser = cloneAdminUser; ENTValidationErrors validationErrors = null; dbUser.Save(ref validationErrors, 0);//pass ID = 0, as it is new user } }
void Master_SaveButton_Click(object sender, EventArgs e) { var validationErrors = new ENTValidationErrors(); var state = (ENTWFStateEO)ViewState[VIEW_STATE_KEY_STATE]; LoadObjectFromScreen(state); if (!state.Save(ref validationErrors, CurrentUser.ID)) { Master.ValidationErrors = validationErrors; } else { GoToGridPage(); } }
void Master_SaveButton_Click(object sender, EventArgs e) { var validationErrors = new ENTValidationErrors(); var wfTransition = (ENTWFTransitionEO)ViewState[VIEW_STATE_KEY_TRANSITION]; LoadObjectFromScreen(wfTransition); if (!wfTransition.Save(ref validationErrors, CurrentUser.ID)) { Master.ValidationErrors = validationErrors; } else { GoToGridPage(); } }
void Master_SaveButton_Click(object sender, EventArgs e) { var validationErrors = new ENTValidationErrors(); var holiday = (HolidayEO)ViewState[VIEW_STATE_KEY_HOLIDAY]; LoadObjectFromScreen(holiday); if (!holiday.Save(ref validationErrors, CurrentUser.ID)) { Master.ValidationErrors = validationErrors; } else { GoToGridPage(); } }
void Master_SaveButton_Click(object sender, EventArgs e) { ENTValidationErrors validationErrors = new ENTValidationErrors(); ENTAuditObjectEO auditObject = (ENTAuditObjectEO)ViewState[VIEW_STATE_KEY_AUDIT_OBJECT]; LoadObjectFromScreen(auditObject); if (!auditObject.Save(ref validationErrors, CurrentUser.ID)) { Master.ValidationErrors = validationErrors; } else { GoToGridPage(); } }
void Master_SaveButton_Click(object sender, EventArgs e) { var validationErrors = new ENTValidationErrors(); var wfOwnerGroup = (ENTWFOwnerGroupEO)ViewState[VIEW_STATE_KEY_WFGROUP]; LoadObjectFromScreen(wfOwnerGroup); if (!wfOwnerGroup.Save(ref validationErrors, CurrentUser.ID)) { Master.ValidationErrors = validationErrors; } else { GoToGridPage(); } }
void Master_SaveButton_Click(object sender, EventArgs e) { var validationErrors = new ENTValidationErrors(); var notification = (ENTNotificationEO)ViewState[VIEW_STATE_KEY_NOTIFICATION]; LoadObjectFromScreen(notification); if (!notification.Save(ref validationErrors, 1)) { Master.ValidationErrors = validationErrors; } else { GoToGridPage(); } }
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."); } } }
void Master_SaveButton_Click(object sender, EventArgs e) { ENTValidationErrors validationErrors = new ENTValidationErrors(); ENTRoleEO role = (ENTRoleEO)ViewState[VIEW_STATE_KEY_ROLE]; LoadObjectFromScreen(role); if (!role.Save(ref validationErrors, CurrentUser.ID)) { Master.ValidationErrors = validationErrors; } else { //Reload the globals Globals.LoadUsers(Page.Cache); Globals.LoadRoles(Page.Cache); GoToGridPage(); } }
public ValidationErrorMessages() { ValidationErrors = new ENTValidationErrors(); }
public override bool Save(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors, int userAccountId) { if (DBAction == DBActionEnum.Save) { //Validate the object Validate(db, ref validationErrors); //Check if there were any validation errors if (validationErrors.Count == 0) { bool isNewRecord = IsNewRecord(); if (isNewRecord) { //Add ID = new PTORequestData().Insert(db, ENTUserAccountId, RequestDate, Convert.ToInt32(PTODayTypeId), Convert.ToInt32(PTORequestTypeId), userAccountId); AuditAdd(db, ref validationErrors, userAccountId); } else { //Update if (!new PTORequestData().Update(db, ID, ENTUserAccountId, RequestDate, Convert.ToInt32(PTODayTypeId), Convert.ToInt32(PTORequestTypeId), userAccountId, Version)) { UpdateFailed(ref validationErrors); if (isNewRecord) { ID = 0; } return(false); } else { AuditUpdate(db, ref validationErrors, userAccountId); } } if (base.SaveWorkflow(db, ref validationErrors, this, userAccountId)) { return(true); } else { if (isNewRecord) { ID = 0; } return(false); } } else { //Didn't pass validation. ID = 0; return(false); } } else { throw new Exception("DBAction not Save."); } }
protected override void ValidateDelete(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors) { throw new NotImplementedException(); }
protected override void Validate(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors) { //Check if this was already selected as a request. }
protected override void ValidateDelete(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors) { }
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); }