コード例 #1
0
ファイル: Add.aspx.cs プロジェクト: nieo7/chienyehtsai
 protected void btImage_Click(object sender, EventArgs e)
 {
     if (fuImage.HasFile)
     {
         string imgFileName = WebUtility.ChangeFileNameAsRandom(fuImage.FileName);
         if (WebUtility.CheckImageExt(System.IO.Path.GetExtension(imgFileName)))
         {
             //從Web.Config取得路徑
             string serverFileName = WebUtility.MergePathAndFileName(imgFileName, Tools.GetAppSettings("ProductImageTempPath"));
             fuImage.SaveAs(serverFileName);
             if (Session["bpImginfo"] == null)
             {
                 bpImgInfos = new List <BannerImgInfo>();
             }
             else
             {
                 bpImgInfos = (List <BannerImgInfo>)Session["bpImginfo"];
             }
             BannerImgInfo info = new BannerImgInfo();
             info.bp_image     = imgFileName;
             info.bp_imagename = imgFileName;
             bpImgInfos.Add(info);
             tfBLL.InsertTempFiles("Banner", Tools.GetAppSettings("NewsImageTempPath") + imgFileName);
             Session["bpImginfo"] = bpImgInfos;
             rpImage.DataSource   = bpImgInfos;
             rpImage.DataBind();
         }
         else
         {
             this.Page.Controls.Add(Tools.Tomsg("副檔名格式錯誤"));
         }
     }
 }
コード例 #2
0
        public void Delete(int bp_id)
        {
            BannerImgInfo info = GetImgByKey(bp_id);

            if (File.Exists(HttpContext.Current.Server.MapPath(Tools.GetAppSettings("BannerImageTruePath") + info.bp_imagename)))
            {
                File.Delete(HttpContext.Current.Server.MapPath(Tools.GetAppSettings("BannerImageTruePath") + info.bp_imagename));
            }
            db.Delete(bp_id);
        }
コード例 #3
0
        public List <BannerImgInfo> GetDataByBid(int b_id)
        {
            List <BannerImgInfo> infos  = new List <Model.BannerImgInfo>();
            IDataReader          reader = db.GetDataByBid(b_id).CreateDataReader();

            while (reader.Read())
            {
                infos.Add(BannerImgInfo.Populate(reader));
            }
            return(infos);
        }
コード例 #4
0
        public BannerImgInfo GetImgByKey(int bp_id)
        {
            BannerImgInfo info   = new Model.BannerImgInfo();
            IDataReader   reader = db.GetDataImgByKey(bp_id).CreateDataReader();

            if (reader.Read())
            {
                info = BannerImgInfo.Populate(reader);
            }
            return(info);
        }
コード例 #5
0
ファイル: Edit.aspx.cs プロジェクト: nieo7/chienyehtsai
 protected void rpImage_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName == "Delete")
     {
         bpBLL.Delete(int.Parse(e.CommandArgument.ToString()));
     }
     if (e.CommandName == "Update")
     {
         BannerImgInfo info = bpBLL.GetImgByKey(int.Parse(e.CommandArgument.ToString()));
         hfImageIndex.Value = info.bp_imagename;
     }
     rpImage.DataSource = bpBLL.GetAllImgWithFriendLink(Tools.GetInt32SafeFromQueryString(this.Page, "id", 0));
     rpImage.DataBind();
 }
コード例 #6
0
ファイル: Add.aspx.cs プロジェクト: nieo7/chienyehtsai
    private void InsertBannerImage(int BannerID)
    {
        BannerImgInfo bpinfo = new BannerImgInfo();

        for (int i = 0; i < rpImage.Items.Count; i++)
        {
            Image lbtxtFormatName = (Image)rpImage.Items[i].FindControl("Image1");
            if (lbtxtFormatName != null)
            {
                if (System.IO.File.Exists(Server.MapPath(Tools.GetAppSettings("ProductImageTempPath") + lbtxtFormatName.AlternateText)))
                {
                    System.IO.FileInfo file = new System.IO.FileInfo(Server.MapPath(Tools.GetAppSettings("ProductImageTempPath") + lbtxtFormatName.AlternateText));
                    file.CopyTo(Server.MapPath(Tools.GetAppSettings("BannerImageTruePath") + lbtxtFormatName.AlternateText));
                }
                bpinfo.b_id         = BannerID;
                bpinfo.bp_image     = lbtxtFormatName.AlternateText;
                bpinfo.bp_imagename = lbtxtFormatName.AlternateText;
            }
            bpBLL.Insert(bpinfo);
        }
    }
コード例 #7
0
ファイル: Edit.aspx.cs プロジェクト: nieo7/chienyehtsai
 protected void btImage_Click(object sender, EventArgs e)
 {
     if (fuImage.HasFile)
     {
         string imgFilename = WebUtility.ChangeFileNameAsRandom(fuImage.FileName);
         if (WebUtility.CheckImageExt(System.IO.Path.GetExtension(imgFilename)))
         {
             string serverFileName = WebUtility.MergePathAndFileName(imgFilename, Tools.GetAppSettings("BannerImageTruePath"));
             fuImage.SaveAs(serverFileName);
             BannerImgInfo info = new BannerImgInfo();
             info.bp_id        = Tools.GetInt32SafeFromQueryString(this.Page, "id", 0);
             info.bp_image     = imgFilename;
             info.bp_imagename = imgFilename;
             bpBLL.Insert(info);
             rpImage.DataSource = bpBLL.GetAllImgWithFriendLink(Tools.GetInt32SafeFromQueryString(this.Page, "id", 0));
             rpImage.DataBind();
         }
     }
     else
     {
         this.ShowMessage("請選擇一個檔案");
     }
 }
コード例 #8
0
 public void Insert(BannerImgInfo info)
 {
     db.Insert(info.b_id, info.bp_image, info.bp_imagename);
 }