Beispiel #1
0
        //根据用户名得到用户User(DrawBitmap.User),可用
        public DrawBitmap.User getUserById(int user_id, bool includeExt = false)
        {
            DrawBitmap.User user = null;
            MySqlCommand    mycm = null;

            if (!includeExt)
            {
                mycm = new MySqlCommand("select name,nickname,User_Image from drawtogether.user where id='" + user_id + "';", conn);
            }
            else
            {
                mycm = new MySqlCommand("select * from drawtogether.user where id='" + user_id + "';", conn);
            }

            MySqlDataReader s = mycm.ExecuteReader();

            while (s.Read())
            {
                if (s.HasRows)
                {
                    if (includeExt)
                    {
                        user                = new User(user_id, null, s.GetString(1), s.GetString(10));
                        user.ext            = new UserExt();
                        user.ext.User_Image = s.GetString(11);
                        //user.ext.Age=s.GetInt32()
                        user.ext.Country   = s.GetString(9);
                        user.ext.Hometown  = s.GetString(7);
                        user.ext.Telephone = s.GetString(8);
                        user.ext.Motto     = s.GetString(6);
                        user.ext.Introduce = s.GetString(4);
                    }
                    else
                    {
                        user                = new User(user_id, null, s.GetString(0), s.GetString(1));
                        user.ext            = new UserExt();
                        user.ext.User_Image = s.GetString(2);
                    }

                    break;
                }
            }
            s.Close();
            mycm.Dispose();

            if (includeExt)
            {
                user.ext.GroupSet = new SortedSet <int>(getGroupListOfUser(user_id));
            }
            return(user);
        }
Beispiel #2
0
        //更新用户信息()不包括xUserExt,返回当前新创建用户的id,可用
        public void UpdateUserInfo(DrawBitmap.User user)
        {
            String sql = "UPDATE  `drawtogether`.`user` SET "
                         + " `name` =  '" + user.name + "',"
                         + " `nickname` =  '" + user.nickname + "',"
                         + "`Level` =  '" + user.ext.Level + "',"
                         + "`Introduce` =  '" + user.ext.Introduce + "',"
                         + "`birthday` =  '" + user.ext.Age + "'," //这里需要对userExt进行修改
                         + "`Motto` =  '" + user.ext.Motto + "',"
                         + "`Hometown` =  '" + user.ext.Hometown + "',"
                         + "`Telephone` =   '" + user.ext.Telephone + "',"
                         + "`Country` =   '" + user.ext.Country + "',"
                         + "`timestamp` ='" + getTimestampOfNow() + "'"
                         + "WHERE  `user`.`id` =" + user.user_id + " ;";

            runSQL(sql);
            UpdateUserExtInfoImage(user.user_id, user.ext);
        }
Beispiel #3
0
 //为调试测试而生
 public void showUser(DrawBitmap.User user)
 {
     Console.WriteLine("用户信息:\nid:{0}\nname:{1}\nnickname:{2}\nmotto:{3}", user.user_id, user.name, user.nickname, user.ext.Motto);
     Console.ReadLine();
 }
Beispiel #4
0
 //创建一个新用户,返回新用户id,可用,
 public int CreateNewUser(DrawBitmap.User user, string paswd)
 {
     return(CreateNewUser(user.name, paswd, user.nickname));
 }