示例#1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["RoleID"] == null || Session["UserID"] == null)
            {
                Util.ShowMessage("用户登录超时,请重新登录!", "Login2.aspx");
            }
            else
            {
                if (Convert.ToInt16(Session["RoleID"]) > 4)
                {
                    Util.ShowMessage("对不起,你无权访问该页面!", "User_Center.aspx");
                }
                else
                {
                    UserID = Session["UserID"].ToString();
                    ArticleRandomID.Text = Request.QueryString["ID"];
                    using (SqlConnection conn = new DB().GetConnection())
                    {
                        SqlDataReader rd;
                        SqlCommand    cmd = conn.CreateCommand();
                        cmd.CommandText = "select * from ResourceTypes";
                        conn.Open();
                        rd = cmd.ExecuteReader();
                        while (rd.Read())
                        {
                            ResourceTypes.Add(rd["Extension"].ToString(), rd["TypeName"].ToString());
                        }
                        rd.Close();
                        conn.Close();

                        /*
                         * cmd.CommandText = "select * from  Resources where UserID = " + UserID + " order by id desc";
                         * rd = cmd.ExecuteReader();
                         * GridView1.DataSource = rd;
                         * GridView1.DataBind();
                         * rd.Close();
                         */
                        cmd.CommandText = "Select * from ResourceFolders where ParentFolderID = '0' order by ID asc";
                        conn.Open();
                        rd = cmd.ExecuteReader();
                        FolderDDL.DataSource     = rd;
                        FolderDDL.DataValueField = "ID";
                        FolderDDL.DataTextField  = "FolderName";
                        FolderDDL.DataBind();
                        rd.Close();
                        FolderDDL.Items.Insert(0, new ListItem("--文件夹目录--", "-1"));
                        FolderDDL.SelectedIndex = 1;
                        conn.Close();

                        MyInit();
                        MyDataBind();
                    }
                }
            }
        }
    }
示例#2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LabelResourceID.Text = Request.QueryString["ID"];
            // RoleID=1,Administrator;RoleID=2,Editor;RoleID=3,Contributor;RoleID=4,Author;
            //if (Session["RoleID"]!=null && !String.IsNullOrEmpty(Session["RoleID"].ToString()) && ( Session["RoleID"].ToString() == "1" || Session["RoleID"].ToString() == "2") )
            //{
            //    //Role.Enabled = true;
            //    FolderDDL.Enabled = true;
            //    //PasswordPanel.Visible = true;
            //}
            //else
            //{
            //    //Role.Enabled = false;
            //    FolderDDL.Enabled = false;
            //    //PasswordPanel.Visible = false;
            //}
            using (SqlConnection conn = new DB().GetConnection())
            {
                string     sql = "Select * from ResourceFolders order by ID asc";
                SqlCommand cmd = new SqlCommand(sql, conn);
                conn.Open();
                SqlDataReader rd = cmd.ExecuteReader();
                FolderDDL.DataSource     = rd;
                FolderDDL.DataTextField  = "FolderName";
                FolderDDL.DataValueField = "ID";
                FolderDDL.DataBind();
                rd.Close();

                cmd.CommandText = "Select * from [Resources] where ID = @ResourceID";
                cmd.Parameters.AddWithValue("@ResourceID", LabelResourceID.Text);
                rd = cmd.ExecuteReader();
                if (rd.Read())
                {
                    ResourceName.Text   = rd["ResourceName"].ToString();
                    UserName.Text       = rd["UserName"].ToString();
                    FileType.Text       = rd["FileType"].ToString();
                    FileSizeInKB.Text   = rd["FileSizeInKB"].ToString();
                    CreateDateTime.Text = rd["CDT"].ToString();
                    string resourcefolderID = rd["FolderID"].ToString();
                    if (FolderDDL.Items.FindByValue(resourcefolderID) != null)
                    {
                        FolderDDL.ClearSelection();
                        FolderDDL.Items.FindByValue(resourcefolderID).Selected = true;
                    }
                }
            }
        }
    }
示例#3
0
    private void MyInit()
    {
        using (SqlConnection conn = new DB().GetConnection())
        {
            SqlCommand cmd = conn.CreateCommand();
            cmd.CommandText = "select distinct typename as typename from ResourceTypes";
            conn.Open();
            SqlDataReader rd = cmd.ExecuteReader();
            ResourceTypeDDL.DataSource     = rd;
            ResourceTypeDDL.DataValueField = "typename";
            ResourceTypeDDL.DataTextField  = "typename";
            ResourceTypeDDL.DataBind();
            rd.Close();
            ResourceTypeDDL.Items.Insert(0, new ListItem("所有资源类型", ""));

            cmd.CommandText = "Select * from ResourceFolders where ParentFolderID = '0' order by ID asc";
            rd = cmd.ExecuteReader();
            FolderDDL.DataSource     = rd;
            FolderDDL.DataValueField = "ID";
            FolderDDL.DataTextField  = "FolderName";
            FolderDDL.DataBind();
            rd.Close();
            FolderDDL.Items.Insert(0, new ListItem("所有文件夹", "-1"));

            // RoleID=1,2,3,4,分别对应Administrator,Editor,Contributor,Author
            int RoleID = Convert.ToInt16(Session["RoleID"].ToString());
            if (RoleID == 1 || RoleID == 2)
            {
                // 只有Administrator和Editor才可以看到所有作者的文章
                AuthorDDL.Items.Clear();
                cmd.CommandText = "select * from Users order by ID desc";
                rd = cmd.ExecuteReader();
                AuthorDDL.DataSource     = rd;
                AuthorDDL.DataValueField = "ID";
                AuthorDDL.DataTextField  = "UserName";
                AuthorDDL.DataBind();
                rd.Close();
                AuthorDDL.Items.Insert(0, new ListItem("所有用户", "-1"));
            }
            else
            {
                // Contributor和Author只能看到自己的文章
                AuthorDDL.Items.Clear();
                AuthorDDL.Items.Insert(0, new ListItem(Session["UserName"].ToString(), Session["UserID"].ToString()));
            }
        }
    }
示例#4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["RoleID"] == null || Session["UserID"] == null)
            {
                Util.ShowMessage("用户登录超时,请重新登录!", "Login2.aspx");
            }
            else
            {
                if (Convert.ToInt16(Session["RoleID"]) > 4)
                {
                    Util.ShowMessage("对不起,你无权访问该页面!", "User_Center.aspx");
                }
                else
                {
                    UserID = Session["UserID"].ToString();

                    using (SqlConnection conn = new DB().GetConnection())
                    {
                        SqlDataReader rd;
                        SqlCommand    cmd = conn.CreateCommand();
                        cmd.CommandText = "Select * from ResourceFolders where ParentFolderID = '0' order by ID asc";
                        conn.Open();
                        rd = cmd.ExecuteReader();
                        FolderDDL.DataSource     = rd;
                        FolderDDL.DataValueField = "ID";
                        FolderDDL.DataTextField  = "FolderName";
                        FolderDDL.DataBind();
                        rd.Close();
                        FolderDDL.Items.Insert(0, new ListItem("--文件夹目录--", "-1"));
                        FolderDDL.SelectedIndex = 1;
                        conn.Close();
                    }
                }
            }
        }
    }
示例#5
0
    private void MyInit()
    {
        using (SqlConnection conn = new DB().GetConnection())
        {
            SqlCommand cmd = conn.CreateCommand();
            cmd.CommandText = "select * from Resources where ID in (" + IDSLabel.Text + ") order by ID desc";
            conn.Open();
            SqlDataReader rd = cmd.ExecuteReader();
            GridView1.DataSource = rd;
            GridView1.DataBind();
            rd.Close();
            conn.Close();

            cmd.CommandText = "Select * from ResourceFolders order by ID asc";
            conn.Open();
            rd = cmd.ExecuteReader();
            FolderDDL.DataSource     = rd;
            FolderDDL.DataTextField  = "FolderName";
            FolderDDL.DataValueField = "ID";
            FolderDDL.DataBind();
            rd.Close();
        }
    }
示例#6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            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;
                }

                UserID = Session["UserID"].ToString();

                using (SqlConnection conn = new DB().GetConnection())
                {
                    SqlDataReader rd;
                    SqlCommand    cmd = conn.CreateCommand();
                    cmd.CommandText = "Select * from ResourceFolders where ParentFolderID = '0' order by ID asc";
                    conn.Open();
                    rd = cmd.ExecuteReader();
                    FolderDDL.DataSource     = rd;
                    FolderDDL.DataValueField = "ID";
                    FolderDDL.DataTextField  = "FolderName";
                    FolderDDL.DataBind();
                    rd.Close();
                    FolderDDL.Items.Insert(0, new ListItem("--文件夹目录--", "-1"));
                    FolderDDL.SelectedIndex = 1;
                    conn.Close();
                }
            }
        }
    }
示例#7
0
    private void MyInit()
    {
        using (SqlConnection conn = new DB().GetConnection())
        {
            SqlCommand cmd = conn.CreateCommand();
            cmd.CommandText = "select * from Resources where ID in (" + IDSLabel.Text + ")  and Valid=1 order  by ID desc";
            conn.Open();
            SqlDataReader rd = cmd.ExecuteReader();
            GridView1.DataSource = rd;
            GridView1.DataBind();
            rd.Close();

            cmd.CommandText = "Select * from ResourceFolders order by ID asc";
            rd = cmd.ExecuteReader();
            FolderDDL.DataSource     = rd;
            FolderDDL.DataTextField  = "FolderName";
            FolderDDL.DataValueField = "ID";
            FolderDDL.DataBind();
            rd.Close();



            //计算要移动的有效的资源共多少
            cmd.CommandText = "select count(*) as maxrow from Resources where ID in (" + IDSLabel.Text + ") and Valid=1 ";
            rd = cmd.ExecuteReader();
            if (rd.Read())
            {
                Count.Text = rd["maxrow"].ToString();
            }
            rd.Close();


            //除作者本人和Editor以上的权限可以对已有效的资源(Valid = 1) 进行 删除(Valid=0)操作,其余会报错。

            string   s           = "";
            int      i           = Convert.ToInt32(Count.Text);
            string[] AuthorID    = new string[i];
            string[] resourceIDS = new string[i];
            cmd.CommandText = "select * from Resources where ID in (" + IDSLabel.Text + ") and Valid=1 order by ID desc";
            SqlDataReader rd2 = cmd.ExecuteReader();
            if (i != 0)
            {
                for (int j = 0; j < i; j++)
                {
                    if (rd2.Read())
                    {
                        AuthorID[j]    = rd2["UserID"].ToString();
                        resourceIDS[j] = rd2["ID"].ToString();
                        int RoleID = Convert.ToInt16(Session["RoleID"].ToString());
                        if (RoleID > 2)
                        {
                            if (AuthorID[j] != Session["UserID"].ToString())
                            {
                                Response.Write("<script>alert('以下资源有其他作者上传的文件,你无法进行移动操作');</script>");
                                Button1.Visible = false;
                                j = i;
                            }
                        }
                        for (int k = 0; k < i; k++)
                        {
                            s = string.Join(",", resourceIDS);

                            ResourceIDS.Text = s;
                        }
                    }
                }
            }
            else
            {
                int s1 = 0;
                ResourceIDS.Text = s1.ToString();
            }

            rd2.Close();



            conn.Close();
        }
    }
示例#8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["RoleID"] == null || Session["UserID"] == null)
            {
                Util.ShowMessage("用户登录超时,请重新登录!", "Login2.aspx");
            }
            else
            {
                if (Convert.ToInt16(Session["RoleID"]) > 4)
                {
                    Util.ShowMessage("对不起,你无权访问该页面!", "User_Center.aspx");
                }
                else
                {
                    LabelResourceID.Text = Request.QueryString["ID"];
                    // RoleID=1,Administrator;RoleID=2,Editor;RoleID=3,Contributor;RoleID=4,Author;
                    //if (Session["RoleID"]!=null && !String.IsNullOrEmpty(Session["RoleID"].ToString()) && ( Session["RoleID"].ToString() == "1" || Session["RoleID"].ToString() == "2") )
                    //{
                    //    //Role.Enabled = true;
                    //    FolderDDL.Enabled = true;
                    //    //PasswordPanel.Visible = true;
                    //}
                    //else
                    //{
                    //    //Role.Enabled = false;
                    //    FolderDDL.Enabled = false;
                    //    //PasswordPanel.Visible = false;
                    //}


                    using (SqlConnection conn = new DB().GetConnection())
                    {
                        string     sql = "Select * from ResourceFolders order by ID asc";
                        SqlCommand cmd = new SqlCommand(sql, conn);
                        conn.Open();
                        SqlDataReader rd = cmd.ExecuteReader();
                        FolderDDL.DataSource     = rd;
                        FolderDDL.DataTextField  = "FolderName";
                        FolderDDL.DataValueField = "ID";
                        FolderDDL.DataBind();
                        rd.Close();

                        cmd.CommandText = "Select * from [Resources] where ID = @ResourceID";
                        cmd.Parameters.AddWithValue("@ResourceID", LabelResourceID.Text);
                        rd = cmd.ExecuteReader();
                        if (rd.Read())
                        {
                            ResourceName.Text   = rd["ResourceName"].ToString();
                            UserName.Text       = rd["UserName"].ToString();
                            UserID.Text         = rd["UserID"].ToString();
                            FileType.Text       = rd["FileType"].ToString();
                            FileSizeInKB.Text   = rd["FileSizeInKB"].ToString();
                            CreateDateTime.Text = rd["CDT"].ToString();
                            string resourcefolderID = rd["FolderID"].ToString();
                            if (FolderDDL.Items.FindByValue(resourcefolderID) != null)
                            {
                                FolderDDL.ClearSelection();
                                FolderDDL.Items.FindByValue(resourcefolderID).Selected = true;
                            }
                            if (FileType.Text.Equals("图片"))
                            {
                                Image1.ImageUrl = rd["FilePath"].ToString();
                            }
                            if (FileType.Text.Equals("压缩"))
                            {
                                Image1.ImageUrl = "upload/Resource_Preview/ys.png";
                            }
                            if (FileType.Text.Equals("文档"))
                            {
                                Image1.ImageUrl = "upload/Resource_Preview/wd.png";
                            }
                            if (FileType.Text.Equals("视频"))
                            {
                                Image1.ImageUrl = "upload/Resource_Preview/sp.png";
                            }
                            if (FileType.Text.Equals("音频"))
                            {
                                Image1.ImageUrl = "upload/Resource_Preview/yp.png";
                            }
                            if (FileType.Text.Equals("Flash"))
                            {
                                Image1.ImageUrl = "upload/Resource_Preview/fl.png";
                            }
                            if (FileType.Text.Equals("附件"))
                            {
                                Image1.ImageUrl = "upload/Resource_Preview/wd.png";
                            }
                        }
                    }

                    int    RoleID    = Convert.ToInt16(Session["RoleID"].ToString());
                    string UserIDstr = Session["UserID"].ToString();
                    if ((RoleID > 2) && (UserIDstr != UserID.Text))
                    {
                        Button1.Visible = false;
                        Button2.Visible = false;
                        ErrorLabel.Text = "用户权限不够,不可编辑他人上传的资源!";
                    }
                    else
                    {
                        Button1.Visible = true;
                        Button2.Visible = true;
                    }
                }
            }
        }
    }