Пример #1
0
    /// <summary>
    /// 删除
    /// </summary>
    /// <param name="source"></param>
    /// <param name="e"></param>
    protected void dljourer_DeleteCommand(object source, DataListCommandEventArgs e)
    {
        int index = e.Item.ItemIndex;
        //string id = this.dljourer.DataKeys[index].ToString();
        int id = Convert.ToInt32(this.dljourer.DataKeys[index]);
        int n  = new BLL_Journal().BLL_delete_journaltable_where_titleID(id);

        if (n != 0)
        {
            Page.ClientScript.RegisterStartupScript(typeof(string), "j", "<script>alert('删除成功')</script>");
            start();
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(typeof(string), "飞", "<script>alert('删除失败')</script>");
        }
    }
Пример #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session ["username"] == null)
            {
                //if (Session["NAME"] != null)//当有人点击姓名时
                //{
                //    string username = Session["dangName"].ToString();
                //    List<UserRegistration> list = new BLL_Journal().BLL_select_UserRegistration_ismaster_name(username);
                //    int count = new BLL_Journal().BLL_select_Blogtable_count(username); //查询博客表中存在的记录数


                //    this.LblName.Text =list [0].Name ;
                //    this.LblAdress.Text =list [0].address ;
                //    this.LblVisitor.Text = username;
                //    if(count !=0)
                //    {
                //        List<Blogtable> liste = new BLL_Journal().BLL_select_Blogtable_all(username);//查询博客表中的记录
                //        this.LblBokeSystem.Text = liste[0].selfname;
                //        this.LblDescribe.Text = liste[0].describe;
                //        this.Image1.ImageUrl = liste[0].userphoto;//博客图片url
                //        //this.LblAdress.Text = address;    //显示地址
                //    }
                //    else
                //    {
                //        this.LblBokeSystem.Text = username;
                //        this.LblDescribe.Text = list[0].Name+"的博客";
                //        this.Image1.ImageUrl = "~/image/blogmaster.jpg";

                //    }


                //}
                //else {
                this.Image1.ImageUrl    = "~/image/blogmaster.jpg";
                this.LblName.Text       = "lanyu";
                this.LblAdress.Text     = "无极天天";
                this.LblVisitor.Text    = "lanyu游客";
                this.LblBokeSystem.Text = "社区博客系统";
                this.LblDescribe.Text   = "博闻天下";
                //}
            }
            //如果不等于NuLL则如下
            else
            {
                string username = Session["username"].ToString();
                //if (Session["NAME"]!=null)
                //{ username =Session ["dangName"].ToString ();}

                this.lbtngerenshezhi.Visible    = true; //个仍设置
                this.lbtnfabiaowenzhang.Visible = true; //发表日志
                this.LBtnBlog.Visible           = true; //  个人博客按钮

                this.Label1.Text = "帅哥止步,美女放行。";
                //if (Session["NAME"] != null)
                //{

                //    this.LblVisitor.Text = username;

                //}
                //else {
                this.LblVisitor.Visible = false;
                this.Label2.Visible     = false;
                //}
                //   //


                List <UserRegistration> list = new BLL_Journal().BLL_select_UserRegistration_ismaster_name(username);
                int count = new BLL_Journal().BLL_select_Blogtable_count(username); //查询博客表中存在的记录数

                int    mast    = list[0].usermaster;                                //是否是管理员
                string Name    = list[0].Name;                                      //姓名
                string address = list[0].address;                                   //地址
                this.LblName.Text = Name;                                           // 姓名
                Session["name"]   = Name;                                           //用户姓名
                if (count != 0)
                {
                    List <Blogtable> liste = new BLL_Journal().BLL_select_Blogtable_all(username); //查询博客表中的记录
                    this.LblBokeSystem.Text = liste[0].selfname;
                    this.LblDescribe.Text   = liste[0].describe;
                    this.Image1.ImageUrl    = liste [0].userphoto; //博客图片url
                    this.LblAdress.Text     = address;             //显示地址
                }
                else
                {
                    this.LblBokeSystem.Text = Name;         //博客名称
                    this.LblDescribe.Text   = Name + "的博客"; //博客描述
                    this.LblAdress.Text     = address;      //显示地址
                }
                if (mast == 0)
                {
                    this.lbtnshangchuantupian.Visible = true;
                    this.lbtnweihuxiangce.Visible     = true;
                }
                this.lbtndenglu.Text = "退出";
            }
        }
    }
Пример #3
0
    protected void dljourer_ItemCommand(object source, DataListCommandEventArgs e)
    {
        if (e.CommandName == "name")
        {
            int ID = Convert.ToInt32(e.CommandArgument);
            Session["ISD"] = ID;
            Response.Redirect(@"~/bogleaspx/discussBolge.aspx?");
        }
        else if (e.CommandName == "lbtnUserName")
        {
            string a = this.dljourer.DataKeys[e.Item.ItemIndex].ToString();                   //获取当前选择项的主键值
            //Session["dang"]=a;
            Label  tbox = (Label)dljourer.Items[e.Item.ItemIndex].FindControl("lblusername"); //获取当选择项的某控件值
            string ddd  = tbox.Text.Trim();
            string name = e.CommandArgument.ToString();
            Session["UsName"]   = name;//当前选择项的CommandArgument 值
            Session["NAME"]     = 0;
            Session["dangName"] = ddd;
            start();//加载 某姓名的日志的方法


            //if (Session["NAME"] != null)//当有人点击姓名时
            //{
            string username = ddd;                                              // Session["dangName"].ToString();
            List <UserRegistration> list = new BLL_Journal().BLL_select_UserRegistration_ismaster_name(username);
            int count = new BLL_Journal().BLL_select_Blogtable_count(username); //查询博客表中存在的记录数

            Label LblName = this.Master.FindControl("LblName") as Label;
            LblName.Text = list[0].Name;  //姓名

            Label LblAdress = this.Master.FindControl("LblAdress") as Label;
            LblAdress.Text = list[0].address;//地址

            Label LblVisitor = this.Master.FindControl("LblVisitor") as Label;
            if (Session["username"] != null)    //如果当前由用户登录
            {
                LblVisitor.Visible = true;
                LblVisitor.Text    = username;//访问用户名
                Label Label1 = this.Master.FindControl("Label1") as Label;
                Label Label2 = this.Master.FindControl("Label2") as Label;
                Label1.Visible = true;
                Label2.Visible = true;
            }
            else//如果当前没有用户登录
            {
                LblVisitor.Text = "游客";//访问用户名
            }


            if (count != 0)
            {
                List <Blogtable> liste = new BLL_Journal().BLL_select_Blogtable_all(username);//查询博客表中的记录

                Label LblBokeSystem = this.Master.FindControl("LblBokeSystem") as Label;
                LblBokeSystem.Text = liste[0].selfname;//博客名

                Label LblDescribe = this.Master.FindControl("LblDescribe") as Label;
                LblDescribe.Text = liste[0].describe; //博客描述

                Image Image1 = this.Master.FindControl("Image1") as Image;
                Image1.ImageUrl = liste[0].userphoto;//博客图片url
                //this.LblAdress.Text = address;    //显示地址
            }
            else
            {
                Label LblBokeSystem = this.Master.FindControl("LblBokeSystem") as Label;
                LblBokeSystem.Text = username;

                Label LblDescribe = this.Master.FindControl("LblDescribe") as Label;
                LblDescribe.Text = list[0].Name + "的博客";

                Image Image1 = this.Master.FindControl("Image1") as Image;
                Image1.ImageUrl = "~/image/blogmaster.jpg";
            }
        }

        else if (e.CommandName == "UpdateClick")
        {
            int ID = Convert.ToInt32(e.CommandArgument);
            Session["edittitleID"] = ID;
            Response.Redirect(@"~/bogleaspx/editorlog.aspx");
        }
    }
Пример #4
0
    /// <summary>
    /// 验证是否是管理员
    /// </summary>
    public void start()
    {
        #region 1
        ////////////  单击个人(bolge)博客时
        if (Session["username"] != null && Request.QueryString["a"] == "1")
        {
            string username = Session["username"].ToString();//用户名
            this.dljourer.DataSource = new BLL_Journal().BLL_proc_selct_Journaltable_userblog(username, 10, Convert.ToInt32(ViewState["Page"]), ref pagecount);
            dljourer.DataBind();
            for (int i = 0; i < dljourer.Items.Count; i++)
            {
                (this.dljourer.Items[i].FindControl("lbtneditor") as LinkButton).Visible = true;
                (this.dljourer.Items[i].FindControl("lbtndelete") as LinkButton).Visible = true;
            }
        }
        #endregion


        //////////////// 如果有用户登录
        else if (Session["username"] != null && Request.QueryString["a"] != "1")   // 如果有用户登录
        {
            string stre = Session["username"].ToString();
            int    a    = new BLL_Journal().BLL_select_UserRegistration_ismaster(stre); //如果等于0表示管理员登陆  如果是1 普通用户



            if (a != 0)                              //如果是普通用户
            {
                if (Request.QueryString["a"] == "2") //如果单击的是分类表
                {
                    if (Session["NAME"] != null)
                    {
                        string nameN = Session["UsName"].ToString();
                        this.dljourer.DataSource = new BLL_Journal().Page_select_journaltable_where_name_putongusername(nameN, 6, Convert.ToInt32(ViewState["Page"]), ref pagecount);
                        List <Journaltable> listes = new BLL_Journal().Page_select_journaltable_where_name_putongusername(nameN, 6, Convert.ToInt32(ViewState["Page"]), ref pagecount);
                        for (int j = 0; j < listes.Count; j++)
                        {
                            string astr = listes[j].username;
                            if (stre == astr)
                            {
                                (this.dljourer.Items[j].FindControl("lbtneditor") as LinkButton).Visible = true;
                                (this.dljourer.Items[j].FindControl("lbtndelete") as LinkButton).Visible = true;
                            }
                            int ao = listes[j].iscomment;
                            if (ao == 1)
                            {
                                (this.dljourer.Items[j].FindControl("lbtnVisitor") as LinkButton).Visible = false;
                            }
                        }
                    }
                    else
                    {
                        int    abc    = Convert.ToInt32(Session["NO"]);
                        string stsort = Session["sort"].ToString();
                        //绑定数据到数据源
                        this.dljourer.DataSource = new BLL_Journal().BLL_proc_select_Journaltable_sort_all(stsort, 6, abc, ref pagecount);
                        dljourer.DataBind();
                        //如果用户日志禁止评论则不输出评论信息
                        List <Journaltable> liste = new BLL_Journal().BLL_proc_select_Journaltable_sort_all(stsort, 6, abc, ref pagecount);
                        for (int j = 0; j < liste.Count; j++)
                        {
                            string astr = liste[j].username;
                            if (stre == astr)
                            {
                                (this.dljourer.Items[j].FindControl("lbtneditor") as LinkButton).Visible = true;
                                (this.dljourer.Items[j].FindControl("lbtndelete") as LinkButton).Visible = true;
                            }
                            int ao = liste[j].iscomment;
                            if (ao == 1)
                            {
                                (this.dljourer.Items[j].FindControl("lbtnVisitor") as LinkButton).Visible = false;
                            }
                        }
                    }
                }
                else//如果单击的不是分类表
                {
                    if (Session["NAME"] != null)
                    {
                        string nameN = Session["UsName"].ToString();
                        this.dljourer.DataSource = new BLL_Journal().Page_select_journaltable_where_name_putongusername(nameN, 6, Convert.ToInt32(ViewState["Page"]), ref pagecount);
                        List <Journaltable> listes = new BLL_Journal().Page_select_journaltable_where_name_putongusername(nameN, 6, Convert.ToInt32(ViewState["Page"]), ref pagecount);
                        for (int j = 0; j < listes.Count; j++)
                        {
                            string astr = listes[j].username;
                            if (stre == astr)
                            {
                                (this.dljourer.Items[j].FindControl("lbtneditor") as LinkButton).Visible = true;
                                (this.dljourer.Items[j].FindControl("lbtndelete") as LinkButton).Visible = true;
                            }
                            int ao = listes[j].iscomment;
                            if (ao == 1)
                            {
                                (this.dljourer.Items[j].FindControl("lbtnVisitor") as LinkButton).Visible = false;
                            }
                        }
                    }
                    else
                    {
                        //如果是普通用户登录则进行如下:
                        string username = Session["username"].ToString();
                        this.dljourer.DataSource = new BLL_Journal().BLL_Proc_select_Journaltable_all(6, Convert.ToInt32(ViewState["Page"]), ref pagecount);
                        List <Journaltable> li = new BLL_Journal().BLL_Proc_select_Journaltable_all(6, Convert.ToInt32(ViewState["Page"]), ref pagecount);
                        dljourer.DataBind();
                        for (int i = 0; i < dljourer.Items.Count; i++)
                        {
                            string astr = li[i].username;
                            if (username == astr)
                            {
                                (this.dljourer.Items[i].FindControl("lbtneditor") as LinkButton).Visible = true;
                                (this.dljourer.Items[i].FindControl("lbtndelete") as LinkButton).Visible = true;
                            }
                        }
                    }
                }
            }


            else if (a == 0) //如果是管理员登录则 编辑 删除按钮 可显示
            {
                if (Request.QueryString["a"] == "2")
                {
                    if (Session["NAME"] != null)
                    {
                        string nameN = Session["UsName"].ToString();
                        this.dljourer.DataSource = new BLL_Journal().Page_admin_select_journaltable_where_name_putongusername(nameN, 6, Convert.ToInt32(ViewState["Page"]), ref pagecount);
                        List <Journaltable> listes = new BLL_Journal().Page_admin_select_journaltable_where_name_putongusername(nameN, 6, Convert.ToInt32(ViewState["Page"]), ref pagecount);
                        dljourer.DataBind();
                        for (int i = 0; i < dljourer.Items.Count; i++)
                        {
                            (this.dljourer.Items[i].FindControl("lbtneditor") as LinkButton).Visible = true;
                            (this.dljourer.Items[i].FindControl("lbtndelete") as LinkButton).Visible = true;
                        }
                    }
                    else
                    {
                        string sort = Session["sort"].ToString();
                        int    abc  = Convert.ToInt32(Session["NO"]);
                        this.dljourer.DataSource = new BLL_Journal().BLL_proc_select_Journaltable_sort_alls(sort, 6, abc, ref pagecount);
                        dljourer.DataBind();
                        for (int i = 0; i < dljourer.Items.Count; i++)
                        {
                            (this.dljourer.Items[i].FindControl("lbtneditor") as LinkButton).Visible = true;
                            (this.dljourer.Items[i].FindControl("lbtndelete") as LinkButton).Visible = true;
                        }
                    }
                }
                else
                {
                    if (Session["NAME"] != null)
                    {
                        string nameN = Session["UsName"].ToString();
                        this.dljourer.DataSource = new BLL_Journal().Page_admin_select_journaltable_where_name_putongusername(nameN, 6, Convert.ToInt32(ViewState["Page"]), ref pagecount);
                        List <Journaltable> listes = new BLL_Journal().Page_admin_select_journaltable_where_name_putongusername(nameN, 6, Convert.ToInt32(ViewState["Page"]), ref pagecount);
                        dljourer.DataBind();
                        for (int i = 0; i < dljourer.Items.Count; i++)
                        {
                            (this.dljourer.Items[i].FindControl("lbtneditor") as LinkButton).Visible = true;
                            (this.dljourer.Items[i].FindControl("lbtndelete") as LinkButton).Visible = true;
                        }
                    }
                    else
                    {
                        //将日志表中所有数据绑定到数据源
                        this.dljourer.DataSource = new BLL_Journal().BLL_Proc_master_select_Journaltable_all(6, Convert.ToInt32(ViewState["Page"]), ref pagecount);
                        dljourer.DataBind();
                        for (int i = 0; i < dljourer.Items.Count; i++)
                        {
                            (this.dljourer.Items[i].FindControl("lbtneditor") as LinkButton).Visible = true;
                            (this.dljourer.Items[i].FindControl("lbtndelete") as LinkButton).Visible = true;
                        }
                    }
                }
            }
        }
        else if (Session["username"] == null && Request.QueryString["a"] == "2")
        {
            int    aaa    = Convert.ToInt32(ViewState["page"]);
            int    abc    = Convert.ToInt32(Session["NO"]);
            string stsort = Session["sort"].ToString();
            //绑定数据到数据源
            this.dljourer.DataSource = new BLL_Journal().BLL_proc_select_Journaltable_sort_all(stsort, 6, abc, ref pagecount);
            dljourer.DataBind();
            //如果用户日志禁止评论则不输出评论信息
            //List<Journaltable> liste = new BLL_Journal().BLL_proc_select_Journaltable_sort_all(stsort, 2, abc, ref pagecount);
            //for (int j = 0; j < liste.Count; j++)
            //{
            //    //string a = this.dljourer.Items[j].FindControl("lbliscomment").ToString();
            //    int a = liste[j].iscomment;
            //    if (a == 1)
            //    {
            //        (this.dljourer.Items[j].FindControl("lbtnVisitor") as LinkButton).Visible = false;
            //    }
            //}
            //////如果点击的是用户的姓名
            if (Session["NAME"] != null)
            {
                string nameN = Session["UsName"].ToString();
                this.dljourer.DataSource = new BLL_Journal().Page_select_journaltable_where_name_putongusername(nameN, 6, Convert.ToInt32(ViewState["Page"]), ref pagecount);
                //List<Journaltable> listes = new BLL_Journal().Page_select_journaltable_where_name_putongusername(nameN, 2, Convert.ToInt32(ViewState["Page"]), ref pagecount);
                //for (int j = 0; j < liste.Count; j++)
                //{
                //    //string a = this.dljourer.Items[j].FindControl("lbliscomment").ToString();
                //    int a = listes[j].iscomment;
                //    if (a == 1)
                //    {
                //        (this.dljourer.Items[j].FindControl("lbtnVisitor") as LinkButton).Visible = false;
                //    }
                //}
                this.dljourer.DataBind();
            }
        }

        //当游客进入界面时如下:
        else
        {
            if (Session["NAME"] == null)
            {
                //绑定数据到数据源
                this.dljourer.DataSource = new BLL_Journal().BLL_Proc_select_Journaltable_all(6, Convert.ToInt32(ViewState["Page"]), ref pagecount);
                dljourer.DataBind();
                //如果用户日志禁止评论则不输出评论信息
                //List<Journaltable> list = new BLL_Journal().BLL_select_Journaltable_all();
                //List<Journaltable> liste = new BLL_Journal().BLL_Proc_select_Journaltable_all(2, Convert.ToInt32(ViewState["Page"]), ref pagecount);
                //for (int j = 0; j < liste.Count; j++)
                //{
                //    //string a = this.dljourer.Items[j].FindControl("lbliscomment").ToString();
                //    int a = liste[j].iscomment;
                //    if (a == 1)
                //    {
                //        (this.dljourer.Items[j].FindControl("lbtnVisitor") as LinkButton).Visible = false;
                //    }
                //}
            }
            //////////如果点击的是某用户的姓名
            else if (Session["NAME"] != null)
            {
                string nameN = Session["UsName"].ToString();
                this.dljourer.DataSource = new BLL_Journal().Page_select_journaltable_where_name_putongusername(nameN, 6, Convert.ToInt32(ViewState["Page"]), ref pagecount);
                //List<Journaltable> listes = new BLL_Journal().Page_select_journaltable_where_name_putongusername(nameN, 2, Convert.ToInt32(ViewState["Page"]), ref pagecount);
                //for (int j = 0; j < listes.Count; j++)
                //{
                //    //string a = this.dljourer.Items[j].FindControl("lbliscomment").ToString();
                //    int a = listes[j].iscomment;
                //    if (a == 1)
                //    {
                //        (this.dljourer.Items[j].FindControl("lbtnVisitor") as LinkButton).Visible = false;
                //    }
                //}
                this.dljourer.DataBind();
            }
        }
    }