private void button1_Click(object sender, EventArgs e)
        {
            string userName = txtUserName.Text.Trim();
            string password = txtUserPassword.Text.Trim();

            if (userName == "" || password == "")
            {
                MessageBox.Show("用户名或密码不能为空!");
                txtUserName.Focus();
                return;
            }
            else
            {
                BLL.User user = new BLL.User();
                if (user.Login(userName, password))
                {
                    UserHelper.Recorder = user.GetName(userName, password, "Recorder");
                    UserHelper.userName = txtUserName.Text.Trim();
                    UserHelper.password = txtUserPassword.Text.Trim();
                    this.Hide();
                    MainForm f = new MainForm();
                    f.Show();
                }
                else
                {
                    MessageBox.Show("用户名或密码错误,请重新输入!", "错误");
                    txtUserName.Text     = "";
                    txtUserPassword.Text = "";
                    txtUserName.Focus();
                }
            }
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //测试验证信息
            string userName = textBox1.Text.Trim();
            string password = textBox2.Text.Trim();

            if (userName == "" || password == "")
            {
                MessageBox.Show("用户名或密码不能为空!");
                textBox1.Focus();
                return;
            }
            else
            {
                BLL.User user = new BLL.User();
                if (user.Login(userName, password))
                {
                    UserHelper.userName = textBox1.Text.Trim();
                    UserHelper.password = textBox2.Text.Trim();
                    FormMain f = new FormMain(userName);
                    f.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("用户名或密码错误,请重新输入!", "错误");
                    textBox1.Text = "";
                    textBox2.Text = "";
                    textBox1.Focus();
                }
            }
        }