JSP(8) - 按卡號查詢顧客資訊
分兩頁。第一頁提示使用者輸入顧客卡號,第二頁根據卡號返回顧客詳細資訊。由於卡號位一確定某位顧客,故該顧客的交易資訊也同時返回。
要點: 源程式 qry_cust_id1.jsp: String path = request.getContextPath(); %> qry_cust_id2.jsp: Class.forName("oracle.jdbc.driver.OracleDriver").newInstance(); %> try { stmt = conn.createStatement(); while(rs.next()) out.println(" } catch (Exception e){ 顧客資訊查詢失敗! %> sQuery = "select to_char(exch_date,'yyyy-mm-dd') exch_date, exch_seq, "; stmt = conn.createStatement(); while(rs.next()) rs.close(); catch (Exception e){ 交易資訊查詢失敗! finally{ %>
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/207/viewspace-800199/,如需轉載,請註明出處,否則將追究法律責任。
1) 根據返回紀錄動態生成表格
out.println("");
out.println(""+sCustId+" ");
out.println(""+sCustName+" ");
......
2) 若某欄位結果為空,則應付值  ,以避免生成的表格缺邊框
sCustEmail = rs.getString("cst_email");
if (sCustEmail==null) sCustEmail=" ";[@more@]
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
<!--
-->
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 sCustId = request.getParameter("cust_id");
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);
ResultSet rs = null;
String sQuery = null;
Statement stmt = null;顧客資訊
卡號
姓名
性別
出生年月
折扣
購物總額
email
手機
辦公室電話
家庭電話
通訊地址
郵編
建立日期
最後修改日期
姓名
卡號
String sCustName = "";
String sCustSex = "";
String sCustYear = "";
String sCustMonth = "";
String sCustAddress = "";
String sCustZipCode = "";
String sCustPhOffice = "";
String sCustPhHome = "";
String sCustMobile = "";
String sCustEmail = "";
String sCustDisc = "";
String sCustTtSum = "";
String sCustCrtDt = "";
String sCustUptDt = "";
sQuery = "select cst_id, cst_name,decode(cst_sex,'M','男','F','女',cst_sex) cst_sex, cst_year, cst_month, cst_address, cst_zip_code, ";
sQuery = sQuery + "cst_ph_office, cst_ph_home, cst_mobile, cst_email, cst_discount, cst_trd_sum, ";
sQuery = sQuery + "to_char(cst_crt_date,'yyyy-mm-dd') cst_crt_date, ";
sQuery = sQuery + "to_char(cst_upt_date,'yyyy-mm-dd') cst_upt_date from customer where cst_id = '"+sCustId+"'";
rs = stmt.executeQuery(sQuery);
{
sCustId = rs.getString("cst_id");
sCustName = rs.getString("cst_name");
sCustSex = rs.getString("cst_sex");
sCustYear = rs.getString("cst_year");
if (sCustYear==null) sCustYear="";
sCustMonth = rs.getString("cst_month");
if (sCustMonth==null) sCustMonth="";
sCustAddress = rs.getString("cst_address");
if (sCustAddress==null) sCustAddress=" ";
sCustZipCode = rs.getString("cst_zip_code");
if (sCustZipCode==null) sCustZipCode=" ";
sCustPhOffice = rs.getString("cst_ph_office");
if (sCustPhOffice==null) sCustPhOffice=" ";
sCustPhHome = rs.getString("cst_ph_home");
if (sCustPhHome==null) sCustPhHome=" ";
sCustMobile = rs.getString("cst_mobile");
if (sCustMobile==null) sCustMobile=" ";
sCustEmail = rs.getString("cst_email");
if (sCustEmail==null) sCustEmail=" ";
sCustDisc = rs.getString("cst_discount");
if (sCustDisc==null) sCustDisc=" ";
sCustTtSum = rs.getString("cst_trd_sum");
sCustCrtDt = rs.getString("cst_crt_date");
sCustUptDt = rs.getString("cst_upt_date");");
out.println(""+sCustId+" ");
out.println(""+sCustName+" ");
out.println(""+sCustSex+" ");
out.println(""+sCustYear+"年"+sCustMonth+"月 ");
out.println(""+sCustDisc+"% ");
out.println(""+sCustTtSum+"元 ");
out.println(""+sCustEmail+" ");
out.println(""+sCustMobile+" ");
out.println(""+sCustPhOffice+" ");
out.println(""+sCustPhHome+" ");
out.println(""+sCustAddress+" ");
out.println(""+sCustZipCode+" ");
out.println(""+sCustCrtDt+" ");
out.println(""+sCustUptDt+" ");
out.println(""+sCustName+" ");
out.println(""+sCustId+" ");
}
System.out.println("顧客資訊查詢失敗!");
e.printStackTrace();
out.println("
out.println( e.getMessage() );
}
該顧客交易資訊
交易日期
當日序號
交易型別
商品
數量
單價
金額
try {
String sExchDate = "";
String sExchSeq = "";
String sExchType = "";
String sExchCommName = "";
String sExchQutt = "";
String sExchCommUnit = "";
String sExchMon="";
sQuery = sQuery + "decode(exch_type,'A','總公司的發貨單','B','本店製作的退貨單','C','銷貨發票','D','購買','E','退貨','F','處理',exch_type) exch_type, ";
sQuery = sQuery + "comm_name, exch_nb, comm_unit, exch_mon from exchange e, commodity c ";
sQuery = sQuery + "where e.exch_comm_id=c.comm_id and exch_cst_id = '"+sCustId+"' order by exch_date desc, exch_seq asc";
rs = stmt.executeQuery(sQuery);
{
sExchDate = rs.getString("exch_date");
sExchSeq = rs.getString("exch_seq");
sExchType = rs.getString("exch_type");
sExchCommName = rs.getString("comm_name");
if (sExchCommName==null) sExchCommName="";
sExchQutt = rs.getString("exch_nb");
sExchCommUnit = rs.getString("comm_unit");
sExchMon = rs.getString("exch_mon");
out.println("");
out.println(""+sExchDate+" ");
out.println(""+sExchSeq+" ");
out.println(""+sExchType+" ");
out.println(""+sExchCommName+" ");
out.println(""+sExchQutt+" ");
out.println(""+sExchCommUnit+"元 ");
out.println(""+sExchMon+"元 ");
}
stmt.close();
conn.close();
}
System.out.println("交易資訊查詢失敗!");
e.printStackTrace();
out.println("
out.println( e.getMessage() );
}
if(stmt != null) stmt.close();
conn.close();
}
相關文章
- 查詢hba卡wwn號
- 條件查詢JSPJS
- JSP(5) - 修改客戶資訊模組JS
- 查詢表資訊
- 高效獲取銀行卡髮卡行所在地資訊——利用銀行卡歸屬地查詢介面
- 查詢 - 符號表符號
- 查詢SQLSERVER版本號SQLServer
- SSH實現客戶按條件查詢\上傳檔案等
- arduino使用SD卡模組以及檢查SD卡資訊UISD卡
- 一個使用JDBC按Date查詢查詢的問題JDBC
- oracle 鎖資訊查詢
- 海光 DCU資訊查詢
- 微課sql最佳化(8)、統計資訊收集(6)-統計資訊查詢SQL
- oracle 補丁號查詢Oracle
- 斷號查詢問題
- 查詢埠號佔用
- 銀聯卡線上餘額查詢
- 檔案批次查詢複製匯出,按檔名批次查詢檔案,按檔案內容批次查詢檔案
- linux平臺下C語言按程式名查詢程式號pidLinuxC語言
- 域名查詢資訊怎麼操作?可以查詢哪些資訊?(中科三方)
- Linux中查詢賬號資訊的命令有哪些?建議收藏!Linux
- ps -ef | grep 查詢資訊
- 【Linux】CPU資訊查詢Linux
- SQL SERVER 查詢鎖資訊SQLServer
- sqlserver查詢table,columns資訊SQLServer
- 表空間查詢資訊
- 企業資訊查詢工具
- SSM的查詢簡單練習+JSPSSMJS
- 小米手機如何用運單號碼查詢快遞資訊 小米手機快速查詢快遞資訊方法
- jpa 聯合查詢資料,查詢使用者資訊與部門資訊
- 域名資訊查詢怎麼操作?Godaddy的whois域名資訊查詢在哪裡?Go
- 每秒百萬條資訊查詢 天翼雲助力江蘇核酸檢測資訊查詢
- 電腦序列號怎麼查詢 電腦序列號的查詢方法介紹
- 物件點查詢和中括號查詢的區別物件
- 牛客網 查詢(二分查詢、北郵機試)
- 蘋果官網序列號查詢蘋果
- 公用查詢帳號的管理
- 如何通過OEM 中Lock 資訊中的特殊行號查詢lock行