Ejemplo n.º 1
0
        public User GetUserByUserName(string userName)
        {
            User user = new User();
            string sql = "select * from Tb_User where UserName=@UserName";
            SqlParameter[] parms = SqlHelperParameterCache.GetCachedParameterSet(sql);
            if (parms == null)
            {
                parms = new SqlParameter[] {
                    new SqlParameter("@UserName",SqlDbType.NVarChar,15)
                };
                SqlHelperParameterCache.CacheParameterSet(sql, parms);
            }

            parms[0].Value = userName;

            using (SqlDataReader dr = SqlHelper.ExecuteReader(connString, CommandType.Text, sql, parms))
            {
                RowHelper row = new RowHelper(dr);
                if (row.Read())
                {
                    user.UserID = row.GetInt32("UserID");
                    user.LastLoginIP = row.GetString("LastLoginIP");
                    user.LastLoginTime = row.GetDateTime("LastLoginTime");
                    user.RegTime = row.GetDateTime("RegTime");
                    user.Server = row.GetString("Server");
                    user.Status = row.GetUInt32("Status");
                    user.UserName = row.GetString("UserName");
                    user.UserPwd = row.GetString("UserPwd");
                }
                dr.Close();
            }
            return user;
        }
Ejemplo n.º 2
0
        public User GetUserByUserID(int userID)
        {
            User   user = new User();
            string sql  = "select * from Tb_User where UserID=@UserID";

            SqlParameter[] parms = SqlHelperParameterCache.GetCachedParameterSet(sql);
            if (parms == null)
            {
                parms = new SqlParameter[] {
                    new SqlParameter("@UserID", SqlDbType.BigInt)
                };
                SqlHelperParameterCache.CacheParameterSet(sql, parms);
            }

            parms[0].Value = userID;

            using (SqlDataReader dr = SqlHelper.ExecuteReader(connString, CommandType.Text, sql, parms))
            {
                RowHelper row = new RowHelper(dr);
                if (row.Read())
                {
                    user.UserID        = row.GetInt32("UserID");
                    user.LastLoginIP   = row.GetString("LastLoginIP");
                    user.LastLoginTime = row.GetDateTime("LastLoginTime");
                    user.RegTime       = row.GetDateTime("RegTime");
                    user.Server        = row.GetString("Server");
                    user.Status        = row.GetUInt32("Status");
                    user.UserName      = row.GetString("UserName");
                    user.UserPwd       = row.GetString("UserPwd");
                }
                dr.Close();
            }
            return(user);
        }
Ejemplo n.º 3
0
        private UserInfo FillUserInfo(RowHelper row)
        {
            UserInfo userInfo = null;

            if (row.Read())
            {
                userInfo = new UserInfo()
                {
                    Age      = row.GetInt32("Age"),
                    BirthDay = row.GetDateTime("BirthDay"),
                    Email    = row.GetString("Email"),
                    NickName = row.GetString("NickName"),
                    Sex      = row.GetInt16("Sex"),
                    UserID   = row.GetInt32("UserID")
                };
            }

            return(userInfo);
        }
Ejemplo n.º 4
0
        private UserInfo FillUserInfo(RowHelper row)
        {
            UserInfo userInfo = null;

            if (row.Read())
            {
                userInfo = new UserInfo()
                {
                    Age = row.GetInt32("Age"),
                    BirthDay = row.GetDateTime("BirthDay"),
                    Email = row.GetString("Email"),
                    NickName = row.GetString("NickName"),
                    Sex = row.GetInt16("Sex"),
                    UserID = row.GetInt32("UserID")
                };
            }

            return userInfo;
        }