Example #1
0
    protected void lvProductImageList_ItemDeleting(object sender, ListViewDeleteEventArgs e)
    {
        DBLL.clsProductImage ProductImage = new DBLL.clsProductImage();
        Label lblnID = (Label)lvProductImageList.Items[e.ItemIndex].FindControl("lblnPImageID");
        int _nID = 0;
        if (int.TryParse(lblnID.Text.Trim(), out _nID) && _nID > 0)
        {
            bool Result = ProductImage.sp_DeleteNormalTableByIDProductImage(int.Parse(_nID.ToString()), "tb_ProductImage");
            if (Result)
            {
                //判断文件是不是存在
                Image ImsPImagePath = (Image)lvProductImageList.Items[e.ItemIndex].FindControl("ImsPImagePath");
                string sSaveFolderFullPath = Server.MapPath(ImsPImagePath.ImageUrl);
                if (File.Exists(sSaveFolderFullPath))
                {
                    //如果存在则删除
                    File.Delete(sSaveFolderFullPath);

                    System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(sSaveFolderFullPath.Substring(0, sSaveFolderFullPath.LastIndexOf("\\")).ToString());
                    System.IO.FileInfo[] dirs = dir.GetFiles();
                    if (dirs.Length > 0)
                    {
                        //有子文件夹
                    }
                    else
                    {
                        Directory.Delete(sSaveFolderFullPath.Substring(0, sSaveFolderFullPath.LastIndexOf("\\")).ToString());
                    }

                    DataTable Imagedt = new DataTable();
                    Imagedt = ProductImage.Select_tb_ProductImageBynProductID(int.Parse(hfProductUpdateID.Value));
                    if (Imagedt != null)
                    {
                        ProductImageList.Clear();
                        ProductImageList.Merge(Imagedt);
                        lvProductImageList.DataSource = ProductImageList;
                        lvProductImageList.DataBind();
                    }
                    else
                    {
                        ProductImageList.Clear();
                        lvProductImageList.DataSource = ProductImageList;
                        lvProductImageList.DataBind();
                    }
                }
            }
        }
    }
Example #2
0
    protected void lvProductList_SelectedIndexChanging(object sender, ListViewSelectEventArgs e)
    {
        Label lblnID = (Label)lvProductList.Items[e.NewSelectedIndex].FindControl("lblnProductID");
        int _nID = 0;
        DBLL.clsProduct Product = new DBLL.clsProduct();
        if (int.TryParse(lblnID.Text.Trim(), out _nID) && _nID > 0)
        {
            DBLL.DBcommon dbcom = new DBLL.DBcommon();
            Model.dsProduct.tb_ProductCategoryDataTable ProductList = new Model.dsProduct.tb_ProductCategoryDataTable();
            ProductList.Merge(dbcom.selectNormalTableofAll(false, "tb_ProductCategory"));
            ddlProductCateTreelist2.ProductList = ProductList;
            ddlProductCateTreelist2.Fresh();

            MultiView1.ActiveViewIndex = 1;
            DataTable dt = Product.Select_tb_ProductBynProductID(_nID);
            cbbHot.Checked = bool.Parse(dt.Rows[0]["bHot"].ToString());
            txtsProductNameCN.Text = dt.Rows[0]["sProductNameCN"].ToString();
            txtsProductNameEN.Text = dt.Rows[0]["sProductNameEN"].ToString();
            txtsSummaryCN.Text = dt.Rows[0]["sSummaryCN"].ToString();
            txtsSummaryEN.Text = dt.Rows[0]["sSummaryEN"].ToString();
            txtsPlaceoforiginCN.Text = dt.Rows[0]["sPlaceoforiginCN"].ToString();
            txtsPlaceoforiginEN.Text = dt.Rows[0]["sPlaceoforiginEN"].ToString();
            txtsModelNoCN.Text = dt.Rows[0]["sModelNoCN"].ToString();
            txtsModelNoEN.Text = dt.Rows[0]["sModelNoEN"].ToString();
            txtsPriceTermsCN.Text = dt.Rows[0]["sPriceTermsCN"].ToString();
            txtsPriceTermsEN.Text = dt.Rows[0]["sPriceTermsEN"].ToString();
            txtsPaymentTermsCN.Text = dt.Rows[0]["sPaymentTermsCN"].ToString();
            txtsPaymentTermsEN.Text = dt.Rows[0]["sPaymentTermsEN"].ToString();
            txtsPackageCN.Text = dt.Rows[0]["sPackageCN"].ToString();
            txtsPackageEN.Text = dt.Rows[0]["sPackageEN"].ToString();
            txtsMinimumOrderCN.Text = dt.Rows[0]["sMinimumOrderCN"].ToString();
            txtsMinimumOrderEN.Text = dt.Rows[0]["sMinimumOrderEN"].ToString();
            txtsDeliveryTimeCN.Text = dt.Rows[0]["sDeliveryTimeCN"].ToString();
            txtsDeliveryTimeEN.Text = dt.Rows[0]["sDeliveryTimeEN"].ToString();
            txtsBrandNameCN.Text = dt.Rows[0]["sBrandNameCN"].ToString();
            txtsBrandNameEN.Text = dt.Rows[0]["sBrandNameEN"].ToString();
            CKEditorControl1.Text = dt.Rows[0]["sIntroCN"].ToString();
            CKEditorControl2.Text = dt.Rows[0]["sIntroEN"].ToString();
            ddlnSorting.SelectedValue = dt.Rows[0]["nSorting"].ToString();
            //ddlProductCateTreelist2.nSelectProductCategoryID = int.Parse(dt.Rows[0]["nProductCategoryID"].ToString());
            ddlProductCateTreelist2.setnSelectID(int.Parse(dt.Rows[0]["nProductCategoryID"].ToString()));
            MutileUploaderUserControl1.Refresh();
            DBLL.clsProductImage ProductImage = new DBLL.clsProductImage();
            DataTable Imagedt = new DataTable();
            Imagedt = ProductImage.Select_tb_ProductImageBynProductID(_nID);
            if (Imagedt != null)
            {
                ProductImageList.Clear();
                ProductImageList.Merge(Imagedt);
                lvProductImageList.DataSource = ProductImageList;
                lvProductImageList.DataBind();
            }
            else
            {
                ProductImageList.Clear();
                lvProductImageList.DataSource = ProductImageList;
                lvProductImageList.DataBind();
            }
            Button1.Text = "显示图片";
            lvProductImageList.Visible = false;
            hfProductUpdateID.Value = _nID.ToString();
        }
    }