ProcductPic.aspx.cs
资源名称:yjal.rar [点击查看]
上传用户:shjujing
上传日期:2022-07-28
资源大小:11244k
文件大小:7k
源码类别:
Email客户端
开发平台:
Visual C++
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- using background;
- public partial class Manage_ProcductPic : System.Web.UI.Page
- {
- uppic up = new uppic();
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void ImageButton1_Command(object sender, CommandEventArgs e)
- {
- Session["linklogo"] = e.CommandArgument.ToString();
- }
- protected void ImageButton2_Command(object sender, CommandEventArgs e)
- {
- Session["Brand"] = e.CommandArgument.ToString();
- }
- protected void ImageButton3_Command(object sender, CommandEventArgs e)
- {
- Session["Pic"] = e.CommandArgument.ToString();
- }
- protected void linkLogoup_Click(object sender, EventArgs e)
- {
- //Response.Write("<script>alert('" + Session["linklogo"].ToString() + "');</script>");
- if (Session["linklogo"] != null)
- {
- if (this.myFile.PostedFile != null)
- {
- string photoName1 = myFile.PostedFile.FileName; //获取初始文件名
- int i = photoName1.LastIndexOf("."); //取得文件名中最后一个"."的索引
- string newext = photoName1.Substring(i); //获取文件扩展名
- newext = newext.ToLower();//转换成小写
- if (newext != ".gif" && newext != ".jpg" && newext != ".jpeg" && newext != ".bmp" && newext != ".png")
- {
- Response.Write("<script>alert('文件格式不正确');</script>");
- Response.End();
- }
- DateTime now = DateTime.Now; //获取系统时间
- string photoName2 = now.Millisecond.ToString() + "_" + myFile.PostedFile.ContentLength.ToString() + newext; //重新为文件命名,时间毫秒部分+文件大小+扩展名
- myFile.PostedFile.SaveAs(Server.MapPath("..\Image\" + photoName2)); // 保存文件到路径,用Server.MapPath()取当前文件的绝对目录.在asp.net里""必须用"\"代替
- bool yes=up.uppicFile(Session["linklogo"].ToString(),photoName2,"linklogo");
- if (yes)
- {
- Response.Write("<script>alert('文件上传成功');</script>");
- Session.Remove("linklogo");
- }
- else {
- Response.Write("<script>alert('文件上传失败');</script>");
- }
- }
- }
- else {
- Response.Write("<script>alert('没有找到与图片相关的商品信息');</script>");
- }
- }
- protected void Brandupbtn_Click(object sender, EventArgs e)
- {
- if (Session["Brand"] != null)
- {
- if (this.myFile1.PostedFile != null)
- {
- string photoName1 = myFile1.PostedFile.FileName; //获取初始文件名
- int i = photoName1.LastIndexOf("."); //取得文件名中最后一个"."的索引
- string newext = photoName1.Substring(i); //获取文件扩展名
- newext = newext.ToLower();//转换成小写
- if (newext != ".gif" && newext != ".jpg" && newext != ".jpeg" && newext != ".bmp" && newext != ".png")
- {
- Response.Write("<script>alert('文件格式不正确');</script>");
- Response.End();
- }
- DateTime now = DateTime.Now; //获取系统时间
- string photoName2 = now.Millisecond.ToString() + "_" + myFile.PostedFile.ContentLength.ToString() + newext; //重新为文件命名,时间毫秒部分+文件大小+扩展名
- myFile1.PostedFile.SaveAs(Server.MapPath("..\Image\" + photoName2)); // 保存文件到路径,用Server.MapPath()取当前文件的绝对目录.在asp.net里""必须用"\"代替
- bool yes = up.uppicFile(Session["Brand"].ToString(), photoName2, "Brand");
- if (yes)
- {
- Response.Write("<script>alert('文件上传成功');</script>");
- Session.Remove("Brand");
- }
- else
- {
- Response.Write("<script>alert('文件上传失败');</script>");
- }
- }
- }
- else {
- Response.Write("<script>alert('没有找到与图片相关的商品信息');</script>");
- }
- }
- protected void picupbtn_Click(object sender, EventArgs e)
- {
- if (Session["Pic"] != null)
- {
- if (this.myFile2.PostedFile != null)
- {
- string photoName1 = myFile2.PostedFile.FileName; //获取初始文件名
- int i = photoName1.LastIndexOf("."); //取得文件名中最后一个"."的索引
- string newext = photoName1.Substring(i); //获取文件扩展名
- newext = newext.ToLower();//转换成小写
- if (newext != ".gif" && newext != ".jpg" && newext != ".jpeg" && newext != ".bmp" && newext != ".png")
- {
- Response.Write("<script>alert('文件格式不正确');</script>");
- Response.End();
- }
- DateTime now = DateTime.Now; //获取系统时间
- string photoName2 = now.Millisecond.ToString() + "_" + myFile.PostedFile.ContentLength.ToString() + newext; //重新为文件命名,时间毫秒部分+文件大小+扩展名
- myFile2.PostedFile.SaveAs(Server.MapPath("..\Image\" + photoName2)); // 保存文件到路径,用Server.MapPath()取当前文件的绝对目录.在asp.net里""必须用"\"代替
- bool yes = up.uppicFile(Session["Pic"].ToString(), photoName2, "Pic");
- if (yes)
- {
- Response.Write("<script>alert('文件上传成功');</script>");
- Session.Remove("Pic");
- }
- else
- {
- Response.Write("<script>alert('文件上传失败');</script>");
- }
- }
- }
- else {
- Response.Write("<script>alert('没有找到与图片相关的商品信息');</script>");
- }
- }
- protected void LinkButton1_Command(object sender, CommandEventArgs e)
- {
- Response.Redirect("particular.aspx?id=" + e.CommandArgument + "");
- }
- }