Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string id   = Context.Request["id"] ?? "";
                string flag = Context.Request["flag"] ?? "";
                if (string.IsNullOrEmpty(id))
                {
                    return;
                }

                newid.Value = id;//add by wsy
                if (flag == "1")
                {
                    //预览
                    newid.Value       = id;
                    hid_preview.Value = "1";
                }
                Cmt_VW_NewPicInfo_BLL    bll  = new Cmt_VW_NewPicInfo_BLL();
                List <Cmt_VW_NewPicInfo> news = bll.GetList(id, false);

                if (news.Count > 0)
                {
                    title.InnerHtml    = news[0].Title;
                    content.InnerHtml  = news[0].N_Content;
                    subtitle.InnerHtml = news[0].SubTitle;
                    StringBuilder sb  = new StringBuilder();
                    StringBuilder sb1 = new StringBuilder();
                    sb1.Append("<ul class='filmstrip'>");
                    for (int i = 0; i < news.Count; i++)
                    {
                        if (news[i].PicPath != "" && news[i].PicPath != null)
                        {
                            sb.Append("<div class='panel' style='margin:0 auto;'>");
                            sb.Append("<img src=../" + news[i].PicPath + " style='width:600px;height:300px;'></img>");
                            sb.Append("</div>");
                            sb1.Append("<li>");

                            sb1.Append("<img src=../" + news[i].PicPath + " style='width:80px;height:80px;'></img>");
                            sb1.Append("</li>");
                        }
                    }
                    sb1.Append("</ul>");
                    if (sb.ToString().Contains("img"))
                    {
                        img.Value = sb.ToString() + sb1.ToString();
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// 删除新闻
        /// 创建人:lwj
        /// 时间:2015-6-16
        /// </summary>
        /// <param name="context"></param>
        private void DeleteNews(HttpContext context)
        {
            string deleteids = context.Request["id"] ?? "";

            //记录要删除的新闻以及图片
            List <Cmt_VW_NewPicInfo> DeletNews = new List <Cmt_VW_NewPicInfo>();

            if (!string.IsNullOrEmpty(deleteids))
            {
                DeletNews = new Cmt_VW_NewPicInfo_BLL().GetListInfos(deleteids.Remove(deleteids.Length - 1));
            }

            string result = new Site_News_BLL().DeleteNews(deleteids);//删除后的返回值

            if (result == "1")
            {
                foreach (var item in DeletNews)
                {
                    #region 剔除文件夹中新闻内容里的图片
                    string          regex = "<img.*?/>";
                    MatchCollection notu  = StringHelper.GetValue(regex, item.N_Content);

                    if (notu.Count > 0)
                    {
                        for (int j = 0; j < notu.Count; j++)
                        {
                            int    place = notu[j].Value.IndexOf("src=") + 5;
                            string hou   = notu[j].Value.Substring(place);
                            int    yin   = hou.IndexOf("\"");
                            string src   = hou.Substring(0, yin);//图片路径
                            if (!string.IsNullOrEmpty(src))
                            {
                                try
                                {
                                    string pa = System.Web.HttpContext.Current.Server.MapPath("~/" + src);
                                    if (File.Exists(pa))
                                    {
                                        File.Delete(pa);
                                    }
                                }
                                catch
                                {
                                    continue;
                                }
                            }
                        }
                    }
                    #endregion
                    #region  除文件夹中的轮播图片
                    try
                    {
                        string pa = System.Web.HttpContext.Current.Server.MapPath("~/" + item.PicPath);
                        if (File.Exists(pa))
                        {
                            File.Delete(pa);
                        }
                    }
                    catch
                    {
                        continue;
                    }
                    #endregion
                    #region    除文件夹中的头条图片
                    if (item.isTop == 1)
                    {
                        try
                        {
                            string path = System.Web.HttpContext.Current.Server.MapPath("~/" + item.BannerPic);
                            if (File.Exists(path))
                            {
                                File.Delete(path);
                            }
                        }
                        catch
                        {
                            continue;
                        }
                    }
                    #endregion
                    //添加日志
                    LogHelper.InserLog((int)EnumClass.OperateType.除操作, PageBase.CurrentOperatName, "删除了标题为" + item.Title + "的新闻");
                }
            }
            context.Response.Write(result);
        }
Beispiel #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string id     = Context.Request["id"] ?? "";
                string flag   = Context.Request["flag"] ?? "";
                string action = Request.QueryString["action"];
                if (!string.IsNullOrEmpty(action) && action == "edit")
                {
                    //编辑
                    Newid.Value = id;
                    Cmt_VW_NewPicInfo_BLL    bll  = new Cmt_VW_NewPicInfo_BLL();
                    List <Cmt_VW_NewPicInfo> news = bll.GetList(id);

                    StringBuilder sb = new StringBuilder();
                    if (news.Count > 0)
                    {
                        title.Value    = news[0].Title;
                        subtitle.Value = news[0].SubTitle;
                        content1.Value = news[0].N_Content;
                        source.Value   = news[0].N_Source;//新闻来源
                        for (int i = 0; i < news.Count; i++)
                        {
                            //图片个数
                            if (!string.IsNullOrEmpty(news[i].PicPath) && news[i].PicPath != null)
                            {
                                string path = Server.MapPath("~/" + news[i].PicPath);

                                if (!string.IsNullOrEmpty(path))
                                {
                                    string str = "<div class='cp_img' id='" + i + "' name='" + news[i].picid + "' style='position:relative;width:121px;height:81px;margin-bottom:10px;'><img style='width:121px;height:81px;' src='../" + news[i].PicPath + "'></img><div class='cp_img_jian' style='display:none; width:121px;height:81px;'></div><div class='int_1' id='div_nameWU_FILE_" + i + "' style='left:0px;width:100%;height:20px;text-align:center;bottom:0px;color:rgb(255,255,255);line-height:20px;display:none;position:absolute;'>" + news[i].PicPath.Substring(news[i].PicPath.LastIndexOf("/") + 1) + "</div><div class='iht' id='div_WU_FILE_" + i + "' style='right:5px;bottom:5px;display:none;position:absolute;width:121px;height:81px;'></div></div>";
                                    sb.Append(str);
                                }
                            }
                        }
                        if (sb.ToString().Contains("img"))
                        {
                            fileList.InnerHtml = sb.ToString();
                            count.Value        = news.Count.ToString();
                            countmore.Value    = news.Count.ToString();
                        }
                        else
                        {
                            count.Value     = "0";
                            countmore.Value = "0";
                        }
                    }
                    if (flag != "1")
                    {
                        back.InnerHtml       = "返回";
                        htmltitile.InnerHtml = "编辑新闻";
                    }
                    else
                    {
                        back.InnerHtml       = "重置";
                        htmltitile.InnerHtml = "添加新闻";
                        previewflag.Value    = "1";
                    }
                }
                else
                {
                    //添加
                    back.InnerHtml       = "重置";
                    htmltitile.InnerHtml = "添加新闻";
                }
            }
        }