Exemple #1
0
        /// <summary>
        /// 查看密码
        /// </summary>
        /// <param name="connStr"></param>
        /// <param name="oper"></param>
        /// <param name="pwdFeildName"></param>
        /// <returns></returns>
        public string WatchPwd(string connStr, string oper, string pwdFeildName)
        {
            string bErr = string.Empty;

            using (SqlConnection scon = new SqlConnection(connStr))
            {
                SqlCommand scmd = new SqlCommand();
                scmd.Connection  = scon;
                scmd.CommandText = string.Format(@"select {0} from t_sys_operator where oper_id=@oper_id", pwdFeildName);
                scmd.Parameters.Add(new SqlParameter("@oper_id", oper));
                scon.Open();
                object oo = scmd.ExecuteScalar();
                if (oo != null)
                {
                    //pwd 解密之前要trim();
                    bErr = oo.ToString().Trim();
                    bErr = EncryptClass.Decrypt(bErr);
                }
            }

            return(bErr);
        }
Exemple #2
0
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtZMUser.Text.Trim()))
            {
                MessageBox.Show("用户名不能为空");
                return;
            }
            if (string.IsNullOrEmpty(txtZMpwd.Text.Trim()))
            {
                MessageBox.Show("密码不能为空");
                return;
            }

            try
            {
                //检查用户是否存在
                string connStr = MakeConnStr();
                if (!_operDB.CheckUser(connStr, txtZMUser.Text))
                {
                    MessageBox.Show("用户不存在");
                    return;
                }
                string newPwd = EncryptClass.Encrypt(txtZMpwd.Text.Trim());
                _operDB.EditUsrPwd(connStr, txtZMUser.Text.Trim(), _pwdFeildName, newPwd);

                //第二密码
                if (!string.IsNullOrEmpty(txt2ndPwd.Text.Trim()) && txt2ndPwd.Visible)
                {
                    string new2ndPwd = EncryptClass.Encrypt(txt2ndPwd.Text.Trim());
                    _operDB.EditUsrPwd(connStr, txtZMUser.Text.Trim(), "confirm_pw", new2ndPwd);
                }

                MessageBox.Show("修改完成");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }