Exemple #1
0
        /// <summary>
        /// ��ȡ���ѷ�ҳ�б�ҳ��
        /// </summary>
        public void GetFriends()
        {
            int start = 0;
            int limit = 10;

            // ����ת�����쳣�򲻴��������Ĭ��ֵ
            try {start = int.Parse(Request.Params["start"]);}catch{}
            try { limit = int.Parse(Request.Params["limit"]); }catch {}

            string txtSearch = Request.Params["search"];
            string userId = Request.Params["userId"];

            Users users = new Users();
            DataTable dt = null;
            DataRow[] dr = null;
            ICollection<Users> listUsers = null;
            VelocityContext vltContext = new VelocityContext();

            if (txtSearch == null || "".Equals(txtSearch.Trim()))
            {
                dt = users.GetFinder();
                string relationships = GetRelationships(userId);
                listUsers = GetUserList(dt, relationships, start, limit);

                vltContext.Put("Count", dt.Rows.Count);
            }
            else
            {
                dr = users.GetUsersToFind(txtSearch);
                string relationships = GetRelationships(userId);
                listUsers = GetUserList(dr, relationships, start, limit);

                vltContext.Put("Count", dr.Length);
            }

            vltContext.Put("ListUsers", listUsers);

            Response.Write(GetTemplateString("friendsTemplate.htm", vltContext));
        }