您好,登录后才能下订单哦!
dispose_bef.jsp:
<%@ page contentType="text/html; charset=GBK" %>
<%@ page language="java" import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ 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+"/";
java.util.Date d=new java.util.Date();
DateFormat dFormat=new SimpleDateFormat("yyyy-MM-dd",Locale.CHINESE);
String sExchId = request.getParameter("exch_id");
String sExchName = "";
String sExchUnit = "";
String sExchQutt = "";
String sCommQutt = request.getParameter("exch_qutt");
boolean rsnull=true;
if(sExchId != null && !sExchId.equals("")){
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 sQuery = null;
Statement stmt = null;
ResultSet rs = null;
try{
sQuery = "select comm_name, comm_unit, comm_qutt from commodity ";
sQuery = sQuery + " where comm_id='"+sExchId+"'";
stmt = conn.createStatement();
rs = stmt.executeQuery(sQuery);
while(rs.next())
{
rsnull=false;
sExchName = rs.getString("comm_name");
sExchUnit = rs.getString("comm_unit");
sExchQutt = rs.getString("comm_qutt");
}
} 检索商品信息时出错!请联系技术支持人员。
catch(Exception e){
System.out.println("检索商品信息时出错!");
e.printStackTrace();
out.println("
out.println( e.getMessage() );
out.println("");
}
finally{
if(stmt != null) stmt.close();
conn.close();
}
}
%>
<!--
-->
javascript:window.alert("商品编号不存在!")<%}%>>
dispose_aft.jsp:
<%@ page contentType="text/html; charset=GBK" %>
<%@ page language="java" import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
String sExchSeq = request.getParameter("exch_seq");
String sExchCommID = request.getParameter("exch_id");
String sExchCustID = "000001";
String sExchQutt = request.getParameter("exch_qutt");
String sExchDate = request.getParameter("exch_date");
String sCommName = null;
String sCommQutt = null;
String sCommUnit = null;
String sExchMon = null;
if (sExchSeq.equals("")){
throw new Exception("当日进货批次不准为空");
}
if (sExchCommID.equals("")){
throw new Exception("商品编号不准为空!");
}
if (sExchQutt.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;
String sQuery = null;
String sUpdate = null;
Statement stmt = null;
ResultSet rs = null;
try {
sQuery = "select comm_name,comm_qutt,comm_unit from commodity where comm_id='"+sExchCommID+"'";
stmt = conn.createStatement();
rs = stmt.executeQuery(sQuery);
if (rs.next()) {
sCommName = rs.getString("comm_name");
sCommQutt = rs.getString("comm_qutt");
sCommUnit = rs.getString("comm_unit");
}
sExchMon = String.valueOf(Double.parseDouble(sCommUnit)*Double.parseDouble(sExchQutt));
sInsert = "insert into exchange(EXCH_SEQ, EXCH_CST_ID, EXCH_COMM_ID, EXCH_NB, EXCH_MON, EXCH_DATE, EXCH_TYPE) ";
sInsert = sInsert + "values("+sExchSeq+",'"+sExchCustID+"','"+sExchCommID+"',"+sExchQutt+","+sExchMon+",to_date('"+sExchDate+"','yyyy-mm-dd'),'F')";
sUpdate = "update commodity set COMM_QUTT=("+sCommQutt+"-"+sExchQutt+") where comm_id='"+sExchCommID+"'";
//out.println(sQuery+"
");
//out.println(sInsert+"
");
//out.println(sUpdate+"
");
stmt = conn.createStatement();
stmt.addBatch(sInsert);
stmt.addBatch(sUpdate);
stmt.executeBatch();
conn.commit();
out.println("商品处理完成
");
out.println("商品编号:"+sExchCommID+"
");
out.println("商品:"+sCommName+"
");
out.println("数量:"+sExchQutt+"
");
out.println("单价:"+sCommUnit+"
");
out.println("金额:"+sExchMon+"
");
}
catch (Exception e){
System.out.println("处理操作失败!");
e.printStackTrace();
out.println("处理操作失败!
");
out.println(e.getMessage());
out.println("");
}
finally {
if (stmt != null) stmt.close();
conn.close();
}
%>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。