Пример #1
0
        private void btUpdateUserInfo_Click(object sender, EventArgs e)
        {
            CtbUserInformation cUser = new CtbUserInformation();

            if (dgvUserList.CurrentRow != null)
            {
                cUser.userName    = dgvUserList.CurrentRow.Cells["userName"].Value.ToString();
                cUser.userPwd     = dgvUserList.CurrentRow.Cells["userPwd"].Value.ToString();
                cUser.userAllName = dgvUserList.CurrentRow.Cells["userAllName"].Value.ToString();
                cUser.userSort    = dgvUserList.CurrentRow.Cells["userSort"].Value.ToString();
                cUser.userPurview = dgvUserList.CurrentRow.Cells["userPurview"].Value.ToString();

                frmUserAddUpdate frmUpdate = new frmUserAddUpdate(cUser);
                frmUpdate.MdiParent = this.MdiParent;
                frmUpdate.Show();
            }
            else
            {
                MessageBox.Show("请选中要修改的信息!", "操作提示");
            }
        }
Пример #2
0
        //重载构造函数
        public frmUserAddUpdate(CtbUserInformation _cUser)
        {
            InitializeComponent();

            //----------修改用户信息------------
            this.Text    = "修改用户信息";
            btEnter.Text = "保存";

            cUser = _cUser;//接收传过来的用户信息

            //----以下提取用户信息进行控件赋值-----
            charPurview = cUser.userPurview.ToCharArray();

            //----组别赋值---
            foreach (Control x in groupBox3.Controls)
            {
                RadioButton ra = (RadioButton)x;
                if (ra.Text == cUser.userSort)
                {
                    ra.Checked = true;
                }
            }

            //----权限控件赋值----
            foreach (Control y in groupBox2.Controls)
            {
                CheckBox ca = (CheckBox)y;
                ca.Checked = CCharToBool.CharToBool(charPurview[int.Parse(ca.Tag.ToString())]);
            }

            //----基本信息赋值----
            tbUserName.Text    = cUser.userName;
            tbUserPwd.Text     = cUser.userPwd;
            tbUserAllName.Text = cUser.userAllName;


            tbUserName.ReadOnly = true;
        }
Пример #3
0
 private void btOK_Click(object sender, EventArgs e)
 {
     if (tbUserName.Text != "" && tbUserPwd.Text != "")
     {
         CtbUserInformationBLL Cuser = new CtbUserInformationBLL();
         if (Cuser.Exists(tbUserName.Text, tbUserPwd.Text, cbUserSort.Text))
         {
             MessageBox.Show("用户登录成功!");
             CtbUserInformation cUser = new CtbUserInformation();
             cUser               = Cuser.GetModel(tbUserName.Text);
             Session.UserName    = cUser.userName;
             Session.UserPwd     = cUser.userPwd;
             Session.UserAllName = cUser.userAllName;
             Session.UserPurview = cUser.userPurview;
             Session.UserRole    = cUser.userSort;
             this.Close();
         }
         else
         {
             MessageBox.Show("不存在此用户或用户名密码错!");
         }
     }
 }
Пример #4
0
        //按钮事件
        private void btEnter_Click(object sender, EventArgs e)
        {
            CtbUserInformationBLL userBll = new CtbUserInformationBLL();

            #region 操作代码
            if (tbUserName.Text != "" && tbUserPwd.Text != "" && tbPwdAgain.Text != "" && tbUserAllName.Text != "")
            {
                if (btEnter.Text == "添加")
                {
                    if (userBll.Exists(tbUserName.Text))
                    {
                        MessageBox.Show("已经存在的用户名!", "操作提示");
                        return;
                    }
                }
                if (!tbPwdAgain.Text.Equals(tbUserPwd.Text))
                {
                    MessageBox.Show("两次密码输入不一致!", "操作提示");
                    return;
                }

                userName    = tbUserName.Text;    //取用户名
                userPwd     = tbUserPwd.Text;     //取密码
                userAllName = tbUserAllName.Text; //取全称

                //--------取组别--------------
                foreach (Control x in groupBox3.Controls)
                {
                    RadioButton ra = (RadioButton)x;
                    if (ra.Checked)
                    {
                        userSort = ra.Text;
                    }
                }
                //----------------------------



                #region     //------取权限----------------
                foreach (Control y in groupBox2.Controls)
                {
                    CheckBox ca    = (CheckBox)y;
                    int      index = int.Parse(ca.Tag.ToString());           //获取字符串中位置

                    charPurview[index] = CBoolToChar.BoolToChar(ca.Checked); //设置权限
                }

                userPurview = new string(charPurview);    //取得权限


                #endregion ----------分割线--------------


                cUser             = new CtbUserInformation();
                cUser.userName    = userName;
                cUser.userPwd     = userPwd;
                cUser.userPurview = userPurview;
                cUser.userAllName = userAllName;
                cUser.userSort    = userSort;

                if (btEnter.Text == "添加")
                {
                    userBll.Add(cUser);

                    MessageBox.Show("添加成功!", "操作成功");
                }
                if (btEnter.Text == "保存")
                {
                    userBll.Update(cUser);

                    MessageBox.Show("修改成功!", "操作成功");
                }
            }
            else
            {
                MessageBox.Show("请讲基本信息填写完整!", "操作提示");
            }
            #endregion
        }