protected void Page_Load(object sender, EventArgs e) { MasterPage.IsSecure = false; MasterPage.PageTitle = "Summer Reading Program - Add / Edit User"; ControlRoomAccessPermission.CheckControlRoomAccessPermission(1000); // Change Appropriately; if (!IsPostBack) { List <RibbonPanel> moduleRibbonPanels = StandardModuleRibbons.SecurityRibbon(); foreach (var moduleRibbonPanel in moduleRibbonPanels) { MasterPage.PageRibbon.Add(moduleRibbonPanel); } MasterPage.PageRibbon.DataBind(); object userIdObject = Session["UID"]; int userId = 0; if (userIdObject == null || !int.TryParse(userIdObject.ToString(), out userId) || userId == 0) { Response.Redirect("Default.aspx"); } SRPUser user = SRPUser.Fetch(userId); this.Username.Text = user.Username; } Error.Visible = !string.IsNullOrEmpty(Error.Text); }
private SRPUser GetUser(string userIdString) { if (!string.IsNullOrWhiteSpace(userIdString)) { int userId = 0; if (int.TryParse(userIdString, out userId)) { return(SRPUser.Fetch(userId)); } } return(null); }
protected void ResetPassword_Click(object sender, EventArgs e) { Error.Text = string.Empty; object userIdObject = Session["UID"]; int userId = 0; if (userIdObject == null || !int.TryParse(userIdObject.ToString(), out userId) || userId == 0) { Response.Redirect("Default.aspx"); } SRPUser user = SRPUser.Fetch(userId); user.NewPassword = uxPassword.Text; try { user.Update(); SRPUser currentUser = Session[SessionData.UserProfile.ToString()] as SRPUser; var changeInfo = new { Changer = currentUser == null ? "unknown" : currentUser.Username, User = user.Username }; this.Log().Info("Admin user {0} changed password for user {1}", changeInfo.Changer, changeInfo.User); } catch (Exception ex) { this.Log().Error("Admin user unable to change password for user {0}: {1}", userId, ex.Message); Error.Text = string.Format("An error occurred: {0}", ex.Message); } Response.Redirect("UserAddEdit.aspx"); }
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 obj = new SRPUser(); int pk = (int)SRPUser.Uid; obj = SRPUser.Fetch(pk); obj.FirstName = ((TextBox)((DetailsView)sender).FindControl("FirstName")).Text; obj.LastName = ((TextBox)((DetailsView)sender).FindControl("Lastname")).Text; obj.LastName = ((TextBox)((DetailsView)sender).FindControl("Lastname")).Text; obj.EmailAddress = ((TextBox)((DetailsView)sender).FindControl("Emailaddress")).Text; obj.Title = ((TextBox)((DetailsView)sender).FindControl("Title")).Text; obj.Department = ((TextBox)((DetailsView)sender).FindControl("Department")).Text; obj.Division = ((TextBox)((DetailsView)sender).FindControl("Division")).Text; obj.LastModDate = DateTime.Now; obj.LastModUser = "******"; // Get from session if (obj.IsValid(BusinessRulesValidationMode.UPDATE)) { obj.Update(); SRPUser = obj; Session[SessionData.UserProfile.ToString()] = obj; 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 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) { //ICMSMasterPage masterPage = (ICMSMasterPage)Master; //masterPage. PageError = String.Format(SRPResources.ApplicationError1, ex.Message); } } }