Exemple #1
0
    //123
    private void dataListDatabind()
    {
        int currentPage;

        try
        {
            currentPage = Convert.ToInt32(Request.QueryString["p"]);
        }
        catch
        {
            currentPage = 1;
        }
        if (currentPage == 0)
        {
            currentPage = 1;
        }
        ArticleOperate  aop = new ArticleOperate();
        PagedDataSource ps  = new PagedDataSource();

        ps.DataSource                          = aop.viewAll();
        ps.AllowPaging                         = true;
        ps.PageSize                            = 8;
        ps.CurrentPageIndex                    = currentPage - 1;
        this.Pagination1.pageCount             = ps.PageCount;
        this.Pagination1.currentPage           = currentPage;
        this.Pagination1.pageUrl               = "Default.aspx";
        this.Pagination1.paramName             = "p";
        this.DataListViewAllArticle.DataSource = ps;
        //1231231231123123123123123
        this.DataListViewAllArticle.DataBind();
    }
Exemple #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.Title = Title + SetTitle.getTitle();
        }
        if (Convert.ToString(Session["admin"]) != "admin")
        {
            Response.Redirect("~/refresh.aspx?msg=" + "对不起,只有管理员才能对文章进行相关的操作0!");
            return;
        }

        int            aid = Convert.ToInt32(Request.QueryString["aid"]);
        ArticleOperate aop = new ArticleOperate();
        bool           b   = aop.delete(aid);

        if (b)
        {
            Response.Redirect("~/refresh.aspx?msg=" + "文章删除成功!");
        }
        else
        {
            Response.Redirect("~/refresh.aspx?msg=" + "文章删除失败!");
        }
    }
Exemple #3
0
 protected void Submit_btn_Click(object sender, EventArgs e)
 {
     Article at = new Article();
     at.liebie = Convert.ToInt32(DropDownList_liebie.SelectedValue);
     at.title = Tit_tbx.Text;
     at.content = FCKeditor_content.Value.ToString();
     at.author = "omycle";
     ArticleOperate ato = new ArticleOperate();
     ato.insert(at);
     Response.Redirect("Default.aspx");
 }
Exemple #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     string Sid = Request.QueryString["id"].ToString() ;
     ArticleOperate ap = new ArticleOperate();
     bool b=ap.delete(Sid);
     CommentOperate co=new CommentOperate();
     bool bb = co.deletebyarticle(Sid);
     if (b)
     {
         Response.Redirect("~/Blog.aspx");
     }
 }
Exemple #5
0
        public ActionResult Index(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            ArticleOperate article_operate = new ArticleOperate();
            ArticleModel   thisData        = new ArticleModel();

            thisData = article_operate.getOneArticle((int)id);
            return(View(thisData));
        }
Exemple #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string         Sid = Request.QueryString["id"].ToString();
        ArticleOperate ap  = new ArticleOperate();
        bool           b   = ap.delete(Sid);
        CommentOperate co  = new CommentOperate();
        bool           bb  = co.deletebyarticle(Sid);

        if (b)
        {
            Response.Redirect("~/Blog.aspx");
        }
    }
Exemple #7
0
    protected void Submit_btn_Click(object sender, EventArgs e)
    {
        Article at = new Article();

        at.liebie  = Convert.ToInt32(DropDownList_liebie.SelectedValue);
        at.title   = Tit_tbx.Text;
        at.content = FCKeditor_content.Value.ToString();
        at.author  = "omycle";
        ArticleOperate ato = new ArticleOperate();

        ato.insert(at);
        Response.Redirect("Default.aspx");
    }
Exemple #8
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     string aid = Request.QueryString["id"].ToString();
      string title = this.TextBox1.Text.ToString();
      int cid = Convert.ToInt32(this.DropDownListclass.SelectedValue);
     string content = this.FCKeditor1.Value.ToString();
     ArticleOperate aop = new ArticleOperate();
     Article ac = new Article(aid,cid,title,content);
     bool b = aop.update(ac);
     if (b)
     {
         Response.Redirect("~/newsarticle.aspx?id="+aid);
     }
 }
Exemple #9
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        string         aid     = Request.QueryString["id"].ToString();
        string         title   = this.TextBox1.Text.ToString();
        int            cid     = Convert.ToInt32(this.DropDownListclass.SelectedValue);
        string         content = this.FCKeditor1.Value.ToString();
        ArticleOperate aop     = new ArticleOperate();
        Article        ac      = new Article(aid, cid, title, content);
        bool           b       = aop.update(ac);

        if (b)
        {
            Response.Redirect("~/newsarticle.aspx?id=" + aid);
        }
    }
Exemple #10
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         this.Title = Title + SetTitle.getTitle();
         string s;
         try
         {
             s = Request.QueryString["s"].ToString();
             if (s.Length > 20)
             {
                 s = s.Substring(0, 20);
             }
             ArticleOperate aop = new ArticleOperate();
             int            currentPage;
             try
             {
                 currentPage = Convert.ToInt32(Request.QueryString["p"]);
             }
             catch
             {
                 currentPage = 1;
             }
             if (currentPage == 0)
             {
                 currentPage = 1;
             }
             PagedDataSource ps = new PagedDataSource();
             ps.DataSource                       = aop.search(s);
             ps.AllowPaging                      = true;
             ps.PageSize                         = 20;
             ps.CurrentPageIndex                 = currentPage - 1;
             this.Pagination1.pageCount          = ps.PageCount;
             this.Pagination1.paramName          = "p";
             this.Pagination1.currentPage        = currentPage;
             this.Pagination1.pageUrl            = "res.aspx?s=" + s;
             this.DataListArticleList.DataSource = ps;
             this.DataListArticleList.DataBind();
         }
         catch
         {
             Response.Redirect("refresh.aspx?msg=" + "请输入要查询的关键字!");
         }
     }
 }
Exemple #11
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string         title   = this.txtTitle.Text.ToString();
        int            cid     = Convert.ToInt32(this.DropDownListClass.SelectedValue);
        string         content = this.txtBody.Value;
        ArticleOperate aop     = new ArticleOperate();
        Article        ac      = new Article(cid, title, content);
        bool           b       = aop.insert(ac);

        if (b)
        {
            Response.Redirect("~/refresh.aspx?msg=" + "恭喜你,发表成功!");
        }
        else
        {
            this.lblMsg.Text = "很遗憾,发表失败,请重新尝试!";
        }
    }
Exemple #12
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Convert.ToString(Session["admin"]) != "admin")
     {
         Response.Redirect("~/refresh.aspx?msg=" + "对不起,只有管理员才能对文章进行相关的操作!");
         return;
     }
     if (!IsPostBack)
     {
         this.Title = Title + SetTitle.getTitle();
         try
         {
             int currentPage;
             try
             {
                 currentPage = Convert.ToInt32(Request.QueryString["p"]);
             }
             catch
             {
                 currentPage = 1;
             }
             if (currentPage == 0)
             {
                 currentPage = 1;
             }
             ArticleOperate  aop = new ArticleOperate();
             PagedDataSource ps  = new PagedDataSource();
             ps.DataSource                       = aop.viewList();
             ps.AllowPaging                      = true;
             ps.PageSize                         = 20;
             ps.CurrentPageIndex                 = currentPage - 1;
             this.Pagination1.pageCount          = ps.PageCount;
             this.Pagination1.currentPage        = currentPage;
             this.Pagination1.pageUrl            = "list.aspx";
             this.Pagination1.paramName          = "p";
             this.DataListArticleList.DataSource = ps;
             this.DataListArticleList.DataBind();
         }
         catch
         {
             Response.Redirect("~/refresh.aspx?msg=" + "显示出错,请稍候尝试!");
         }
     }
 }
Exemple #13
0
    protected void datasetbind()
    {
        int currentPage;
        int leibie;

        try
        {
            leibie      = Convert.ToInt32(Request.QueryString["Leibie"]);
            currentPage = Convert.ToInt32(Request.QueryString["page"]);
        }
        catch
        {
            leibie      = 0;
            currentPage = 1;
        }
        if (currentPage == 0)
        {
            currentPage = 1;
        }
        ArticleOperate  aop = new ArticleOperate();
        PagedDataSource ps  = new PagedDataSource();

        if (leibie != 0)
        {
            ps.DataSource = aop.viewAllByleibie(leibie);
        }
        else
        {
            ps.DataSource = aop.viewAll();//数据源为一个链表!,如此之棒,赞~!
        }

        ps.AllowPaging                  = true;
        ps.PageSize                     = 5;
        ps.CurrentPageIndex             = currentPage - 1;
        this.Pagination1.pageCount      = ps.PageCount;
        this.Pagination1.currentPage    = currentPage;
        this.Pagination1.pageUrl        = "Blog.aspx?Leibie=" + leibie;
        this.Pagination1.paramName      = "page";
        this.DataListViewAll.DataSource = ps;
        this.DataListViewAll.DataBind();
        //    this.DataListViewAll.DataKeyField = "ID";
    }
Exemple #14
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         this.Title = Title + SetTitle.getTitle();
         try
         {
             int cid = Convert.ToInt32(Request.QueryString["cid"]);
             int currentPage;
             try
             {
                 currentPage = Convert.ToInt32(Request.QueryString["p"]);
             }
             catch
             {
                 currentPage = 1;
             }
             if (currentPage == 0)
             {
                 currentPage = 1;
             }
             ArticleOperate  aop = new ArticleOperate();
             PagedDataSource ps  = new PagedDataSource();
             ps.DataSource                = aop.viewAllByCid(cid);
             ps.AllowPaging               = true;
             ps.PageSize                  = 20;
             ps.CurrentPageIndex          = currentPage - 1;
             this.Pagination1.currentPage = currentPage;
             this.Pagination1.pageCount   = ps.PageCount;
             this.Pagination1.pageUrl     = "list.aspx?cid=" + cid;
             this.Pagination1.paramName   = "p";
             MyClassOperate mop = new MyClassOperate();
             this.Page.Title = (mop.getByCid(cid)).cname + this.Page.Title;
             this.DataListArticleList.DataSource = ps;
             this.DataListArticleList.DataBind();
         }
         catch
         {
             Response.Redirect("refresh.aspx?msg=" + "对不起没有此分类的信息");
         }
     }
 }
Exemple #15
0
    protected void datasetbind()
    {
        int currentPage;
        int leibie;
        try
        {
            leibie = Convert.ToInt32(Request.QueryString["Leibie"]);
            currentPage = Convert.ToInt32(Request.QueryString["page"]);
        }
        catch
        {
            leibie = 0;
            currentPage = 1;
        }
        if (currentPage == 0)
        {
            currentPage = 1;
        }
        ArticleOperate aop = new ArticleOperate();
        PagedDataSource ps = new PagedDataSource();
        if (leibie != 0)
        {
            ps.DataSource = aop.viewAllByleibie(leibie);

        }
        else
        {
            ps.DataSource = aop.viewAll();//数据源为一个链表!,如此之棒,赞~!
        }

        ps.AllowPaging = true;
        ps.PageSize = 5;
        ps.CurrentPageIndex = currentPage - 1;
        this.Pagination1.pageCount = ps.PageCount;
        this.Pagination1.currentPage = currentPage;
        this.Pagination1.pageUrl = "Blog.aspx?Leibie=" + leibie;
        this.Pagination1.paramName = "page";
        this.DataListViewAll.DataSource = ps;
        this.DataListViewAll.DataBind();
        //    this.DataListViewAll.DataKeyField = "ID";
    }
Exemple #16
0
        public ActionResult Add(NewArticle data)
        {
            if (ModelState.IsValid)
            {
                ArticleModel art = new ArticleModel();
                art.Name    = data.Name;
                art.Title   = data.Title;
                art.Content = data.Content;
                art.Time    = DateTime.Now;

                ArticleOperate artOp      = new ArticleOperate();
                int            Article_Id = artOp.addArticle(art);

                ArticleToTagModel artTag = new ArticleToTagModel();
                artTag.Article_Id = Article_Id;
                artTag.Tag_Id     = data.Tag_Id;

                ArticleToTagOperate artToTag = new ArticleToTagOperate();
                artToTag.insert(artTag);
            }
            return(RedirectToAction("Index", "TagClass", new { id = data.Tag_Id }));
        }
Exemple #17
0
        // GET: TagClass
        public ActionResult Index(int id, int page = 1)
        {
            TagOperate tag_operate = new TagOperate();
            string     name        = tag_operate.getIdName(id);

            ViewBag.TagName = name;
            ArticleToTagOperate a_t_operate     = new ArticleToTagOperate();
            var                 list            = a_t_operate.select(1, id);
            ArticleOperate      article_operate = new ArticleOperate();
            List <ArticleModel> dataList        = new List <ArticleModel>();

            foreach (var a in list)
            {
                ArticleModel thisData = new ArticleModel();
                thisData = article_operate.getOneArticle(a.Article_Id);
                dataList.Add(thisData);
            }
            ViewBag.dataList = dataList;
            var data = dataList.ToPagedList(pageNumber: page, pageSize: 10);

            return(View(data));
        }
Exemple #18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            string         id  = Request.QueryString["artid"].ToString();
            string         Sid = Request.QueryString["id"].ToString();
            Article        ar  = new Article();
            ArticleOperate ao  = new ArticleOperate();
            ar = ao.getByAid(id);
            ar.gentieCount--;
            ao.update(ar);
            CommentOperate co = new CommentOperate();
            bool           b  = co.delete(Sid);

            if (b)
            {
                Response.Redirect("~/newsarticle.aspx?id=" + id);
            }
        }
        catch
        { }
    }
Exemple #19
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {

            string id = Request.QueryString["artid"].ToString();
            string Sid = Request.QueryString["id"].ToString();
            Article ar = new Article();
            ArticleOperate ao = new ArticleOperate();
            ar = ao.getByAid(id);
            ar.gentieCount--;
            ao.update(ar);
            CommentOperate co = new CommentOperate();
            bool b = co.delete(Sid);

            if (b)
            {
                Response.Redirect("~/newsarticle.aspx?id="+id);
            }
        }
        catch
        { }
    }
Exemple #20
0
 public newsarticle()
 {
     aot = new ArticleOperate();
 }