JSP(4) - 增加客戶模組
分成before和after兩個介面。before介面用於讓使用者輸入顧客資訊,after介面用於後臺處理。
要點
1)jsp中引入java類
2)得到系統當前時間,並自定義格式顯示在網頁中
DateFormat dFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINESE); %>
......
最後修改日起:
3)在網頁之間傳遞資料
before頁:
add_cust_aft.jsp
String sCustID = request.getParameter("cust_id");
String sCustName = request.getParameter("cust_name");
String sCustSex = request.getParameter("cust_sex");
String sCustYear = request.getParameter("cust_year");
String sCustMonth = request.getParameter("cust_month");
String sCustAddr = request.getParameter("cust_addr");
String sCustZip = request.getParameter("cust_zip");
String sCustPhOff = request.getParameter("cust_ph_office");
String sCustPhHom = request.getParameter("cust_ph_home");
String sCustMob = request.getParameter("cust_mobile");
String sCustEmail = request.getParameter("cust_email");
Float fCustDis = Float.valueOf(request.getParameter("cust_discount"));
Float fCustTtSum = Float.valueOf(request.getParameter("cust_trd_sum"));
String dCustAdd = request.getParameter("cust_crt_date");
String dCustUpt = request.getParameter("cust_upt_date");
String sCustID2 = new String(sCustID.getBytes("iso-8859-1"),"GBK");
String sCustName2 = new String(sCustName.getBytes("iso-8859-1"),"GBK");
String sCustAddr2 = new String(sCustAddr.getBytes("iso-8859-1"),"GBK");
String sCustPhOff2 = new String(sCustPhOff.getBytes("iso-8859-1"),"GBK");
String sCustPhHom2 = new String(sCustPhHom.getBytes("iso-8859-1"),"GBK");
if (sCustID.equals("")){
throw new Exception("客戶卡號不準為空.");
}
if (sCustName.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;
Statement stmt = null;
try{
sInsert = "insert into customer(cst_id,cst_name,cst_sex, cst_year,cst_month,cst_address,cst_zip_code,";
sInsert = sInsert + "cst_ph_office, cst_ph_home, cst_mobile, cst_email, cst_discount, cst_trd_sum,";
sInsert = sInsert + "cst_crt_date, cst_upt_date) values('"+sCustID2+"','"+sCustName2+"','"+sCustSex+"','"+sCustYear+"','"+sCustMonth
+"','"+sCustAddr2+"','"+sCustZip+"','"+sCustPhOff2+"','"+sCustPhHom2+"','"+sCustMob+"','"+sCustEmail+"',"+
fCustDis+","+fCustTtSum+",to_date('"+dCustAdd+"','yyyy-mm-dd'),to_date('"+dCustUpt+"','yyyy-mm-dd'))";
stmt = conn.createStatement();
stmt.execute(sInsert);
conn.commit();
out.println("增加使用者"+sCustName2+"完成");
}
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-799591/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 如何利用sockserver模組程式設計實現客戶端併發Server程式設計客戶端
- 從客戶管理到資料分析:CRM系統模組詳解
- mysqlslap 負載模擬客戶端MySql負載客戶端
- Apollo 4 客戶端 SDK 設計客戶端
- magento2 在小程式模組增加 ApiAPI
- PHP提供Oracle支援增加oci8模組PHPOracle
- 這樣選擇CRM系統,客戶增加好幾倍!
- 驢媽媽客戶端頻道頁模組化設計思路及實踐客戶端
- IdentityServer4-客戶端定義-翻譯IDEServer客戶端
- SecureCRT for Mac(終端模擬器/SSH客戶端)SecurecrtMac客戶端
- 人工智慧在客戶關係管理軟體銷售和服務模組中的應用人工智慧
- CRM從4方面梳理客戶關係
- UE4 在當前遊戲模組新增一個新的模組遊戲
- 4G模組軟體指南 | 必讀篇之模組資訊(hmeta)
- Nginx 學習總結(4)—— Rewrite 模組Nginx
- UE4網路模組解析(一)
- Identity Server 4 - Hybrid Flow - MVC客戶端身份驗證IDEServerMVC客戶端
- IdentityServer4 (1) 客戶端授權模式(Client Credentials)IDEServer客戶端模式client
- SecureCRT\FX (終端模擬器\FTP客戶端)下載SecurecrtFTP客戶端
- 【Mac】Termius for mac(終端模擬器/SSH/SFTP客戶端)MacFTP客戶端
- python爬蟲實踐: 豆瓣小組命令列客戶端Python爬蟲命令列客戶端
- 序列化模組,隨機數模組,os模組,sys模組,hashlib模組隨機
- 企業客戶管理系統:智慧管理客戶資料 擴充客戶資源
- 4款.NET開源的Redis客戶端驅動庫Redis客戶端
- 4 個步驟啟動VOC(客戶之聲)計劃
- 客戶管理系統如何提高客戶滿意度
- 如何篩選CRM客戶系統無效客戶
- python 模組:itsdangerous 模組Python
- path模組 fs模組
- Python模組:time模組Python
- dubbo客戶端客戶端
- Pulsar客戶端客戶端
- mqtt 客戶端MQQT客戶端
- 2021年4月中國移動5G套餐客戶突破2億戶
- 為開源專案 go-gin-api 增加後臺任務模組GoAPI
- day18:json模組&time模組&zipfile模組JSON
- Cornerstone 4 for Mac - 專業可靠的SVN客戶端,完美相容版Mac客戶端
- Identity Server 4 從入門到落地(八)—— .Net Framework 客戶端IDEServerFramework客戶端
- Identity Server 4 從入門到落地(七)—— 控制檯客戶端IDEServer客戶端