Ejemplo n.º 1
0
        /// <summary>
        /// 登录验证
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_登录_Click(object sender, EventArgs e)
        {
            if (pwdnum < 2)
            {
                if (textBox_用户名.Text != "" && textBox_密码.Text != "")
                {
                    #region 查询并验证
                    ManagerInfoBll MIBll = new ManagerInfoBll();
                    int            type;
                    int            num = MIBll.GetRowInfo(textBox_用户名.Text, textBox_密码.Text, out type);
                    switch (num)
                    {
                    case 0:
                        MessageBox.Show("账号不正确,请确认账号后再重新输入");
                        break;

                    case 1:
                        //这里设置登录窗口隐藏,打开新的窗体
                        主界面 fm = new 主界面();
                        fm.Tag = type;
                        fm.Show();
                        this.Hide();
                        break;

                    case 2:
                        MessageBox.Show("密码错误");
                        label_密码错误提示.Text = string.Format("密码错误,还剩余{0}次", (2 - pwdnum));
                        pwdnum            = pwdnum + 1;
                        break;
                    }
                    ;
                    #endregion
                }
                else
                {
                    MessageBox.Show("用户名和密码不能为空");
                }
            }
            else
            {
                MessageBox.Show("错误次数太多,程序关闭");
                Application.Exit();
            }
        }