예제 #1
0
        private void LoginFrm_Load(object sender, EventArgs e)
        {
            //从cookie中获取自动登陆的状态、记录账号密码的状态
            if (op.getIsLogPwd() == 1)
            {
                //填充账号密码
                DataTable cookies = op.getCookies();
                usrnameTbx.Text   = cookies.Rows[0]["username"].ToString();
                pwdTbx.Text       = cookies.Rows[0]["passwd"].ToString();
                rempwdckb.Checked = true;
            }
            if (op.getIsAuto() == 1)
            {
                autologincbx.Checked = true;
                //Thread.Sleep(500);
                //执行登陆按钮
                this.BeginInvoke(new Action(() =>
                {
                    this.Hide();
                    this.Opacity = 1;
                }));
                #if true
                //从cookie数据库中获取账号和密码
                String pwd = op.getPwdbyUname(usrnameTbx.Text);

                if (pwd != pwdTbx.Text)
                {
                    MessageBox.Show("账号密码错误,请重新输入!");
                    return;
                }
                #else
                #endif
                Form MainFrm = new MainFrm();
                MainFrm.Show();

                MainFrm.Closed += new EventHandler(this.f2_Closed);
            }
        }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //test();
            //return;

            username = usernametxt.Text;
            password = pwdtxt.Text;

            User user = null;
            user = userDB.selectUserByUserName(username);
            //MessageBox.Show(user.ToString());

            if (user == null)
            {
                MessageBox.Show("用户名不存在!", "登陆出错");
                usernametxt.Select();
                return;
            }
            if(user.PassWord!=password)
            {
                MessageBox.Show("密码错误!", "登陆出错");
                pwdtxt.Select();
                return;
            }

            MainFrm main = new MainFrm();
            main.Show();
            this.Hide();
        }