protected void Page_PreRender(object sender, EventArgs e)
        {
            Master.PageTitle  = UsersStrings.GetText(@"UsersPageTitle");
            Master.ActiveMenu = "Users";

            Master.AddClientScriptInclude(@"dgDateManager.js");
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            HasEditPermission = Permissions.PermissionsForUser(SessionHelper.UserId()).Contains(Permissions.PermissionKeys.sys_perm);

            Master.AddButtonNew(UsersStrings.GetText(@"NewUserButton"), @"EditUser.aspx?New=yes", new string[] { Permissions.PermissionKeys.sys_perm });

            dgUsers.PageIndexChanged += dgUsers_PageIndexChanging;
        }
Exemple #3
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            Master.PageTitle  = UsersStrings.GetText(IsNewMode ? @"NewUserPageTitle" : @"EditUserPageTitle");
            Master.ActiveMenu = IsNewMode ? "NewUser" : "Users";

            trCurrentPassword.Visible          = !IsNewMode && UserId == SessionHelper.UserId();
            rfvPasswordRequired.Visible        = rfvPasswordRequired.Enabled = IsNewMode;
            rfvConfirmPasswordRequired.Visible = rfvConfirmPasswordRequired.Enabled = IsNewMode;
        }
Exemple #4
0
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         core.DAL.User.Delete(UserId);
         Master.MessageCenter.DisplaySuccessMessage(UsersStrings.GetText(@"MessageUserDeleted"));
         lblDeleteConfirm.Visible = false;
         chkDeleteConfirm.Visible = false;
         btnDelete.Visible        = false;
     }
 }
        protected void LoadItems()
        {
            if (!HasEditPermission)
            {
                dgUsers.Columns[dgUsers.Columns.Count - 1].Visible = false;
            }

            Query qry = new Query(core.DAL.User.TableSchema);

            bool isSearchActive;

            if (!bool.TryParse(hfIsSearchActive.Value, out isSearchActive))
            {
                isSearchActive = false;
            }
            if (isSearchActive)
            {
                string searchString = "%" + txtSearch.Text.Trim() + "%";
                qry.Where(core.DAL.User.Columns.Email, WhereComparision.Like, searchString);
            }

            dgUsers.VirtualItemCount = (int)qry.GetCount(core.DAL.User.Columns.UserId);
            if (dgUsers.VirtualItemCount == 0)
            {
                phHasItems.Visible   = false;
                phHasNoItems.Visible = true;
                lblNoItems.Text      = isSearchActive ? UsersStrings.GetText(@"MessageNoUsersFound") : UsersStrings.GetText(@"MessageNoDataHere");
            }
            else
            {
                phHasItems.Visible   = true;
                phHasNoItems.Visible = false;

                qry.OrderBy(core.DAL.User.Columns.Email, dg.Sql.SortDirection.ASC);

                if (dgUsers.PageSize * dgUsers.CurrentPageIndex > dgUsers.VirtualItemCount)
                {
                    dgUsers.CurrentPageIndex         = 0;
                    hfCurrentPageIndex_dgUsers.Value = dgUsers.CurrentPageIndex.ToString();
                }
                qry.LimitRows(dgUsers.PageSize).OffsetRows(dgUsers.PageSize * dgUsers.CurrentPageIndex);

                UserCollection items = UserCollection.FetchByQuery(qry);

                BindList(items);
            }
        }
Exemple #6
0
 protected void Page_Init(object sender, EventArgs e)
 {
     Master.AddButtonNew(UsersStrings.GetText(@"NewUserButton"), @"EditUser.aspx?New=yes", new string[] { Permissions.PermissionKeys.sys_perm });
 }
Exemple #7
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }

            string UserEmail    = null;
            bool   EmailChanged = false;

            if (IsNewMode)
            {
                User user = null;
                Membership.UserCreateResults results = Membership.CreateUser(txtEmail.Text, txtPassword.Text.Trim(), out user);
                switch (results)
                {
                default:
                case Membership.UserCreateResults.UnknownError:
                    Master.MessageCenter.DisplayErrorMessage(UsersStrings.GetText(@"MessageCreateFailedUnknown"));
                    return;

                case Membership.UserCreateResults.AlreadyExists:
                    Master.MessageCenter.DisplayErrorMessage(UsersStrings.GetText(@"MessageCreateFailedAlreadyExists"));
                    return;

                case Membership.UserCreateResults.InvalidEmailAddress:
                    Master.MessageCenter.DisplayErrorMessage(UsersStrings.GetText(@"MessageCreateFailedEmailAddressInvalid"));
                    return;

                case Membership.UserCreateResults.Success:
                    break;
                }
                if (chkIsLocked.Checked != user.IsLocked)
                {
                    user.IsLocked = chkIsLocked.Checked;
                    user.Save();
                }
                UserId    = user.UserId;
                UserEmail = user.Email;
            }
            else
            {
                User user = core.DAL.User.FetchByID(UserId);
                UserEmail = user.UniqueEmail;

                if (user.UniqueEmail != txtEmail.Text.NormalizeEmail() ||
                    user.IsLocked != chkIsLocked.Checked)
                {
                    try
                    {
                        user.Email       = txtEmail.Text.Trim();
                        user.UniqueEmail = user.Email.NormalizeEmail();
                        user.IsLocked    = chkIsLocked.Checked;
                        user.Save();
                        if (user.UniqueEmail != UserEmail)
                        {
                            UserEmail    = user.Email;
                            EmailChanged = true;
                        }
                    }
                    catch
                    {
                        Master.MessageCenter.DisplayWarningMessage(UsersStrings.GetText(@"MessageEmailChangeFailed"));
                    }
                }

                if (txtPassword.Text.Length > 0)
                {
                    Membership.UserPasswordChangeResults results;
                    if (UserId == SessionHelper.UserId())
                    {
                        results = Membership.ChangeUserPassword(user.Email, txtCurrentPassword.Text, txtPassword.Text);
                    }
                    else
                    {
                        results = Membership.ChangeUserPassword(user.Email, txtPassword.Text);
                    }
                    switch (results)
                    {
                    default:
                        Master.MessageCenter.DisplayWarningMessage(UsersStrings.GetText(@"MessagePasswordChangeFailedUnknown"));
                        break;

                    case Membership.UserPasswordChangeResults.PasswordDoNotMatch:
                        Master.MessageCenter.DisplayWarningMessage(UsersStrings.GetText(@"MessagePasswordChangeBadOldPassword"));
                        break;

                    case Membership.UserPasswordChangeResults.Success:
                        break;
                    }
                }
                UserEmail = user.Email;
            }

            if (IsNewMode)
            {
                string successMessage = UsersStrings.GetText(@"MessageUserCreated");
                string url            = @"EditUser.aspx?Email=" + UserEmail;
                url += @"&message-success=" + Server.UrlEncode(successMessage);
                Response.Redirect(url, true);
            }
            else
            {
                string successMessage = UsersStrings.GetText(@"MessageUserSaved");
                if (EmailChanged)
                {
                    string url = @"EditUser.aspx?message-success=" + Server.UrlEncode(successMessage);
                    if (UserId != SessionHelper.UserId())
                    {
                        url += @"&Email=" + UserEmail;
                    }
                    Response.Redirect(url, true);
                }
                else
                {
                    Master.MessageCenter.DisplaySuccessMessage(successMessage);
                }
            }
        }
Exemple #8
0
 public string PermissionDescription(object permission)
 {
     return(UsersStrings.GetText(@"Perm_" + permission.ToString()));
 }
Exemple #9
0
 protected void Page_PreRender(object sender, EventArgs e)
 {
     Master.PageTitleHtml = string.Format(UsersStrings.GetText(@"DeleteUserPageTitle"), UserName);
     Master.ActiveMenu    = "Users";
 }