productedInsert.jsp
上传用户:yatiankong
上传日期:2014-05-16
资源大小:5604k
文件大小:4k
源码类别:

Applet

开发平台:

Java

  1. <%@ page contentType="text/html; charset=GB2312"%>
  2. <%@ page import="java.sql.*,com.jspsmart.upload.*"%>
  3. <%@ page import="java.sql.* ,java.util.Date,java.text.SimpleDateFormat"%>
  4. <jsp:useBean id="file_Bean" class="MyFly.Bean.file_Bean" scope="request"/>
  5. <jsp:useBean id="useclassBean" class="MyFly.Bean.useclassBean" scope="request"/>
  6. <jsp:useBean id="characterclassBean" class="MyFly.Bean.characterclassBean" scope="request"/>
  7. <jsp:useBean id="productinfoBean" class="MyFly.Bean.productinfoBean" scope="request"/>
  8. <%!
  9.    String fun(String str)
  10.    {
  11.       try
  12.   {
  13.       return new String(str.getBytes("ISO8859_1"));
  14.   }
  15.   catch(Exception e)
  16.   {
  17.      return "";
  18.   }
  19.    }
  20. %>
  21. <html>
  22. <body>
  23. <%
  24.   try{
  25.   
  26.    String str=request.getRealPath("/");
  27.    str+="\XKB\product_image";
  28.    SmartUpload mySmartUpload=new SmartUpload();
  29.    mySmartUpload.initialize(pageContext);
  30.  
  31.   mySmartUpload.setTotalMaxFileSize(20000000);
  32.   mySmartUpload.upload();
  33.   
  34.   //int count;
  35.   //count=mySmartUpload.save("/XKB/product_image");  
  36.   
  37.    String productID=mySmartUpload.getRequest().getParameter("productID");
  38.     productinfoBean.setProductID(productID);
  39.    
  40.    String productName=mySmartUpload.getRequest().getParameter("productName");
  41.    productinfoBean.setProductName(productName);
  42.   
  43.    String useclassID=mySmartUpload.getRequest().getParameter("useclassID");
  44.    
  45.    productinfoBean.setUseclassID(Integer.parseInt(useclassID));
  46.    
  47.    String characterID=mySmartUpload.getRequest().getParameter("characterID");
  48.    productinfoBean.setCharacterID(Integer.parseInt(characterID));
  49.    
  50.    String marketPrice=mySmartUpload.getRequest().getParameter("marketPrice");
  51.    productinfoBean.setMarketPrice(Float.parseFloat(marketPrice));
  52.    
  53.    String preferPrice=mySmartUpload.getRequest().getParameter("preferPrice");
  54.    productinfoBean.setPreferPrice(Float.parseFloat(preferPrice));
  55.    
  56.    SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd");//将显示"1999-10-1 21:03:10"的格式. 
  57.     Date currentTime_1 = new Date(); 
  58.     String appendTime = formatter.format(currentTime_1); 
  59.    productinfoBean.setShangData(appendTime);
  60.    
  61.   String storage=mySmartUpload.getRequest().getParameter("storage");
  62.    productinfoBean.setStorage(Integer.parseInt(storage));
  63.    
  64.    com.jspsmart.upload.File maxpic=mySmartUpload.getFiles().getFile(0);
  65.    String max=maxpic.getFileName();
  66.    String maxFile="max"+max;
  67.    file_Bean.setPathName(str);
  68.    String maxName=file_Bean.getFileName(maxFile);
  69.  
  70.    productinfoBean.setMaxPicture(maxName);
  71.    
  72.    com.jspsmart.upload.File minpic=mySmartUpload.getFiles().getFile(1);
  73.    String min=minpic.getFileName();
  74.    String minFile="min"+min;
  75.    file_Bean.setPathName(str);
  76.    String minName=file_Bean.getFileName(minFile);
  77.    
  78.    productinfoBean.setMinPicture(minName);
  79.    String introduce=mySmartUpload.getRequest().getParameter("content");
  80.    productinfoBean.setIntroduce(introduce);
  81.    
  82.     String publish=mySmartUpload.getRequest().getParameter("publish");//???
  83.    productinfoBean.setPublish(publish);
  84.    
  85.     String author=mySmartUpload.getRequest().getParameter("author");//??
  86.    productinfoBean.setAuthor(author);
  87.    //System.out.print(author);
  88.    
  89.    String tuijian=mySmartUpload.getRequest().getParameter("tuijian");
  90.    if(tuijian==null)
  91.    {
  92.        productinfoBean.setTuijian(0);
  93.    }
  94.    else
  95.    {
  96.       productinfoBean.setTuijian(1);
  97.    }
  98.    
  99.     String isnew=mySmartUpload.getRequest().getParameter("isnew");//?????
  100.    if(isnew==null)
  101.    {
  102.        productinfoBean.setIsnew(0);
  103.    }
  104.    else
  105.    {
  106.       productinfoBean.setIsnew(1);
  107.    }
  108.    
  109.    
  110.    
  111.    
  112.    
  113.    if(productinfoBean.addNew()==0)
  114.    {
  115.        out.println("<Script language=JavaScript>alert('添加失败');javascript:history.back();</Script>");
  116.    }
  117.    else
  118.    { 
  119.        maxpic.saveAs("/XKB/product_image/" + maxName);
  120.    minpic.saveAs("/XKB/product_image/" + minName);
  121.        response.sendRedirect("produceinfoView.jsp?success=true");
  122.    }
  123.   }
  124.   catch(Exception e)
  125.    {
  126.      out.println("<Script language=JavaScript>alert('添加失败');javascript:history.back();</Script>");
  127.    }
  128.    %>
  129.  </body>
  130. </html>