JSP(11) - 退貨模組
該模組處理退貨資訊,基本上是銷售模組 (http://blog.itpub.net/post/334/32291) 的反過程。
[@more@]return_back_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 sCommId="";
String sCommName="";
String sCommUnit="";
String sCommQutt="";
String sCustId = "";
String sCustName = "";
String sCustDisc = "";
String sCustTtSum = "";
String sExchQutt = "";
String sExchSeq = "1";
String sTodaySeq = "";
if( request.getAttribute("commName")!=null){
sCommId = request.getAttribute("commId").toString();
sCommName = request.getAttribute("commName").toString();
sCommUnit = request.getAttribute("commUnit").toString();
sCommQutt = request.getAttribute("commQutt").toString();
sCustId = request.getAttribute("custId").toString();
sCustName = request.getAttribute("custName").toString();
sCustDisc = request.getAttribute("custDisc").toString();
sCustTtSum = request.getAttribute("custTtSum").toString();
sExchQutt = request.getAttribute("exchQutt").toString();
sExchSeq = request.getAttribute("exchSeq").toString();
sTodaySeq = request.getAttribute("todaySeq").toString();
}
if ( request.getAttribute("custName")!=null){
sCustId = request.getAttribute("custId").toString();
sCustName = request.getAttribute("custName").toString();
sCustDisc = request.getAttribute("custDisc").toString();
sCustTtSum = request.getAttribute("custTtSum").toString();
sCommId = request.getAttribute("commId").toString();
sCommName = request.getAttribute("commName").toString();
sCommUnit = request.getAttribute("commUnit").toString();
sCommQutt = request.getAttribute("commQutt").toString();
sExchQutt = request.getAttribute("exchQutt").toString();
sExchSeq = request.getAttribute("exchSeq").toString();
sTodaySeq = request.getAttribute("todaySeq").toString();
}
%>
<!--
-->
商品名稱:
單價:
庫存:
顧客姓名:
折扣:
購物總額:
該顧客今天已經有筆交易紀錄
return_back_aft.jsp:
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
String sCommId=request.getParameter("exch_comm_id");
String sCustId = request.getParameter("exch_cust_id");
String sExchQutt = request.getParameter("exch_qutt");
String sExchSeq = request.getParameter("exch_seq");
String sExchDate = request.getParameter("exch_date");
String sCommName="";
String sCommUnit="";
String sCommQutt="";
String sCustName = "";
String sCustDisc = "";
String sCustTtSum = "";
String sExchCurMon = "";
String sCommLeft = "";
String sExchMon = "";
if (sExchSeq.equals("")){
throw new Exception("當日交易批次不準為空");
}
if (sCommId.equals("")){
throw new Exception("商品編號不準為空!");
}
if (sExchQutt.equals("")){
throw new Exception("退貨數量不準為空!");
}
if (sCustId.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 sQuery = null;
String sInsert = null;
String sUpdate1 = null;
String sUpdate2 = null;
Statement stmt = null;
ResultSet rs = null;
try {
sQuery = "select comm_name, comm_unit, comm_qutt from commodity where comm_id='"+sCommId+"'";
stmt = conn.createStatement();
rs = stmt.executeQuery(sQuery);
while(rs.next())
{
sCommName = rs.getString("comm_name");
sCommUnit = rs.getString("comm_unit");
sCommQutt = rs.getString("comm_qutt");
}
sQuery = "select cst_name,cst_discount, cst_trd_sum from customer where cst_id='"+sCustId+"'";
stmt = conn.createStatement();
rs = stmt.executeQuery(sQuery);
while(rs.next())
{
sCustName = rs.getString("cst_name");
sCustDisc = rs.getString("cst_discount");
sCustTtSum = rs.getString("cst_trd_sum");
}
sCommLeft = String.valueOf(Double.parseDouble(sCommQutt)+Double.parseDouble(sExchQutt));
sExchCurMon = String.valueOf(Double.parseDouble(sExchQutt)*Double.parseDouble(sCommUnit)*Double.parseDouble(sCustDisc)/100);
sExchMon = String.valueOf(Double.parseDouble(sCustTtSum)-Double.parseDouble(sExchCurMon));
sInsert = "insert into exchange(EXCH_SEQ, EXCH_CST_ID, EXCH_COMM_ID, EXCH_NB, EXCH_MON, EXCH_DATE, EXCH_TYPE) ";
sInsert = sInsert + "values("+sExchSeq+",'"+sCustId+"','"+sCommId+"',"+sExchQutt+","+sExchCurMon+",to_date('"+sExchDate+"','yyyy-mm-dd'),'E')";
sUpdate1 = "update commodity set COMM_QUTT="+sCommLeft+" where comm_id='"+sCommId+"'";
sUpdate2 = "update customer set cst_trd_sum="+sExchMon+" where cst_id='"+sCustId+"'";
//out.println(sInsert+"
");
//out.println(sUpdate1+"
");
//out.println(sUpdate2+"
");
stmt = conn.createStatement();
stmt.addBatch(sInsert);
stmt.addBatch(sUpdate1);
stmt.addBatch(sUpdate2);
stmt.executeBatch();
conn.commit();
out.println("退貨操作完成!"+"
");
out.println("退貨的商品編號:"+sCommId+" 商品名稱:"+sCommName+"
");
out.println("退貨顧客卡號:"+sCustId+" 顧客姓名:"+sCustName+"
");
out.println("商品單價:"+sCommUnit+"元
");
out.println("商品數量:"+sExchQutt+"
");
out.println("顧客折扣:"+sCustDisc+"%
");
out.println("退貨金額:"+sExchCurMon+"元
");
out.println("顧客累計購物金額:"+sExchMon+"元
");
out.println("這是該顧客今天的第"+sExchSeq+"筆交易。
");
out.println("商品"+sCommName+"尚有存貨"+sCommLeft);
}
catch (Exception e){
System.out.println("退貨操作失敗!");
e.printStackTrace();
out.println("退貨操作失敗!
");
out.println(e.getMessage());
out.println("");
}
finally {
if (stmt != null) stmt.close();
conn.close();
}
%>
return_check_cust.jsp:
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String sCustId = request.getParameter("exch_cust_id");
String sCustName = "";
String sCustDisc = "";
String sCustTtSum = "";
String sExchSeq = request.getParameter("exch_seq");
String sExchQutt = request.getParameter("exch_qutt");
String sCommId = request.getParameter("exch_comm_id");
String sCommName = request.getParameter("comm_name");
sCommName = new String(sCommName.getBytes("ISO8859-1"));
String sCommUnit = request.getParameter("comm_unit");
String sCommQutt = request.getParameter("comm_qutt");
String sTodaySeq = "";
boolean rsnull=true;
if(sCustId != null && !sCustId.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 cst_name, cst_discount, cst_trd_sum from customer ";
sQuery = sQuery + " where cst_id='"+sCustId+"'";
stmt = conn.createStatement();
rs = stmt.executeQuery(sQuery);
while(rs.next())
{
rsnull=false;
sCustName = rs.getString("cst_name");
sCustDisc = rs.getString("cst_discount");
sCustTtSum = rs.getString("cst_trd_sum");
}
sQuery = "select count(*) count from exchange where exch_cst_id='"+sCustId+"'" ;
sQuery = sQuery + " and to_char(exch_date,'yyyy-mm-dd')=to_char(sysdate,'yyyy-mm-dd')";
stmt = conn.createStatement();
rs = stmt.executeQuery(sQuery);
while(rs.next())
{
sTodaySeq = rs.getString("count");
}
}
catch(Exception e){
System.out.println("檢索顧客資訊時出錯!");
e.printStackTrace();
out.println("
out.println( e.getMessage() );
out.println("");
}
finally{
if(stmt != null) stmt.close();
conn.close();
}
}
request.setAttribute("custId",sCustId);
request.setAttribute("custName",sCustName);
request.setAttribute("custDisc",sCustDisc);
request.setAttribute("custTtSum",sCustTtSum);
request.setAttribute("exchSeq", sExchSeq);
request.setAttribute("exchQutt", sExchQutt);
request.setAttribute("commId", sCommId);
request.setAttribute("commName", sCommName);
request.setAttribute("commUnit", sCommUnit);
request.setAttribute("commQutt", sCommQutt);
request.setAttribute("todaySeq", sTodaySeq);
%>
return_check_comm.jsp:
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String sCommId = request.getParameter("exch_comm_id");
String sCommName = "";
String sCommUnit = "";
String sCommQutt = "";
String sExchQutt = request.getParameter("exch_qutt");
String sExchSeq = request.getParameter("exch_seq");
String sCustId = request.getParameter("exch_cust_id");
String sCustName = request.getParameter("cust_name");
sCustName = new String(sCustName.getBytes("ISO8859-1"));
String sCustDisc = request.getParameter("comm_dis");
String sCustTtSum = request.getParameter("comm_tt_sum");
String sTodaySeq = request.getParameter("today_seq");
boolean rsnull=true;
if(sCommId != null && !sCommId.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='"+sCommId+"'";
stmt = conn.createStatement();
rs = stmt.executeQuery(sQuery);
while(rs.next())
{
rsnull=false;
sCommName = rs.getString("comm_name");
sCommUnit = rs.getString("comm_unit");
sCommQutt = 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();
}
}
request.setAttribute("commId",sCommId);
request.setAttribute("commName",sCommName);
request.setAttribute("commUnit",sCommUnit);
request.setAttribute("commQutt",sCommQutt);
request.setAttribute("exchSeq",sExchSeq);
request.setAttribute("exchQutt",sExchQutt);
request.setAttribute("custId",sCustId);
request.setAttribute("custName",sCustName);
request.setAttribute("custDisc",sCustDisc);
request.setAttribute("custTtSum",sCustTtSum);
request.setAttribute("todaySeq",sTodaySeq);
%>
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/207/viewspace-800204/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- day11-模組
- Nodejs教程11:assert(斷言)模組NodeJS
- Angular入門到精通系列教程(11)- 模組(NgModule),延遲載入模組Angular
- 金蝶雲星空資料整合案例分享:銷售退貨單-銷售退貨
- 歐特歐諮詢:2018天貓雙11商品退貨率分析報告
- 智雲通CRM:客戶說“我要退貨”,如何解決退貨糾紛?
- (PHP7核心剖析-11) 模組擴充套件PHP套件
- 序列化模組,隨機數模組,os模組,sys模組,hashlib模組隨機
- 退換貨通道不關閉,買家笑,賣家哭?雙11實在需要RPA
- 真棒:使用Java 11實現應用的模組化Java
- python 模組:itsdangerous 模組Python
- path模組 fs模組
- Python模組:time模組Python
- day18:json模組&time模組&zipfile模組JSON
- 11.20 CW 模擬賽 T3.貨物分組
- CommonJS模組 和 ECMAScript模組JS
- Python模組之urllib模組Python
- python模組之collections模組Python
- 【Java】若以框架(ruoyi-master)——11.新建業務模組Java框架AST
- 序列化模組,subprocess模組,re模組,常用正則
- 模組學習之hashlib模組
- 模組學習之logging模組
- 聊天模組及分享模組分享
- [Python模組學習] glob模組Python
- 畫素寶典 #11 1-bit、UI、黑暗、模組動畫UI動畫
- 解讀:Java 11中的模組感知服務載入器Java
- Python常用模組(random隨機模組&json序列化模組)Pythonrandom隨機JSON
- 模組
- 使命召喚11win10閃退怎麼辦_win10使命召喚11閃退問題如何解決Win10
- ECDSA—模乘模組
- x11 轉 wayland 後 qBittorrent 啟動閃退
- win10系統程式閃退提示錯誤模組名稱ucrtbase.dll如何解決Win10
- 料狠猛貨 dark base 700 全模組側透機箱
- Profinet遠端IO模組:模擬量模組_軟體組態說明
- Python入門(二十六):檔案模組(os模組與shutil模組)Python
- Python模組、第三方模組安裝、模組匯入教程Python
- Vue — 請求模組、api模組封裝VueAPI封裝
- 【StoneDB 模組介紹】伺服器模組伺服器
- Python基礎12(模組與datetime模組)Python