using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
//该源码下载自www.51aspx.com(５１ａｓｐｘ．ｃｏｍ)

public partial class _Default : System.Web.UI.Page
{
    int i = 1;
    protected void Page_Load(object sender, EventArgs e)
    {
        this.ClientScript.RegisterClientScriptInclude("ggg", "js/Nagive.js");
        this.ClientScript.RegisterClientScriptInclude("gkg", "js/md5.js");
        Ajax.Utility.RegisterTypeForAjax(this.GetType());
        ENews news = new ENews();
        this.newsList.DataSource = news.GetIndexNews;
        this.newsList.EnableViewState = false;
        this.newsList.DataBind();
        this.itemShow.DataSource = new EItem().SelectItemIndex();
        this.itemShow.DataBind();
        itemShow.EnableViewState = false;
        this.ClientScript.RegisterClientScriptBlock(this.GetType(), "kkk", "<script>window.onload = function(){boologin();};</script>");
    }
    /// <summary>
    /// 返回一个菜肴的详细信息
    /// </summary>
    /// <param name="id">菜肴ID</param>
    /// <returns></returns>
    [Ajax.AjaxMethod]
    public string GetItem(string id)
    {
        EItem item = new EItem();
        return item.SelectOneItem(long.Parse(id));
    }
    /// <summary>
    /// 登陆
    /// </summary>
    /// <param name="userId">用户登录名</param>
    /// <param name="passWord">密码</param>
    /// <returns></returns>
    [Ajax.AjaxMethod]
    public string LogIn(string userId, string passWord)
    {
        EUser user = new EUser();
        return user.LogIn(userId, passWord);
    }
    /// <summary>
    /// 注销
    /// </summary>
    [Ajax.AjaxMethod]
    public void LogOut()
    {
        EUser user = new EUser();
        user.LogOut();
    }
    /// <summary>
    /// 判断是否已经登陆
    /// </summary>
    /// <returns></returns>
    [Ajax.AjaxMethod]
    public string BoologIn()
    {
        EUser user = new EUser();
        return user.BoologIn();
    }
    #region 绑定事件

    protected void itemShow_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
        {

            if (i % 2 == 0)
            {
                e.Item.Controls.Add(new LiteralControl("</tr><tr>"));
            }
            i++;
        }
    }
    #endregion

}
