Пример #1
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            db_users modeluser = new db_users();

            if (new db_users().Exists(publicModel.username, "duanruo") || new db_users().Exists(publicModel.username, DESEncrypt.Encrypt(txtOldPwd.Text.Trim())))
            {
                new db_users().UpdateNewsField(publicModel.username, " userPwd='" + DESEncrypt.Encrypt(txtNewPwd.Text.Trim()) + "'");
                MessageBox.Show("密码修改成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                Close();
            }
            else
            {
                MessageBox.Show("旧密码不正确!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Пример #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string username = txtUserName.Text.Trim();
            string userpwd  = txtPwd.Text.Trim();

            if (string.IsNullOrEmpty(username))
            {
                MessageBox.Show("请输入用户名!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtUserName.Focus();
            }
            else if (string.IsNullOrEmpty(userpwd))
            {
                MessageBox.Show("请输入密码!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtPwd.Focus();
            }
            else
            {
                db_users userModel = new db_users();
                string   pwd       = DESEncrypt.Encrypt(userpwd);
                //上下午设置
                string am = "";
                string pm = "";
                if (rbtn_am.Checked)
                {
                    am = rbtn_am.Text;
                }
                if (rbtn_pm.Checked)
                {
                    pm = rbtn_pm.Text;
                }

                if (userModel.Exists(username, pwd))
                //if (true)
                {
                    publicModel.am_pm    = am + pm;
                    publicModel.username = txtUserName.Text.Trim();
                    DialogResult         = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("用户名密码错误!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtUserName.Focus();
                }
            }
        }