示例#1
0
        private void butjiesuo_Click(object sender, EventArgs e)
        {
            string password = txtpwd.Text;

            if (txtpwd.Text == "")
            {
                MessageBox.Show("密码输入不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                //密码处理,经过加密
                byte[] result = Encoding.Default.GetBytes(password);//password为输入密码的文本框
                MD5    md5    = new MD5CryptoServiceProvider();
                byte[] output = md5.ComputeHash(result);

                BU_UserInfo bll = new BU_UserInfo();
                DataSet     ds  = bll.ExistsPwd(lbuser.Text.Trim(), BitConverter.ToString(output).Replace("-", ""));

                if (ds.Tables[0].Rows.Count > 0)
                {
                    MessageBox.Show("解锁成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("密码输入错误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
        }
示例#2
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            string username = this.txt_username.Text;

            string password = this.txt_Pwd.Text;

            if (username == "")
            {
                MessageBox.Show("用户名不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else if (password == "")
            {
                MessageBox.Show("密码不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }

            else if (this.textBox1.Text.Trim() == "")
            {
                MessageBox.Show("验证码不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                if (checkCode.ToLower() != this.textBox1.Text.Trim().ToLower())
                {
                    MessageBox.Show("验证码输入错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    BU_UserInfo Bll = new BU_UserInfo();
                    int         a   = Bll.ExistsName(username);
                    if (a != 0)
                    {
                        //密码处理,经过加密
                        byte[]  result = Encoding.Default.GetBytes(password);//password为输入密码的文本框
                        MD5     md5    = new MD5CryptoServiceProvider();
                        byte[]  output = md5.ComputeHash(result);
                        DataSet ds     = Bll.ExistsPwd(username, BitConverter.ToString(output).Replace("-", ""));
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            LoginRoler.U_Id        = Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString()); //用户主键
                            LoginRoler.U_Name      = username;                                            //获取当前登录的用户名
                            LoginRoler.U_ROlesType = Convert.ToInt32(ds.Tables[0].Rows[0][1].ToString()); //用户类型
                            LoginRoler.U_DpaType   = Convert.ToInt32(ds.Tables[0].Rows[0][2].ToString()); //
                            LoginRoler.U_Position  = ds.Tables[0].Rows[0][3].ToString();                  //
                            this.Visible           = false;
                            checkCode = "";
                            Frm登陆成功显示进度 frm = new Frm登陆成功显示进度();
                            frm.ShowDialog();
                        }
                        else
                        {
                            MessageBox.Show("密码输入错误,请重新输入密码", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            this.txt_Pwd.Text      = "";
                            this.txt_username.Text = "";
                            this.textBox1.Text     = "";
                            pictureBox2_Click(sender, e);//调用刷新验证码方法
                        }
                    }
                    else
                    {
                        MessageBox.Show("用户名不存在,请重新输入用户名", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        this.txt_Pwd.Text      = "";
                        this.txt_username.Text = "";
                        this.textBox1.Text     = "";
                        pictureBox2_Click(sender, e);//调用刷新验证码方法
                    }
                }
            }
        }