예제 #1
0
        //添加
        private void AddBtn_Click(object sender, EventArgs e)
        {
            string strName = textName.Text;
            string strPwd  = textPwd.Text;

            //检查用户名和密码是否为空;
            if (string.IsNullOrEmpty(strName))
            {
                MessageBox.Show("请输入用户名", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                textName.Focus();
                return;
            }
            if (string.IsNullOrEmpty(strPwd))
            {
                MessageBox.Show("请输入密码", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                textPwd.Focus();
                return;
            }
            //权限0为员工,1为管理员;
            int role = 0;

            if (rbAdmin.Checked == true)
            {
                role = 1;
            }
            try
            {
                Mouse_2017101992.User_2017101992 user_2017101992 = new Mouse_2017101992.User_2017101992(strName, strPwd, role);
                if (BLL_2017101992.UserManager.AddUser(user_2017101992))
                {
                    MessageBox.Show("添加成功");
                }
                else
                {
                    MessageBox.Show("添加失败");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("添加失败");
            }
            //MessageBox.Show(strName + "" + strPwd + "" + role);
        }
예제 #2
0
        //登录系统
        private void LoginBtn_Click(object sender, EventArgs e)
        {
            string strName = textName.Text;
            string strPwd  = textPwd.Text;

            //检查用户名或者密码是否为空
            if (string.IsNullOrEmpty(strName))
            {
                MessageBox.Show("用户名不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                textName.Focus();
                return;
            }
            if (string.IsNullOrEmpty(strPwd))
            {
                MessageBox.Show("密码不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                textPwd.Focus();
                return;
            }
            //检验是否为客户
            //if (strName == "zhangsan" && strPwd == "123")

            Mouse_2017101992.User_2017101992 user = BLL_2017101992.UserManager.GetUser(strName, strPwd);
            if (user == null)
            {
                MessageBox.Show("错误的用户名或密码", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                BLL_2017101992.RoleManager_2017101992.curUser = user;
                this.Hide();
                MainForm_2017101992 frm_2017101992 = new MainForm_2017101992();
                frm_2017101992.Show();
            }
            //BLL_2017101992.RoleManager_2017101992.curUser.Pwd = strPwd;
            //BLL_2017101992.RoleManager_2017101992.curUser.Role = 1;//管理员权限
            //MessageBox.Show("欢迎使用本系统!")
        }