Пример #1
0
        public void Delete(int p_id)
        {
            //由此開始刪除圖片
            List <ProductImageInfo> ImgInfos = pdImgBLL.GetallImgWithProduct(p_id);

            foreach (ProductImageInfo infoimg in ImgInfos)
            {
                if (System.IO.File.Exists(HttpContext.Current.Server.MapPath(Tools.GetAppSettings("ProductImageTruePath") + infoimg.pi_imageName)))
                {
                    System.IO.File.Delete(HttpContext.Current.Server.MapPath(Tools.GetAppSettings("ProductImageTruePath") + infoimg.pi_imageName));
                }
                if (System.IO.File.Exists(HttpContext.Current.Server.MapPath(Tools.GetAppSettings("ProductImageTruePath") + infoimg.pi_thumb)))
                {
                    System.IO.File.Delete(HttpContext.Current.Server.MapPath(Tools.GetAppSettings("ProductImageTruePath") + infoimg.pi_thumb));
                }
                pdImgBLL.Delete(infoimg.pi_id);
            }
            //由此開始刪除檔案
            List <ProductDownloadInfo> FileInfos = pddBLL.GetallFilesWithProduct(p_id);

            foreach (ProductDownloadInfo infoFile in FileInfos)
            {
                if (System.IO.File.Exists(HttpContext.Current.Server.MapPath(Tools.GetAppSettings("ProductDLTruePath") + infoFile.pd_name)))
                {
                    System.IO.File.Delete(HttpContext.Current.Server.MapPath(Tools.GetAppSettings("ProductDLTruePath") + infoFile.pd_name));
                }
                pddBLL.Delete(infoFile.pd_id);
            }
            //由此開始刪除格式
            List <ProductSubFormatInfo> SubInfos = pdsFMBLL.GetFormatWithProduct(p_id);

            foreach (ProductSubFormatInfo infoFormat in SubInfos)
            {
                pdsFMBLL.Delete(infoFormat.psf_id);
            }
            //由此開始刪除排序
            ProductInfo        info         = GetProductForEdit(p_id);
            List <ProductInfo> SortingInfos = GetProductSortingWithDelete(info.pc_id, info.p_sorting);

            foreach (ProductInfo pdinfo in SortingInfos)
            {
                db.Update(pdinfo.pc_id, pdinfo.pcs_id, pdinfo.p_name, pdinfo.p_serial, pdinfo.p_status, pdinfo.p_show, pdinfo.p_show_hot, pdinfo.p_detail, pdinfo.p_stock, pdinfo.p_stock_unit, pdinfo.p_price1, pdinfo.p_price2, pdinfo.p_price3, pdinfo.p_price4, pdinfo.p_price5, pdinfo.p_createDate, pdinfo.p_editDate, pdinfo.p_hits, pdinfo.p_sorting - 1, pdinfo.p_img, pdinfo.p_files, pdinfo.l_id, pdinfo.p_id);
            }
            db.Delete(p_id);
        }
Пример #2
0
 public void Delete(int productid)
 {
     _product.Delete(productid);
 }