Exemple #1
0
        private void BtnAddUser_Click(object sender, EventArgs e)
        {
            AuthUserManage authUserManage = new AuthUserManage(null, this._rcUser.Authority);

            while (authUserManage.ShowDialog() == DialogResult.OK)
            {
                if (!(authUserManage.TBoxPassword.Text != authUserManage.TBoxRePassword.Text))
                {
                    string    text      = authUserManage.TBoxID.Text;
                    Authority authority = (Authority)Enum.Parse(typeof(Authority), authUserManage.CBoxAuthLevel.Text);
                    foreach (object obj in this.LViewUsers.Items)
                    {
                        ListViewItem listViewItem = (ListViewItem)obj;
                        if (listViewItem.SubItems[0].Text == text)
                        {
                            Utility.ShowErrorMessage(LocalizeText.Get(181));
                            return;
                        }
                    }
                    this._rcUser.RegisterUser(text, Utility.GetHashedPassword(authUserManage.TBoxPassword.Text), authority);
                    this.AddMember(text, authority);
                    break;
                }
                Utility.ShowErrorMessage(LocalizeText.Get(180));
            }
        }
Exemple #2
0
        private void BtnChangeUser_Click(object sender, EventArgs e)
        {
            string    text      = this.LViewUsers.SelectedItems[0].SubItems[0].Text;
            Authority authority = (Authority)Enum.Parse(typeof(Authority), this.LViewUsers.SelectedItems[0].SubItems[1].Text);

            if (text == this._rcUser.ID)
            {
                Utility.ShowErrorMessage(LocalizeText.Get(183));
                return;
            }
            AuthUserManage authUserManage = new AuthUserManage(text, this._rcUser.Authority);

            while (authUserManage.ShowDialog() == DialogResult.OK)
            {
                if (authUserManage.TBoxPassword.Text != authUserManage.TBoxRePassword.Text)
                {
                    Utility.ShowErrorMessage(LocalizeText.Get(184));
                }
                else
                {
                    if (authUserManage.TBoxPassword.Text.Length > 0)
                    {
                        this._rcUser.ChangeOtherPassword(text, Utility.GetHashedPassword(authUserManage.TBoxPassword.Text));
                    }
                    if (authUserManage.CBoxAuthLevel.SelectedIndex != -1)
                    {
                        Authority authority2 = (Authority)Enum.Parse(typeof(Authority), authUserManage.CBoxAuthLevel.Text);
                        this._rcUser.ModifyUser(text, authority2);
                        this.LViewUsers.Items.RemoveAt(this.LViewUsers.SelectedIndices[0]);
                        this.AddMember(text, authority2);
                        break;
                    }
                    break;
                }
            }
        }