Exemplo n.º 1
0
        /// <summary>
        /// 编辑广告
        /// 创建人:wsy
        /// 时间2015-07-23
        /// </summary>
        /// <param name="context"></param>
        public void EditAdv(HttpContext context)
        {
            string pic = UploadPic(context);//上传图片

            if (pic == "-1")
            {
                //格式不正确
                context.Response.Write(pic);
                return;
            }
            else if (pic == "-2")
            {
                //文件大小>5M
                context.Response.Write(pic);
                return;
            }
            else
            {
                string id         = context.Request["advid"]; //广告ID
                string url        = context.Request["url"];   //图片跳转链接
                string altname    = context.Request["altname"];
                string isnofollow = context.Request["isnofollow"];

                string       oldpic = "";
                Psys_Adv_BLL bll    = new Psys_Adv_BLL();
                Psys_Adv     adv    = bll.SelectEntity(id);//根据ID查询广告
                if (adv != null)
                {
                    adv.PicUrl         = url;
                    adv.LastEditUserID = new Guid(RequestSession.GetSessionUser().UserId);
                    adv.LastEditDate   = DateTime.Now;
                    oldpic             = adv.PicPath;
                    adv.IsNofollow     = Convert.ToInt32(isnofollow);
                    adv.AltName        = altname;
                    if (!string.IsNullOrEmpty(pic) && pic != "-3")
                    {
                        adv.PicPath = "/Upload/AdvPic/" + pic;
                    }
                    string result = bll.Update(adv).ToString();
                    if (result == "1" && !string.IsNullOrEmpty(pic) && pic != "-3")
                    {
                        //删除原来的图片
                        if (!string.IsNullOrEmpty(oldpic))
                        {
                            string pa = System.Web.HttpContext.Current.Server.MapPath(oldpic);
                            if (File.Exists(pa))
                            {
                                File.Delete(pa);
                            }
                        }
                    }
                    context.Response.Write(result);
                    LogHelper.InserLog((int)EnumClass.OperateType.编辑操作, PageBase.CurrentOperatName, "编辑了名称为" + adv.Name + "的广告");
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 删除广告
        /// 创建人:wsy
        /// 时间2015-07-23
        /// </summary>
        /// <param name="context"></param>
        public void DeletePic(HttpContext context)
        {
            string       id  = context.Request["id"];
            Psys_Adv_BLL bll = new Psys_Adv_BLL();
            Psys_Adv     adv = bll.SelectEntity(id);//根据ID查询广告

            adv.Status = 1;
            context.Response.Write(bll.Update(adv));//将广告状态改为已删除
            LogHelper.InserLog((int)EnumClass.OperateType.除操作, PageBase.CurrentOperatName, "删除了名称为" + adv.Name + "的广告");
        }