Ejemplo n.º 1
0
 // 保存修改的用户信息
 private void save_Click(object sender, RoutedEventArgs e)
 {
     if (modify)  // 如果更改了用户信息
     {
         User user = new User();
         if (passwd.Text != changepwd.Text)
         {
             MessageBox.Show("输入的密码有错,请检查!!!");
             return;
         }
         user.UserName = username.Text;
         user.Password = passwd.Text;
         user.RealName = realname.Text;
         user.Job = job.Text;
         user.Group = Convert.ToInt32(group.SelectedValue);   // 这一项还有待改变
         if (helper.changeUserInfo(user) == 1)
         {
             MessageBox.Show("修改成功!!!");
         }
         else
         {
             MessageBox.Show("修改失败!!!");
         }
     }
     return;
 }
Ejemplo n.º 2
0
 public User getSingleUserInfo(string name)
 {
     string cmdText = "select * from Users where user_name = '" + name + "'";
     SqlCommand cmd = new SqlCommand(cmdText, conn);
     conn.Open();
     SqlDataReader reader = cmd.ExecuteReader();
     reader.Read();
     User user = new User(Convert.ToString(reader["user_name"]), Convert.ToString(reader["passwd"]),
             Convert.ToString(reader["real_name"]), Convert.ToString(reader["job"]),
             Convert.ToInt32(reader["user_group"]));
     conn.Close();
     return user;
 }
Ejemplo n.º 3
0
 // 获取所有的用户信息
 public List<User> getAllUsers()
 {
     List<User> users = new List<User>();
     string cmdText = "select * from Users";
     SqlCommand cmd = new SqlCommand(cmdText, conn);
     conn.Open();
     SqlDataReader reader = cmd.ExecuteReader();
     while (reader.Read())
     {
         User user = new User(Convert.ToString(reader["user_name"]), Convert.ToString(reader["passwd"]),
             Convert.ToString(reader["real_name"]),Convert.ToString(reader["job"]), 
             Convert.ToInt32(reader["user_group"]));
         users.Add(user);
     }
     conn.Close();
     return users;  // 返回用户的信息
 }
Ejemplo n.º 4
0
 // 写入修改的用户的信息
 public int changeUserInfo(User user)
 {
     int temp = 0;
     string cmdText = "update Users set passwd = '" + user.Password + "',real_name = '" +
         user.RealName + "', job = '" + user.Job + "', user_group =" + user.Group +
         "where user_name = '" + user.UserName + "'";
     SqlCommand cmd = new SqlCommand(cmdText, conn);
     conn.Open();
     temp = cmd.ExecuteNonQuery();  // 返回更改的行数
     conn.Close();
     return temp;
 }