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 ListMasterPage : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string userName = Session["UserName"].ToString();
        if (userName != "") // 用户登录
        {
            this.LinkButton2.Visible = false;
            this.LinkButton3.Visible = false;
            this.Label1.Visible = false;
            this.Button2.Visible = true;
            this.Label3.Text = userName;
        }
        else
        {
            this.LinkButton2.Visible = true;
            this.LinkButton3.Visible = true;
            this.Label1.Visible = true;
            this.Button2.Visible = false;
            this.Label3.Text = "游客";
        }
    }
    
   protected void Button1_Click(object sender, EventArgs e)
    {
        string choice = this.DropDownList1.SelectedValue;
        if (choice == "0")
        {
            Response.Redirect("~/BlogSearchResult.aspx?bloger_title=" + this.TextBox1.Text);
        }
        if (choice == "1")
        {
            Response.Redirect("~/LogSearchResult.aspx?log_title=" + this.TextBox1.Text);
        }
        if (choice == "2")
        {
            Response.Redirect("~/AuthorSearchResult.aspx?bloger_name=" + this.TextBox1.Text);
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        string userName = Session["UserName"].ToString();
        if (Roles.IsUserInRole(userName, "Admin"))
        {
            Response.Redirect("~/Admin/CollegeManage.aspx");
        }
        else if (Roles.IsUserInRole(userName, "Bloger"))
        {
            Response.Redirect("~/Bloger/BlogManage/BlogConfig.aspx");
        }
        else if (Roles.IsUserInRole(userName, "Register"))
        {
            Response.Redirect("~/Register/RegisterManage.aspx");
        }
    }
    protected void LoginStatus1_LoggedOut(object sender, EventArgs e)
    {
        Session["UserName"] = "";
    }
}
