JSP(6) - 進貨模組

zhyuh發表於2005-06-14

處理商品進貨資訊,並允許根據商品編號核實該商品詳細資訊及存貨資訊。

要點:
1) 點選button觸發javascript 事件

function checkID() {
document.frmComm.action = './jsp/purch_in_bef.jsp';
document.frmComm.submit();
}
......


2) 在同一頁面中,將頁面輸入結果傳入資料庫,並顯示資料庫返回的處理結果
商品名稱: 

以及原始碼中以上部分


3)處理select 型別的物件
進貨型別:

[@more@]

'purch_in_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");
String sExchType = request.getParameter("exch_type");

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

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/207/viewspace-800176/,如需轉載,請註明出處,否則將追究法律責任。

相關文章