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;

public partial class Common_Header : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Label1.Text = "〖" + DateTime.Now.ToString("yyyy年MM月dd日") + " " + DateTime.Today.DayOfWeek.ToString() + "〗";
        login();
    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        logout();
    }
    protected void LinkButton2_Click(object sender, EventArgs e)
    {
        logout();
    }
    public void login()
    {
        if (Session["ID"] == null)
        {
            Label2.Text = "您现在是游客身份，只可以发表帖子！如果想回复信息，请注册/登录！";
            return;
        }
        if (Session["ID"].ToString() == "0")
        {
            Label2.Text = "[" + Session["Name"].ToString() + "]，您现在是本站会员，您不想说点什么吗！";
            Panel1.Visible = false;
            Panel2.Visible = true;
            Panel3.Visible = false;
            return;
        }
        if (Session["ID"].ToString() == "1")
        {
            Label2.Text = "[" + Session["Name"].ToString() + "]，您现在是本站版主，您不想说点什么吗！";
            HyperLink16.Enabled = true;
            Panel1.Visible = false;
            Panel2.Visible = true;
            Panel3.Visible = false;
            return;
        }
        if (Session["ID"].ToString() == "2")
        {
            Label2.Text = "[" + Session["Name"].ToString() + "]，您现在是本站管理员。";
            Panel1.Visible = false;
            Panel2.Visible = false;
            Panel3.Visible = true;
            return;
        }
    }
    //注销用户、版主或管理员
    public void logout()
    {
        Panel1.Visible = true;
        Panel2.Visible = false;
        Panel3.Visible = false;
        FormsAuthentication.SignOut();//清除验证信息
        HttpContext.Current.Session.Clear();//清除Session内容
        HttpContext.Current.Session.Abandon();//取消当前会话
        Session["ID"] = null;
        Session["Name"] = null;
        Session["Pop"] = null;
        login();
    }
    protected void LinkButton3_Click(object sender, EventArgs e)
    {
        Response.Redirect("Common/Login.aspx?id=0");
    }
    protected void LinkButton4_Click(object sender, EventArgs e)
    {
        Response.Redirect("Common/Login.aspx?id=1");
    }
}
