protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string userid = Convert.ToString(Session["UserID"]); int RoleID = Convert.ToInt16(Session["RoleID"].ToString()); if (Session["RoleID"] == null || Session["UserID"] == null) { Util.ShowMessage("用户登录超时,请重新登录!", "Login2.aspx"); } else if (RoleID > 1) { Util.ShowMessage("您没有访问该页面的权限!", "Login2.aspx"); } else { string username = Convert.ToString(Session["UserName"]); int roleID = Util.UpdateAvatar(username); using (SqlConnection conn = new DB().GetConnection()) { SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "select distinct RoleName as RoleName from Roles"; conn.Open(); SqlDataReader rd = cmd.ExecuteReader(); RoleTypeDDL.DataSource = rd; RoleTypeDDL.DataValueField = "RoleName"; RoleTypeDDL.DataTextField = "RoleName"; RoleTypeDDL.DataBind(); rd.Close(); RoleTypeDDL.Items.Insert(0, new ListItem("角色类型", "")); cmd.CommandText = "select distinct Valid as Valid from Users"; rd = cmd.ExecuteReader(); IsValid.DataSource = rd; IsValid.DataValueField = "Valid"; IsValid.DataTextField = "Valid"; IsValid.DataBind(); rd.Close(); IsValid.Items.Insert(0, new ListItem("状态", "")); cmd.CommandText = "select * from UserTags where UserID = @UserID and Users <> 0 order by ID desc"; cmd.Parameters.AddWithValue("@UserID", userid); rd = cmd.ExecuteReader(); CheckBoxList1.DataSource = rd; CheckBoxList1.DataTextField = "TagName"; CheckBoxList1.DataValueField = "ID"; CheckBoxList1.DataBind(); rd.Close(); } MyDataBind2(); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string userid = Convert.ToString(Session["UserID"]); if (Session["RoleID"] == null || Session["UserID"] == null) { Util.ShowMessage("用户登录超时,请重新登录!", "Login.aspx"); } else { string username = Convert.ToString(Session["UserName"]); int roleID = Util.UpdateAvatar(username); AvatarImage.ImageUrl = Session["Avatar"].ToString(); AvatarImage1.ImageUrl = Session["Avatar"].ToString(); if (roleID == 1) { AdminUser.Visible = true; EditorArctile.Visible = true; FilePanel.Visible = true; ClassPanel.Visible = true; FocusPanel.Visible = true; MenuPanel.Visible = true; UserTagPanel.Visible = true; } else if (roleID == 2) { AdminUser.Visible = false; EditorArctile.Visible = true; FilePanel.Visible = false; ClassPanel.Visible = true; FocusPanel.Visible = false; MenuPanel.Visible = true; UserTagPanel.Visible = false; } else if (roleID == 3) { AdminUser.Visible = false; EditorArctile.Visible = false; FilePanel.Visible = false; ClassPanel.Visible = false; FocusPanel.Visible = false; MenuPanel.Visible = false; UserTagPanel.Visible = false; } else if (roleID == 4) { AdminUser.Visible = false; EditorArctile.Visible = false; FilePanel.Visible = false; ClassPanel.Visible = false; FocusPanel.Visible = false; MenuPanel.Visible = false; UserTagPanel.Visible = false; } else { AdminUser.Visible = false; EditorArctile.Visible = false; FilePanel.Visible = false; ClassPanel.Visible = false; FocusPanel.Visible = false; MenuPanel.Visible = false; UserTagPanel.Visible = false; } using (SqlConnection conn = new DB().GetConnection()) { SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "select distinct RoleName as RoleName from Roles"; conn.Open(); SqlDataReader rd = cmd.ExecuteReader(); RoleTypeDDL.DataSource = rd; RoleTypeDDL.DataValueField = "RoleName"; RoleTypeDDL.DataTextField = "RoleName"; RoleTypeDDL.DataBind(); rd.Close(); RoleTypeDDL.Items.Insert(0, new ListItem("角色类型", "")); cmd.CommandText = "select distinct Valid as Valid from Users"; rd = cmd.ExecuteReader(); IsValid.DataSource = rd; IsValid.DataValueField = "Valid"; IsValid.DataTextField = "Valid"; IsValid.DataBind(); rd.Close(); IsValid.Items.Insert(0, new ListItem("状态", "")); cmd.CommandText = "select * from UserTags where UserID = @UserID and Users <> 0 order by ID desc"; cmd.Parameters.AddWithValue("@UserID", userid); rd = cmd.ExecuteReader(); CheckBoxList1.DataSource = rd; CheckBoxList1.DataTextField = "TagName"; CheckBoxList1.DataValueField = "ID"; CheckBoxList1.DataBind(); rd.Close(); } } // MyDataBind(); MyDataBind2(); } }