using System;
using System.Data;
using System.Xml;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.Web;
using IlgharCMS;
using IlgharCMS.ArticleModule;
public partial class CIlgharCMS : IlgharCMS.Lib.AdminPageBase
{
public CIlgharCMS()
: base("IlgharCMS.ArticleModule/article_category/list.dwt.aspx")
{}
protected XmlDocument _xmlTemplate;
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
_xmlTemplate = XmlData.GetXmlDocument();
if (!String.IsNullOrEmpty(Request.QueryString["GetPageCount"]))
                            {
                                Response.Write(1);
                                Response.End();
                            }
                        
}

protected string Condition()
{
	StringBuilder condition = new StringBuilder();
	string and = String.Empty;

	#region 是否显示
	string isDisplay = Request.QueryString["IsDisplay"];
	if (isDisplay == null)
		condition.Append(Alias.ArticleCategory.IsDisplay + "=true");
	else if (isDisplay != String.Empty)
		condition.Append(Alias.ArticleCategory.IsDisplay + "=" + isDisplay);
	#endregion

	if (and == String.Empty && condition.Length != 0)
		and = " AND ";

	#region 是否推荐
	string isRecommended = Request.QueryString["IsRecommended"];
	if (!String.IsNullOrEmpty(isRecommended))
		condition.Append(and + Alias.ArticleCategory.IsRecommended + "=" + isRecommended);
	#endregion

	if (and == String.Empty && condition.Length != 0)
		and = " AND ";

	#region 是否置顶
	string isHeld = Request.QueryString["IsHeld"];
	if (!String.IsNullOrEmpty(isHeld))
		condition.Append(and + Alias.ArticleCategory.IsHeld + "=" + isHeld);
	#endregion
	
	return condition.ToString();
}

protected string Sort()
{
	string sort = String.Empty;
	switch (Request.QueryString["Sort"])
	{
		case "1":
			sort = Alias.ArticleCategory.Sort + " ASC";
			break;
		case "2":
			sort = Alias.ArticleCategory.Recommend + " DESC";
			break;
		case "3":
			sort = Alias.ArticleCategory.Recommend + " ASC";
			break;
		case "4":
			sort = Alias.ArticleCategory.Hold + " DESC";
			break;
		case "5":
			sort = Alias.ArticleCategory.Hold + " ASC";
			break;
		default:
			sort = Alias.ArticleCategory.Sort + " ASC";
			break;
	}
	
	return sort;
}

                        protected int t5083IDRecordCount
                        {
                            get
                            {
                                int instanceID;
instanceID = InstanceID;
                                using (IlgharCMS.ArticleModule.IArticleCategory bll = (IlgharCMS.ArticleModule.IArticleCategory)Manager.CreateObject("ArticleCategory", instanceID, ContentLang, true))
                                {
                                    string condition = null;
condition += Condition();


                                    return bll.GetRecordCount(condition);
                                }
                            }
                        }
                        
                            protected int t5083IDCounter = 0;
                            protected object t5083IDRecord = null;
                        
                            private DataTable t5083ID;
                            private DataTable t5083ID_
                            {
                                get
                                {
                                    string condition = null;
condition += Condition();


                                    string sort = null;sort = Sort();

                                    int instanceID;
instanceID = InstanceID;

                                    using (IlgharCMS.ArticleModule.IArticleCategory bll = (IlgharCMS.ArticleModule.IArticleCategory)Manager.CreateObject("ArticleCategory", instanceID, ContentLang, true))
                                    {
                                        t5083ID = bll.List(-1, -1, condition, sort);
                                    }

                                    return t5083ID;
                                }
                            }
                        
                            protected string t5083
                            {
                                get
                                {
                                    XmlNode node = _xmlTemplate.SelectSingleNode("//t5083");
                                    Dictionary<string, object> replacementPair = new Dictionary<string, object>();
                                    replacementPair["{#Control#}"] = null;replacementPair["{#ChildRecords#}"] = null;
                                        replacementPair[@"{#ImagePath#}"] = new CustomBuildTree(
                                                                        delegate(TreeNode record, int index)
                                                                        {
                                                                            object t6659 = ImagePath;
                                                                            if (t6659 != null)
                                                                                return t6659.ToString();
                                                                            else
                                                                                return String.Empty;
                                                                        }
                                                                        );
                                                
                                        replacementPair[@"{#ContentLang#}"] = new CustomBuildTree(
                                                                        delegate(TreeNode record, int index)
                                                                        {
                                                                            object t6834 = ContentLang;
                                                                            if (t6834 != null)
                                                                                return t6834.ToString();
                                                                            else
                                                                                return String.Empty;
                                                                        }
                                                                        );
                                                replacementPair["{#InnerID#}"] = IlgharCMS.ArticleModule.Alias.ArticleCategory.InnerID;replacementPair["{#ParentInnerID#}"] = IlgharCMS.ArticleModule.Alias.ArticleCategory.InnerID;replacementPair["{#Name#}"] = IlgharCMS.ArticleModule.Alias.ArticleCategory.Name;replacementPair["{#ID#}"] = IlgharCMS.ArticleModule.Alias.ArticleCategory.ID;
                                    StringBuilder all = Manager.BuildTree(node, t5083ID_, replacementPair, IlgharCMS.ArticleModule.Alias.ArticleCategory.ParentID, IlgharCMS.ArticleModule.Alias.ArticleCategory.ID, ref t5083IDRecord, ref t5083IDCounter);
                                    
                                    
                                    
                                    return all.ToString();
                                }
                            }
                          }
