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.ShopModule;
public partial class CIlgharCMS : IlgharCMS.Lib.AdminPageBase
{
public CIlgharCMS()
: base("IlgharCMS.ShopModule/goods_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.GoodsCategory.IsDisplay + "=true");
	else if (isDisplay != String.Empty)
		condition.Append(Alias.GoodsCategory.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.GoodsCategory.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.GoodsCategory.IsHeld + "=" + isHeld);
	#endregion
	
	return condition.ToString();
}

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

                        protected int t5049IDRecordCount
                        {
                            get
                            {
                                int instanceID;
instanceID = InstanceID;
                                using (IlgharCMS.ShopModule.IGoodsCategory bll = (IlgharCMS.ShopModule.IGoodsCategory)Manager.CreateObject("GoodsCategory", instanceID, ContentLang, true))
                                {
                                    string condition = null;
condition += Condition();


                                    return bll.GetRecordCount(condition);
                                }
                            }
                        }
                        
                            protected int t5049IDCounter = 0;
                            protected object t5049IDRecord = null;
                        
                            private DataTable t5049ID;
                            private DataTable t5049ID_
                            {
                                get
                                {
                                    string condition = null;
condition += Condition();


                                    string sort = null;sort = Sort();

                                    int instanceID;
instanceID = InstanceID;

                                    using (IlgharCMS.ShopModule.IGoodsCategory bll = (IlgharCMS.ShopModule.IGoodsCategory)Manager.CreateObject("GoodsCategory", instanceID, ContentLang, true))
                                    {
                                        t5049ID = bll.List(-1, -1, condition, sort);
                                    }

                                    return t5049ID;
                                }
                            }
                        
                            protected string t5049
                            {
                                get
                                {
                                    XmlNode node = _xmlTemplate.SelectSingleNode("//t5049");
                                    Dictionary<string, object> replacementPair = new Dictionary<string, object>();
                                    replacementPair["{#Control#}"] = null;replacementPair["{#ChildRecords#}"] = null;
                                        replacementPair[@"{#ImagePath#}"] = new CustomBuildTree(
                                                                        delegate(TreeNode record, int index)
                                                                        {
                                                                            object t6371 = ImagePath;
                                                                            if (t6371 != null)
                                                                                return t6371.ToString();
                                                                            else
                                                                                return String.Empty;
                                                                        }
                                                                        );
                                                
                                        replacementPair[@"{#ContentLang#}"] = new CustomBuildTree(
                                                                        delegate(TreeNode record, int index)
                                                                        {
                                                                            object t6522 = ContentLang;
                                                                            if (t6522 != null)
                                                                                return t6522.ToString();
                                                                            else
                                                                                return String.Empty;
                                                                        }
                                                                        );
                                                replacementPair["{#InnerID#}"] = IlgharCMS.ShopModule.Alias.GoodsCategory.InnerID;replacementPair["{#ParentInnerID#}"] = IlgharCMS.ShopModule.Alias.GoodsCategory.InnerID;replacementPair["{#Name#}"] = IlgharCMS.ShopModule.Alias.GoodsCategory.Name;replacementPair["{#ID#}"] = IlgharCMS.ShopModule.Alias.GoodsCategory.ID;
                                    StringBuilder all = Manager.BuildTree(node, t5049ID_, replacementPair, IlgharCMS.ShopModule.Alias.GoodsCategory.ParentID, IlgharCMS.ShopModule.Alias.GoodsCategory.ID, ref t5049IDRecord, ref t5049IDCounter);
                                    
                                    
                                    
                                    return all.ToString();
                                }
                            }
                          }
