Exemplo n.º 1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            Facade.LoginUsers user     = new Facade.LoginUsers();
            string            username = txtUserName.Text.Trim(); //获取界面输入的用户名
            string            password = txtPassword.Text.Trim(); //获取界面输入的密码

            Entity.GoAnyWhere.id = username;                      // 将登陆id赋值给全局变量
            Entity.Login users = new Entity.Login();
            users.username = username;
            users.password = password;

            if (username == "") //判断用户名是否为空
            {
                MessageBox.Show("请输入用户名!", "温馨提示");
            }
            else if (password == "") //判断密码是否为空
            {
                MessageBox.Show("请输入密码!", "温馨提示");
            }
            else
            {
                bool result = user.username(username);
                if (result == false) //判断用户是否存在
                {
                    MessageBox.Show("您输入的用户名不存在!", "温馨提示");
                }
                else
                {
                    //判断密码是否正确
                    Facade.LoginUsers pwd     = new Facade.LoginUsers();
                    string            result2 = pwd.password(users);
                    if (result2 == Convert.ToString(false))
                    {
                        MessageBox.Show("密码错误,请重新输入!", "温馨提示");
                    }
                    //判断是否允许登录
                    else if (result2.Trim() == "禁止登录")
                    {
                        MessageBox.Show("非法用户,请到前台开户!", "温馨提示");
                    }
                    else
                    {
                        //判断用户的类型
                        string result3 = user.userlevel(username);
                        Entity.GoAnyWhere.level = result3;
                        this.DialogResult       = DialogResult.OK; //上面的执行成功则显示主窗体
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void btnOk_Click(object sender, EventArgs e)  //单击确定按钮
        {
            Entity.Login user = new Entity.Login();
            user.username = txtUserName.Text.Trim();
            user.password = txtPassword.Text.Trim();
            user.level    = "收银员";
            user.status   = "允许登录";
            //判断用户是否已经存在
            Facade.LoginUsers fuser = new Facade.LoginUsers();
            bool result             = fuser.username(user.username);

            if (result == true) //判断用户是否存在
            {
                MessageBox.Show("您输入的用户名已存在!", "温馨提示");
            }
            else
            {
                int result2 = fuser.addusers(user);
                if (result2 > 0)
                {
                    MessageBox.Show("添加用户成功!", "温馨提示");
                }
            }
        }