Exemple #1
0
    protected void lnkDelMultiMessage_Click(object sender, EventArgs e)
    {
        string[] mid          = hidId.Value.Trim().TrimEnd(',').Split(',');
        string   physicalpath = string.Empty;
        string   thumpath     = string.Empty;
        string   filename     = string.Empty;

        if (mid.Length > 0)
        {
            for (int i = 0; i < mid.Length; i++)
            {
                int id = CommonMethod.ConvertToInt(mid[i], 0);
                if (id > 0)
                {
                    XiHuan_GoodsImageEntity note = new XiHuan_GoodsImageEntity();
                    note.Id = id;
                    note.Retrieve();
                    if (note.IsPersistent)
                    {
                        physicalpath = Server.MapPath(note.ImgSrc);
                        filename     = Path.GetFileNameWithoutExtension(physicalpath);
                        if (File.Exists(physicalpath))
                        {
                            File.Delete(physicalpath);
                        }
                        thumpath = physicalpath.Replace(filename, GlobalVar.DefaultPhotoSize);
                        if (File.Exists(thumpath))
                        {
                            File.Delete(thumpath);
                        }
                        thumpath = physicalpath.Replace(filename, GlobalVar.BigPhotoSize);
                        if (File.Exists(thumpath))
                        {
                            File.Delete(thumpath);
                        }
                        note.Delete();
                    }
                }
            }

            BindReceive();
            if (rptGoodsList.Items.Count == 0)
            {
                Query.ProcessSqlNonQuery("update XiHuan_UserGoods set IsHavePhoto=0 ,DefaultPhoto='images/none.jpg' where Id=" + Request["id"], GlobalVar.DataBase_Name);
            }
            Alert("恭喜:选中的图片已成功删除!");
        }
    }
Exemple #2
0
    protected void lnkDelMessage_Click(object sender, EventArgs e)
    {
        int id = CommonMethod.ConvertToInt(hidId.Value, 0);

        if (id > 0)
        {
            XiHuan_GoodsImageEntity note = new XiHuan_GoodsImageEntity();
            note.Id = id;
            note.Retrieve();
            if (note.IsPersistent)
            {
                string phypath  = Server.MapPath(note.ImgSrc);
                string filename = Path.GetFileNameWithoutExtension(phypath);
                string thumpath = phypath.Replace(filename, filename + GlobalVar.DefaultPhotoSize);
                if (File.Exists(phypath))
                {
                    File.Delete(phypath);
                }
                if (File.Exists(thumpath))
                {
                    File.Delete(thumpath);
                }
                thumpath = phypath.Replace(filename, filename + GlobalVar.BigPhotoSize);
                if (File.Exists(thumpath))
                {
                    File.Delete(thumpath);
                }
                note.Delete();
                BindReceive();
                if (rptGoodsList.Items.Count == 0)
                {
                    Query.ProcessSqlNonQuery("update XiHuan_UserGoods set IsHavePhoto=0 ,DefaultPhoto='images/none.jpg' where Id=" + Request["id"], GlobalVar.DataBase_Name);
                }
                Alert("恭喜:图片已成功删除!");
            }
        }
    }