Esempio n. 1
0
        /// <summary>
        /// 自定义登陆
        /// </summary>
        private void LoGIin()
        {
            //TODO
            bool isEmpty = UserInputCheck();

            if (isEmpty == true)
            {
                HY_Model.User u = new User();
                u.UserName = this.userName.Text.Trim();
                u.PassWord = this.passWord.Text.Trim();

                HY_BLL.HY_setbll hyset = new HY_setbll();
                DataTable        dt    = hyset.userAuthentication(u);
                if (dt.Rows.Count > 0)
                {
                    if (int.Parse(dt.Rows[0]["h_Status"].ToString()) > 0)
                    {
                        string user = this.userName.Text.Trim();
                        if (!this.userName.AutoCompleteCustomSource.Contains(user))
                        {
                            this.userName.AutoCompleteCustomSource.Add(user);
                        }
                        MianForm mf = new MianForm();
                        mf.UserName = this.userName.Text.Trim();
                        mf.Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBoxEx.Show("此账户已被锁定暂无法登录!", "登陆提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        this.userName.Text = "";
                        this.passWord.Text = "";
                        this.userName.Focus();
                    }
                }
                else
                {
                    MessageBoxEx.Show("登陆失败:用户名或密码错误,请重新输入!", "登陆提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.userName.Text = "";
                    this.passWord.Text = "";
                    this.userName.Focus();
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 保存(包括新增用户、修改用户保存)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolStripSave_Click(object sender, EventArgs e)
        {  //TODO:添加
            if (this.h_UserName.Text.Trim() == string.Empty || this.h_UserPwd.Text.Trim() == string.Empty)
            {
                MessageBox.Show("用户名或密码不能为空!");
                this.h_UserName.Focus();
                return;
            }
            else if (this.h_UserPwd.Text.Length < 6)
            {
                MessageBox.Show("账户密码不能小于6位数字!");
                this.h_UserPwd.Focus();
                return;
            }
            HY_Model.User u = new User();  //给USER表实体类赋值
            u.UserName = this.h_UserName.Text.Trim();
            u.PassWord = this.h_UserPwd.Text.Trim();

            if (this.h_Status.Checked)
            {
                u.UserStatus = 1;
            }
            if (this.toolStripEdit.Enabled == false)//添加帐户数据判断
            {
                HY_BLL.HY_setbll hyset = new HY_setbll();
                int res = hyset.userOperation(u);
                if (res > 0)
                {
                    MessageBox.Show("系统用户添加成功!");
                    dgv_User();
                }
            }
            else if (this.toolStripAdd.Enabled == false)//修改帐户数据判断
            {
                int rowIndex           = int.Parse(this.dataGridView_user.SelectedRows[0].Cells[0].Value.ToString());
                HY_BLL.HY_setbll hyset = new HY_setbll();
                int res = hyset.userOperationUpdate(u, rowIndex);
                if (res > 0)
                {
                    MessageBox.Show("用户帐号修改成功!");
                    dgv_User();
                }
            }
        }