/// <summary>
 /// 初始化修改页面
 /// </summary>
 /// <param name="newsId">新闻id</param>
 private void ShowInfo(int newsId)
 {
     BLL.CCOM.News   bll   = new BLL.CCOM.News();
     Model.CCOM.News model = bll.GetModel(newsId);
     if (model != null)
     {
         this.txtTitle.Text = model.News_title;
         //this.hidNewsType.Value = model.News_type_id.ToString();
         this.txtReleaseTime.Text = model.News_date.ToString();
         this.hidEditorCnt.Value  = model.News_content;
         if (model.News_top != null)
         {
             this.optTop.Checked  = (bool)model.News_top;
             this.txtTopTime.Text = model.News_top_time.ToString();
             //this.trTop.Style.Add("display", "");
         }
         List <Model.CCOM.News_attach> attach_model = new BLL.CCOM.News_attach().GetModelList(" News_id=" + newsId);
         if (attach_model != null && attach_model.Count > 0)
         {
             rptAttach.DataSource = attach_model;
             rptAttach.DataBind();
         }
     }
     else
     {
         JscriptMsg("资讯不存在或已被删除!", "back", "Error");
     }
 }
        //单个删除
        protected void lbtSingleDelete_Click(object sender, EventArgs e)
        {
            var lbtn = sender as LinkButton;

            BLL.CCOM.News_type bll      = new BLL.CCOM.News_type();
            BLL.CCOM.News      news_bll = new BLL.CCOM.News();
            if (lbtn != null)
            {
                bool result     = false;
                int  newsTypeId = Int32.Parse(DESEncrypt.Decrypt(lbtn.ToolTip.ToString()));
                if (newsTypeId > 0)
                {
                    Model.CCOM.News_type model = bll.GetModel(newsTypeId);
                    if (model.News_type_creator_id == GetAdminInfo_CCOM().User_id)
                    {
                        news_bll.Delete(" News_type_id=" + newsTypeId);
                        result = bll.Delete(newsTypeId);
                    }
                    int page = MyRequest.GetQueryInt("page", 1);
                    if (result)
                    {
                        JscriptMsg("删除成功!", Utils.CombUrlTxt("News_type_manage.aspx", "&keywords={0}&page={1}&fun_id={2}",
                                                             keywords, page.ToString(), DESEncrypt.Encrypt(this.fun_id)), "Success");
                    }
                }
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //按时间先后
            DataTable dt = new BLL.CCOM.News().GetList(0, "", " News_date DESC").Tables[0];

            if (dt != null && dt.Rows.Count > 0)
            {
                var           class_media      = "media";
                var           class_span       = "label pull-left news-bg";
                var           class_img_circle = "img-circle";
                var           img_src          = "/admin/images/water.jpg";
                var           class_media_body = "media-body";
                var           p_title          = "text news-title";
                var           img_style        = "width:40px; height:40px;";
                StringBuilder sb = new StringBuilder();
                foreach (DataRow dr in dt.Rows)
                {
                    sb.Append("<li><div class=\"" + class_media + "\"><span class=\"" + class_span + "\"><img class=\"" +
                              class_img_circle + "\" src=\"" + img_src + "\" alt=\"资讯\" style=\"" + img_style + "\"/></span>");
                    sb.Append("<div class=\"" + class_media_body + "\"><p class=\"" + p_title + "\"><a href=\"" + dr["News_URL"] + "\">" +
                              dr["News_title"] + "</a></p><span>" + dr["News_date"] + "</span></div></div></li>");
                }
                context.Response.Write(sb.ToString());
            }
            else
            {
                context.Response.Write("暂无资讯");
            }


            //不按时间先后
            //var news_list = new BLL.CCOM.News().GetModelList("");
            //if (news_list != null && news_list.Count > 0)
            //{
            //    var class_media = "media";
            //    var class_span = "label pull-left news-bg";
            //    var class_img_circle = "img-circle";
            //    var img_src = "/admin/images/water.jpg";
            //    var class_media_body = "media-body";
            //    var p_title = "text news-title";
            //    var img_style = "width:40px; height:40px;";
            //    StringBuilder sb = new StringBuilder();
            //    for (int i = 0; i < news_list.Count; i++)
            //    {
            //        Model.CCOM.News model = news_list[i];
            //        sb.Append("<li><div class=\"" + class_media + "\"><span class=\"" + class_span + "\"><img class=\"" +
            //            class_img_circle + "\" src=\"" + img_src + "\" alt=\"资讯\" style=\"" + img_style + "\"/></span>");
            //        sb.Append("<div class=\"" + class_media_body + "\"><p class=\"" + p_title + "\"><a href=\"" + model.News_URL + "\">" +
            //            model.News_title + "</a></p><span>" + model.News_date + "</span></div></div></li>");
            //        //context.Response.Write(sb.ToString());
            //    }
            //    context.Response.Write(sb.ToString());
            //}
            //else
            //{
            //    context.Response.Write("暂无资讯");
            //}
        }
Beispiel #4
0
        /// <summary>
        /// 获取页码
        /// </summary>
        /// <param name="context"></param>
        private void GetNewsPage(HttpContext context, int typeId, string strWhere, int page)
        {
            //var response = new HttpBaseResponse();
            int    total_count = new BLL.CCOM.News().GetRecordCount(strWhere);
            string pageStr     = Utils.OutPageList(pageSize, page, total_count, "javascript:gotoNewsPage(__id__);", 8, true);

            context.Response.Write(pageStr);
        }
        /// <summary>
        /// 获取通知信息
        /// </summary>
        /// <param name="typeId"></param>
        /// <param name="page">返回页码</param>
        /// <returns></returns>
        protected string InitialPage(Int32 typeId, int page)
        {
            string sqlWhere = string.Empty;

            if (typeId != 0)
            {
                sqlWhere = " News_type_id='" + typeId + "'";
            }
            //不按时间
            //var list = new BLL.CCOM.News().GetModelList(sqlWhere);
            //if (list != null && list.Count > 0)
            //{
            //    List<string> page_item = new List<string>();
            //    StringBuilder sb = new StringBuilder();
            //    for (int i = 1; i <= list.Count; i++)
            //    {
            //        Model.CCOM.News model = list[0];
            //        sb.Append("<li class='notice-li'>" + "<a href='" + model.News_URL + "'>" + i  + "、" + model.News_title + "<a/>" + "<li/>");
            //        if (i % 10 == 0)
            //        {
            //            page_item.Add(sb.ToString());
            //            sb = new StringBuilder();
            //        }
            //    }
            //    if(page_item.Count==0)
            //    {
            //        page_item.Add(sb.ToString());
            //    }
            //    this.news_list.InnerHtml = page_item[page];
            //}

            //按时间
            DataTable dt = new BLL.CCOM.News().GetList(0, sqlWhere, " News_date DESC").Tables[0];

            if (dt != null && dt.Rows.Count > 0)
            {
                int           i  = 1;
                StringBuilder sb = new StringBuilder();
                foreach (DataRow dr in dt.Rows)
                {
                    sb.Append("<li class=\"notice-li\">" + "<a href=\"" + dr["News_URL"] + "\">" + i + "、" + dr["News_title"] + "<a/>" + "<li/>");
                    if (i % 10 == 0)
                    {
                        page_item.Add(sb.ToString());
                        sb = new StringBuilder();
                    }
                    i++;
                }
                if (sb != null && sb.ToString().Length > 0)
                {
                    page_item.Add(sb.ToString());
                }
                return(page_item[page - 1]);
            }
            return(null);
        }
Beispiel #6
0
 public static void UpdateNewsReadNum(int newsId)
 {
     if (HttpContext.Current.Session[newsId.ToString()] == null)
     {
         var news = new BLL.CCOM.News().GetModel(newsId);
         news.News_readnumber++;
         new BLL.CCOM.News().Update(news);
         HttpContext.Current.Session[newsId.ToString()] = 1;
     }
 }
Beispiel #7
0
        public static void CreateWebNewsHtml(String newsId, String fileName, bool checkExists)
        {
            if ((!checkExists) || (!System.IO.File.Exists(fileName)))
            {
                var news = new BLL.CCOM.News().GetModel(Int32.Parse(newsId));
                if (news != null)
                {
                    // 读取模板文件
                    string temp    = HttpContext.Current.Server.MapPath("news_temp.html");
                    String newsStr = FileOperate.ReadFile(temp);
                    newsStr = newsStr.Replace("titlexxx", news.News_title);
                    StringBuilder sb         = new StringBuilder();
                    int           creator_id = news.News_creator_id;
                    string        realname   = new BLL.CCOM.User_information().GetModel(creator_id).User_realname;
                    if (realname != "请填写真实姓名")
                    {
                        sb.Append("<span>发布者:").Append(realname).Append("</span>");
                    }

                    sb.Append("&nbsp;&nbsp;");
                    sb.Append(news.News_date);
                    //sb.Append("&nbsp;&nbsp;").Append("阅读次数:").Append(news.NI_ReadNum);
                    newsStr = newsStr.Replace("desxxx", sb.ToString());
                    String content = HttpContext.Current.Server.HtmlDecode(news.News_content);

                    newsStr = newsStr.Replace("contentxxx", content);
                    sb.Clear();
                    //var newsAttach = new BLL.news.News_NewsInfo().GetModel(Int64.Parse(newsId)).NewsAttach;
                    string strWhere   = " News_id=" + newsId;
                    var    newsAttach = new BLL.CCOM.News_attach().GetModelList(strWhere);
                    if (newsAttach != null && newsAttach.Count > 0)
                    {
                        sb.Append("<p class='attachTitle'>附件:</p>");
                        var itemCnt = 1;
                        foreach (var item in newsAttach)
                        {
                            sb.Append("<p class='attachItem'>(").Append(itemCnt).Append(")&nbsp;<a href='")
                            .Append("/home/news/Attach.aspx?id=").Append(DESEncrypt.Encrypt(item.News_attach_id.ToString()))
                            .Append("&address=").Append(HttpUtility.UrlEncode(item.News_attach_address))
                            .Append("&name=").Append(HttpUtility.UrlEncode(item.News_attach_name))
                            .Append("' target='_blank' >")
                            .Append(item.News_attach_name)
                            .Append("</a>")
                            .Append(OnlineViewHelper.GetOnlineViewWrapLink(item.News_attach_address, item.News_attach_name))
                            .Append("</p>");
                            itemCnt++;
                        }
                    }
                    newsStr = newsStr.Replace("attachxxx", sb.ToString());
                    ////写文件
                    FileOperate.WriteNewFile(fileName, newsStr);
                }
            }
        }
        /// <summary>
        /// 置顶
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void lbtTop_Click(object sender, EventArgs e)
        {
            var bll  = new BLL.CCOM.News();
            var lbtn = sender as LinkButton;

            if (lbtn != null)
            {
                int  news_id = Int32.Parse(DESEncrypt.Decrypt(lbtn.ToolTip.ToString()));
                bool isTop   = false;
                bool result  = true;
                try
                {
                    var model = bll.GetModel(news_id);
                    if (model.News_top != null && !(bool)model.News_top)
                    {
                        isTop          = false;
                        model.News_top = true;
                        DateTime date      = Convert.ToDateTime(model.News_date);
                        TimeSpan time_span = DateTime.Now - date;
                        int      day       = time_span.Days;
                        model.News_top_time = day + 3;
                        bll.Update(model);
                    }
                    else
                    {
                        isTop               = true;
                        model.News_top      = false;
                        model.News_top_time = 0;
                        bll.Update(model);
                    }
                    result = true;
                }
                catch
                {
                    result = false;
                }
                //string keywords = MyRequest.GetQueryString("keywords");
                int page = MyRequest.GetQueryInt("page", 1);
                if (result == true)
                {
                    JscriptMsg(isTop ? "取消置顶成功!" : "置顶成功!", Utils.CombUrlTxt("News_list_manager.aspx", "keywords={0}&page={1}&fun_id={2}",
                                                                             keywords, page.ToString(), DESEncrypt.Encrypt(this.fun_id)), "Success");
                }
                else
                {
                    JscriptMsg(isTop ? "取消置顶失败!" : "置顶失败!", Utils.CombUrlTxt("News_list_manager.aspx", "keywords={0}&page={1}&fun_id={2}",
                                                                             keywords, page.ToString(), DESEncrypt.Encrypt(this.fun_id)), "Error");
                }
            }
        }
Beispiel #9
0
        /// <summary>
        /// 获取新闻生成的日期目录
        /// </summary>
        /// <param name="newsId">新闻Id</param>
        private static string GetNewsDatePath(int newsId)
        {
            //var m = new BLL.news.News_NewsInfo().GetModel(newsId);
            var model = new BLL.CCOM.News().GetModel(newsId);

            if (model == null || model.News_date == null)
            {
                return("");
            }
            //按年月/日存入不同的文件夹
            DateTime dt = Convert.ToDateTime(model.News_date);

            return(dt.ToString("yyyyMM") + "/" + dt.ToString("dd") + "/");
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string id     = context.Request.Params["newsId"];
            int    newsId = int.Parse(DESEncrypt.Decrypt(id));

            Model.CCOM.News model = new BLL.CCOM.News().GetModel(newsId);
            if (model != null)
            {
                context.Response.Write(model.News_readnumber);
            }
            else
            {
                context.Response.Write("0");
            }
        }
Beispiel #11
0
        /// <summary>
        /// 获取所有新闻
        /// </summary>
        /// <param name="context"></param>
        private void GetAllNewList(HttpContext context, int typeId, string strWhere, int page)
        {
            //初始化置顶数据
            if (page == 1)
            {
                var bll  = new BLL.CCOM.News();
                var list = bll.GetModelList("News_top=1");
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i].News_date != null)
                    {
                        DateTime date = Convert.ToDateTime(list[i].News_date);
                        if (list[i].News_top_time != null)
                        {
                            if (date.AddDays((double)list[i].News_top_time) < DateTime.Now)
                            {
                                var model = bll.GetModel(list[i].News_id);
                                model.News_top      = false;
                                model.News_top_time = 0;
                                bll.Update(model);
                            }
                        }
                        else
                        {
                            //若为空,默认为3天
                            if (date.AddDays(3.0) < DateTime.Now)
                            {
                                var model = bll.GetModel(list[i].News_id);
                                model.News_top      = false;
                                model.News_top_time = 0;
                                bll.Update(model);
                            }
                        }
                    }
                }
            }
            int       start_index = pageSize * (page - 1) + 1;
            int       end_index   = pageSize * page;
            DataTable dt          = new BLL.CCOM.News().GetListByPage(strWhere, "News_top DESC ,News_date DESC ", start_index, end_index).Tables[0];
            string    json        = ToJson(dt);

            context.Response.Write(json);
        }
        private int DoAdd()
        {
            var model = new Model.CCOM.News();

            model.News_title      = this.txtTitle.Text.Trim();
            model.News_URL        = "/AdminMetro/index.aspx";
            model.News_creator_id = (int)GetAdminInfo_CCOM().User_id;
            if (this.txtReleaseTime.Text.Trim() != null && this.txtReleaseTime.Text.Trim().Length > 0)
            {
                model.News_date = Convert.ToDateTime(this.txtReleaseTime.Text.Trim());
            }
            else
            {
                model.News_date = DateTime.Now;
            }
            model.News_readnumber = 1;
            model.News_type_id    = int.Parse(DESEncrypt.Decrypt(this.hidNewsType.Value));
            model.News_content    = this.hidEditorCnt.Value.Replace("'", "");
            model.News_top        = false;
            if (this.optTop.Checked)
            {
                model.News_top = true;
                string time = this.txtTopTime.Text.Trim();
                if (time != null && time.Length > 0)
                {
                    int last_time = int.Parse(time);
                    model.News_top_time = last_time;
                }
                else
                {
                    model.News_top_time = 3;//默认置顶3天
                }
            }

            Int32 newsId = 0;

            newsId = new BLL.CCOM.News().Add(model);
            if (newsId > 0)
            {
                #region ====================附件
                //保存附件
                string hidFileList = Request.Params["hidFileName"];
                if (!string.IsNullOrEmpty(hidFileList))
                {
                    string[] fileListArr = hidFileList.Split(',');
                    //var list = new List<Model.CCOM.News_attach>();
                    for (int i = 0; i < fileListArr.Length; i++)
                    {
                        string[] fileArr = fileListArr[i].Split('|');
                        if (fileArr.Length == 3)
                        {
                            int    attach_id  = Int32.Parse(fileArr[0]);
                            String toFilePath = DataDic.News_Attach_Path + DateTime.Now.Ticks.ToString() + i.ToString() +
                                                FileOperate.GetPostfixStr(fileArr[2]);
                            try
                            {
                                FileOperate.FileMove(Server.MapPath(fileArr[2]),
                                                     Server.MapPath(toFilePath));
                                //上传附件至文件服务器
                                UI.UpLoad.UploadFileThread(toFilePath);
                            }
                            catch (Exception ex)
                            {
                                toFilePath = fileArr[2];
                            }
                            Model.CCOM.News_attach model_attach = new Model.CCOM.News_attach();
                            model_attach.News_id             = newsId;
                            model_attach.News_attach_name    = fileArr[1];
                            model_attach.News_attach_address = toFilePath;
                            new BLL.CCOM.News_attach().Add(model_attach);
                        }
                    }
                }
                #endregion
                //修改URL
                Model.CCOM.News model1 = new BLL.CCOM.News().GetModel(newsId);
                model1.News_URL = "/AdminMetro/CCOM/notification/ViewNews.aspx?id=" + DESEncrypt.Encrypt(newsId.ToString());
                new BLL.CCOM.News().Update(model1);
                //生成静态页
                NewsHtml.CreateHtml(newsId, false);
            }
            return(newsId);
        }
        /// <summary>
        /// 初始化资讯类别
        /// </summary>
        private void InitialNewsType()
        {
            var           news_type_list = new BLL.CCOM.News_type().GetModelList("");
            StringBuilder sb             = new StringBuilder();

            if (news_type_list != null && news_type_list.Count > 0)
            {
                string news_id    = MyRequest.GetQueryString("id");
                var    className  = "btn btn-success";
                var    className1 = "btn";
                if (news_id != null && news_id.Length > 0)//编辑
                {
                    Model.CCOM.News model = new BLL.CCOM.News().GetModel(int.Parse(DESEncrypt.Decrypt(news_id)));
                    if (model != null)
                    {
                        int news_type_id = model.News_type_id;
                        if (news_type_id != 0)
                        {
                            sb.Append("<a href=\"javascript:;\" class='btn' onclick='newsTypeTabs(\"" + DESEncrypt.Encrypt("0") + "\",this)'>未分类</a>&nbsp;&nbsp;");
                            for (int i = 0; i < news_type_list.Count; i++)
                            {
                                if (news_type_list[i].News_type_id == news_type_id)
                                {
                                    sb.Append("<a href=\"javascript:;\" class='" + className +
                                              "' onclick='newsTypeTabs(\"" +
                                              DESEncrypt.Encrypt(news_type_list[i].News_type_id.ToString()) + "\",this)'>");
                                    this.hidNewsType.Value = DESEncrypt.Encrypt(news_type_list[i].News_type_id.ToString());
                                }
                                else
                                {
                                    sb.Append("<a href=\"javascript:;\" class='" + className1 +
                                              "' onclick='newsTypeTabs(\"" +
                                              DESEncrypt.Encrypt(news_type_list[i].News_type_id.ToString()) + "\",this)'>");
                                }
                                sb.Append(news_type_list[i].News_type_name + "</a>&nbsp;&nbsp;");
                            }
                        }
                        else
                        {
                            this.hidNewsType.Value = DESEncrypt.Encrypt("0");
                            sb.Append("<a href=\"javascript:;\" class='btn btn-success' onclick='newsTypeTabs(\"" + DESEncrypt.Encrypt("0") + "\",this)'>未分类</a>&nbsp;&nbsp;");
                            for (int i = 0; i < news_type_list.Count; i++)
                            {
                                sb.Append("<a href=\"javascript:;\" class='" + className1 +
                                          "' onclick='newsTypeTabs(\"" +
                                          DESEncrypt.Encrypt(news_type_list[i].News_type_id.ToString()) + "\",this)'>");
                                sb.Append(news_type_list[i].News_type_name + "</a>&nbsp;&nbsp;");
                            }
                        }
                    }
                }
                else//发布
                {
                    this.hidNewsType.Value = DESEncrypt.Encrypt("0");
                    sb.Append("<a href=\"javascript:;\" class='btn btn-success' onclick='newsTypeTabs(\"" + DESEncrypt.Encrypt("0") + "\",this)'>未分类</a>&nbsp;&nbsp;");
                    for (int i = 0; i < news_type_list.Count; i++)
                    {
                        sb.Append("<a href=\"javascript:;\" class='" + className1 +
                                  "' onclick='newsTypeTabs(\"" +
                                  DESEncrypt.Encrypt(news_type_list[i].News_type_id.ToString()) + "\",this)'>");
                        sb.Append(news_type_list[i].News_type_name + "</a>&nbsp;&nbsp;");
                    }
                }
            }
            else
            {
                sb.Append("<a href=\"javascript:;\" class='btn btn-success' onclick='newsTypeTabs(\"" + DESEncrypt.Encrypt("0") + "\",this)'>未分类</a>&nbsp;&nbsp;");
                this.hidNewsType.Value = DESEncrypt.Encrypt("0");
            }
            sb.Append("<a href=\"javascript:;\" class='btn' style='font-size: 18px;' onclick='addPushType()'><i class=\"icon-plus\"></i></a>");
            this.NewsTypeDiv.InnerHtml = sb.ToString();
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="_id">资讯ID</param>
        /// <returns></returns>
        private bool DoEdit(int _id)
        {
            #region =====================================附件
            string hidFileList = Request.Params["hidFileName"];
            string strWhere    = " News_id=" + _id;
            var    news_attach = new BLL.CCOM.News_attach().GetModelList(strWhere);
            if (!string.IsNullOrEmpty(hidFileList))
            {
                string[] fileListArr = hidFileList.Split(',');
                //附件发生变化,重新上传(从无到有,数目发生变化,内容发生变化)
                if (news_attach != null && news_attach.Count > 0 && news_attach.Count != fileListArr.Length || this.attachChange.Value == "1" || news_attach.Count == 0)
                {
                    var bll = new BLL.CCOM.News_attach();
                    for (int i = 0; i < news_attach.Count; i++)
                    {
                        string str = " News_attach_id=" + news_attach[i].News_attach_id;
                        bll.Delete(str);
                    }

                    for (int i = 0; i < fileListArr.Length; i++)
                    {
                        string[] fileArr = fileListArr[i].Split('|');
                        if (fileArr.Length == 3)
                        {
                            long   attach_id  = Int64.Parse(fileArr[0]);
                            String toFilePath = DataDic.News_Attach_Path + DateTime.Now.Ticks.ToString() + i.ToString() +
                                                FileOperate.GetPostfixStr(fileArr[2]);
                            //新增文件
                            if (attach_id == 0)
                            {
                                try
                                {
                                    FileOperate.FileMove(Server.MapPath(fileArr[2]),
                                                         Server.MapPath(toFilePath));
                                    //上传附件至文件服务器
                                    UI.UpLoad.UploadFileThread(toFilePath);
                                }
                                catch
                                {
                                    toFilePath = fileArr[2];
                                }
                            }
                            else
                            {
                                toFilePath = fileArr[2];    //原有附件地址不变
                            }

                            Model.CCOM.News_attach model_attach = new Model.CCOM.News_attach();
                            model_attach.News_id             = newsId;
                            model_attach.News_attach_name    = fileArr[1];
                            model_attach.News_attach_address = toFilePath;
                            new BLL.CCOM.News_attach().Add(model_attach);
                        }
                    }
                }
            }
            else
            {
                //从有到无,删除数据库数据
                if (news_attach != null && news_attach.Count > 0)
                {
                    var bll = new BLL.CCOM.News_attach();
                    for (int i = 0; i < news_attach.Count; i++)
                    {
                        string str = " News_attach_id=" + news_attach[i].News_attach_id;
                        bll.Delete(str);
                    }
                }
            }
            #endregion
            //var model = new Model.CCOM.News();
            var model = new BLL.CCOM.News().GetModel(_id);
            model.News_title = this.txtTitle.Text.Trim();
            if (this.txtReleaseTime.Text.Trim() != null && this.txtReleaseTime.Text.Trim().Length > 0)
            {
                model.News_date = Convert.ToDateTime(this.txtReleaseTime.Text.Trim());
            }
            model.News_last_editor = (int)GetAdminInfo_CCOM().User_id;
            model.News_type_id     = int.Parse(DESEncrypt.Decrypt(this.hidNewsType.Value));
            model.News_content     = this.hidEditorCnt.Value.Replace("'", "");
            model.News_top         = false;//默认不置顶
            if (this.optTop.Checked)
            {
                model.News_top = true;
                string time = this.txtTopTime.Text.Trim();
                if (time != null && time.Length > 0)
                {
                    int last_time = int.Parse(time);
                    model.News_top_time = last_time;
                }
                else
                {
                    model.News_top_time = 3;//默认置顶3天
                }
            }

            if (new BLL.CCOM.News().Update(model))
            {
                NewsHtml.CreateHtml(_id, false);
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            BLL.CCOM.News        bll  = new BLL.CCOM.News();
            BLL.CCOM.News_attach bll1 = new BLL.CCOM.News_attach();
            int  count  = 0;
            bool result = false;

            for (int i = 0; i < this.rptList.Items.Count; i++)
            {
                System.Web.UI.WebControls.CheckBox cb = (System.Web.UI.WebControls.CheckBox)rptList.Items[i].FindControl("chkId");
                if (!cb.Checked)
                {
                    continue;
                }
                else
                {
                    int newsId = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
                    if (newsId > 0)
                    {
                        Model.CCOM.News model = bll.GetModel(newsId);
                        if (model.News_creator_id == GetAdminInfo_CCOM().User_id)
                        {
                            //删除附件
                            var list = bll1.GetModelList(" News_id=" + newsId);
                            if (list != null && list.Count > 0)
                            {
                                for (int j = 0; j < list.Count; j++)
                                {
                                    string path = list[j].News_attach_address;
                                    if (File.Exists(Server.MapPath(path)))
                                    {
                                        FileInfo fi = new FileInfo(path);
                                        if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1)
                                        {
                                            fi.Attributes = FileAttributes.Normal;
                                        }
                                        File.Delete(Server.MapPath(path));
                                    }
                                    bll1.Delete(list[j].News_attach_id);
                                }
                            }

                            //删除静态页
                            String name = NewsHtml.GetWebNewsPath(newsId);
                            if (File.Exists(Server.MapPath(name)))
                            {
                                FileInfo fi = new FileInfo(name);
                                if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1)
                                {
                                    fi.Attributes = FileAttributes.Normal;
                                }
                                string path_name = Server.MapPath(name);
                                File.Delete(Server.MapPath(name));
                            }

                            //删除记录
                            result = bll.Delete(model.News_id);
                        }
                        if (result)
                        {
                            count++;
                        }
                    }
                }
            }
            if (count < 1)
            {
                JscriptMsg("请您选择需要删除的新闻!", "", "Error");
                return;
            }
            string keywords = MyRequest.GetQueryString("keywords");
            int    page     = MyRequest.GetQueryInt("page", 1);

            if (result == true)
            {
                JscriptMsg("批量删除成功!", Utils.CombUrlTxt("News_list_manager.aspx", "&keywords={0}&page={1}&fun_id={2}",
                                                       keywords, page.ToString(), DESEncrypt.Encrypt(this.fun_id)), "Success");
            }
            else
            {
                JscriptMsg("批量删除失败!", Utils.CombUrlTxt("News_list_manager.aspx", "keywords={0}&page={1}&fun_id={2}",
                                                       keywords, page.ToString(), DESEncrypt.Encrypt(this.fun_id)), "Error");
            }
        }
        /// <summary>
        /// 单个删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void lbtSingleDelete_Click(object sender, EventArgs e)
        {
            BLL.CCOM.News        bll  = new BLL.CCOM.News();
            BLL.CCOM.News_attach bll1 = new BLL.CCOM.News_attach();
            var lbtn = sender as LinkButton;

            if (lbtn != null)
            {
                int news_id = Int32.Parse(DESEncrypt.Decrypt(lbtn.ToolTip.ToString()));
                if (news_id > 0)
                {
                    Model.CCOM.News model  = bll.GetModel(news_id);
                    bool            result = false;
                    if (model != null)
                    {
                        if (model.News_creator_id == GetAdminInfo_CCOM().User_id)
                        {
                            //删除附件
                            var list = bll1.GetModelList(" News_id=" + news_id);
                            if (list != null && list.Count > 0)
                            {
                                for (int j = 0; j < list.Count; j++)
                                {
                                    string path = list[j].News_attach_address;
                                    if (File.Exists(Server.MapPath(path)))
                                    {
                                        FileInfo fi = new FileInfo(path);
                                        if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1)
                                        {
                                            fi.Attributes = FileAttributes.Normal;
                                        }
                                        File.Delete(Server.MapPath(path));
                                    }
                                    bll1.Delete(list[j].News_attach_id);
                                }
                            }

                            //删除静态页
                            String name = NewsHtml.GetWebNewsPath(news_id);
                            if (File.Exists(Server.MapPath(name)))
                            {
                                FileInfo fi = new FileInfo(name);
                                if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1)
                                {
                                    fi.Attributes = FileAttributes.Normal;
                                }
                                string path_name = Server.MapPath(name);
                                File.Delete(Server.MapPath(name));
                            }
                            result = bll.Delete(model.News_id);
                        }
                    }
                    string keywords = MyRequest.GetQueryString("keywords");
                    int    page     = MyRequest.GetQueryInt("page", 1);
                    if (result == true)
                    {
                        JscriptMsg("删除成功!", Utils.CombUrlTxt("News_list_manager.aspx", "&keywords={0}&page={1}&fun_id={2}",
                                                             keywords, page.ToString(), get_fun_id("CCOM/notification/News_list_manager.aspx")), "Success");
                    }
                    else
                    {
                        JscriptMsg("删除失败!", Utils.CombUrlTxt("News_list_manager.aspx", "keywords={0}&page={1}&fun_id={2}",
                                                             keywords, page.ToString(), get_fun_id("CCOM/notification/News_list_manager.aspx")), "Error");
                    }
                }
            }
        }
        /// <summary>
        /// 绑定资讯内容
        /// </summary>
        private void bindNewsData()
        {
            //更新置顶数据
            var bll  = new BLL.CCOM.News();
            var list = bll.GetModelList("News_top=1");

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].News_date != null)
                {
                    DateTime date = Convert.ToDateTime(list[i].News_date);
                    if (list[i].News_top_time != null)
                    {
                        if (date.AddDays((double)list[i].News_top_time) < DateTime.Now)
                        {
                            var model = bll.GetModel(list[i].News_id);
                            model.News_top      = false;
                            model.News_top_time = 0;
                            bll.Update(model);
                        }
                    }
                    else
                    {
                        //若为空,默认为3天
                        if (date.AddDays(3.0) < DateTime.Now)
                        {
                            var model = bll.GetModel(list[i].News_id);
                            model.News_top      = false;
                            model.News_top_time = 0;
                            bll.Update(model);
                        }
                    }
                }
            }


            string strWhere = string.Empty;
            int    pageSize = GetPageSize(15); //每页数量
            int    page     = MyRequest.GetQueryInt("page", 1);

            keywords = MyRequest.GetQueryString("keywords");
            string news_type_id = MyRequest.GetQueryString("news_type_id");

            if (news_type_id != null && news_type_id.Length > 0)
            {
                string news_type = DESEncrypt.Decrypt(news_type_id);
                if (news_type != "0")
                {
                    strWhere += " News_type_id=" + news_type;
                }
            }
            if (keywords != null && keywords.Length > 0)
            {
                if (strWhere != "")
                {
                    strWhere = strWhere + " and News_title like '%" + keywords + "%' ";
                }
                else
                {
                    strWhere = " News_title like '%" + keywords + "%' ";
                }
            }
            int start_index = pageSize * (page - 1) + 1;
            int end_index   = pageSize * page;


            //计算数量
            int totalCount = bll.GetRecordCount("");

            //绑定当页

            this.rptList.DataSource = bll.GetListByPage(strWhere, " News_date DESC ", start_index, end_index);
            this.rptList.DataBind();

            //for (int i = 0; i < rptList.Items.Count; i++)
            //{
            //    LinkButton lbt = (LinkButton)rptList.Items[i].FindControl("lbtDelete");
            //    HiddenField hide = (HiddenField)rptList.Items[i].FindControl("hideCreatorId");
            //    int CreatorId = int.Parse(hide.Value);
            //    if(CreatorId==GetAdminInfo_CCOM().User_id)
            //    {

            //    }
            //}
            //绑定页码
            this.txtPageNum.Text = pageSize.ToString();
            string pageUrl = Utils.CombUrlTxt("News_list_manager.aspx", "keywords={0}&page={1}&fun_id={2}", keywords, "__id__", DESEncrypt.Encrypt(this.fun_id));

            this.PageContent.InnerHtml = Utils.OutPageList(pageSize, page, totalCount, pageUrl, 8, true);
        }
        /// <summary>
        /// 初始化资讯
        /// </summary>
        /// <param name="typeId"></param>
        protected void InitialPage(int page)
        {
            //更新置顶数据
            var bll  = new BLL.CCOM.News();
            var list = bll.GetModelList("News_top=1");

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].News_date != null)
                {
                    DateTime date = Convert.ToDateTime(list[i].News_date);
                    if (list[i].News_top_time != null)
                    {
                        if (date.AddDays((double)list[i].News_top_time) < DateTime.Now)
                        {
                            var model = bll.GetModel(list[i].News_id);
                            model.News_top      = false;
                            model.News_top_time = 0;
                            bll.Update(model);
                        }
                    }
                    else
                    {
                        //若为空,默认为3天
                        if (date.AddDays(3.0) < DateTime.Now)
                        {
                            var model = bll.GetModel(list[i].News_id);
                            model.News_top      = false;
                            model.News_top_time = 0;
                            bll.Update(model);
                        }
                    }
                }
            }
            int start_index = 1;
            int end_index   = 10;

            DataTable dt = bll.GetListByPage("", "News_top DESC ,News_date DESC ", start_index, end_index).Tables[0];

            if (dt != null && dt.Rows.Count > 0)
            {
                string li = string.Empty;
                foreach (DataRow dr in dt.Rows)
                {
                    bool top = false;
                    try
                    {
                        top = Convert.ToBoolean(dr["News_top"]);
                    }
                    catch
                    {
                        top = false;
                    }
                    finally
                    {
                        DateTime date = Convert.ToDateTime(dr["News_date"]);
                        string   time = date.ToString("yyyy/MM/dd");
                        if (top)
                        {
                            li += "<li class=\"notice-li\">" + "<a href=\"" +
                                  dr["News_URL"] + "\"  target=\"_blank\">" + "<img src=\"/images/news/news_logo2.png\"  class=\"img_logo\"/>" + "<span style=\"color:red;\">[置顶] </span>" +
                                  dr["News_title"] + "</a>" + "<span class=\"date\">" +
                                  time + "</span>" + "</li>";
                        }
                        else
                        {
                            li += "<li class=\"notice-li\">" + "<a href=\"" +
                                  dr["News_URL"] + "\"  target=\"_blank\">" + "<img src=\"/images/news/news_logo2.png\" class=\"img_logo\"/>" +
                                  dr["News_title"] + "</a>" + "<span class=\"date\">" +
                                  time + "</span>" + "</li>";
                        }
                    }
                }
                this.news_list.InnerHtml = li;
            }
            int newsNum = bll.GetRecordCount("");
            int pageNum = 0;

            if (newsNum % 10 == 0)
            {
                pageNum = newsNum / 10;
            }
            else
            {
                pageNum = newsNum / 10 + 1;
            }
            this.page_num.Value = pageNum + "";
        }