示例#1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         using (SqlConnection conn = new DB().GetConnection())
         {
         }
         if (Session["RoleID"] == null || Session["UserID"] == null)
         {
             Util.ShowMessage("用户登录超时,请重新登录!", "Login.aspx");
         }
         else
         {
             using (SqlConnection conn = new DB().GetConnection())
             {
                 SqlCommand cmd = conn.CreateCommand();
                 cmd.CommandText = "select distinct Valid as Valid from Users";
                 conn.Open();
                 SqlDataReader rd = cmd.ExecuteReader();
                 RoleTypeDDL.DataSource     = rd;
                 RoleTypeDDL.DataValueField = "Valid";
                 RoleTypeDDL.DataTextField  = "Valid";
                 RoleTypeDDL.DataBind();
                 rd.Close();
                 RoleTypeDDL.Items.Insert(0, new ListItem("状态", ""));
             }
         }
         MyDataBind2();
     }
 }
示例#2
0
    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();
            }
        }
    }
示例#3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            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
            {
                if (Request.QueryString["ID"] != null)
                {
                    IDSLabel.Text = Request.QueryString["ID"];
                    string[] array = IDSLabel.Text.Split(',');
                    int      t     = array.Length;
                    Label6.Text = t.ToString();
                    using (SqlConnection conn = new DB().GetConnection())
                    {
                        string     userid = Convert.ToString(Session["UserID"]);
                        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 * from UserTags where ID in (" + IDSLabel.Text + ") order by ID desc";
                        rd = cmd.ExecuteReader();
                        TagsList.DataSource     = rd;
                        TagsList.DataTextField  = "TagName";
                        TagsList.DataValueField = "ID";
                        TagsList.DataBind();
                        rd.Close();

                        cmd.CommandText = "select count(*) as maxrow from [Users_UserTags] where UserTagID=@TagID1";
                        cmd.Parameters.AddWithValue("@TagID1", IDSLabel.Text);
                        SqlDataReader rd1 = cmd.ExecuteReader();
                        if (rd1.Read())
                        {
                            count.Text = rd1["maxrow"].ToString();
                        }
                        rd1.Close();


                        string   s      = "";
                        int      i      = Convert.ToInt32(count.Text);
                        string[] UserID = new string[i];
                        cmd.CommandText = "select * from [Users_UserTags] where UserTagID in (" + IDSLabel.Text + ")";
                        SqlDataReader rd2 = cmd.ExecuteReader();
                        if (i != 0)
                        {
                            for (int j = 0; j < i; j++)
                            {
                                if (rd2.Read())
                                {
                                    UserID[j] = rd2["UserID"].ToString();
                                    for (int k = 0; k < i; k++)
                                    {
                                        s            = string.Join(",", UserID);
                                        UserIDs.Text = s;
                                    }
                                }
                            }
                        }

                        else
                        {
                            int s1 = 0;
                            UserIDs.Text = s1.ToString();
                        }
                        rd2.Close();
                        MyDataBind2();
                    }
                }


                for (int i = 0; i <= TagsList.Items.Count - 1; i++)
                {
                    TagsList.Items[i].Selected = true;
                }
            }
        }
    }
示例#4
0
    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();
        }
    }