Esempio n. 1
0
        public frmMain(frmLogin f, User u)
        {
            InitializeComponent();
            frmMain.main       = this;
            this.parent        = f;
            user               = u;
            tsslUserInfo.Text  = "当前用户:" + u.RealName;
            tsslLoginTime.Text = "登陆时间:" + DateTime.Now.ToString();
            Rolers role = UserManage.getRolerByID(u.RoleId);

            tsslRoleInfo.Text = "职位:" + role.Name;
        }
Esempio n. 2
0
        public static int addRolers(Rolers rolers)
        {
            int result = 0;

            using (MySqlConnection conn = DBHelper.getCon())
            {
                string       str = "insert into rolers (role_name) values(@name)";
                MySqlCommand cmd = new MySqlCommand(str, conn);
                cmd.Parameters.AddWithValue("@name", rolers.Name);

                conn.Open();
                result = (int)cmd.ExecuteNonQuery();
                conn.Close();
            }
            return(result);
        }
Esempio n. 3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.txtJob.Text))
            {
                MessageBox.Show("请输入职位名!", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            Rolers role = new Rolers();

            role.Name = this.txtJob.Text;
            int result = UserManage.addRolers(role);

            if (result == 1)
            {
                LoadAllRolers();
                MessageBox.Show("添加成功!");
                txtJob.Text = "";
            }
        }
Esempio n. 4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (txtPass.Text == "")
            {
                MessageBox.Show("请输入密码!", "提示", MessageBoxButtons.OK); return;
            }
            else if (txtPass.Text != txtRePass.Text)
            {
                MessageBox.Show("两次输入的密码不一致!", "提示", MessageBoxButtons.OK); return;
            }
            else if (txtUName.Text == "")
            {
                MessageBox.Show("真实姓名不能为空!", "提示", MessageBoxButtons.OK); return;
            }
            else if (cboJob.Text == "")
            {
                MessageBox.Show("请选择职位!", "提示", MessageBoxButtons.OK); return;
            }
            user          = new User();
            user.Code     = UserManage.getLastUserId() == 0 ?"AC100000":"AC" + (100000 + (UserManage.getLastUserId())).ToString();
            user.Pass     = txtPass.Text;
            user.RealName = txtUName.Text;
            Rolers roler = cboJob.SelectedItem as Rolers;

            user.RoleId = roler.Id;
            user.Active = 1;
            int result = UserManage.addUser(user);

            if (result == 1)
            {
                MessageBox.Show("添加成功!员工号:" + user.Code);
                txtPass.Text        = "";
                txtRePass.Text      = "";
                txtUName.Text       = "";
                cboJob.SelectedItem = cboJob.Items[0];
            }
            else
            {
                MessageBox.Show("添加失败!");
            }
        }
Esempio n. 5
0
        public static Rolers getRolerByID(int id)
        {
            Rolers role = null;

            using (MySqlConnection con = DBHelper.getCon())
            {
                string       str = "select * from rolers where role_id=@id";
                MySqlCommand cmd = new MySqlCommand(str, con);
                cmd.Parameters.AddWithValue("@id", id);
                con.Open();
                using (MySqlDataReader reader = cmd.ExecuteReader())
                {
                    if (reader.Read())
                    {
                        role      = new Rolers();
                        role.Id   = int.Parse(reader["role_id"].ToString());
                        role.Name = reader["role_name"].ToString();
                    }
                }
                con.Close();
                con.Dispose();
            }
            return(role);
        }
Esempio n. 6
0
        public static List <Rolers> getAllRolers()
        {
            List <Rolers> rolers = new List <Rolers>();

            using (MySqlConnection con = DBHelper.getCon())
            {
                string       str = "select * from rolers";
                MySqlCommand cmd = new MySqlCommand(str, con);
                con.Open();
                using (MySqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        Rolers roler = new Rolers();
                        roler.Id   = int.Parse(reader["role_id"].ToString());
                        roler.Name = reader["role_name"].ToString();
                        rolers.Add(roler);
                    }
                }
                con.Close();
                con.Dispose();
            }
            return(rolers);
        }
Esempio n. 7
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (UserManage.getPassByCode(this.txtNumber.Text) == txtPass.Text)
     {
         u.Code     = txtNumber.Text;
         u.Pass     = txtNewPass.Text;
         u.RealName = txtName.Text;
         Rolers role = cboJob.SelectedItem as Rolers;
         u.RoleId = role.Id;
         u.Active = rabNormal.Checked ? 1 : 0;
         int resule = UserManage.updateUser(u);
         if (resule == 1)
         {
             txtPass.Text    = "";
             txtNewPass.Text = "";
             form.LoadAllUser();
             MessageBox.Show("修改成功!");
         }
     }
     else
     {
         MessageBox.Show("密码错误!");
     }
 }
Esempio n. 8
0
 public static int addRolers(Rolers rolers)
 {
     return(UserService.addRolers(rolers));
 }