溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

JSP(12) - 商品處理模塊

發(fā)布時(shí)間:2020-08-09 18:32:33 來源:ITPUB博客 閱讀:130 作者:zhyuh 欄目:編程語言
該模塊基本上為 進(jìn)貨模塊(http://blog.itpub.net/post/334/32287)的反過程。[@more@]

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為你的數(shù)據(jù)庫的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("檢索商品信息時(shí)出錯(cuò)!");
e.printStackTrace();
out.println("

檢索商品信息時(shí)出錯(cuò)!請聯(lián)系技術(shù)支持人員。

");
out.println( e.getMessage() );
out.println("");
}
finally{
if(stmt != null) stmt.close();
conn.close();
}
}
%>



">

進(jìn)貨







<!--

-->



javascript:window.alert("商品編號(hào)不存在!")<%}%>>

<!---->

處理


商品編號(hào): 

當(dāng)日處理批次:  


         




商品名稱: 

單價(jià): 

庫存: 






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("當(dāng)日進(jìn)貨批次不準(zhǔn)為空");
}
if (sExchCommID.equals("")){
throw new Exception("商品編號(hào)不準(zhǔn)為空!");
}
if (sExchQutt.equals("")){
throw new Exception("進(jìn)貨數(shù)量不準(zhǔn)為空!");
}

Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@TCSCH074.tcsgdccn.com:1521:orcl";
//orcl為你的數(shù)據(jù)庫的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("商品編號(hào):"+sExchCommID+"
");
out.println("商品:"+sCommName+"
");
out.println("數(shù)量:"+sExchQutt+"
");
out.println("單價(jià):"+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();
}
%>


向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI