Example #1
0
 protected void gridView_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "InfoDelete")
     {
         Cultural.Model.Information info = new Cultural.Model.Information();
         info        = InfoBll.GetModel(int.Parse(e.CommandArgument.ToString()));
         info.Status = "0";
         InfoBll.Update(info);
         BindData();
     }
     if (e.CommandName == "InfoTop")
     {
         Cultural.Model.Information info = new Cultural.Model.Information();
         info = InfoBll.GetModel(int.Parse(e.CommandArgument.ToString()));
         if (info.Weight == 100)
         {
             info.Weight = 1;
             InfoBll.Update(info);
         }
         else if (info.Weight == 1)
         {
             InfoBll.SetTop(int.Parse(e.CommandArgument.ToString()));
         }
         BindData();
     }
 }
Example #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     id = Request.QueryString["id"];
     if (!IsPostBack)
     {
         if (id != null && id.Trim() != "")
         {
             infomation = InfoBll.GetModel(int.Parse(id));
             BindInfo(infomation);
         }
     }
 }
Example #3
0
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     if (ddlSBoardID.Items.Count > 0)
     {
         string title   = txtTitle.Text.Trim();
         string content = txtContent.Text;
         int    boardID = int.Parse(ddlSBoardID.Items[ddlSBoardID.SelectedIndex].Value);
         int    weight  = ddlTopShow.SelectedValue == "0" ? 1 : 100;
         int    author  = int.Parse(Session[Common.Session_MemID].ToString());
         string pubtime = string.Format("{0}-{1}-{2} {3}:{4}", DateTime.Now.Year, DateTime.Now.Month.ToString().PadLeft(2, '0'), DateTime.Now.Day.ToString().PadLeft(2, '0'), DateTime.Now.Hour.ToString().PadLeft(2, '0'), DateTime.Now.Minute.ToString().PadLeft(2, '0'));
         int    readnum = 0;
         string status  = "1";
         string picUrl  = hidImgPath.Value;
         string accURL  = hidFilePath.Value;
         string accname = hidFileOriName.Value;
         if (title != "" && content.Trim() != "")
         {
             Cultural.Model.Information info = new Cultural.Model.Information();
             info.Author   = author;
             info.BoardID  = boardID;
             info.Content  = content;
             info.PubTime  = pubtime;
             info.ReadNum  = readnum;
             info.Status   = status;
             info.Title    = title;
             info.Weight   = weight;
             info.PicURL1  = picUrl;
             info.AccURL1  = accURL;
             info.AccName1 = accname;
             try
             {
                 InfoBll.Add(info);
                 Maticsoft.Common.MessageBox.ShowAndRedirect(this.Page, "添加成功!", "AddNews.aspx");
             }
             catch
             {
                 Maticsoft.Common.MessageBox.Show(this.Page, "添加失败!");
             }
         }
         else
         {
             MessageBox.Show(this.Page, "标题和内容不能为空!添加失败!");
         }
     }
     else
     {
         MessageBox.Show(this.Page, "该板块还尚未添加子版块,请添加子版块后再填写新闻!");
     }
 }
Example #4
0
        public void BindInfo(Cultural.Model.Information inf)
        {
            DataSet bList = new DataSet();
            bList = Boardbll.GetAllList();
            ddlBoardID.Items.Clear();
            for (int i = 0; i < bList.Tables[0].Rows.Count; i++)
            {
                ddlBoardID.Items.Add(new ListItem(bList.Tables[0].Rows[i]["BoardName"].ToString(), bList.Tables[0].Rows[i]["BoardID"].ToString()));
            }
            ddlBoardID.SelectedIndex = ddlBoardID.Items.IndexOf(ddlBoardID.Items.FindByValue(inf.BoardID.ToString()));

            ddlTopShow.SelectedIndex = inf.Weight == 100 ? 1 : 0;
            txtTitle.Text = inf.Title;
            txtContent.Text = inf.Content;
            lblAccName.Text = inf.AccName1;
            ImgPath =@"../../Image/News/"+ inf.PicURL1;
            FilePath = inf.AccName1;
            hidFilePath.Value = inf.AccURL1;
            hidImgPath.Value = inf.PicURL1;
        }
Example #5
0
        public void ProcessRequest(HttpContext context)
        {
            Cultural.BLL.Information infoBLL = new Cultural.BLL.Information();
            context.Response.ContentType = "text/plain";
            string paraFID = context.Request["FID"];                                                                      //读取参数PageSize

            if (paraFID != null && paraFID.Trim() == "NL")                                                                //列表界面
            {
                int      paraIndex   = context.Request["Index"] == null ? 1 : int.Parse(context.Request["Index"]);        //读取参数PageSize
                int      paraSize    = context.Request["PageSize"] == null ? 10 : int.Parse(context.Request["PageSize"]); //读取参数PageSize
                string   paraBoardID = context.Request["BoardID"] == null ? "0" : context.Request["BoardID"].ToString();  //读取参数
                NewsInfo newsInfo    = new NewsInfo();
                newsInfo.Info     = infoBLL.DataTableToList(infoBLL.GetListByPage(string.Format(" BoardID={0} and Status!='0' ", paraBoardID), " Weight desc,PubTime desc ", (paraIndex - 1) * paraSize, paraIndex * paraSize).Tables[0]);
                newsInfo.TotalNum = infoBLL.GetRecordCount(string.Format(" BoardID={0} and Status!='0' ", paraBoardID));
                newsInfo.BoardID  = paraBoardID;
                for (int i = 0; i < newsInfo.Info.Count; i++)
                {
                    newsInfo.Info[i].Content = newsInfo.Info[i].Content == null ? "" : Maticsoft.Common.CommonFun.ClearHtml(newsInfo.Info[i].Content).Length > 230 ? Maticsoft.Common.CommonFun.ClearHtml(newsInfo.Info[i].Content).Substring(0, 229) + "…" :CommonFun.ClearHtml(newsInfo.Info[i].Content);
                }
                context.Response.Write(JsonHelper.Serialize(newsInfo));
            }
            else if (paraFID != null && paraFID.Trim() == "ND")                                            //详细界面
            {
                int paraID = context.Request["InfoID"] == null ? 1 : int.Parse(context.Request["InfoID"]); //读取参数PageSize
                if (paraID != null && paraID.ToString().Trim() != "")
                {
                    Cultural.Model.Information info = new Cultural.Model.Information();
                    info = infoBLL.GetModel(paraID);
                    NewsInfo newsInfo = new NewsInfo();
                    newsInfo.Info = new List <Cultural.Model.Information>();
                    if (info != null)
                    {
                        newsInfo.Info.Add(info);
                        //阅读次数更新
                        info.ReadNum += 1;
                        infoBLL.Update(info);
                        Cultural.BLL.Member memBll = new Cultural.BLL.Member();
                        newsInfo.Author = memBll.GetModel(int.Parse(info.Author.ToString().Trim())).MembName;
                        Cultural.BLL.Board   boardBll = new Cultural.BLL.Board();
                        Cultural.Model.Board board    = new Cultural.Model.Board();
                        board = boardBll.GetModel(int.Parse(info.BoardID.ToString()));
                        if (board != null && board.ParentID == 0)
                        {
                            newsInfo.BoardID   = board.BoardID.ToString();
                            newsInfo.BoardName = board.BoardName;
                            newsInfo.BName     = "";
                        }
                        else if (board != null && board.ParentID != 0)
                        {
                            Cultural.Model.Board board2 = new Cultural.Model.Board();
                            board2 = boardBll.GetModel(int.Parse(board.ParentID.ToString()));
                            if (board2 != null)
                            {
                                newsInfo.BoardID   = board2.BoardID.ToString();
                                newsInfo.BoardName = board2.BoardName;
                                newsInfo.BName     = board.BoardName;
                            }
                            else
                            {
                                newsInfo.BoardID   = board.BoardID.ToString();
                                newsInfo.BoardName = board.BoardName;
                                newsInfo.BName     = "";
                            }
                        }
                        else
                        {
                            newsInfo.BoardID   = board.BoardID.ToString();
                            newsInfo.BoardName = board.BoardName;
                            newsInfo.BName     = "";
                        }
                    }
                    context.Response.Write(JsonHelper.Serialize(newsInfo));
                }
                else
                {
                    context.Response.Write(JsonHelper.Serialize("error"));
                }
            }
            else if (paraFID != null && paraFID.Trim() == "CND")                                                  //中心概括界面  邹瑶修改20140225
            {
                int      paraID   = context.Request["InfoID"] == null ? 1 : int.Parse(context.Request["InfoID"]); //读取参数PageSize
                NewsInfo newsInfo = new NewsInfo();
                if (paraID != null && paraID.ToString().Trim() != "")
                {
                    newsInfo.Info = infoBLL.GetModelList(string.Format(" BoardID ={0} and  Status!='0' order by Weight desc,PubTime desc  ", paraID));
                }
                context.Response.Write(JsonHelper.Serialize(newsInfo));
            }
            else
            {
                context.Response.Write(JsonHelper.Serialize("error"));
            }
        }