Ejemplo n.º 1
0
        //口令修改
        private void ToolStripMenuItem_PasswordModify_Click(object sender, EventArgs e)
        {
            if (this.currentUser != null)
            {
                FormPswModify fpm = new FormPswModify(this.currentUser.UserName, this.currentUser.PassWord);
                if (fpm.ShowDialog() == DialogResult.OK)
                {
                    string newPsw = fpm.newPsw;
                    this.currentUser.PassWord = newPsw;

                    for (int i = 0; i < UserManager.UserList.Count; i++)
                    {
                        if (UserManager.UserList[i].UserName.Equals(this.currentUser.UserName))
                        {
                            UserManager.UserList[i].PassWord = newPsw;
                            break;
                        }
                    }


                    if (UserManager.SaveUserListToFile())
                    {
                        MessageBox.Show("\n                口令修改成功             \n");
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 口令修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PasswordModify_Click(object sender, EventArgs e)
        {
            if (this.currentUser != null)
            {
                FormPswModify fpm = new FormPswModify(this.currentUser.UserName, this.currentUser.PassWord); //打开密码修改菜单
                if (fpm.ShowDialog() == DialogResult.OK)                                                     //如果返回的窗体结果为OK
                {
                    string newPsw = fpm.newPsw;
                    this.currentUser.PassWord = newPsw;                                         //获取设置的新密码

                    for (int i = 0; i < UserManager.UserList.Count; i++)                        //对用户列表里的所有用户进行遍历
                    {
                        if (UserManager.UserList[i].UserName.Equals(this.currentUser.UserName)) //抓取当前要改密码的用户名
                        {
                            UserManager.UserList[i].PassWord = newPsw;                          //将抓取到的用户名的密码改为新密码
                            break;
                        }
                    }

                    //修改成功后显示提示
                    if (UserManager.SaveUserListToFile())
                    {
                        MessageBox.Show("\n                口令修改成功             \n");
                    }
                }
            }
        }