protected void uvButton_Click(object sender, EventArgs e) { SRPUser user = new SRPUser((int)((SRPUser)Session[SessionData.UserProfile.ToString()]).Uid); var valid = SRPUser.VerifyPassword(user.Username, uxCPass.Text); if(!valid) { MasterPage.PageError = String.Format(SRPResources.ApplicationError1, "Your current password is invalid."); return; } user.LastPasswordReset = DateTime.Now; user.MustResetPassword = false; user.NewPassword = uxPassword.Text; try { user.ClearErrorCodes(); if(user.Update()) { Session[SessionData.UserProfile.ToString()] = user; MasterPage.PageMessage = String.Format("Password has been changed."); } else { string message = String.Format(SRPResources.ApplicationError1, "<ul>"); foreach(BusinessRulesValidationMessage m in user.ErrorCodes) { message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage); } message = string.Format("{0}</ul>", message); MasterPage.PageError = message; } } catch(Exception ex) { MasterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message); } }
protected void DvItemCommand(object sender, DetailsViewCommandEventArgs e) { string returnURL = "~/ControlRoom/Modules/Security/Default.aspx"; if(e.CommandName.ToLower() == "back") { Response.Redirect(returnURL); } if(e.CommandName.ToLower() == "refresh") { try { odsSRPUser.DataBind(); dv.DataBind(); dv.ChangeMode(DetailsViewMode.Edit); MasterPage.PageMessage = SRPResources.RefreshOK; } catch(Exception ex) { MasterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message); } } if(e.CommandName.ToLower() == "add" || e.CommandName.ToLower() == "addandback") { try { SRPUser obj = new SRPUser(); obj.Username = ((TextBox)((DetailsView)sender).FindControl("Username")).Text; obj.NewPassword = ((TextBox)((DetailsView)sender).FindControl("Password")).Text; obj.FirstName = ((TextBox)((DetailsView)sender).FindControl("FirstName")).Text; obj.LastName = ((TextBox)((DetailsView)sender).FindControl("LastName")).Text; obj.EmailAddress = ((TextBox)((DetailsView)sender).FindControl("EmailAddress")).Text; obj.Division = ((TextBox)((DetailsView)sender).FindControl("Division")).Text; obj.Department = ((TextBox)((DetailsView)sender).FindControl("Department")).Text; obj.Title = ((TextBox)((DetailsView)sender).FindControl("Title")).Text; //((TextBox)((DetailsView)sender).FindControl("Password")).Attributes["value"] = obj.Password; obj.IsActive = true; obj.MustResetPassword = true; obj.IsDeleted = false; obj.AddedDate = DateTime.Now; obj.AddedUser = ((SRPUser)Session[SessionData.UserProfile.ToString()]).Username; //"N/A"; // Get from session obj.LastModDate = obj.AddedDate; obj.LastModUser = obj.AddedUser; obj.TenID = (int)CRTenantID; if(obj.IsValid(BusinessRulesValidationMode.INSERT)) { obj.Insert(); if(e.CommandName.ToLower() == "addandback") { Response.Redirect(returnURL); } lblUID.Text = obj.Uid.ToString(); odsSRPUser.DataBind(); dv.DataBind(); dv.ChangeMode(DetailsViewMode.Edit); MasterPage.PageMessage = SRPResources.AddedOK; } else { string message = String.Format(SRPResources.ApplicationError1, "<ul>"); foreach(BusinessRulesValidationMessage m in obj.ErrorCodes) { message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage); } message = string.Format("{0}</ul>", message); MasterPage.PageError = message; } } catch(Exception ex) { MasterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message); } } if(e.CommandName.ToLower() == "save" || e.CommandName.ToLower() == "saveandback") { try { int pk = int.Parse(((DetailsView)sender).Rows[0].Cells[1].Text); SRPUser obj = new SRPUser(pk); obj.Username = ((TextBox)((DetailsView)sender).FindControl("Username")).Text; obj.FirstName = ((TextBox)((DetailsView)sender).FindControl("FirstName")).Text; obj.LastName = ((TextBox)((DetailsView)sender).FindControl("LastName")).Text; obj.EmailAddress = ((TextBox)((DetailsView)sender).FindControl("EmailAddress")).Text; obj.Division = ((TextBox)((DetailsView)sender).FindControl("Division")).Text; obj.Department = ((TextBox)((DetailsView)sender).FindControl("Department")).Text; obj.Title = ((TextBox)((DetailsView)sender).FindControl("Title")).Text; obj.IsActive = ((CheckBox)((DetailsView)sender).FindControl("IsActive")).Checked; obj.MustResetPassword = ((CheckBox)((DetailsView)sender).FindControl("MustResetPassword")).Checked; //((TextBox)((DetailsView)sender).FindControl("Password")).Attributes.Add("value", obj.Password); //obj.IsDeleted = ((TextBox)((DetailsView)sender).FindControl("IsDeleted")).Text; //obj.LastPasswordReset = ((TextBox)((DetailsView)sender).FindControl("LastPasswordReset")).Text; //obj.DeletedDate = ((TextBox)((DetailsView)sender).FindControl("DeletedDate")).Text; //obj.LastModDate = ((TextBox)((DetailsView)sender).FindControl("LastModDate")).Text; //obj.LastModUser = ((TextBox)((DetailsView)sender).FindControl("LastModUser")).Text; //obj.AddedDate = ((TextBox)((DetailsView)sender).FindControl("AddedDate")).Text; //obj.AddedUser = ((TextBox)((DetailsView)sender).FindControl("AddedUser")).Text; obj.LastModDate = DateTime.Now; obj.LastModUser = ((SRPUser)Session[SessionData.UserProfile.ToString()]).Username; //"N/A"; // Get from session if(obj.IsValid(BusinessRulesValidationMode.UPDATE)) { obj.Update(); SaveGroups((DetailsView)sender, obj); //SavePermissions((DetailsView)sender, obj); //SaveFolders((DetailsView)sender, obj); if(e.CommandName.ToLower() == "saveandback") { Response.Redirect(returnURL); } odsSRPUser.DataBind(); dv.DataBind(); dv.ChangeMode(DetailsViewMode.Edit); MasterPage.PageMessage = SRPResources.SaveOK; } else { string message = String.Format(SRPResources.ApplicationError1, "<ul>"); foreach(BusinessRulesValidationMessage m in obj.ErrorCodes) { message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage); } message = string.Format("{0}</ul>", message); MasterPage.PageError = message; } } catch(Exception ex) { MasterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message); } } if(e.CommandName.ToLower() == "loginhistory") { int key = Convert.ToInt32(lblUID.Text); Session["UID"] = key; Response.Redirect("~/ControlRoom/Modules/Security/LoginHistory.aspx"); //Response.Redirect(String.Format("{0}?UID={1}", "~/ControlRoom/Modules/Security/LoginHistory.aspx", key)); } //if (e.CommandName.ToLower() == "audituser") //{ // int key = Convert.ToInt32(lblUID.Text); // Response.Redirect(String.Format("{0}?UID={1}", "~/ControlRoom/Modules/Security/UserAudit.aspx", key)); //} }
protected void DvItemCommand(object sender, DetailsViewCommandEventArgs e) { string returnURL = "~/ControlRoom/"; if (e.CommandName.ToLower() == "back") { Response.Redirect(returnURL); } if (e.CommandName.ToLower() == "password") { Response.Redirect("~/ControlRoom/Modules/PortalUser/PasswordReset.aspx"); } if (e.CommandName.ToLower() == "refresh") { try { odsCMSUser.DataBind(); dv.DataBind(); dv.ChangeMode(DetailsViewMode.Edit); //ICMSMasterPage masterPage = (ICMSMasterPage)Master; //masterPage. PageMessage = SRPResources.RefreshOK; } catch (Exception ex) { //ICMSMasterPage masterPage = (ICMSMasterPage)Master; //masterPage. PageError = String.Format(SRPResources.ApplicationError1, ex.Message); } } if (e.CommandName.ToLower() == "save" || e.CommandName.ToLower() == "saveandback") { try { SRPUser updateSrpUser = new SRPUser(); int pk = (int)SRPUser.Uid; updateSrpUser = SRPUser.Fetch(pk); updateSrpUser.FirstName = ((TextBox)((DetailsView)sender).FindControl("FirstName")).Text; updateSrpUser.LastName = ((TextBox)((DetailsView)sender).FindControl("Lastname")).Text; updateSrpUser.LastName = ((TextBox)((DetailsView)sender).FindControl("Lastname")).Text; updateSrpUser.EmailAddress = ((TextBox)((DetailsView)sender).FindControl("Emailaddress")).Text; updateSrpUser.Title = ((TextBox)((DetailsView)sender).FindControl("Title")).Text; updateSrpUser.Department = ((TextBox)((DetailsView)sender).FindControl("Department")).Text; updateSrpUser.Division = ((TextBox)((DetailsView)sender).FindControl("Division")).Text; updateSrpUser.LastModDate = DateTime.Now; updateSrpUser.LastModUser = "******"; // Get from session string signature = ((TextBox)((DetailsView)sender).FindControl("MailSignature")).Text; if(!string.IsNullOrWhiteSpace(signature.Trim())) { updateSrpUser.MailSignature = signature.Trim(); } if (updateSrpUser.IsValid(BusinessRulesValidationMode.UPDATE)) { updateSrpUser.Update(); SRPUser = updateSrpUser; Session[SessionData.UserProfile.ToString()] = updateSrpUser; if (e.CommandName.ToLower() == "saveandback") { Response.Redirect(returnURL); } odsCMSUser.DataBind(); dv.DataBind(); dv.ChangeMode(DetailsViewMode.Edit); //ICMSMasterPage masterPage = (ICMSMasterPage)Master; //masterPage. PageMessage = SRPResources.SaveOK; } else { //ICMSMasterPage masterPage = (ICMSMasterPage)Master; string message = String.Format(SRPResources.ApplicationError1, "<ul>"); foreach (BusinessRulesValidationMessage m in updateSrpUser.ErrorCodes) { message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage); } message = string.Format("{0}</ul>", message); //masterPage. PageError = message; } } catch (Exception ex) { //ICMSMasterPage masterPage = (ICMSMasterPage)Master; //masterPage. PageError = String.Format(SRPResources.ApplicationError1, ex.Message); } } }