JSP(9) - 增加商品模块

以下模块无要点技术信息,放在此处仅为系统的完整性考虑。

该模块增加商品种类信息。

[@more@]

add_comm_bef.jsp:

<%@ page contentType="text/html; charset=GBK" %>
<%@ page language="java" import="java.util.*" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.text.DateFormat" %>
<%
response.setHeader("Cache-Control","no-store"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader("Expires", 0); //prevents caching at the proxy server

String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
Date d = new Date();
DateFormat dFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINESE);
%>







增加商品












增加商品


商品编号:     

商品名称:     

商品类别:     

单价:         

库存数量:     

颜色:         

尺寸:         

最后修改日起:


           






add_comm_aft.jsp:

<%@ page contentType="text/html; charset=GBK" %>
<%@ page language="java" import="java.util.*" %>
<%@ page import="java.sql.*" %>



增加商品信息



<%
String sCommID = request.getParameter("comm_id");
String sCommName = request.getParameter("comm_name");
String sCommCate = request.getParameter("comm_type");
String sCommUnit = request.getParameter("comm_unit");
String sCommColor = request.getParameter("comm_color");
String sCommSize = request.getParameter("comm_size");
String sCommUptDate = request.getParameter("comm_upt_date");

String sCommID2 = new String(sCommID.getBytes("iso-8859-1"),"GBK");
String sCommName2 = new String(sCommName.getBytes("iso-8859-1"),"GBK");
String sCommCate2 = new String(sCommCate.getBytes("iso-8859-1"),"GBK");
String sCommColor2 = new String(sCommColor.getBytes("iso-8859-1"),"GBK");
String sCommSize2 = new String(sCommSize.getBytes("iso-8859-1"),"GBK");

if (sCommID.equals("")){
throw new Exception("商品编号不准为空");
}
if (sCommName.equals("")){
throw new Exception("商品名称不准为空");
}

Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@TCSCH074.tcsgdccn.com:1521:orcl";
//orcl为你的数据库的SID
String user="store";
String password="store";
Connection conn= DriverManager.getConnection(url,user,password);
String sInsert = null;
Statement stmt = null;


String sCommQutt = request.getParameter("comm_qutt");

try{
sInsert = "insert into commodity (comm_id, comm_name, comm_cate, comm_unit, comm_qutt,";
sInsert = sInsert + "comm_upt_date, comm_color, comm_size) values(";
sInsert = sInsert + "'"+sCommID2+"','"+sCommName2+"','"+sCommCate2+"','"+sCommUnit;
sInsert = sInsert + "',"+sCommQutt +",to_date('"+sCommUptDate+"','yyyy-mm-dd'),'"+sCommColor2+"','"+sCommSize2+"')";
//out.println(sInsert);
stmt = conn.createStatement();
stmt.execute(sInsert);
conn.commit();
out.println("增加商品"+sCommName2+"完成。");
}

catch (Exception e){
System.out.println("增加商品失败!");
e.printStackTrace();
out.println("增加商品失败!
");
out.println(e.getMessage());
out.println("

");
}

finally {
if (stmt != null) stmt.close();
conn.close();
}
%>

请使用浏览器的分享功能分享到微信等