using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.Text.RegularExpressions;
using JuSNS.Model;
using JuSNS.Factory;
using JuSNS.Profile;
using JuSNS.Config;

namespace JuSNS.SQLServer
{
    public class UtilPage : DbBase, IUtilPage
    {
        /// <summary>
        ///最新相
        /// </summary>
        protected string[] photos_aspx = { "PhotoID", "PhotoID,Description,UploadUser,AlbumID,PostTime,FilePath,(select UserName from NT_User where UserID=NT_photo.UploadUser) as UserName", "NT_photo Where UploadUser in (select FriendID from NT_Friend where NT_Friend.UserID=@UserID) and isLock=0 and state=0 and albumID!=0", "order by PhotoID desc" };

        /// <summary>
        ///最新相某人)
        /// </summary>
        protected string[] photos_ID_aspx = { "PhotoID", "PhotoID,Description,UploadUser,AlbumID,PostTime,FilePath,(select UserName from NT_User where UserID=NT_photo.UploadUser) as UserName", "NT_photo Where UploadUser=@UserID and isLock=0 and state=0", "order by PhotoID desc" };

        #region 会员前台
        /// <summary>
        /// 私信通知列表
        /// </summary>
        protected string[] Notice_aspx = { "a.ID", "a.ID,a.Content,a.PostTime,a.Sender,a.MsgType,a.Correspond,b.UserName,a.IsRead", "NT_NOTICE a inner join NT_User b on a.Sender=b.UserID where a.IsLock=0 and a.IsDel=0 and a.Receiver=@Receiver", "order by a.IsRead asc,a.Id desc" };

        /// <summary>
        /// 私信收件箱列
        /// </summary>
        protected string[] Inbox_aspx = { "a.ID", "a.ID,a.Sender,a.Receiver,a.Title,a.Content,a.PostTime,a.IsReply,a.LtType,a.RelativeID,b.UserName,d.FilePath", "NT_Mail as a inner join NT_User as b on a.Sender=b.UserID left Join Nt_Photo as d On b.Portrait=d.PhotoID And d.IsLock=0 where (a.ID IN (SELECT letterid FROM NT_Mailinbox WHERE userid=@Receiver) and a.TopicID=0)", "order by a.Id desc" };

        /// <summary>
        /// 私信发件箱列
        /// </summary>
        protected string[] Outbox_aspx = { "a.ID", "a.ID,a.Sender,a.Receiver,a.Title,a.Content,a.PostTime,a.IsReply,a.LtType,a.RelativeID,b.UserName,d.FilePath", "NT_Mail as a inner join NT_User as b on a.Receiver=b.UserID left Join Nt_Photo as d On b.Portrait=d.PhotoID And d.IsLock=0 where (a.ID IN (SELECT letterid FROM NT_MailOutbox WHERE userid=@Sender) and a.TopicID=0)", "order by a.Id desc" };

        /// <summary>
        /// 私信回复列表
        /// </summary>
        protected string[] Mailinfo_aspx = { "a.ID", "a.ID,a.Sender,a.Title,a.Content,a.PostTime,a.LtType,a.RelativeID,b.UserName,c.FilePath", "NT_Mail as a inner join NT_User as b on a.Sender=b.UserID Left Join Nt_Photo as c On b.Portrait=c.PhotoID And c.IsLock=0 where a.ID=@TopicID Or a.TopicID=@TopicID", "order by a.Id Asc" };

        /// <summary>
        /// 我的群组最新讨论主题列
        /// </summary>
        protected string[] DyanGroup_aspx = { "a.ID", "a.ID,a.GroupID,a.UserID,a.Topic,a.LastPostTime,a.LastPoster,a.Replys,a.LastPoster,a.TopNum,b.UserName,c.GroupName", "NT_GroupDiscuss as a inner join NT_User as b on a.UserID=b.UserID Inner Join NT_UserGroup as c on a.GroupID=c.GroupID  where a.GroupID In(Select GroupID From NT_GroupMember Where UserID=@UserID) And a.DiscussType=0 And a.State=0 and a.BelongTopic=0", "order by a.Id Desc" };
        /// <summary>
        /// 群组最新讨论主题列
        /// </summary>
        protected string[] GroupDiscuss_aspx = { "a.ID", "a.ID,a.GroupID,a.UserID,a.Topic,a.LastPostTime,a.LastPoster,a.Replys,a.LastPoster,a.TopNum,b.UserName,c.GroupName", "NT_GroupDiscuss as a inner join NT_User as b on a.UserID=b.UserID Inner Join NT_UserGroup as c on a.GroupID=c.GroupID  where a.GroupID=@GroupID And a.DiscussType=0 And a.State=0", "order by a.TopNum Desc,a.Id Desc" };

        /// <summary>
        /// 群组主题回复列表
        /// </summary>
        protected string[] GroupDiscussInfo_aspx = { "a.ID", "a.ID,a.GroupID,a.UserID,a.Content,a.PostTime,a.LastModifyTime,a.ReplyTack,a.SeriesNum,a.State,b.UserName,c.Name,d.FilePath", "NT_GroupDiscuss as a inner join NT_User as b on a.UserID=b.UserID Inner Join NT_Dict_Area as c on b.Province=c.ID Left Join Nt_Photo as d On b.Portrait=d.PhotoID And d.IsLock=0 where (a.BelongTopic=@ID Or a.ID=@ID)", "order by a.Id Asc" };

        /// <summary>
        /// 用户)加入的群
        /// </summary>
        protected string[] Group_My_aspx = { "a.GroupID", "a.GroupID,a.GroupName,a.UserID,a.Members,a.Portrait,a.Bulletin,(Select Count(b.ID) From NT_GroupDiscuss as b Where b.DiscussType=0 And b.State=0 And a.GroupID=b.GroupID) as Cnt", "NT_UserGroup a where (a.GroupID In(Select c.GroupID From NT_GroupMember as c Where c.UserID=@UserID) and a.State=0)", "order by a.GroupID desc" };
        /// <summary>
        /// 用户)创建的群
        /// </summary>
        protected string[] Group_Creat_aspx = { "a.GroupID", "a.GroupID,a.GroupName,a.UserID,a.Members,a.Portrait,a.Bulletin,(Select Count(b.ID) From NT_GroupDiscuss as b Where b.DiscussType=0 And b.State=0 And a.GroupID=b.GroupID) as Cnt", "NT_UserGroup a where a.UserID=@UserID and a.State=0", "order by a.GroupID desc" };

        /// <summary>
        /// 群组列表(所
        /// </summaryGroup_Creat_aspx
        protected string[] GroupList_aspx ={ "a.GroupID", "a.GroupID,a.GroupName,a.UserID,a.Members,a.Portrait,a.Bulletin,(Select Count(b.ID) From NT_GroupDiscuss as b Where b.DiscussType=0 And b.State=0 And a.GroupID=b.GroupID ) as Cnt", "NT_UserGroup a Where a.State=0 and a.UserID!=@UserID", "order by newid()" };
        /// <summary>
        /// 群组列表（好友）
        /// </summaryGroup_Creat_aspx
        protected string[] GroupList_Friend_aspx ={ "a.GroupID", "a.GroupID,a.GroupName,a.UserID,a.Members,a.Portrait,a.Bulletin,(Select Count(b.ID) From NT_GroupDiscuss as b Where b.DiscussType=0 And b.State=0 And a.GroupID=b.GroupID ) as Cnt", "NT_UserGroup a Where a.State=0 and a.UserID!=@UserID and  a.UserID in (select FriendID from NT_Friend where NT_Friend.UserID=@UserID)", "order by a.GroupID desc" };

        /// <summary>
        /// 群组列表(搜索，所
        /// </summary>
        protected string[] GroupList_Key_aspx ={ "a.GroupID", "a.GroupID,a.GroupName,a.UserID,a.Members,a.Portrait,a.Bulletin,(Select Count(b.ID) From NT_GroupDiscuss as b Where b.DiscussType=0 And b.State=0 And a.GroupID=b.GroupID ) as Cnt", "NT_UserGroup a where a.GroupName Like @GroupName and a.state=0 and a.UserID!=@UserID", "order by a.GroupID desc" };

        /// <summary>
        /// 群组列表(搜索，好
        /// </summary>
        protected string[] GroupList_Key_Friend_aspx ={ "a.GroupID", "a.GroupID,a.GroupName,a.UserID,a.Members,a.Portrait,a.Bulletin,(Select Count(b.ID) From NT_GroupDiscuss as b Where b.DiscussType=0 And b.State=0 And a.GroupID=b.GroupID ) as Cnt", "NT_UserGroup a where a.GroupName Like @GroupName and a.state=0 and a.UserID!=@UserID and a.UserID in (select FriendID from NT_Friend where NT_Friend.UserID=@UserID)", "order by a.GroupID desc" };

        /// <summary>
        /// 留言
        /// </summary>
        protected string[] leaveword_aspx = { "a.ID", "a.ID,a.SendID,a.RecID,a.Content,a.PostTime,b.UserName,c.Name,d.FilePath,(select count(id) from NT_gbook where ParentID=a.ID) as ReplayCount", "NT_gbook a inner join NT_User b on a.SendID=b.UserID inner join NT_Dict_Area c on b.Province=c.ID left join NT_Photo d on b.Portrait=d.PhotoID and d.IsLock=0 where a.IsLock=0 and a.RecID=@Receiver and A.ParentID=0 and a.SendID!=@Receiver", "order by a.Id desc" };

        /// <summary>
        /// 留言管理
        /// </summary>
        protected string[] leaveword_manage_aspx = { "a.ID", "a.ID,a.SendID,a.RecID,a.Content,a.PostTime,(select count(id) from NT_gbook where ParentID=a.ID) as ReplayCount", "NT_gbook a where a.IsLock=0 and ((a.SendID=@Receiver and a.RecID=-1) or (a.SendID=-1 and a.RecID=@Receiver)) and A.ParentID=0", "order by a.Id desc" };

        /// <summary>
        /// 留言板对话录
        /// </summary>
        protected string[] leaveword_record_aspx = { "a.ID", "a.ID,a.SendID,a.RecID,a.Content,a.PostTime,b.UserName,c.Name,d.FilePath,(select count(id) from NT_gbook where ParentID=a.ID) as ReplayCount", "NT_gbook a inner join NT_User b on a.SendID=b.UserID inner join NT_Dict_Area c on b.Province=c.ID left join NT_Photo d on b.Portrait=d.PhotoID and d.IsLock=0 where a.IsLock=0 and (a.RecID=@Receiver and a.SendID=@SendID or a.RecID=@SendID and a.SendID=@Receiver)", "order by a.Id desc" };

        /// <summary>
        ///好友邀请记录列
        /// </summary>
        protected string[] friend_invite = { "ID", "ID,Invitee,PostTime", "NT_FriendInvite where UserID=@UserID and Reply=@Reply and Method=1", "order by ID desc" };


        /// <summary>
        ///在线好友
        /// </summary>
        protected string[] OnlineFriend_aspx = { "ID", "ID,UserID,UserName,LastTime,(select top 1 Content from NT_Mood where NT_Mood.UserID=NT_OnlineUser.UserID and IsLock=0 order by PostTime Desc,ID Desc) as mood", "NT_OnlineUser Where UserID in (select FriendID from NT_Friend where NT_Friend.UserID=@UserID) and UserID!=@UserID", "Order By LastTime Desc" };

        /// <summary>
        ///可能认识的人
        /// </summary>
        //protected string[] GetSFriendList_aspx = { "UserID", "UserID,(select top 1 Content from NT_Mood where NT_Mood.UserID=NT_User.UserID and IsLock=0 order by PostTime Desc) as mood,(select count(ID) from NT_OnlineUser where UserID=NT_user.UserID) as isOnline", "[NT_user] where (State=5 or State=2) and  userid in(select friendid from [NT_friend] where userid in(select friendid from [NT_friend] where userid=@UserID and UserID not in (" + JuSNS.Common.Public.GetXMLValue("defaultfriend") + "))) and userid not in(select friendid from [NT_friend] where userid=@UserID) and userID!=@UserID", "order by newid()" };
        protected string[] GetSFriendList_aspx = { "UserID", "UserID,(select top 1 Content from NT_Mood where NT_Mood.UserID=NT_User.UserID and IsLock=0 order by PostTime Desc) as mood,(select count(ID) from NT_OnlineUser where UserID=NT_user.UserID) as isOnline", "[NT_user] where (State=5 or State=2) and  userid in(select friendid from [NT_friend] where userid in(select friendid from [NT_friend] where userid=@UserID)) and userid not in(select friendid from [NT_friend] where userid=@UserID) and userID!=@UserID", "order by newid()" };

        /*首页推荐或者随便看看*/
        protected string[] Friend_Index_Rec_aspx = { "a.UserID", "a.UserID,a.UserName", "[NT_user] a inner join NT_Photo b on a.Portrait=b.PhotoID where (a.State=5 or a.State=2) and a.isRec=1", "order by newid()" };
        protected string[] Friend_Index_Hot_aspx = { "a.UserID", "a.UserID,a.UserName", "[NT_user] a inner join NT_Photo b on a.Portrait=b.PhotoID where (a.State=5 or a.State=2)", "order by a.Click desc" };
        protected string[] Friend_Index_GG_aspx = { "a.UserID", "a.UserID,a.UserName", "[NT_user] a inner join NT_Photo b on a.Portrait=b.PhotoID where (a.State=5 or a.State=2) and (select c.Sex from NT_UserInfo c where c.UserID=a.UserID)=1", "order by (a.Click+a.integral) desc" };
        protected string[] Friend_Index_MM_aspx = { "a.UserID", "a.UserID,a.UserName", "[NT_user] a inner join NT_Photo b on a.Portrait=b.PhotoID where (a.State=5  or a.State=2) and (select c.Sex from NT_UserInfo c where c.UserID=a.UserID)=0", "order by (a.Click+a.integral) desc" };
        protected string[] Friend_Index_JF_aspx = { "a.UserID", "a.UserID,a.UserName", "[NT_user] a inner join NT_Photo b on a.Portrait=b.PhotoID where (a.State=5 or a.State=2)", "order by a.integral desc,UserID desc" };
        protected string[] Friend_Index_HY_aspx = { "a.UserID", "a.UserID,a.UserName", "[NT_user] a inner join NT_Photo b on a.Portrait=b.PhotoID where (a.State=5 or a.State=2)", "order by (a.Click+a.LoginTimes+a.integral) desc" };
        /// <summary>
        ///我拜访过
        /// </summary>
        protected string[] GetVisitList_Out_aspx = { "UserID", "UserID,VisitorID,LastVisitTime,(select top 1 Content from NT_Mood where NT_Mood.UserID=NT_visit.UserID and IsLock=0 order by PostTime Desc) as mood", "NT_visit Where VisitorID=@UserID", "Order By LastVisitTime Desc,ID DESC" };

        /// <summary>
        ///来访
        /// </summary>
        protected string[] GetVisitList_In_aspx = { "UserID", "UserID,VisitorID,LastVisitTime,(select top 1 Content from NT_Mood where NT_Mood.UserID=NT_visit.VisitorID and IsLock=0 order by PostTime Desc) as mood,(select count(ID) from NT_OnlineUser where UserID=NT_visit.VisitorID) as isOnline", "NT_visit Where UserID=@UserID", "Order By LastVisitTime Desc,ID DESC" };

        /// <summary>
        ///根据姓名查找好友列表
        /// </summary>
        protected string[] friend_search = { "a.UserID", "a.UserID,a.UserName,a.Province,b.Name,c.FilePath", "NT_User a inner join NT_Dict_Area b on a.Province=b.ID left join NT_Photo c on a.Portrait=c.PhotoID and c.IsLock=0 where a.State=" + (int)EnumUserState.Normal + " and a.UserName like @UserName", "order by a.UserID desc" };
        /// <summary>
        ///我的博客日志列表
        /// </summary>
        protected string[] blog_list_my = { "a.ID", "a.ID,a.UserID,a.Title,a.PostTime,a.Comments,a.Reads,a.Content,a.PicPath,a.Privacy,b.UserName,c.Name,d.FilePath", "NT_Blog a inner join NT_User b on a.UserID=b.UserID inner join NT_Dict_Area c on b.Province=c.ID left join NT_Photo d on b.Portrait=d.PhotoID  where a.IsLock=0 and a.UserID=@UserID", "order by a.ID desc" };
        /// <summary>
        ///所有用户的博客日志
        /// </summary>
        protected string[] blog_list_all = { "a.ID", "a.ID,a.UserID,a.Title,a.PostTime,a.Comments,a.Reads,a.Content,a.PicPath,a.Privacy,b.UserName,c.Name,d.FilePath", "NT_Blog a inner join NT_User b on a.UserID=b.UserID inner join NT_Dict_Area c on b.Province=c.ID left join NT_Photo d on b.Portrait=d.PhotoID  where a.IsLock=0 and a.UserID!=@UserID", "order by a.ID desc" };
        /// <summary>
        ///所有用户的博客日志(首页推荐)
        /// </summary>
        protected string[] BlogList_Index_Rec_aspx = { "a.ID", "a.ID,a.UserID,a.Title,a.PostTime,a.Comments,a.Reads,a.Content,a.PicPath,a.Privacy,b.UserName,c.Name,d.FilePath", "NT_Blog a inner join NT_User b on a.UserID=b.UserID inner join NT_Dict_Area c on b.Province=c.ID left join NT_Photo d on b.Portrait=d.PhotoID  where a.IsLock=0 and a.isRec=1", "order by a.ID desc" };
        protected string[] BlogList_Index_Hot_aspx = { "a.ID", "a.ID,a.UserID,a.Title,a.PostTime,a.Comments,a.Reads,a.Content,a.PicPath,a.Privacy,b.UserName,c.Name,d.FilePath", "NT_Blog a inner join NT_User b on a.UserID=b.UserID inner join NT_Dict_Area c on b.Province=c.ID left join NT_Photo d on b.Portrait=d.PhotoID  where a.IsLock=0 and a.isRec=1", "order by (a.Comments+a.Reads) desc,a.ID desc" };
        
        /// <summary>
        ///所有用户的博客日志(搜索)
        /// </summary>
        protected string[] blog_list_allk = { "a.ID", "a.ID,a.UserID,a.Title,a.PostTime,a.Comments,a.Reads,a.Content,a.PicPath,a.Privacy,b.UserName,c.Name,d.FilePath", "NT_Blog a inner join NT_User b on a.UserID=b.UserID inner join NT_Dict_Area c on b.Province=c.ID left join NT_Photo d on b.Portrait=d.PhotoID  where a.IsLock=0 and (a.Title like @key or a.Content like @key)", "order by a.ID desc" };

        /// <summary>
        ///好友日志列表
        /// </summary>
        protected string[] blog_list_friend = { "a.ID", "a.ID,a.UserID,a.Title,a.PostTime,a.Comments,a.Reads,a.Content,a.PicPath,a.Privacy,b.UserName,c.Name,d.FilePath", "NT_Blog a inner join NT_User b on a.UserID=b.UserID inner join NT_Dict_Area c on b.Province=c.ID left join NT_Photo d on b.Portrait=d.PhotoID  where (a.IsLock=0 and a.UserID in (select FriendID from NT_Friend where UserID=@UserID) and a.UserID!=@UserID and a.Privacy<>" + (int)EnumPrivacy.ForOwner + ")", "order by a.ID desc" };

        ///<summary>
        ///关于我的日志
        /// </summary>
        //protected string[] blog_aboutme_list = { "a.ID", "a.ID,a.UserID,a.Title,a.PostTime,a.Comments,a.Reads,a.Content,a.PicPath,a.Privacy,b.UserName,c.Name,d.FilePath", "NT_Blog a inner join NT_User b on a.UserID=b.UserID inner join NT_Dict_Area c on b.Province=c.ID left join NT_Photo d on b.Portrait=d.PhotoID  where (a.IsLock=0 and (a.Title like @UserName or a.Content like @UserName or charindex(@UserID, a.relatUser)>0) and a.Privacy<>" + (int)EnumPrivacy.ForOwner + ")", "order by a.ID desc" };
        protected string[] blog_aboutme_list = { "a.ID", "a.ID,a.UserID,a.Title,a.PostTime,a.Comments,a.Reads,a.Content,a.PicPath,a.Privacy,b.UserName,c.Name,d.FilePath", "NT_Blog a inner join NT_User b on a.UserID=b.UserID inner join NT_Dict_Area c on b.Province=c.ID left join NT_Photo d on b.Portrait=d.PhotoID  where (a.IsLock=0 and (a.Title like @UserName or a.Content like @UserName) and a.Privacy<>" + (int)EnumPrivacy.ForOwner + ")", "order by a.ID desc" };
        /// <summary>
        ///某用户的日志列表
        /// </summary>
        protected string[] blog_id_list = { "a.ID", "a.ID,a.UserID,a.Title,a.PostTime,a.Comments,a.Reads,a.Content,a.PicPath,a.Privacy,b.UserName,c.Name,d.FilePath", "NT_Blog a inner join NT_User b on a.UserID=b.UserID inner join NT_Dict_Area c on b.Province=c.ID left join NT_Photo d on b.Portrait=d.PhotoID  where a.UserID=@UserID and a.Privacy<>" + (int)EnumPrivacy.ForOwner + "", "order by a.ID desc" };

        /// <summary>
        ///好友的心情日记列
        /// </summary>
        protected string[] mood_friend = { "a.ID", "a.ID,a.UserID,a.Content,a.PostTime,b.UserName,c.FilePath,a.MType", "NT_Mood a inner join NT_User b on a.UserID=b.UserID left join NT_Photo c on b.Portrait=c.PhotoID and c.IsLock=0 where (a.IsLock=0 and (a.UserID in (select FriendID from NT_Friend where UserID=@UserID) and a.UserID!=@UserID))", "order by a.ID desc" };
        /// <summary>
        ///好友的心情日记列评论
        /// </summary>
        protected string[] mood_id = { "a.ID", "a.ID,a.UserID,a.Content,a.PostTime,b.UserName,c.FilePath,a.MType", "NT_Mood a inner join NT_User b on a.UserID=b.UserID left join NT_Photo c on b.Portrait=c.PhotoID and c.IsLock=0 where (a.IsLock=0 and a.ID=@MID and (a.UserID in (select FriendID from NT_Friend where (UserID=@UserID) or (FriendID=@UserID)) or a.UserID!=@UserID))", "order by a.ID desc" };

        /// <summary>
        ///我的心情日记列表
        /// </summary>
        protected string[] mood_my = { "a.ID", "a.ID,a.UserID,a.Content,a.PostTime,b.UserName,c.FilePath,a.MType", "NT_Mood a inner join NT_User b on a.UserID=b.UserID left join NT_Photo c on b.Portrait=c.PhotoID and c.IsLock=0 where (a.IsLock=0 and (a.UserID = @UserID))", "order by a.ID desc" };

        /// <summary>
        ///所有的心情日记列表
        /// </summary>
        protected string[] mood_all = { "a.ID", "a.ID,a.UserID,a.Content,a.PostTime,b.UserName,c.FilePath,a.MType", "NT_Mood a inner join NT_User b on a.UserID=b.UserID left join NT_Photo c on b.Portrait=c.PhotoID and c.IsLock=0 where (a.IsLock=0 and (a.UserID != @UserID))", "order by a.ID desc" };
        
        /// <summary>
        ///所有的心情日记列表
        /// </summary>
        protected string[] mood_all_ram = { "a.ID", "a.ID,a.UserID,a.Content,a.PostTime,b.UserName,(select count(id) from NT_MoodComment c where c.MiniBlogID=a.ID) as cc", "NT_Mood a inner join NT_User b on a.UserID=b.UserID  where (a.IsLock=0)", "order by a.ID desc" };
        /// <summary>
        ///草稿列表
        /// </summary>
        protected string[] blog_draft = { "ID", "ID,Title,PostTime,Content,PicPath,Privacy", "NT_BlogDraft where (IsLock=0 and UserID=@UserID)", "order by ID desc" };
        /// <summary>
        ///群组成员列表
        /// </summary>
        protected string[] GroupMember_aspx = { "a.ID", "a.UserID,b.UserName", "NT_GroupMember AS a INNER JOIN NT_User AS b ON a.[userid]=b.[userid] where a.[GroupID]=@GroupID", "order by a.[ID] desc" };
        /// <summary>
        /// 相册列表
        /// </summary>
        protected string[] photo_list ={ "a.AlbumID", "a.AlbumID,a.UserID,a.Title,a.Description,a.ImagesCount,a.CreateTime,a.Privacy,a.LastUploadTime,c.FilePath,(select count(b.PhotoID) from NT_Photo b where b.IsLock=0 and b.AlbumID=a.AlbumID) as Cnt", "NT_Album a inner join NT_Photo c on c.AlbumID=a.AlbumID where UserID=@UserID and c.IsCover=1", "order by a.AlbumID desc" };


        /// <summary>
        ///好友电影列表
        /// </summary>
        protected string[] MovieList_1_aspx = { "MovieID", "MovieID,Title,PosterFile,gut,Director,Billing,YearOnShow,hits,comment,UserID,CreatTime", "NT_Movie Where UserID in (select FriendID from NT_Friend where NT_Friend.UserID=@UserID)", "order by MovieID desc" };

        /// <summary>
        ///好友电影列表(分类)
        /// </summary>
        protected string[] MovieList_2_aspx = { "MovieID", "MovieID,Title,PosterFile,gut,Director,Billing,YearOnShow,hits,comment,UserID,CreatTime", "NT_Movie Where UserID in (select FriendID from NT_Friend where NT_Friend.UserID=@UserID) and SortID=@s", "order by MovieID desc" };

        /// <summary>
        ///我的
        /// </summary>
        protected string[] MovieList_my_aspx = { "MovieID", "MovieID,Title,PosterFile,gut,Director,Billing,YearOnShow,hits,comment,UserID,CreatTime", "NT_Movie Where UserID =@UserID", "order by MovieID desc" };

        /// <summary>
        ///所
        /// </summary>
        protected string[] MovieList_all_aspx = { "MovieID", "MovieID,Title,PosterFile,gut,Director,Billing,YearOnShow,hits,comment,UserID,CreatTime", "NT_Movie Where 1 =1", "order by MovieID desc" };

        /// <summary>
        ///所带分
        /// </summary>
        protected string[] MovieList_all1_aspx = { "MovieID", "MovieID,Title,PosterFile,gut,Director,Billing,YearOnShow,hits,comment,UserID,CreatTime", "NT_Movie Where SortID=@s", "order by MovieID desc" };
        /// <summary>
        ///电影搜索，前台
        /// </summary>
        protected string[] MovieList_Key1_aspx = { "MovieID", "MovieID,Title,PosterFile,gut,Director,Billing,YearOnShow,hits,comment,UserID,CreatTime,SortID", "NT_Movie Where (Title like @Key or Director like @Key or Billing like @Key or gut like @Key or YearOnShow like @Key)", "order by MovieID desc" };
        /// <summary>
        ///电影搜索，Director
        /// </summary>
        protected string[] MovieList_Director_aspx = { "MovieID", "MovieID,Title,PosterFile,gut,Director,Billing,YearOnShow,hits,comment,UserID,CreatTime,SortID", "NT_Movie Where Director like @Key", "order by MovieID desc" };
        /// <summary>
        ///电影搜索，Billing
        /// </summary>
        protected string[] MovieList_Billing_aspx = { "MovieID", "MovieID,Title,PosterFile,gut,Director,Billing,YearOnShow,hits,comment,UserID,CreatTime,SortID", "NT_Movie Where Billing like @Key", "order by MovieID desc" };
        /// <summary>
        ///电影搜索，YearOnShow
        /// </summary>
        protected string[] MovieList_YearOnShow_aspx = { "MovieID", "MovieID,Title,PosterFile,gut,Director,Billing,YearOnShow,hits,comment,UserID,CreatTime,SortID", "NT_Movie Where YearOnShow like @Key", "order by MovieID desc" };
        /// <summary>
        /// 分享列表(所有人)
        /// </summary>
        protected string[] User_share_index_all ={ "ID", "id,UserID,Title,Description,URL,ShareType, CaseID,IsLock,PostTime,PostIP,Comments,Privacy", "NT_Share where isLock=0 and Privacy!=3 and UserID!=@UserID", "order by Id desc" };

        /// <summary>
        /// 分享列表(所有的好友)
        /// </summary>
        protected string[] User_share_index_Friend ={ "ID", "id,UserID,Title,Description,URL,ShareType, CaseID,IsLock,PostTime,PostIP,Comments,Privacy", "NT_Share where isLock=0 and UserID in (select FriendID from NT_Friend where UserID=@UserID) and Privacy!=3", "order by Id desc" };

        /// <summary>
        /// 分享列表(我的)
        /// </summary>
        protected string[] User_share_index_my ={ "ID", "id,UserID,Title,Description,URL,ShareType,CaseID,IsLock,PostTime,PostIP,Comments,Privacy", "NT_Share where (UserID=@UserID Or FriendIDGroup=@UserID)", "Order by Id desc" };

        /// <summary>
        /// 分享列表(用户
        /// </summary>
        protected string[] User_share_index_UserID ={ "ID", "id,UserID,Title,Description,URL,ShareType,CaseID,IsLock,PostTime,PostIP,Comments,Privacy", "NT_Share where UserID=@UserID", "Order by Id desc" };

        /// <summary>
        /// 好友请求
        /// </summary>
        protected string[] Friend_Request ={ "a.ID", "a.ID,a.Demander,b.UserName,c.Name", "NT_Request a inner join NT_User b on a.Demander=b.UserID left join NT_Dict_Area c on b.Province=c.ID where (a.Receiver=@Receiver and a.ReplyResult=" + (int)EnumReply.NoneReply + " and a.RequestType=" + (int)EnumRequestType.MakeFriends + ")", "order by a.Id desc" };

        /// <summary>
        /// 照片评论列表
        /// </summary>
        protected string[] PhotoCommentList = { "ID", "ID,PhotoID,UserID,Content,PostTime,PostIP,IsLock,CommentID", "NT_PhotoComment where PhotoID=@PhotoID", "order by ID desc" };

        /// <summary>
        /// 朋友的相册列
        /// </summary>
        protected string[] Friend_Album_List ={ "AlbumID", "[AlbumID],[UserID],[Title],[Description],[ImagesCount],[CreateTime],[Privacy],[GroupID]", "[NT_Album] Where [UserID] in (select FriendID from [NT_Friend] where UserID=@UserID)  and Privacy!=3 and UserID!=@UserID", "order by AlbumID desc" };

        /// <summary>
        /// 相册列表(随便看看)
        /// </summary>
        protected string[] Friend_Album_List_All = { "AlbumID", "[AlbumID],[UserID],[Title],[Description],[ImagesCount],[CreateTime],[Privacy],[GroupID]", "[NT_Album] Where [UserID] !=@UserID  and Privacy=0", "order by newid()" };
        /// <summary>
        /// 相册列表(首页)
        /// </summary>
        protected string[] Friend_Album_List_All_Index ={ "AlbumID", "[AlbumID],[UserID],[Title],[Description],[ImagesCount],[CreateTime],[Privacy],[GroupID]", "[NT_Album] Where Privacy=0 and (select count(*) from NT_Photo where NT_Photo.AlbumID=NT_Album.AlbumID)>0", "order by newid()" };

        
        /// <summary>
        /// 我的相册列表
        /// </summary>
        protected string[] My_Album_List ={ "AlbumID", "[AlbumID],[UserID],[Title],[Description],[ImagesCount],[CreateTime],[Privacy],[GroupID]", "[NT_Album] Where [UserID]=@UserID", "order by AlbumID desc" };

        /// <summary>
        /// 群组相册列表
        /// </summary>
        protected string[] Group_Album_List ={ "AlbumID", "[AlbumID],[UserID],[Title],[Description],[ImagesCount],[CreateTime],[Privacy],[GroupID]", "[NT_Album] Where [UserID] in (select FriendID from [NT_Friend] where GroupID=@GroupID)", "order by AlbumID desc" };

        /// <summary>
        /// 相册查看
        /// </summary>
        protected string[] Album_View ={ "PhotoID", "[PhotoID],[AlbumID],[Description],[Views],[FileSize],[State],[IsCover],[Comments],[PostTime],[PostIP],[IsLock],[PhotoType],[Width],[Height],[UploadUser],[FilePath]", "[NT_Photo] where IsLock=0 and PhotoType=1 and AlbumID=@AlbumID", "order by PhotoID desc" };

        /// <summary>
        /// 头像相册查看
        /// </summary>
        protected string[] Album_Head_View ={ "PhotoID", "[PhotoID],[AlbumID],[Description],[Views],[FileSize],[State],[IsCover],[Comments],[PostTime],[PostIP],[IsLock],[PhotoType],[Width],[Height],[UploadUser],[FilePath]", "[NT_Photo] where IsLock=0 and PhotoType=0 and AlbumID=@AlbumID and [UploadUser]=@UserID", "order by PhotoID desc" };

        /// <summary>
        /// 被圈好友列表
        /// </summary>
        protected string[] FriendLasso_List ={ "ID", "[ID],[PhotoID],[FriendID],[UserID],[PosX],[PosY],[PostTime],[PostIP],[IsLock],[Description]", "[NT_PhotoLasso] Where  IsLock=(0) and [FriendID] in (select FriendID from [NT_Friend] where UserID=@UserID)", "order by ID desc" };

        /// <summary>
        /// 系统留言列表
        /// </summary>
        protected string[] guestbook_aspx ={ "a.ID", "a.UserID,a.Content,a.PostTime,a.ReplyContent,a.ReplyTime,b.UserName", "[NT_SysNotepad] as a Inner Join NT_User as b on a.UserID=b.UserID Where a.Replier!=0", "order by a.ID desc" };

        /// <summary>
        /// 事件
        /// </summary>
        protected string[] NotePad_aspx ={ "a.ID", "a.ID,a.title,a.content,a.txtime,a.LastPostTime,a.LastPostIP", "[NT_Notepad] a where a.IsLock=0 and a.UserID=@UserID", "order by a.ID desc" };

        /// <summary>
        /// 动作表情
        /// </summary>
        protected string[] Poke_My_aspx ={ "ID", "ID,UserID,FriendID,PostTime,PostIP,IsRead,gType,isPub,poketo,pokefrom,isDel", "[NT_greet] where FriendID=@UserID and isDel=0", "order by ID desc" };

        /// <summary>
        /// 应用程序列表
        /// </summary>
        protected string[] AppList_aspx = { "AppID", "AppID,AppName,Description,CreationTime,UserID,IsLock,Url,Icon,[Type],Hot,MidIcon,BigIcon,IsSys", "[App_App] where isLock=0 and toadmin=1", "Order by AppID desc" };

        /// <summary>
        /// 开发者应用程序列
        /// </summary>
        protected string[] DevAppList_aspx ={ "AppID", "AppID,AppName,Description,CreationTime,UserID,IsLock,Url,Icon,[Type],Hot,MidIcon,BigIcon,IsSys,AppKey,ToAdmin", "[App_App] where UserID=@UserID", "Order by AppID desc" };

        /// <summary>
        /// 我的应用 @UserID
        /// </summary>
        protected string[] MyAppList_aspx = { "AppID", "AppID,AppName,Description,CreationTime,UserID,IsLock,Url,Icon,[Type],Hot,MidIcon,BigIcon,IsSys", "[App_App] where IsLock=0  and toadmin=1 and AppID in (Select AppID from App_UserApp where UserID=@UserID)", "Order by AppID desc" };

        /// <summary>
        /// 热门应用
        /// </summary>
        protected string[] AppHot_aspx ={ "AppID", "AppID,AppName,Description,CreationTime,UserID,IsLock,Url,Icon,[Type],Hot,MidIcon,BigIcon,IsSys", "[App_App] where isLock=0 and toadmin=1", "Order by hot desc" };

        /// <summary>
        /// 按照类别 @Type
        /// </summary>
        protected string[] AppType_aspx = { "AppID", "AppID,AppName,Description,CreationTime,UserID,IsLock,Url,Icon,[Type],Hot,MidIcon,BigIcon,IsSys", "[App_App] where isLock=0 and [type]=@type  and toadmin=1", "Order by hot desc" };

        /// <summary>
        /// 最新投
        /// </summary>
        protected string[] vote_new_aspx ={ "a.ID", "a.ID,a.Title,a.Intro,a.UserID,a.AddTime,a.Mode,a.EndTime,a.JCnt,b.UserName", "NT_Vote AS a INNER JOIN NT_User AS b ON a.[userid]=b.[userid] Where a.ID Not In(Select VoteID From Nt_ToVote Where UserID=@UserID)", "order by a.ID desc" };


        /// <summary>
        /// 最新投朋友
        /// </summary>
        protected string[] vote_friend_aspx ={ "a.ID", "a.ID,a.Title,a.Intro,a.UserID,a.AddTime,a.Mode,a.EndTime,a.JCnt,b.UserName", "NT_Vote AS a INNER JOIN NT_User AS b ON a.[userid]=b.[userid] Where a.ID Not In(Select VoteID From Nt_ToVote Where UserID=@UserID) and a.UserID!=@UserID and a.UserID in (select FriendID from NT_Friend where NT_Friend.UserID=@UserID)", "order by a.ID desc" };

        /// <summary>
        /// 最新投指定某人
        /// </summary>
        protected string[] vote_ID_aspx ={ "a.ID", "a.ID,a.Title,a.Intro,a.UserID,a.AddTime,a.Mode,a.EndTime,a.JCnt,b.UserName", "NT_Vote AS a INNER JOIN NT_User AS b ON a.[userid]=b.[userid] Where a.UserID=@UserID", "order by a.ID desc" };

        /// <summary>
        /// 最新投我的
        /// </summary>
        protected string[] vote_my_aspx ={ "a.ID", "a.ID,a.Title,a.Intro,a.UserID,a.AddTime,a.Mode,a.EndTime,a.JCnt,b.UserName", "NT_Vote AS a INNER JOIN NT_User AS b ON a.[userid]=b.[userid] Where a.UserID=@UserID", "order by a.ID desc" };

        /// <summary>
        /// 最新投我参与的
        /// </summary>
        protected string[] vote_myc_aspx ={ "a.ID", "a.ID,a.Title,a.Intro,a.UserID,a.AddTime,a.Mode,a.EndTime,a.JCnt,c.UserName", "NT_Vote As a Inner Join Nt_ToVote As b On a.ID=b.VoteID inner join NT_User AS c on a.[userid]=c.[userid] Where b.UserID=@UserID", "order by b.ID desc" };

        /// <summary>
        /// 最新投热点
        /// </summary>
        protected string[] vote_hot_aspx ={ "a.ID", "a.ID,a.Title,a.Intro,a.UserID,a.AddTime,a.Mode,a.EndTime,a.JCnt,b.UserName", "NT_Vote AS a INNER JOIN NT_User AS b ON a.[userid]=b.[userid]", "order by a.JCnt desc,a.ID desc" };
        #endregion

        /// <summary>
        ///电影类型列表
        /// </summary>
        protected string[] sortlist_aspx = { "ID", "ID,SortName", "NT_Dict_MovieSort Where 1=1", "order by ID desc" };

        /// <summary>
        ///电影列表
        /// </summary>
        protected string[] movieList_aspx = { "MovieID", "MovieID,Title,Director,YearOnShow,Score,Billing,(select SortName from NT_MovieSort where NT_Movie.SortID=NT_MovieSort.ID) as CName,SortID", "NT_Movie  Where 1=1", "order by MovieID desc" };

        /// <summary>
        ///电影列表(搜索)
        /// </summary>
        protected string[] MovieList_Key_aspx = { "MovieID", "MovieID,Title,Director,YearOnShow,Score,Billing,(select SortName from NT_MovieSort where NT_Movie.SortID=NT_MovieSort.ID) as CName,SortID", "NT_Movie  Where (Title like @Key or Billing like @Key)", "order by MovieID desc" };
        /// <summary>
        ///电影列表(分类)
        /// </summary>
        protected string[] MovieList_C_aspx = { "MovieID", "MovieID,Title,Director,YearOnShow,Score,Billing,(select SortName from NT_MovieSort where NT_Movie.SortID=NT_MovieSort.ID) as CName,SortID", "NT_Movie  Where SortID=@C", "order by MovieID desc" };

        /// <summary>
        ///电影海报列表
        /// </summary>
        protected string[] moviepiclist_aspx = { "ID", "ID,FileName,UserID,isLock", "NT_MoviePoster Where MovieID=@MovieID", "order by ID desc" };

        /// <summary>
        ///电影海报列表(前台)
        /// </summary>
        protected string[] moviepiclist_u_aspx = { "ID", "ID,FileName,UserID", "NT_MoviePoster Where MovieID=@MovieID and islock=0", "order by ID desc" };

        /// <summary>
        ///获取会员列表
        /// </summary>
        protected string[] UserList_u_aspx = { "UserID", "UserID,Email,UserName,State=(case State when 0 then '等待验证' when 1 then '锁定' when 5 then '正常' when 2 then '正常，未验证邮件' end),RegTime,LoginTimes,Recommended=(case isRec when 1 then '是' else '不是' end)", "NT_User where 1=1", "order by UserID desc" };

        /// <summary>
        ///获取会员列表(带状态条件)
        /// </summary>
        protected string[] UserList_aspx = { "UserID", "UserID,Email,UserName,State=(case State when 0 then '等待验证' when 1 then '锁定' when 5 then '正常' when 2 then '正常，未验证邮件' end),RegTime,LoginTimes,Recommended=(case isRec when 1 then '是' else '不是' end)", "NT_User where State=@s", "order by UserID desc" };

        /// <summary>
        ///按姓名查询会(带状态条件)
        /// </summary>
        protected string[] UserList_Name_aspx = { "UserID", "UserID,Email,UserName ,State=(case State when 0 then '等待验证' when 1 then '锁定' when 5 then '正常' when 2 then '正常，未验证邮件' end),RegTime,LoginTimes,Recommended=(case isRec when 1 then '是' else '不是' end)", "NT_User where Email like @Key or UserName like @Key", "order by UserID desc" };

        /// <summary>
        ///获取会员教育信息列表
        /// </summary>
        protected string[] EducationList_aspx = { "a.ID", "ID,a.UserID,Degree=(case a.DegreeID when 1 then '初中' when 2 then '高中' when 3 then '大学' when 4 then '研究 else '博士' end),SchoolName=(select SchoolName from NT_Dict_School where SchoolID=a.SchoolID),Name=(select Name from NT_Dict_Academy where ID=a.AcademyID),a.MatriculationYear,IsLock=(case IsLock when 0 then '正常' when 1 then '锁定' end)", "NT_UserEducation a where a.UserID=@UserID", "order by a.PostTime desc" };

        /// <summary>
        ///获取会员工作信息列表
        /// </summary>
        protected string[] CareerList_aspx = { "ID", "UserID,ID,Company,Description,IsStill=(case IsStill when 0 then '已离 when 1 then '在职' end),JoinYear,JoinMonth,LeaveYear,LeaveMonth", "NT_UserCareer where UserID=@UserID", "order by PostTime desc" };

        /// <summary>
        /// 群组列表
        /// </summary>
        protected string[] managegrouplist_aspx ={ "a.GroupID", "a.GroupID,a.GroupName,a.UserID,a.Members,a.Bulletin,a.Publicity,a.Portrait,a.State,a.PostTime,a.IsRec,b.UserName,c.[Name],(Select Count(d.ID) From NT_GroupDiscuss as d Where d.DiscussType=0 And d.State=0 And a.GroupID=d.GroupID ) as Cnt", "NT_UserGroup as a inner Join NT_User as b On a.UserID=b.UserID Left Join NT_Dict_Area as c on a.NetWork=c.id", "order by a.GroupID desc" };
        /// <summary>
        /// 群组列表(首页推荐)
        /// </summary>
        protected string[] Group_Index_Rec_aspx ={ "GroupID", "GroupID,GroupName,UserID,Members,Bulletin,Portrait", "NT_UserGroup where isRec=1 and Publicity=0 and (Portrait<>'' and Portrait not like '%default/images/000.jpg%') and members>10 and (select count(ID) from NT_groupdiscuss where NT_groupdiscuss.GroupID=NT_UserGroup.GroupID)>10", "order by newid()" };
        /// <summary>
        /// 群组列表(搜索)
        /// </summary>
        protected string[] managegrouplist_Key_aspx ={ "a.GroupID", "a.GroupID,a.GroupName,a.UserID,a.Members,a.Bulletin,a.Publicity,a.Portrait,a.State,a.PostTime,a.IsRec,b.UserName,c.[Name],(Select Count(d.ID) From NT_GroupDiscuss as d Where d.DiscussType=0 And d.State=0 And a.GroupID=d.GroupID ) as Cnt", "NT_UserGroup as a inner Join NT_User as b On a.UserID=b.UserID Left Join NT_Dict_Area as c on a.NetWork=c.id Where (a.GroupName Like @Key) Or (b.UserName Like @Key) Or (c.[Name] Like @Key)", "order by a.GroupID desc" };

        /// <summary>
        /// 相册列表
        /// </summary>
        protected string[] manageAlbumList_aspx ={ "a.AlbumID", "a.AlbumID,a.UserID,a.Title,a.Description,a.ImagesCount,a.CreateTime,a.Privacy,a.LastUploadTime,b.UserName", "NT_Album a inner join nt_user b on b.UserID=a.UserID", "order by @order desc" };

        /// <summary>
        /// 相册搜索
        /// </summary>
        protected string[] manageAlbumlist_key_aspx ={ "a.AlbumID", "a.AlbumID,a.UserID,a.Title,a.Description,a.ImagesCount,a.CreateTime,a.Privacy,a.LastUploadTime,b.UserName", "NT_Album a inner join nt_user b on b.UserID=a.UserID where Title like @key or description like @key or b.UserName like @key", "order by @order desc" };

        /// <summary>
        /// 照片列表
        /// </summary>
        protected string[] managePhotoList_aspx ={ "a.PhotoID", "a.PhotoID,a.AlbumID,a.UploadUser,a.Description,a.Views,a.FileSize,a.State,a.IsCover,a.Comments,a.PostTime,a.PostIP,a.isLock,a.PhotoType,a.Width,a.Height,a.FilePath,b.Title as AlbumTitle,c.UserName", "NT_Photo a inner join nt_Album b on b.AlbumID=a.AlbumID inner join Nt_User c on c.UserID=a.UploadUser", "order by @order desc" };

        /// <summary>
        /// 照片搜索
        /// </summary>
        protected string[] managePhotoList_key_aspx ={ "a.PhotoID", "a.PhotoID,a.AlbumID,a.UploadUser,a.Description,a.Views,a.FileSize,a.State,a.IsCover,a.Comments,a.PostTime,a.PostIP,a.isLock,a.PhotoType,a.Width,a.Height,a.FilePath,b.Title as AlbumTitle,c.UserName", "NT_Photo a inner join nt_Album b on b.AlbumID=a.AlbumID inner join Nt_User c on c.UserID=a.UploadUser where a.Description like @key or b.Title like @key or c.UserName like @key", "order by @order desc" };

        /// <summary>
        /// 地区列表
        /// </summary>
        protected string[] AreaList_aspx ={ "ID", "ID,ParentID,Name,IsLock=case IsLock when '0' then '正常' when '1' then '锁定' end", "NT_Dict_Area where 1=1", "order by ID desc" };

        /// <summary>
        /// 系统留言列表
        /// </summary>
        protected string[] guestbook_1_aspx ={ "a.ID", "a.ID,a.SendID,a.RecID,a.Content,a.PostTime,a.PostIP,b.UserName", "[NT_gbook] as a Inner Join NT_User as b on a.SendID=b.UserID", "order by a.ID desc" };
        /// <summary>
        /// 系统留言列表(给管理员的)
        /// </summary>
        protected string[] guestbookA_1_aspx ={ "a.ID", "a.ID,a.SendID,a.RecID,a.Content,a.PostTime,a.PostIP,b.UserName", "[NT_gbook] as a Inner Join NT_User as b on a.SendID=b.UserID and a.RecID=-1", "order by a.ID desc" };

        ///搜索帮助
        protected string[] Search_HelpList_aspx ={ "ID", "ID,SN,Title,Content", "NT_Help where SN like @SN", "order by ID desc" };
        ///搜索帮助
        protected string[] HelpList_aspx ={ "ID", "ID,SN,Title,Content", "NT_Help where 1=1", "order by ID desc" };

        ///按照用户名或者电子邮件搜
        protected string[] Search_Name_User ={ "a.UserID", "a.UserID,a.UserName,b.Favourite,b.BirthidayDisplay,b.Birthday,(select Name from NT_Dict_Area where id=a.Province) as Province,(select FilePath from NT_Photo where PhotoID=a.Portrait and PhotoType=0) as Photo,(select Sex=case Sex when 0 then '美女' when 1 then '帅哥' end) as Sex,(select Name from NT_Dict_Area where id=a.City) as City", "NT_User a left join  NT_UserInfo b on a.UserID=b.UserID where  (a.Email like @key or a.UserName like @key) and (a.State=5 or a.State=2)", "order by a.UserID desc" };

        /// <summary>
        /// 搜索地区列表
        /// </summary>
        protected string[] Search_AreaList_aspx ={ "ID", "ID,ParentID,Name,IsLock=case IsLock when '0' then '正常' when '1' then '锁定' end", "NT_Dict_Area where Name like @Name", "order by ID desc" };

        /// <summary>
        /// 搜索行业列表
        /// </summary>
        protected string[] Search_VocationList_aspx ={ "ID", "ID,VocName,IsLock=case IsLock when '0' then '正常' when '1' then '锁定' end", "NT_dict_vocation where VocName like @Name", "order by ID desc" };
        /// <summary>
        /// 搜索行业列表
        /// </summary>
        protected string[] VocationList_aspx ={ "ID", "ID,VocName,IsLock=case IsLock when '0' then '正常' when '1' then '锁定' end", "NT_dict_vocation where 1=1", "order by ID desc" };
        /// <summary>
        /// 礼物（后台）
        /// </summary>
        protected string[] Gift_m_aspx ={ "ID", "ID,GName,IsLock=case IsLock when '0' then '正常' when '1' then '锁定' end,Picture,UseNumber,point,Content,classID,(select CName from NT_GIFTClass where nt_giftclass.id=nt_gift.classID) as CName", "NT_Gift where 1=1", "order by ID desc" };
        /// <summary>
        /// 礼物（后台）
        /// </summary>
        protected string[] Gift_mc_aspx ={ "ID", "ID,GName,IsLock=case IsLock when '0' then '正常' when '1' then '锁定' end,Picture,UseNumber,point,Content,classID,(select CName from NT_GIFTClass where nt_giftclass.id=nt_gift.classID) as CName", "NT_Gift where classID=@C", "order by ID desc" };

        ///新闻分页
        protected string[] News_ALL_aspx ={ "ID", "ID,Title,CreatTime,ClassID,Content,Pic,click,(select ClassName from NT_Newsclass where NT_Newsclass.ID=NT_News.ClassID) as CName", "NT_News where isLock=0 and isSys=0", "order by ID desc" };

        ///新闻分页(管理)
        protected string[] Mange_News_aspx ={ "ID", "ID,Title,CreatTime,ClassID,Content,Pic,click,isLock=case IsLock when '0' then '正常' when '1' then '锁定' end,isSys=case isSys when '0' then '普通' when '1' then '系统' end,(select ClassName from NT_Newsclass where NT_Newsclass.ID=NT_News.ClassID) as CName", "NT_News where 1=1", "order by ID desc" };
        ///新闻分页(管理)
        protected string[] Mange_NewsL_aspx ={ "ID", "ID,Title,CreatTime,ClassID,Content,Pic,click,isLock=case IsLock when '0' then '正常' when '1' then '锁定' end,isSys=case isSys when '0' then '普通' when '1' then '系统' end,(select ClassName from NT_Newsclass where NT_Newsclass.ID=NT_News.ClassID) as CName", "NT_News where (Title like @Key) or (Content like @Key)", "order by ID desc" };
        ///新闻分页(管理)
        protected string[] Mange_NewsC_aspx ={ "ID", "ID,Title,CreatTime,ClassID,Content,Pic,click,isLock=case IsLock when '0' then '正常' when '1' then '锁定' end,isSys=case isSys when '0' then '普通' when '1' then '系统' end,(select ClassName from NT_Newsclass where NT_Newsclass.ID=NT_News.ClassID) as CName", "NT_News where ClassID=@c", "order by ID desc" };

        ///新闻分页(热点)
        protected string[] News_hot_aspx ={ "ID", "ID,Title,CreatTime,ClassID,Content,click,Pic,(select ClassName from NT_Newsclass where NT_Newsclass.ID=NT_News.ClassID) as CName", "NT_News where isLock=0 and isSys=0", "order by click desc" };

        ///新闻分页(栏目)
        protected string[] News_Class_aspx ={ "ID", "ID,Title,CreatTime,ClassID,Content,click,Pic,(select ClassName from NT_Newsclass where NT_Newsclass.ID=NT_News.ClassID) as CName", "NT_News where isLock=0 and ClassID=@ClassID", "order by ID desc" };

        ///新闻评论分页
        protected string[] NewsComment_aspx ={ "ID", "ID,newsID,content,UserID,(select UserName from NT_User where NT_User.UserID=NT_NewsComment.UserID) as UserName,parentID,IP,CreatTime", "NT_NewsComment where NewsID=@NewsID", "order by ID desc" };
        /// <summary>
        /// 管理员所有应用程序列表
        /// </summary>
        protected string[] manageAppList_aspx = { "AppID", "AppID,AppName,Description,CreationTime,UserID,IsLock,Url,Icon,[Type],Hot,MidIcon,BigIcon,IsSys,toadmin,mobile,tel,email", "[App_App]", "Order by AppID desc" };
        /// <summary>
        /// 管理员分类应用列表
        /// </summary>
        protected string[] manageTypeAppList_aspx ={ "AppID", "AppID,AppName,Description,CreationTime,UserID,IsLock,Url,Icon,[Type],Hot,MidIcon,BigIcon,IsSys,toadmin,mobile,tel,email", "[App_App] where [Type]=@ctype", "Order by AppID desc" };
        /// <summary>
        /// 作者申请
        /// </summary>
        protected string[] devRequest_aspx ={ "ID", "ID,UserID,CreationTime,Enabled", "App_Developer", "Order By ID desc" };
        /// <summary>
        /// 管理员搜索应用程序列表
        /// </summary>
        protected string[] manageSearchAppList_aspx ={ "AppID", "AppID,AppName,Description,CreationTime,UserID,IsLock,Url,Icon,[Type],Hot,MidIcon,BigIcon,IsSys,toadmin,mobile,tel,email", "[App_App] where AppName like @likekey or Description like @likekey ", "Order by AppID desc" };

        /// <summary>
        /// 问答，所有
        /// </summary>
        protected string[] ask_all_aspx ={ "ID", "ID,title,classID,isJinji,isClose,UserID,(select ClassName from NT_askClass where NT_askClass.ID=NT_ask.ClassID) as ClassName", "[NT_ask] where ParentID=0 and isLock=0", "Order by ID desc" };
        protected string[] ask_my_aspx ={ "ID", "ID,title,classID,isJinji,isClose,UserID,(select ClassName from NT_askClass where NT_askClass.ID=NT_ask.ClassID) as ClassName", "[NT_ask] where ParentID=0 and  UserID=@UserID", "Order by ID desc" };
        protected string[] ask_unclose_aspx ={ "ID", "ID,title,classID,isJinji,isClose,UserID,(select ClassName from NT_askClass where NT_askClass.ID=NT_ask.ClassID) as ClassName", "[NT_ask] where ParentID=0 and  isclose=0", "Order by ID desc" };
        protected string[] ask_isclose_aspx ={ "ID", "ID,title,classID,isJinji,isClose,UserID,(select ClassName from NT_askClass where NT_askClass.ID=NT_ask.ClassID) as ClassName", "[NT_ask] where ParentID=0 and  isclose=1", "Order by ID desc" };
        protected string[] ask_friend_aspx ={ "ID", "ID,title,classID,isJinji,isClose,UserID,(select ClassName from NT_askClass where NT_askClass.ID=NT_ask.ClassID) as ClassName", "[NT_ask] where ParentID=0 and  userid in (select FriendID From NT_Friend where NT_Friend.UserID=@UserID) and UserID!=@UserID", "Order by ID desc" };
        protected string[] ask_ji_aspx ={ "ID", "ID,title,classID,isJinji,UserID,isClose,(select ClassName from NT_askClass where NT_askClass.ID=NT_ask.ClassID) as ClassName", "[NT_ask] where ParentID=0 and  isclose=0 and isJinji=1", "Order by ID desc" };
        /// <summary>
        /// 问答，所有(搜索)
        /// </summary>
        protected string[] ask_all_key_aspx ={ "ID", "ID,title,classID,isJinji,UserID,isClose,(select ClassName from NT_askClass where NT_askClass.ID=NT_ask.ClassID) as ClassName", "[NT_ask] where ParentID=0 and isLock=0 and (title like @key or Content like @key or tag like @key )", "Order by ID desc" };
        /// <summary>
        /// 问答，所有(分类)
        /// </summary>
        protected string[] ask_all_class_aspx ={ "ID", "ID,title,classID,isJinji,UserID,isClose,(select ClassName from NT_askClass where NT_askClass.ID=NT_ask.ClassID) as ClassName", "[NT_ask] where ParentID=0 and isLock=0 and  classID=@ClassID", "Order by ID desc" };

        ///搜索个人爱好信息
        protected string[] Search_Favourite_aspx ={ "a.UserID", "a.UserID,a.UserName,Province=(select Name from NT_Dict_Area where id=a.Province),b.MSN,b.GTalk,b.Mobile,Photo=(select FilePath from NT_Photo where PhotoID=a.Portrait and PhotoType=0) ", "NT_User a inner join  NT_UserInfo b on a.UserID=b.UserID where Favourite like @where", "order by a.RegTime desc" };
        ///搜索个人喜欢的音乐
        protected string[] Search_FavMusics_aspx ={ "a.UserID", "a.UserID,a.UserName,Province=(select Name from NT_Dict_Area where id=a.Province),b.MSN,b.GTalk,b.Mobile,Photo=(select FilePath from NT_Photo where PhotoID=a.Portrait and PhotoType=0) ", "NT_User a inner join  NT_UserInfo b on a.UserID=b.UserID where FavMusics like @where", "order by a.RegTime desc" };
        ///搜索个人喜欢的电影
        protected string[] Search_FavMovies_aspx ={ "a.UserID", "a.UserID,a.UserName,Province=(select Name from NT_Dict_Area where id=a.Province),b.MSN,b.GTalk,b.Mobile,Photo=(select FilePath from NT_Photo where PhotoID=a.Portrait and PhotoType=0) ", "NT_User a inner join  NT_UserInfo b on a.UserID=b.UserID where FavMovies like @where", "order by a.RegTime desc" };
        ///搜索个人喜欢的动漫
        protected string[] Search_FavCartoons_aspx ={ "a.UserID", "a.UserID,a.UserName,Province=(select Name from NT_Dict_Area where id=a.Province),b.MSN,b.GTalk,b.Mobile,Photo=(select FilePath from NT_Photo where PhotoID=a.Portrait and PhotoType=0) ", "NT_User a inner join  NT_UserInfo b on a.UserID=b.UserID where FavCartoons like @where", "order by a.RegTime desc" };
        ///搜索个人喜欢的游戏
        protected string[] Search_FavGames_aspx ={ "a.UserID", "a.UserID,a.UserName,Province=(select Name from NT_Dict_Area where id=a.Province),b.MSN,b.GTalk,b.Mobile,Photo=(select FilePath from NT_Photo where PhotoID=a.Portrait and PhotoType=0) ", "NT_User a inner join  NT_UserInfo b on a.UserID=b.UserID where FavGames like @where", "order by a.RegTime desc" };
        ///搜索个人喜欢的运动
        protected string[] Search_FavSports_aspx ={ "a.UserID", "a.UserID,a.UserName,Province=(select Name from NT_Dict_Area where id=a.Province),b.MSN,b.GTalk,b.Mobile,Photo=(select FilePath from NT_Photo where PhotoID=a.Portrait and PhotoType=0) ", "NT_User a inner join  NT_UserInfo b on a.UserID=b.UserID where FavSports like @where", "order by a.RegTime desc" };
        ///搜索个人喜欢的书
        protected string[] Search_FavBooks_aspx ={ "a.UserID", "a.UserID,a.UserName,Province=(select Name from NT_Dict_Area where id=a.Province),b.MSN,b.GTalk,b.Mobile,Photo=(select FilePath from NT_Photo where PhotoID=a.Portrait and PhotoType=0) ", "NT_User a inner join  NT_UserInfo b on a.UserID=b.UserID where FavBooks like @where", "order by a.RegTime desc" };
        ///搜索个人欣赏的人
        protected string[] Search_AppreciateMen_aspx ={ "a.UserID", "a.UserID,a.UserName,Province=(select Name from NT_Dict_Area where id=a.Province),b.MSN,b.GTalk,b.Mobile,Photo=(select FilePath from NT_Photo where PhotoID=a.Portrait and PhotoType=0) ", "NT_User a inner join  NT_UserInfo b on a.UserID=b.UserID where AppreciateMen like @where", "order by a.RegTime desc" };
        ///搜索同一公司的人
        protected string[] Search_Company_aspx ={ "a.UserID", "a.UserID,a.ID,b.UserName,Province=(select Name from NT_Dict_Area where id=b.Province),a.Company,a.JoinYear,a.IsStill,a.JoinMonth,a.LeaveYear,a.LeaveMonth,Photo=(select FilePath from NT_Photo where PhotoID=b.Portrait and PhotoType=0) ", "NT_UserCareer a inner join NT_User b on a.userID=b.UserID  where a.Company like @where", "order by b.RegTime desc" };
        ///搜索同一学校的人
        protected string[] Search_SchoolID_aspx ={ "c.UserID", "c.UserID,c.UserName,Province=(select Name from NT_Dict_Area where id=c.Province),Photo=(select FilePath from NT_Photo where PhotoID=c.Portrait and PhotoType=0),c.RegTime", "NT_Dict_School a inner join NT_UserEducation b on a.SchoolID=b.SchoolID inner join NT_User c  on b.UserID=c.UserID where b.SchoolID=@where", "order by c.RegTime desc,c.UserID desc" };
        ///搜索同一学校同一院校的人
        protected string[] Search_AcademyID_aspx ={ "c.UserID", "c.UserID,c.UserName,Province=(select Name from NT_Dict_Area where id=c.Province),Photo=(select FilePath from NT_Photo where PhotoID=c.Portrait and PhotoType=0),c.RegTime ", "NT_Dict_School a join NT_UserEducation b on a.SchoolID=b.SchoolID join NT_User c  on b.UserID=c.UserID where b.SchoolID=@SchoolID and b.AcademyID=@AcademyID", "order by c.RegTime desc" };

        /// <summary>
        /// 获取SQL语句
        /// </summary>
        /// <param name="PageName"></param>
        /// <returns></returns>
        protected string[] GetSqlSentence(string PageName)
        {
            FieldInfo fi = this.GetType().GetField(PageName, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.IgnoreCase);
            if (fi == null)
                throw new Exception("没有找到SQL");
            return (string[])fi.GetValue(this);
        }

        /// <summary>
        /// 取得分页
        /// </summary>
        /// <param name="pageCode">分页代码,通常为类/param>
        /// <param name="pageIndex">当前页码(从１开始，大于总页数，则为最后一</param>
        /// <param name="pageSize">每页记录条数</param>
        /// <param name="recordCount">返回记录总数</param>
        /// <param name="pageCount">返回总页/param>
        /// <param name="conditions">查询条件</param>
        /// <returns></returns>
        DataTable IUtilPage.GetPage(string pageCode, int pageIndex, int pageSize, out int recordCount, out int pageCount, params SqlConditionInfo[] conditions)
        {
            try
            {
                string[] Sql = GetSqlSentence(pageCode);
                string IndexField = Sql[0];
                string AllFields = Sql[1];
                string TablesAndWhere = Sql[2];
                string OrderFields = Sql[3];
                if (conditions != null)
                {
                    foreach (SqlConditionInfo con in conditions)
                    {
                        if (con == null)
                            continue;
                        string paramnme = con.ParamName;
                        if (paramnme.IndexOf("@") == -1)
                        {
                            paramnme = "@" + paramnme; ;
                        }
                        TablesAndWhere = TablesAndWhere.Replace(paramnme, Util.GetStr(con));
                        OrderFields = OrderFields.Replace(con.ParamName, con.ParamValue.ToString());
                    }
                }
                return Pagination.ProcPage(AllFields, TablesAndWhere, IndexField, OrderFields, pageIndex, pageSize, out recordCount, out pageCount);
            }
            catch (SqlException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new Exception("用于分页的SQL语句无效," + e.Message);
            }
        }


        /// <summary>
        /// 找好朋友分页
        /// </summary>
        /// <param name="keywords">标识</param>
        /// <param name="pr">/param>
        /// <param name="city">/param>
        /// <param name="beginYear">最小年/param>
        /// <param name="endyear">最大年/param>
        /// <param name="sex">性别</param>
        /// <param name="tx">是否显示头像</param>
        /// <param name="PageSize"></param>
        /// <param name="RecordCount"></param>
        /// <param name="PageCount"></param>
        /// <param name="SqlCondition"></param>
        /// <returns></returns>
        DataTable IUtilPage.GetUserPage(int pr, int city, int beginYear, int endyear, int sex, int tx, int PageIndex, int PageSize, out int RecordCount, out int PageCount, params SqlConditionInfo[] SqlCondition)
        {
            SqlParameter[] param = new SqlParameter[5];
            param[0] = new SqlParameter("@pr", SqlDbType.Int, 4);
            param[0].Value = pr;
            param[1] = new SqlParameter("@city", SqlDbType.Int, 4);
            param[1].Value = city;
            param[2] = new SqlParameter("@beginYear", SqlDbType.Int, 4);
            param[2].Value = beginYear;
            param[3] = new SqlParameter("@endyear", SqlDbType.Int, 4);
            param[3].Value = endyear;
            param[4] = new SqlParameter("@sex", SqlDbType.Bit, 1);
            param[4].Value = sex;

            string sFilter = " where a.UserID<>'' ";
            string IndexField = "a.UserID";
            string OrderFields = "order by newid()";
            string AllFields = " a.UserID,a.UserName,b.Favourite,b.BirthidayDisplay,b.Birthday,Province=(select Name from NT_Dict_Area where id=a.Province),Photo=(select FilePath from NT_Photo where PhotoID=a.Portrait and PhotoType=0),Sex=(select Sex=case Sex when 0 then '美女' when 1 then '帅哥' end),City=(select Name from NT_Dict_Area where id=a.City) ";
            string Condition = " NT_User a inner join  NT_UserInfo b on a.UserID=b.UserID ";

            if (pr != 0)
            {
                sFilter += " and Province=@pr ";
            }
            if (city != 0)
            {
                sFilter += " and City=@city ";
            }
            if (beginYear != 0)
            {
                sFilter += " and (datepart(year, getdate()) -datepart(year,b.Birthday))>=@beginYear ";
            }
            if (endyear != 0)
            {
                sFilter += " and (datepart(year, getdate()) -datepart(year,b.Birthday))<=@endyear ";
            }
            if (sex != 2)
            {
                sFilter += " and b.Sex=@sex ";
            }
            if (tx == 1)
            {
                sFilter += " and c.FilePath<>'' ";
                Condition = " NT_User a inner join NT_UserInfo b on a.UserID=b.UserID inner join NT_Photo c on c.PhotoID=a.Portrait and PhotoType=0 ";
                AllFields = " a.UserID,a.UserName,b.Favourite,b.BirthidayDisplay,b.Birthday,Province=(select Name from NT_Dict_Area where id=a.Province),Photo=c.FilePath,Sex=(select Sex=case Sex when 0 then '美女' when 1 then '帅哥' end),City=(select Name from NT_Dict_Area where id=a.City) ";
            }
            Condition = Condition + sFilter;
            return DbHelper.ExecutePage(AllFields, Condition, IndexField, OrderFields, PageIndex, PageSize, out RecordCount, out PageCount, param);
        }

        DataTable IUtilPage.GetMinPage(int PageIndex, int PageSize, out int RecordCount, out int PageCount, params SqlConditionInfo[] SqlCondition)
        {
            string sFilter = " ";
            string IndexField = "a.ID";
            string OrderFields = "ORDER BY a.ID DESC";
            string AllFields = " a.ID, a.UserID, b.Content, b.PostTime, b.MType ";
            string Condition = " (SELECT UserID, MAX(ID) AS ID FROM NT_Mood WHERE isrec = 1 GROUP BY UserID) a INNER JOIN NT_Mood b ON b.ID = a.ID";
            Condition = Condition + sFilter;
            return DbHelper.ExecutePage(AllFields, Condition, IndexField, OrderFields, PageIndex, PageSize, out RecordCount, out PageCount, null);
        }
    }
}
