//对登陆进行判断,如果用户和密码正确,进入主界面,若其中一个错误,则弹出相应错误提示
        private void button1_Click(object sender, EventArgs e)
        {
            Accessor accessor = Accessor.Instance;
            //在数据库中查询输入用户名
             IList<Users> s = accessor.GetUsersByFirstname(textBox1.Text);
            //判断数据库中用户名是否存在
             if (s.Count != 0)
                 //如果用户名存在,则判断密码是否正确
                 if (s[0].password.ToString() == textBox2.Text)
                 {
                     //密码正确,将原窗口隐藏,显示新的窗口
                     MainForm Reg = new MainForm(this.textBox1.Text);
                     this.Hide();
                     Reg.Owner = this;
                     //让新建的窗口不在任务栏显示并显示新窗口
                     Reg.ShowDialog();
                     //新建的窗口关闭后,再使原窗口可见
                     this.Show();
                 }
                 else
                 {
                     this.errorProvider1.SetError(textBox2, "输入密码错误");

                 }
             else
             {
                 this.errorProvider1.SetError(textBox1, "输入用户名不存在");
             }
        }
Exemple #2
0
        private void SignInB_Click(object sender, EventArgs e)
        {
            int f = 0;

            foreach (var user in domainData)
            {
                if (user.Login == LoginBox.Text && user.Password == PasswordBox.Text.GetHashCode())
                {
                    f = 1;
                    MainForm form = new MainForm(this.LoginBox.Text);
                    form.ShowDialog();
                    this.Hide();
                }
            }
            if (f == 0)
            {
                MessageBox.Show("Неверный логин или пароль");
            }
            else
            {
                Application.Exit();
            }
        }
Exemple #3
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            IList <ManagerUser> managerUserList = new List <ManagerUser>();
            //IManagerUserManager managerUserManager = new ManagerUserManager();    /*IManagerUserManager用于处理逻辑,界面可不使用*/
            IManagerUserStorage managerUserStorage = new ManagerUserStorage();
            QueryManagerUser    queryManagerUser   = new QueryManagerUser();

            if (txtUserName.Text.Trim() == "" || txtUserPassword.Text.Trim() == "")
            {
                MessageBox.Show("请输入用户名和密码");
            }
            else
            {
                queryManagerUser.UserID       = null; /*对应数据库中的查询存储过程*/
                queryManagerUser.UserName     = txtUserName.Text.Trim();
                queryManagerUser.UserPassword = txtUserPassword.Text.Trim();
                queryManagerUser.UserSort     = null;

                /*managerUserList = managerUserManager.GetManagerUserList(  //对应上述的managerUserManager
                 *  managerUserStorage,
                 *  queryManagerUser);*/
                managerUserList = managerUserStorage.ListManagerUser(   /*调用managerUserList,将集合(数组)取到*/
                    queryManagerUser);


                if (managerUserList.Count == 1) /*一条记录符合,跳转到主界面*/
                {
                    this.Hide();
                    MainForm mainFrom = new MainForm();
                    mainFrom.ShowDialog();
                }
                else
                {
                    MessageBox.Show("账号或密码不正确");
                }
            }
        }