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("副檔名格式錯誤")); } } }
protected void btFile_Click(object sender, EventArgs e) { //ProductFile產品檔案 if (fuFile.HasFile) { string filename = WebUtility.ChangeFileNameAsRandom(fuFile.FileName); string ServerFilename = WebUtility.MergePathAndFileName(filename, Tools.GetAppSettings("ProductDLTempPath")); fuFile.SaveAs(ServerFilename); if (Session["pdinfo"] == null) { pdDlInfos = new List <ProductDownloadInfo>(); } else { pdDlInfos = (List <ProductDownloadInfo>)Session["pdinfo"]; } ProductDownloadInfo info = new ProductDownloadInfo(); info.pd_name = filename; pdDlInfos.Add(info); tfBLL.InsertTempFiles("product", Tools.GetAppSettings("ProductDLTempPath") + filename); Session["pdinfo"] = pdDlInfos; rpDownload.DataSource = pdDlInfos; rpDownload.DataBind(); } else { this.ShowMessage(this.Getmessage("30011")); } }
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("ProductImageTempPath")); fuImage.SaveAs(serverFileName); if (Session["arimginfo"] == null) { arimgInfos = new List <ArticleImageInfo>(); } else { arimgInfos = (List <ArticleImageInfo>)Session["arimginfo"]; } ArticleImageInfo info = new ArticleImageInfo(); info.ap_imagename = imgFilename; info.ap_name = imgFilename; arimgInfos.Add(info); tfBLL.InsertTempFiles("article", Tools.GetAppSettings("ProductImageTempPath") + imgFilename); Session["arimginfo"] = arimgInfos; rpImage.DataSource = arimgInfos; rpImage.DataBind(); } } }
protected void btFile_Click(object sender, EventArgs e) { if (fuFile.HasFile) { string filename = WebUtility.ChangeFileNameAsRandom(fuFile.FileName); string ServerFilename = WebUtility.MergePathAndFileName(filename, Tools.GetAppSettings("ProductDLTruePath")); fuFile.SaveAs(ServerFilename); ProductDownloadInfo info = new ProductDownloadInfo(); info.pd_name = filename; info.pd_type = filename; info.p_id = Tools.GetInt32SafeFromQueryString(this.Page, "id", 0); PddBLL.Insert(info); rpDownload.DataSource = PddBLL.GetallFilesWithProduct(Tools.GetInt32SafeFromQueryString(this.Page, "id", 0)); rpDownload.DataBind(); } else { this.ShowMessage("請選擇一個檔案"); } }
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))) { Button1.Enabled = false; string serverFileName = WebUtility.MergePathAndFileName(imgFileName, Tools.GetAppSettings("ProductImageTempPath")); fuImage.SaveAs(serverFileName); tfBLL.InsertTempFiles("FriendLink", Tools.GetAppSettings("ProductImageTempPath") + imgFileName); Image1.ImageUrl = Tools.GetAppSettings("ProductImageTempPath") + imgFileName; Image1.AlternateText = imgFileName; Button1.Enabled = true; } else { this.Page.Controls.Add(Tools.Tomsg("副檔名格式錯誤")); } } }
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))) { Button1.Enabled = false; string serverfilename = WebUtility.MergePathAndFileName(imgFilename, Tools.GetAppSettings("ProductImageTruePath")); fuImage.SaveAs(serverfilename); ProductImageInfo pdimg = new ProductImageInfo(); pdimg.p_id = Tools.GetInt32SafeFromQueryString(this.Page, "id", 0); pdimg.pi_imageName = imgFilename; pdimg.pi_image = imgFilename; pdImgBLL.Insert(pdimg); Button1.Enabled = true; rpImage.DataSource = pdImgBLL.GetallImgWithProduct(Tools.GetInt32SafeFromQueryString(this.Page, "id", 0)); rpImage.DataBind(); } } }
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("請選擇一個檔案"); } }
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("ArticleTruePath")); fuImage.SaveAs(serverFileName); ArticleImageInfo info = new ArticleImageInfo(); info.a_id = Tools.GetInt32SafeFromQueryString(this.Page, "id", 0); info.ap_name = imgFilename; info.ap_imagename = imgFilename; aiBLL.Insert(info); tfBLL.InsertTempFiles("Ariticle", Tools.GetAppSettings("ArticleTruePath") + imgFilename); rpImage.DataSource = aiBLL.GetDataByAid(Tools.GetInt32SafeFromQueryString(this.Page, "id", 0)); rpImage.DataBind(); } } else { this.ShowMessage("請選擇一個檔案"); } }