Beispiel #1
0
        /// <summary>
        /// 添加用户信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtStaffNumber.Text) && VirafiryNumber(txtStaffNumber.Text))
            {
                MessageBox.Show("请输入账号", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (string.IsNullOrEmpty(txtStaffName.Text))
            {
                MessageBox.Show("请输入名称", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (string.IsNullOrEmpty(txtStaffPassword.Text))
            {
                MessageBox.Show("请输入密码", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            User user = new User();

            user.Id       = Convert.ToInt32(txtStaffNumber.Text);
            user.Name     = txtStaffName.Text;
            user.Password = MD5Unit.ToByte(txtStaffPassword.Text);
            user.Access   = (cmbAccess.SelectedItem == "管理员权限" ? 1 : 2);
            user.Remark   = txtRemark.Text;
            if (acount.CreatAcount(user) == 1)
            {
                this.gridControlMessage.DataSource = acount.LoadUserAcount();
                MessageBox.Show("添加成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                txtStaffNumber.Clear();
                txtStaffName.Clear();
                txtStaffPassword.Clear();
                txtRemark.Clear();
            }
        }
Beispiel #2
0
        public User Login(string userName, string userPassword)
        {
            string      strSQL   = CommandFormate("SELECT * FROM [Table_User] WHERE Id = {0}id AND Password = {0}password");
            List <User> userInfo = ExcuteSelect <User>(strSQL, parmater =>
            {
                parmater.Add(parmater.CreateParameter("id", userName));
                parmater.Add(parmater.CreateParameter("password", MD5Unit.ToByte(userPassword)));
            });

            if (userInfo.Count > 0)
            {
                return(userInfo[0]);
            }
            return(null);
        }
Beispiel #3
0
        /// <summary>
        /// 修改用户信息保存修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnResize_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtPassword_Resize.Text))
            {
                MessageBox.Show("请输入密码", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            User user = new User();

            user.Id       = Convert.ToInt32(cmbStaffNumber.SelectedItem);
            user.Name     = txtName_Resize.Text;
            user.Password = MD5Unit.ToByte(txtPassword_Resize.Text);
            user.Access   = (cmbAccessOperation.SelectedItem == "管理员权限" ? 1 : 2);
            user.Remark   = txtRemark_Resize.Text;
            if (acount.ResizeAcount(user) == 1)
            {
                this.gridControlMessage.DataSource = acount.LoadUserAcount();
                MessageBox.Show("修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                txtName_Resize.Clear();
                txtPassword_Resize.Clear();
                txtRemark_Resize.Clear();
            }
        }