protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         btnClose.OnClientClick = ActiveWindow.GetHideReference();
         BindGrid();
         Calendar1.SelectedDate = DateTime.Now;
         if (!String.IsNullOrEmpty(Request.QueryString["tyId"]))
         {
             ddlfatherId.SelectedValue = Request.QueryString["tyId"];
             ddlfatherId.Enabled       = false;
         }
         if (!String.IsNullOrEmpty(Request.QueryString["Id"]))
         {
             ddlfatherId.Enabled = true;
             Maticsoft.BLL.tArticle   bll   = new Maticsoft.BLL.tArticle();
             Maticsoft.Model.tArticle model = bll.GetModel(int.Parse(Request.QueryString["Id"]));
             imgPhoto.ImageUrl         = model.FengMian;
             txtTile.Text              = model.Title;
             txtRemark.Text            = model.Remark;
             txtEdit.Text              = model.Editor;
             Calendar1.SelectedDate    = model.UpdateTime;
             ddlfatherId.SelectedValue = model.ArtTyID.ToString();
             txtSort.Text              = model.Sort.ToString();
             hfEditorInitValue.Text    = model.ArticleContent;
         }
     }
 }
        protected void GetView()
        {
            int Tid = 0;

            if (string.IsNullOrEmpty(TMailList.SelectedNodeID))
            {
                Tid = 0;
            }
            else
            {
                Tid = int.Parse(TMailList.SelectedNodeID);
            }

            Maticsoft.BLL.tArticle BLL = new Maticsoft.BLL.tArticle();
            if (Tid == 0)
            {
                Grid.RecordCount = BLL.GetRecordCount("");
                Grid.DataSource  = BLL.GetListByPage("", " Sort desc,UpdateTime desc ", Grid.PageIndex * Grid.PageSize, (Grid.PageIndex + 1) * Grid.PageSize);
            }
            else
            {
                Grid.RecordCount = BLL.GetRecordCount(" ArtTyID=" + Tid);
                Grid.DataSource  = BLL.GetListByPage(" ArtTyID=" + Tid, " Sort desc,UpdateTime desc ", Grid.PageIndex * Grid.PageSize, (Grid.PageIndex + 1) * Grid.PageSize);
            }
            Grid.DataBind();
        }
        protected void btnSelect_Click(object sender, EventArgs e)
        {
            string txtVal = this.txtValue.Text.Trim();

            if (txtVal == "")
            {
                GetView();
            }


            int Tid = 0;

            if (string.IsNullOrEmpty(TMailList.SelectedNodeID))
            {
                Tid = 0;
            }
            else
            {
                Tid = int.Parse(TMailList.SelectedNodeID);
            }

            Maticsoft.BLL.tArticle BLL = new Maticsoft.BLL.tArticle();
            if (Tid == 0)
            {
                Grid.RecordCount = BLL.GetRecordCount(String.Format(" Title like '%{0}%' ", txtVal));
                Grid.DataSource  = BLL.GetListByPage(String.Format(" Title like '%{0}%' ", txtVal), " Sort desc,UpdateTime desc ", Grid.PageIndex * Grid.PageSize, (Grid.PageIndex + 1) * Grid.PageSize);
            }
            else
            {
                Grid.RecordCount = BLL.GetRecordCount(String.Format(" Title like '%{0}%' and ArtTyID=" + Tid, txtVal));
                Grid.DataSource  = BLL.GetListByPage(String.Format(" Title like '%{0}%' and ArtTyID=" + Tid, txtVal), " Sort desc,UpdateTime desc ", Grid.PageIndex * Grid.PageSize, (Grid.PageIndex + 1) * Grid.PageSize);
            }

            Grid.DataBind();
        }
Пример #4
0
        public DataTable GetArtByTid(int tid, int top)
        {
            Maticsoft.BLL.tArticle BLL = new Maticsoft.BLL.tArticle();
            DataTable dt = BLL.GetListByPage(" IsEnable=1 and ArtTyID=" + tid, " Sort desc,UpdateTime desc ", 0, top).Tables[0];

            return(dt);
        }
Пример #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["tId"] == null && Request.QueryString["Id"] == null)
            {
                Response.Redirect("index.aspx");
                return;
            }
            int tId = 0;

            try
            {
                tId = int.Parse(Request.QueryString["tId"].ToString());
            }
            catch
            {
                Response.Redirect("index.aspx");
                return;
            }
            if (!IsPostBack)
            {
                getNav(tId);
            }
            Maticsoft.Model.tArticle model = null;
            Maticsoft.BLL.tArticle   BLL   = new Maticsoft.BLL.tArticle();
            model       = BLL.GetModel(int.Parse(Request.QueryString["Id"]));
            model.Click = (model.Click + 1);
            BLL.Update(model);
            lit_title.Text   = model.Title;
            this.Title      += "-" + model.Title;
            lit_content.Text = model.ArticleContent;
            lit_edit.Text    = model.Editor;
            lit_click.Text   = model.Click.ToString();
            lit_time.Text    = Convert.ToDateTime(model.UpdateTime).ToString("yyyy-MM-dd");
        }
 protected void BindGridByTid(int Tid)
 {
     Maticsoft.BLL.tArticle BLL = new Maticsoft.BLL.tArticle();
     if (Tid == 0)
     {
         Grid.RecordCount = BLL.GetRecordCount("");
         Grid.DataSource  = BLL.GetListByPage("", " Sort desc,UpdateTime desc ", Grid.PageIndex * Grid.PageSize, (Grid.PageIndex + 1) * Grid.PageSize);
     }
     else
     {
         Grid.RecordCount = BLL.GetRecordCount(" ArtTyID=" + Tid);
         Grid.DataSource  = BLL.GetListByPage(" ArtTyID=" + Tid, " Sort desc,UpdateTime desc ", Grid.PageIndex * Grid.PageSize, (Grid.PageIndex + 1) * Grid.PageSize);
     }
     Grid.DataBind();
 }
        protected void Grid_RowCommand(object sender, GridCommandEventArgs e)
        {
            int artId = GetSelectedDataKeyID(Grid);


            if (e.CommandName == "Delete")
            {
                Maticsoft.BLL.tArticle BLL = new Maticsoft.BLL.tArticle();

                Maticsoft.Model.tArticle model = BLL.GetModel(artId);
                if (!string.IsNullOrEmpty(model.FengMian) && (model.FengMian != "../../upload/blank.png"))
                {
                    string directoryPath = Server.MapPath(model.FengMian);
                    File.Delete(directoryPath);
                    //删除掉原来的图片
                }
                BLL.Delete(artId);
                GetView();
            }
            if (e.CommandName == "Edit")
            {
                PageContext.RegisterStartupScript(Window1.GetShowReference("ArticlesEdit.aspx?Id=" + artId));
            }
        }
Пример #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int tId = 7;



            Maticsoft.BLL.tArticle BLLT = new Maticsoft.BLL.tArticle();
            DataTable dt = BLLT.GetList(" IsEnable=1 and ArtTyID=" + tId + " order by Sort desc,UpdateTime desc ").Tables[0];

            PagedDataSource objPds = new PagedDataSource();

            objPds.DataSource  = dt.DefaultView;
            objPds.AllowPaging = true;
            objPds.PageSize    = 10;//  每页多少条
            int PageSum = objPds.PageCount;

            if (PageSum == 1)
            {
                PageView.Text = "";
            }

            else
            {
                int CurPage;
                if (Request.QueryString["Page"] != null)
                {
                    CurPage = Convert.ToInt32(Request.QueryString["Page"]);
                }
                else
                {
                    CurPage = 1;
                }
                objPds.CurrentPageIndex = CurPage - 1;

                if (CurPage < PageSum + 1)
                {
                    PageView.Text += " <a  href='?tId=" + tId + "'  >&lt;&lt;</a> ";
                    if (!objPds.IsFirstPage)
                    {
                        PageView.Text += "<a  href='?Page=" + (CurPage - 1) + "&tId=" + tId + "' >上一页</a>";
                    }
                    else
                    {
                        PageView.Text += "<a  title='已是第一页' >上一页</a>";
                    }
                    for (int i = CurPage - 5; i < CurPage + 5; i++)
                    {
                        if (i < 0 || i >= PageSum)
                        {
                            continue;
                        }

                        else
                        {
                            if (CurPage == (i + 1))
                            {
                                PageView.Text += " <span class=\"current\">" + (i + 1) + "</span>";
                            }
                            else
                            {
                                PageView.Text += "<a  href='?Page=" + (i + 1) + "&tId=" + tId + "' >" + (i + 1) + "</a>";
                            }
                        }
                    }
                }

                if (!objPds.IsLastPage)
                {
                    PageView.Text += "<a  href='?Page=" + (CurPage + 1) + "&tId=" + tId + "'  >下一页</a>";
                }
                else
                {
                    PageView.Text += "<a  title='已是最后页' >下一页</a>";
                }
                PageView.Text += "<a  href='?Page=" + PageSum + "&tId=" + tId + "' title='末页'>&gt;&gt;</a>";
            }

            DataList1.DataSource = objPds;
            DataList1.DataBind();
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Maticsoft.BLL.tArticle bll = new Maticsoft.BLL.tArticle();
            if (imgPhoto.ImageUrl == "")
            {
                filePhoto.MarkInvalid("请先上传封面图片!");

                Alert.ShowInTop("请先上传封面图片!");
                return;
            }
            if (Calendar1.SelectedDate == null)
            {
                Calendar1.SelectedDate = DateTime.Now;
            }
            string content = Request.Form["editor1"] == null ? "" : Request.Form["editor1"];

            if (!String.IsNullOrEmpty(Request.QueryString["tyId"]))
            {
                Maticsoft.Model.tArticle model = new Maticsoft.Model.tArticle();
                model.FengMian       = imgPhoto.ImageUrl;
                model.Title          = txtTile.Text;
                model.Remark         = txtRemark.Text;
                model.Editor         = txtEdit.Text;
                model.UpdateTime     = Calendar1.SelectedDate;
                model.ArtTyID        = int.Parse(ddlfatherId.SelectedValue);
                model.Sort           = int.Parse(txtSort.Text);
                model.ArticleContent = content;
                model.IsEnable       = 1;
                int k = bll.Add(model);



                if (k > 0)
                {
                    PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
                }
            }
            if (!String.IsNullOrEmpty(Request.QueryString["Id"]))
            {
                Maticsoft.Model.tArticle model = bll.GetModel(int.Parse(Request.QueryString["Id"]));
                if (imgPhoto.ImageUrl != model.FengMian)
                {
                    if (!string.IsNullOrEmpty(model.FengMian) && (model.FengMian != "../../upload/blank.png"))
                    {
                        string directoryPath = Server.MapPath(model.FengMian);
                        File.Delete(directoryPath);
                        //删除掉原来的图片
                    }
                }
                model.FengMian       = imgPhoto.ImageUrl;
                model.Title          = txtTile.Text;
                model.Remark         = txtRemark.Text;
                model.Editor         = txtEdit.Text;
                model.UpdateTime     = Calendar1.SelectedDate;
                model.ArtTyID        = int.Parse(ddlfatherId.SelectedValue);
                model.Sort           = int.Parse(txtSort.Text);
                model.ArticleContent = content;
                model.IsEnable       = 1;
                bll.Update(model);
                PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
            }
        }