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.SystemModule;
public partial class CIlgharCMS : IlgharCMS.Lib.AdminPageBase
{
public CIlgharCMS()
: base("IlgharCMS.SystemModule/channel/edit.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 Dictionary<string, object> ThisChannel
                            {
                                get
                                {
                                    object id = null;
                                    id = Convert.ToInt32(Request.QueryString["ID"]);
                                    if (_ThisChannelID != null && _ThisChannelID == id)
                                        return _ThisChannel;

                                    int instanceID;
instanceID = InstanceID;

                                    using (IlgharCMS.SystemModule.IChannel bll = (IlgharCMS.SystemModule.IChannel)Manager.CreateObject("Channel", instanceID, ContentLang, true))
                                    {
                                        _ThisChannelID = id;
                                        _ThisChannel = bll.Get(id);
                                    }

                                    return _ThisChannel;
                                }
                            }
                            private Dictionary<string, object> _ThisChannel;
                            private object _ThisChannelID;
                            
protected string CurrentModuleID
{
	get
	{
		object instanceID = ThisChannel[IlgharCMS.SystemModule.Alias.Channel.InstanceID];
		if (Guid.Equals(instanceID, Guid.Empty))
			return Guid.Empty.ToString();
		
		DataRow[] rows = Manager.Channels.Select(IlgharCMS.SystemModule.Alias.Instance.ID + "='" + instanceID + "'");
		return rows[0][IlgharCMS.SystemModule.Alias.Module.ID].ToString();
	}
}

                        protected int t4342IDRecordCount
                        {
                            get
                            {
                                int instanceID;
instanceID = InstanceID;
                                using (IlgharCMS.SystemModule.IInstance bll = (IlgharCMS.SystemModule.IInstance)Manager.CreateObject("Instance", instanceID, ContentLang, false))
                                {
                                    string condition = null;
condition += "P2131_3_57=";
object v0 = CurrentModuleID;
                                            if (v0 == null)
                                                condition = condition.Substring(0, condition.Length - 11);
                                            else if (v0.ToString() == String.Empty)
                                                condition = condition.Substring(0, condition.Length - 1) + " IS NULL ";
                                            else
                                                condition += v0.ToString();
                                            

                                    return bll.GetRecordCount(condition);
                                }
                            }
                        }
                        
                            protected int t4342IDCounter = 0;
                            protected object t4342IDRecord = null;
                            private DataTable t4342IDData;
                            protected DataTable t4342ID
                            {
                                get
                                {
                                    if (t4342IDData != null)
                                        return t4342IDData;

                                    t4342IDData = t4342ID_;
                                    return t4342IDData;
                                }
                            }
                        
                                private DataTable t4342ID_
                                {
                                    get
                                    {
                                        string condition = null;
condition += "P2131_3_57=";
object v0 = CurrentModuleID;
                                            if (v0 == null)
                                                condition = condition.Substring(0, condition.Length - 11);
                                            else if (v0.ToString() == String.Empty)
                                                condition = condition.Substring(0, condition.Length - 1) + " IS NULL ";
                                            else
                                                condition += v0.ToString();
                                            

                                        string sort = null;

                                        int instanceID;
instanceID = InstanceID;

                                        using (IlgharCMS.SystemModule.IInstance bll = (IlgharCMS.SystemModule.IInstance)Manager.CreateObject("Instance", instanceID, ContentLang, false))
                                        {
                                            t4342IDData = bll.List(-1, -1, condition, sort);
                                        }

                                        return t4342IDData;
                                    }
                                }
                            
                            protected string t4342
                            {
                                get
                                {
                                    XmlNode node = _xmlTemplate.SelectSingleNode("//t4342");
                                    Dictionary<string, object> replacementPair = new Dictionary<string, object>();
                                    
                                        replacementPair["{#t4511#}"] = new CustomBuild(
                                                                        delegate(DataRow record, int index)
                                                                        {string t4511 = String.Empty;
if (Guid.Equals((ThisChannel==null?null:ThisChannel[IlgharCMS.SystemModule.Alias.Channel.InstanceID]),t4342ID.Rows[t4342IDCounter][IlgharCMS.SystemModule.Alias.Instance.ID]))
{t4511 = _xmlTemplate.SelectSingleNode("/" + "/t4511/If").InnerText;}
else
{t4511 = _xmlTemplate.SelectSingleNode("/" + "/t4511/Else").InnerText;}

                                                                            return t4511;
                                                                        }
                                                                        );
                                                replacementPair["{#ID#}"] = IlgharCMS.SystemModule.Alias.Instance.ID;replacementPair["{#Name#}"] = IlgharCMS.SystemModule.Alias.Instance.Name;
                                    StringBuilder all = Manager.Build(node, t4342ID_, replacementPair, ref t4342IDRecord, ref t4342IDCounter);
                                    
                                    
                                    object t4453 = ContentLang;
all.Replace("{#t4453#}",t4453 == null ? "" : t4453.ToString());

                                    return all.ToString();
                                }
                            }
                          
                        protected int t4982IDRecordCount
                        {
                            get
                            {
                                int instanceID;
instanceID = InstanceID;
                                using (IlgharCMS.SystemModule.IChannel bll = (IlgharCMS.SystemModule.IChannel)Manager.CreateObject("Channel", instanceID, ContentLang, false))
                                {
                                    string condition = null;


                                    return bll.GetRecordCount(condition);
                                }
                            }
                        }
                        
                            protected int t4982IDCounter = 0;
                            protected object t4982IDRecord = null;
                        
                            private DataTable t4982ID;
                            private DataTable t4982ID_
                            {
                                get
                                {
                                    string condition = null;


                                    string sort = null;

                                    int instanceID;
instanceID = InstanceID;

                                    using (IlgharCMS.SystemModule.IChannel bll = (IlgharCMS.SystemModule.IChannel)Manager.CreateObject("Channel", instanceID, ContentLang, false))
                                    {
                                        t4982ID = bll.List(-1, -1, condition, sort);
                                    }

                                    return t4982ID;
                                }
                            }
                        
                            protected string t4982
                            {
                                get
                                {
                                    XmlNode node = _xmlTemplate.SelectSingleNode("//t4982");
                                    Dictionary<string, object> replacementPair = new Dictionary<string, object>();
                                    
                                        replacementPair["{#t5462#}"] = new CustomBuildTree(
                                                                        delegate(TreeNode record, int index)
                                                                        {string t5462 = String.Empty;
if (Guid.Equals((t4982IDRecord as TreeNode).Row[IlgharCMS.SystemModule.Alias.Channel.ID],(ThisChannel==null?null:ThisChannel[IlgharCMS.SystemModule.Alias.Channel.ParentID])))
{t5462 = _xmlTemplate.SelectSingleNode("/" + "/t5462/If").InnerText;}
else
{t5462 = _xmlTemplate.SelectSingleNode("/" + "/t5462/Else").InnerText;}

                                                                            return t5462;
                                                                        }
                                                                        );
                                                replacementPair["{#Control#}"] = null;replacementPair["{#ChildRecords#}"] = null;replacementPair["{#ID#}"] = IlgharCMS.SystemModule.Alias.Channel.ID;replacementPair["{#Name#}"] = IlgharCMS.SystemModule.Alias.Channel.Name;
                                    StringBuilder all = Manager.BuildTree(node, t4982ID_, replacementPair, IlgharCMS.SystemModule.Alias.Channel.ParentID, IlgharCMS.SystemModule.Alias.Channel.ID, ref t4982IDRecord, ref t4982IDCounter);
                                    
                                    
                                    
                                    return all.ToString();
                                }
                            }
                          }
