Ejemplo n.º 1
0
        protected void DeleteImage(int imageID)
        {
            Images img = ImagesView.GetModelByID(imageID.ToS());

            Voodoo.IO.File.Delete(Server.MapPath(img.FilePath));
            Voodoo.IO.File.Delete(Server.MapPath(img.SmallPath));

            ImagesView.DelByID(imageID);

            rp_list.DataSource = ImagesView.GetModelList(string.Format("AlbumID={0} order by id", WS.RequestString("id")));
            rp_list.DataBind();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 加载信息
        /// </summary>
        protected void LoadInfo()
        {
            ddl_Class.DataSource     = NewsAction.NewsClass.Where(p => p.IsLeafClass && p.ModelID == 2);
            ddl_Class.DataTextField  = "ClassName";
            ddl_Class.DataValueField = "ID";
            ddl_Class.DataBind();

            ddl_Class.SelectedValue = cls.ToS();

            ddl_Author.DataSource     = SysUserView.GetModelList();
            ddl_Author.DataTextField  = "UserName";
            ddl_Author.DataValueField = "ID";
            ddl_Author.DataBind();

            ImageAlbum imga = ImageAlbumView.GetModelByID(id.ToS());

            //txt_Title.Text = imga.Title;
            //ddl_Author.SelectedValue = imga.AuthorID.ToS();
            //txt_Folder.Text = imga.Folder;
            //txt_Keyword.Text=imga.

            if (id > 0)
            {
                ddl_Class.SelectedValue = imga.ClassID.ToS();
                txt_Title.Text          = imga.Title;
                ddl_Author.Text         = imga.AuthorID.ToS();
                //txt_Folder.Text = imga.Folder;
                txt_Keyword.Text    = imga.KeyWords;
                txt_ClickCount.Text = imga.ClickCount.ToS();
                txt_ReplyCount.Text = imga.ClickCount.ToS();
                txt_Intro.Text      = imga.Intro;

                rp_list.DataSource = ImagesView.GetModelList(string.Format("AlbumID={0} order by id", imga.ID));
                rp_list.DataBind();
            }
            else
            {
                ImageAlbumView.Del("AuthorID=0 and CreateTime<'" + DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + "'");
                imga = new ImageAlbum()
                {
                    ClassID = cls, ClickCount = 0, ReplyCount = 0, ZtID = 0, CreateTime = DateTime.Now, AuthorID = 0, UpdateTime = DateTime.Now
                };
                ImageAlbumView.Insert(imga);
                Response.Redirect(string.Format("ImageEdit.aspx?class={0}&id={1}", cls, imga.ID));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 删除图片
        /// </summary>
        /// <param name="m_where"></param>
        /// <returns></returns>
        public static Result DeleteImage(string m_where)
        {
            Result r = new Result();

            try
            {
                var imgs = ImagesView.GetModelList(m_where);
                foreach (var img in imgs)
                {
                    Voodoo.IO.File.Delete(HttpContext.Current.Server.MapPath(img.SmallPath));
                    Voodoo.IO.File.Delete(HttpContext.Current.Server.MapPath(img.FilePath));
                }
                ImagesView.Del(m_where);
                r.Success = false;
                r.Text    = string.Format("删除{0}张图片成功!", imgs.Count);
            }
            catch (Exception ex)
            {
                r.Success = false;
                r.Text    = ex.Message;
            }
            return(r);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 刷新页面
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btn_Refresh_Click(object sender, EventArgs e)
 {
     rp_list.DataSource = ImagesView.GetModelList(string.Format("AlbumID={0} order by id", WS.RequestString("id")));
     rp_list.DataBind();
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btn_Save_Click(object sender, EventArgs e)
        {
            Class cls = ClassView.GetModelByID(ddl_Class.SelectedValue);

            ImageAlbum imga = ImageAlbumView.GetModelByID(WS.RequestString("id"));

            imga.ClassID    = ddl_Class.SelectedValue.ToInt32();
            imga.Title      = txt_Title.Text.TrimDbDangerousChar();
            imga.AuthorID   = ddl_Author.SelectedValue.ToInt32();
            imga.Author     = ddl_Author.SelectedItem.Text;
            imga.ClickCount = txt_ClickCount.Text.ToInt32(0);
            if (imga.ID <= 0)
            {
                imga.CreateTime = DateTime.Now;
                imga.Folder     = DateTime.Now.ToString("yyyy-MM-dd");
            }
            imga.Intro      = txt_Intro.Text.TrimDbDangerousChar();
            imga.KeyWords   = txt_Keyword.Text.TrimDbDangerousChar();
            imga.ReplyCount = txt_ReplyCount.Text.ToInt32(0);
            imga.SetTop     = false;
            //imga.ShotCut = "";
            //imga.Size = 0;
            imga.Title      = txt_Title.Text;
            imga.UpdateTime = DateTime.Now;
            imga.ZtID       = 0;

            if (imga.ID > 0)
            {
                ImageAlbumView.Update(imga);
            }
            else
            {
                ImageAlbumView.Insert(imga);
            }

            //保存单个图片设置
            string[] t**s  = WS.RequestString("tit[]").Split(',');
            string[] intrs = WS.RequestString("intro[]").Split(',');

            var imgs = ImagesView.GetModelList(string.Format("AlbumID={0} order by id", imga.ID));

            for (int i = 0; i < imgs.Count; i++)
            {
                try
                {
                    imgs[i].Title = t**s[i].ToS();
                    imgs[i].Intro = intrs[i].ToS();
                    ImagesView.Update(imgs[i]);
                }
                catch { }
            }

            //生成页面

            CreatePage.CreateContentPage(imga, cls);

            ImageAlbum pre = GetPreImage(imga, cls);

            if (pre != null)
            {
                CreatePage.CreateContentPage(pre, cls);
            }
            CreatePage.CreateListPage(cls, 1);


            Js.AlertAndChangUrl("保存成功!", url);
        }