using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using SK.MemberBLL;

namespace SK.MemberWeb.admin
{
	/// <summary>
	/// Rights 的摘要说明。
	/// </summary>
	public class Rights : BasePage
	{
		protected System.Web.UI.WebControls.Repeater lstRight;
		RightSystem right = new RightSystem();
		RightMemberSystem rightmember = new RightMemberSystem();
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			if(!IsPostBack)
			{
				if(!rightmember.Allow(0,"Right",this.CurrentMemberID))
					Response.Redirect("noright.aspx");
				BindData();
			}
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.lstRight.ItemDataBound += new System.Web.UI.WebControls.RepeaterItemEventHandler(this.lstRight_ItemDataBound);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion
		private void BindData()
		{
			lstRight.DataSource = right.List();
			lstRight.DataBind();
		}

		private void lstRight_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
		{
			if(e.Item.ItemType == ListItemType.AlternatingItem)
			{
				((Repeater)e.Item.FindControl("lstManager1")).DataSource = rightmember.List(((DataRowView)e.Item.DataItem).Row["RightID"],true);
				((Repeater)e.Item.FindControl("lstManager1")).DataBind();

				((Repeater)e.Item.FindControl("lstManager2")).DataSource = rightmember.List(((DataRowView)e.Item.DataItem).Row["RightID"],false);
				((Repeater)e.Item.FindControl("lstManager2")).DataBind();
			}
			if(e.Item.ItemType == ListItemType.Item)
			{
				((Repeater)e.Item.FindControl("lstManager3")).DataSource = rightmember.List(((DataRowView)e.Item.DataItem).Row["RightID"],true);
				((Repeater)e.Item.FindControl("lstManager3")).DataBind();

				((Repeater)e.Item.FindControl("lstManager4")).DataSource = rightmember.List(((DataRowView)e.Item.DataItem).Row["RightID"],false);
				((Repeater)e.Item.FindControl("lstManager4")).DataBind();
			}
		}
		
	}
}
