Exemplo n.º 1
0
    //删除图片
    protected void btndelinfo_Click(object sender, EventArgs e)
    {
        string ls_filepath1 = "", ls_filepath2 = "";
        TPortalClass.HyFileatt HyFileatt = new TPortalClass.HyFileatt();
        DataTable dt = HyFileatt.Getdocbyid(this.txtuids.Value);
        if (dt.Rows.Count > 0)
        {
            if (dt.Rows[0]["hy_fm"].ToString() == "1")
            {
                Response.Write("<script>alert('封面图片不能删除');window.location.href=window.location.href;</script>");
                return;
            }
            //删除文件夹里的图片
            ls_filepath1 = Server.MapPath("~/") + dt.Rows[0]["hy_filepath"].ToString();
            ls_filepath2 = Server.MapPath("~/") + dt.Rows[0]["hy_filepath"].ToString().Replace("thumbnail", "original");
            if (System.IO.File.Exists(ls_filepath1))
            {
                System.IO.File.Delete(ls_filepath1);
            }
            if (System.IO.File.Exists(ls_filepath2))
            {
                System.IO.File.Delete(ls_filepath2);
            }
        }

        //删除数据库记录
        HyFileatt.Delete(this.txtuids.Value);
        //操作日志
        TPortalClass.JpCommon HyCommon = new TPortalClass.JpCommon();
        //  HyCommon.WriteLog("删除图片", "删除图片ID:" + this.txtuids.Value, this.Session["hy_id"].ToString(), this.Session["hy_name"].ToString());
        // LoadingPictures();
        Response.Write("<script>location.replace(location);</script>");
    }
Exemplo n.º 2
0
 protected void btnDel_Click(object sender, EventArgs e)
 {
     HyFileatt hyFileatt = new HyFileatt();
     DataTable dt = hyFileatt.Getdocbyid(this.delId.Value);
     //删除文件夹里的图片
     if (dt.Rows.Count > 0)
     {
         string ls_filepath1 = Server.MapPath("~/") + dt.Rows[0]["hy_filepath"].ToString();
         string ls_filepath2 = Server.MapPath("~/") + dt.Rows[0]["hy_filepath"].ToString().Replace("thumbnail", "original");
         if (System.IO.File.Exists(ls_filepath1))
         {
             System.IO.File.Delete(ls_filepath1);
         }
         if (System.IO.File.Exists(ls_filepath2))
         {
             System.IO.File.Delete(ls_filepath2);
         }
     }
     hyFileatt.DeleteImg(this.delId.Value);
     ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>hymainajax_img('" + this.txtDocid.Value + "');</script>");
 }