javaWeb書(shū)店管理系統(tǒng)_第1頁(yè)
javaWeb書(shū)店管理系統(tǒng)_第2頁(yè)
javaWeb書(shū)店管理系統(tǒng)_第3頁(yè)
javaWeb書(shū)店管理系統(tǒng)_第4頁(yè)
javaWeb書(shū)店管理系統(tǒng)_第5頁(yè)
已閱讀5頁(yè),還剩39頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、一、實(shí)驗(yàn)?zāi)康睦斫獠⒄莆站幋a與測(cè)試相關(guān)理論與方法;進(jìn)一步熟悉利用編程語(yǔ)言實(shí)現(xiàn)系統(tǒng);要求學(xué)生理解測(cè)試在軟件開(kāi)發(fā)中的重要地位;學(xué)生了解測(cè)試用例與測(cè)試報(bào)告的相關(guān)書(shū)寫(xiě)規(guī)范。二、實(shí)驗(yàn)內(nèi)容與要求根據(jù)系統(tǒng)的特點(diǎn),選取 javaWeb MVC 開(kāi)發(fā)模型實(shí)現(xiàn)該系統(tǒng);系統(tǒng)的編碼結(jié)構(gòu):邊界類: 1 個(gè) html (項(xiàng)目首頁(yè)),13 個(gè) jsp (中間跳轉(zhuǎn)的頁(yè)面),一個(gè) css(界面美化功能),一個(gè) javascript (控制輸入合法性) 。控制類:一個(gè) servlet類(連接邊界類和實(shí)體類)實(shí)體類:一個(gè) datebase類(連接數(shù)據(jù)庫(kù)),一個(gè) bookinfo類(書(shū)本的增刪檢查操作)服務(wù)器采用 tomcat 。如下

2、圖展示:對(duì)系統(tǒng)進(jìn)行測(cè)試分析,并對(duì)系統(tǒng)功能實(shí)施測(cè)試,編寫(xiě)測(cè)試用例,系統(tǒng)已經(jīng)實(shí)現(xiàn)可以讓手機(jī)電腦一起訪問(wèn)并做操作;撰寫(xiě)實(shí)驗(yàn)報(bào)告,同時(shí)需要了解測(cè)試報(bào)告相應(yīng)的規(guī)范與寫(xiě)法。下面是一些界面的 展示(沒(méi)有全部展示):登錄頁(yè)面顧客首頁(yè)購(gòu)買(mǎi)頁(yè)面訂單頁(yè)面查詢頁(yè)面查詢結(jié)果管理員頁(yè)面添加圖書(shū)頁(yè)面添加圖書(shū)信息不完整頁(yè)面三、完整開(kāi)發(fā)代碼 (按照上面截圖部署即可實(shí)現(xiàn))Table.css:bodybackground: #ffffff;margin: 15;body,table,th,td,input,select,textareafont-family: Tahoma,Verdana,Arial,Helvetica,sans

3、-serif;font-size: 12px;table.defaultborder: 1px solid #3366CC;border-collapse: collapse;width: 80%;table.default tdpadding: 2 5 2 5;height: 26px;text-align: center;border: 1px solid #ffffff;background-color: #f0f0f0;table.default tr.title tdfont-weight: bold;text-align: center;background: #99CCFF;co

4、lor: red;border: 1px solid #ffffff;white-space: nowrap;height: 26px;table.default th.itemfont-weight: bold;color: #333333;text-align: center;vertical-align: top;padding: 10px;font-size: 14px;xyh.css:body font-family: Arial, Helvetica, sans-serif;font-size:12px;color:#666666;background:#fff;text-alig

5、n:center;* margin:0;padding:0;a color:#1E7ACE;text-decoration:none; a:hover color:#000;text-decoration:underline;h3 font-size:14px;font-weight:bold;pre,p color:#1E7ACE;margin:4px;input, select,textarea padding:1px;margin:2px;font-size:11px;.buttompadding:1px 10px;font-size:12px;border:1px #1E7ACE so

6、lid;background:#D0F0FF;#formwrapper width:450px;margin:15px auto;padding:20px;text-align:left;border:1px solid #A4CDF2;fieldset padding:10px;margin-top:5px;border:1px solid #A4CDF2;background:#fff;fieldset legend color:#1E7ACE;font-weight:bold;padding:3px 20px 3px 20px;border:1px solid #A4CDF2;backg

7、round:#fff;fieldset label float:left;width:120px;text-align:right;padding:4px;margin:1px;fieldset div clear:left;margin-bottom:2px;.input width:120px;.enter text-align:center;.clear clear:both;Common.js:function isNum(num)for(i=0;i9|c0)return false;return true;function check()alert (no id!);return f

8、alse;alert(no name!);return false;alert(no author!);return false;alert(no press!);return false;alert(no date!)return false;if(!isNum(form1.price)alert(price is wrong!)return false;if(!isNum(form1.account)alert(account is wring!)return false;Bookinfo.java:package bean;public class bookinfoprivate Str

9、ing id;private String name;private String author;private String press;private String date;private int price;private int account;public void setName(String name) = name;public String getName() return name;public void setAuthor(String author) this.author = author;public String getAuthor() return autho

10、r;public void setDate(String date) this.date = date;public String getDate() return date;public void setPress(String press) this.press = press;public String getPress() return press;public void setId(String id) this.id = id;public String getId() return id;public void setAccount(int acount) this.accoun

11、t = acount;public int getAccount() return account;public void setPrice(int price) this.price = price;public int getPrice() return price;public static ArrayList getbooklist()ArrayList list=new ArrayList();String sql=select * from book.bookshop;dbbean jdbc=new dbbean();ResultSet rs=jdbc.executeQuery(s

12、ql);trywhile(rs.next()bookinfo bi=new bookinfo();bi.setId(rs.getString(id);bi.setName(rs.getString(name);bi.setAuthor(rs.getString(author);bi.setPress(rs.getString(press);bi.setDate(rs.getString(date);bi.setPrice(rs.getInt(price);bi.setAccount(rs.getInt(account);list.add(bi);rs.close();catch(SQLExce

13、ption e)e.printStackTrace();jdbc.close();return list;通過(guò)編號(hào) 書(shū)名 作者來(lái)搜索publicstaticArrayListgetbookbyway(Stringid,Stringname,String author)ArrayList list=new ArrayList();String sql=null;int way=0;if (!id.equals()way=way+1;if (!name.equals()way=way+10;if (!author.equals()way=way+100;if (way=1|way=11|way=1

14、01)sql=select * from book.bookshop where id=+id+;if (way=10)sql=select* from book.bookshopwhere name like%+name+%;if (way=100)sql=select* from bookshop where authorlike%+author+%;if (way=110)sql=select * from bookshop where name like %+name+% andauthor like %+author+%;dbbean jdbc=new dbbean();Result

15、Set rs=jdbc.executeQuery(sql);trywhile(rs.next()bookinfo bi=new bookinfo();bi.setDate(rs.getString(date);bi.setPress(rs.getString(press);bi.setAuthor(rs.getString(author);bi.setName(rs.getString(name);bi.setId(rs.getString(id);bi.setPrice(rs.getInt(price);bi.setAccount(rs.getInt(account);list.add(bi

16、);rs.close();catch(SQLException e)jdbc.close();return list;public static bookinfo getbookbyid(String id)String sql=select * from book.bookshop where id=+id+;dbbean jdbc=new dbbean();ResultSet rs=jdbc.executeQuery(sql);bookinfo bi = new bookinfo();tryif(rs.next()bi.setDate(rs.getString(date);bi.setPr

17、ess(rs.getString(press);bi.setAuthor(rs.getString(author);bi.setName(rs.getString(name);bi.setId(rs.getString(id);bi.setPrice(rs.getInt(price);bi.setAccount(rs.getInt(account);rs.close();catch(SQLException e)jdbc.close();return bi;publicstaticintupdatebook(Stringid,Stringauthor,String press,String d

18、ate,int price,int account)Stringsql=updatebook.bookshopname,String setname=+name+,author=+author+,press=+press+,date=+date+,price=+price+,account=+account+ where id=+id+;dbbean jdbc=new dbbean();result=jdbc.executeUpdate(sql);return result;public static int deletebook(String id)int result=0;String s

19、ql=delete from book.bookshop where id=+id+;dbbean jdbc=new dbbean();result=jdbc.executeUpdate(sql);return result;public static int addbook(String id,String name,String author,Stringpress,String date,int price,int account)int result=0;Stringsql=insertintobook.bookshop(id,name,author,press,date,price,

20、account)values(+id+,+name+,+author+,+press+,+date+,+price+,+account+);dbbean jdbc=new dbbean();result=jdbc.executeUpdate(sql);return result;Dbbean.java:package bean;import java.lang.*;import java.sql.*;public class dbbeanprivate String name=root;private String password=xyh201268;private Connection c

21、onn=null;private Statement stmt=null;public dbbean()tryClass.forName(driverStr);conn=DriverManager.getConnection(connStr,name,password);stmt=conn.createStatement();catch(Exception ex)public int executeUpdate(String s)int result=0;tryresult=stmt.executeUpdate(s);catch(Exception ex)return result;publi

22、c ResultSet executeQuery(String s)ResultSet rs=null;tryrs=stmt.executeQuery(s);catch(Exception ex)return rs;public void close()trystmt.close();conn.close();catch(Exception ex)Servl et.java:package servlets;import java.lang.*;/*Created by Administrator on 14-5-31.*/public class Servlet extends HttpSe

23、rvlet protected void doGet(HttpServletRequest request, HttpServletResponseresponse) throws ServletException, IOException doPost(request, response);protectedvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse) throws ServletException, IOException request.setCharacterEncoding(utf-8);Strin

24、g action=request.getServletPath();if(action.equals(/servlets/depend.do)String value=request.getParameter(password);if(value.equals(123)request.setAttribute(list, list);request.getRequestDispatcher(/manager.jsp).forward(request,response);elserequest.setAttribute(list, list);request.getRequestDispatch

25、er(/reader.jsp).forward(request,response);else if (action.equals(/servlets/list_m.do)request.setAttribute(list, list);request.getRequestDispatcher(/manager.jsp).forward(request,response);else if (action.equals(/servlets/list_r.do)request.setAttribute(list, list);request.getRequestDispatcher(/reader.

26、jsp).forward(request,response);else if(action.equals(/servlets/edit.do)String id =request.getParameter(id);request.setAttribute(bi,bi);request.getRequestDispatcher(/edit.jsp).forward(request,response);else if(action.equals(/servlets/update.do)String id=request.getParameter(id);String name=request.ge

27、tParameter(name);String author=request.getParameter(author);String press=request.getParameter(press);String date=request.getParameter(date);String s_price=request.getParameter(price);String s_account=request.getParameter(account);int price=Integer.parseInt(s_price);int account=Integer.parseInt(s_acc

28、ount);if (r=1)request.getRequestDispatcher(/success_m.jsp).forward(request,response);elserequest.getRequestDispatcher(/failure_m.jsp).forward(request,response);else if (action.equals(/servlets/delete.do)String id=request.getParameter(id);if (r=1)request.getRequestDispatcher(/success_m.jsp).forward(r

29、equest,response);elserequest.getRequestDispatcher(/failure_m.jsp).forward(request,response);else if (action.equals(/servlets/add.do)String id=request.getParameter(id);String name=request.getParameter(name);String author=request.getParameter(author);String press=request.getParameter(press);String dat

30、e=request.getParameter(date);String s_price=request.getParameter(price);String s_account=request.getParameter(account);int price=Integer.parseInt(s_price);int account=Integer.parseInt(s_account);if (r=1)request.getRequestDispatcher(/success_m.jsp).forward(request,response);elserequest.getRequestDisp

31、atcher(/failure_m.jsp).forward(request,response);else if (action.equals(/servlets/buy.do)String buy=request.getParameter(buy);request.setAttribute(bi,bi);request.getRequestDispatcher(/buy.jsp).forward(request,response);else if (action.equals(/servlets/search_r.do)String id=request.getParameter(id);S

32、tring name=request.getParameter(name);String author=request.getParameter(author);String user=request.getParameter(user);request.setAttribute(list, list);if (user.equals(reader)request.getRequestDispatcher(/sear_result_r.jsp).forward(request,response);if (user.equals(manager)request.getRequestDispatc

33、her(/sear_result_m.jsp).forward(request,response);else if (action.equals(/servlets/check_buy.do)String id=request.getParameter(id);String s_num_buy=request.getParameter(num_buy);int num_buy=Integer.parseInt(s_num_buy);if(bi.getAccount()=num_buy)request.setAttribute(bi,bi);request.setAttribute(s_num_

34、buy,s_num_buy);request.getRequestDispatcher(/success_buy.jsp).forward(request,response);elserequest.getRequestDispatcher(/failure_r.jsp).forward(request,response);else if (action.equals(/servlets/print_order.do)String id=request.getParameter(id);String s_num_buy=request.getParameter(s_num_buy);int n

35、um_buy=Integer.parseInt(s_num_buy);request.getRequestDispatcher(/print_order.jsp).forward(request,response);Add_book.jsp: 圖書(shū)信息 編號(hào)*( 不能為空 ) 書(shū)名*( 不能為空 ) 作者*(不能為空 ) 出 版 社 *( 不能為空 ) 出 版 日 期 *( 不能為空 ) 價(jià)格*(只能數(shù)字 ) 庫(kù)存*(只能數(shù)字 ) buy.jsp:訂單信息 編號(hào)inputtype=textvalue= name=name 書(shū) 名 input value= name=name type=text

36、 作 者 input value= name=author type=text 出 版 社 input value= name=press type=text出 版 日 期inputtype=textvalue= name=date 價(jià) 格 input value= name=price type=text 庫(kù) 存 input value= name=account type=text購(gòu)買(mǎi)數(shù)量name=num_buyedit.jsp:修改信息 編號(hào) inputtype=textvalue= name=id 書(shū)名 inputtype=textvalue= name=name 作者 inputty

37、pe=textvalue= name=author 出 版 社 inputtype=textvalue= name=press 出 版 日 期 inputtype=textvalue= name=date 價(jià)格 inputtype=textvalue= name=price 庫(kù)存 inputtype=textvalue= name=account failure_m.jsp:操作失敗 點(diǎn)擊返回 failure_r.jsp:購(gòu)買(mǎi)信息錯(cuò)誤 點(diǎn)擊返回 index.html:圖書(shū)商店用戶登錄顧客 / 管理員登錄用戶名 *(顧客不用輸入)密碼 *(顧客不用輸入 )記住我 您忘記密碼 ?友請(qǐng) 連接 sina Copyright 2014-2015NETWORK.席燚海鄧勻翔袁野 manager.jsp:添加圖書(shū) ahref=/bookshop/search_r.jsp?user=點(diǎn)擊查詢 編號(hào) 書(shū)名 作者 出版社 出版日 期 價(jià) 格 庫(kù) 存 管理 %request.setCharacterEncoding(utf-8);ArrayListlist=(ArrayList)request.getAttribute(list);for(bookinfo bi:li

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論