using System;
using System.Data;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using EKETEAM.FrameWork;
using EKETEAM.Data;

namespace eFrameWork.AppMobile
{
    public partial class Default : System.Web.UI.Page
    {
        private eUser user;

        public ApplicationMenu appmenu;
        protected void Page_Load(object sender, EventArgs e)
        {
            user = new eUser("AppMobile");
            user.Check();
            appmenu = new ApplicationMenu(user);

            if (appmenu.UserApps.Rows.Count == 0)
            {
                Response.Write("没有权限!");
                Response.End();
            }
            appmenu.UserApps.DefaultView.Sort = "appSort";
            DataTable tb = appmenu.UserApps.DefaultView.ToTable(true, "ApplicationID", "MC", "Pic");
            if (tb.Rows.Count == 0)
            {
                Response.Write("没有权限!");
                Response.End();
            }
            if (tb.Rows.Count == 1 && 1==2) //直接跳转应用
            {
                string ApplicationID = tb.Rows[0]["ApplicationID"].ToString();
                string url = appmenu.getTopModelUrl(ApplicationID);

      
                Response.Redirect(url, true);
            }
            else //用户选择应用
            {
                //Rep.ItemDataBound += new RepeaterItemEventHandler(Rep_ItemDataBound);
                Rep.DataSource = tb;
                Rep.DataBind();
            }
        }
        protected void Rep_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Control ctrl = e.Item.Controls[0];
                Literal lit = (Literal)ctrl.FindControl("LitTags");
                if (lit != null)
                {
                    //lit.Text = DataBinder.Eval(e.Item.DataItem, "ModelTabID").ToString();
                }
            }
        }
    }
}