JSP(12) - 商品處理模組
dispose_bef.jsp:
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:
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();
}
%>
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/207/viewspace-800205/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- JSP(9) - 增加商品模組JS
- JSP(10) - 修改商品資訊模組JS
- JSP 異常處理如何處理?JS
- JSP 日期處理概述JS
- JSP Session處理 (轉)JSSession
- 處理JSP中的中文 (轉)JS
- jsp:useBean的亂碼處理JSBean
- Python資料處理:Pandas模組的 12 種實用技巧Python
- JSP筆記-XML 資料處理JS筆記XML
- 商品模組設計
- 商品模組介面文件
- 12事務處理
- 常用模組 PHP 錯誤處理PHP
- JSP中Beans 與 Forms處理機制JSBeanORM
- Laravel——商品模組難點Laravel
- JSP 商品瀏覽[Web application]JSWebAPP
- maven模組互相依賴打包處理Maven
- PythonIP處理模組IPy(轉載)Python
- 深入剖析JSP和Servlet對中文的處理JSServlet
- 請教JSP/servlet容器對更新的JSP頁面處理的原理JSServlet
- 【故障處理】ORA-12162 錯誤的處理
- mysql 1129處理MySql
- Python 模組的一般處理Python
- JSP(11) - 退貨模組JS
- JSP(7) - 銷售模組JS
- JSP(6) - 進貨模組JS
- 【故障處理】ORA- 2730*,status 12故障分析與處理
- SPM12之fMRI批次預處理——NII檔案處理
- Node.js 如何處理 ES6 模組Node.js
- pip安裝模組超時怎麼處理
- 【轉】從msql資料庫處理高併發商品超賣SQL資料庫
- Springboot 多模組 jspSpring BootJS
- JSP(4) - 增加客戶模組JS
- nodejs檔案上傳處理模組formidableNodeJSORM
- CSS 預處理語言的模組化實踐CSS
- CSS預處理語言的模組化實踐CSS
- 處理程式“ExtensionlessUrlHandler-Integrated-4.0”在其模組列表
- Python模組學習:time 日期時間處理Python