网上书店信息管理系统“加”代码“加”数据库表_第1页
网上书店信息管理系统“加”代码“加”数据库表_第2页
网上书店信息管理系统“加”代码“加”数据库表_第3页
网上书店信息管理系统“加”代码“加”数据库表_第4页
网上书店信息管理系统“加”代码“加”数据库表_第5页
已阅读5页,还剩168页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

学生姓名:蒋斌指导老师:罗永红摘要本课程设计主要是设计一个书店信息管理的系统,实现用户的注册、登加、删除、修改、查询及图书的购买等功能。程序设计平台初步实现了目标。TheDesignandImplementationofnformationagementSystemNameJiangBinAdvisorLuoYonghongAbstractThiscoursedesignismainlytomakeainformationmanagementsystemofaonlinebookstore,Thefunctionofthesystemincludebook’adding,deletingandqueryingandpurchasebooks.ProgramdesignplatformisWindowsXP,programminglanguageisJAVA,aretheconnecteddatabaseisOracle10g.Intheprogramprocess,Iadoptedtwosolutionofthestructuredandobject-oriented.Programrunthroughthedebugger,achievingtheinitialgoal.KeywordsDatabase;oracle10g;JAVA;OnlineBookstoreInformationManagement目录 1.1课题背景 11.2课程设计目的 1 结构分析 22.1需求分析 22.2功能模块图 3 3.1概念结构设计 4 实现 10 4.2登录界面 11 4.5书籍修改 134.6图书删除 144.7图书删除 144.8订单查询修改 15 19特别重要。因此网上书店的出现成为必然。统,以达到上述的目的。管理,修改管理,查询管理。登录,客户的购书等。与开发,采用Eclipse和oracle10g等软件为开发工具。通过对计算机硬件和软开发实践。在指导老师的帮助下,已经基本上成功地实现了设计任务书的要求,使得设计的数据库系统能够实现一般数据库的管理。构分析需求分析发设计的。通过对书籍信息管理,使客户能轻松购买书籍。经过综合分析,确定了网上书店信息管理系统的主要包括以下功能:(1)商家:此模块的主要功能是用于商家注册账号;此模块的主要功能是用于拥有商家账号的用户登陆系统对自己的书店进行管理;此模块的主要功能是用于商家发布一些新书共客户查看及购买;此模块的主要功能是用于商家修改自己书店书籍的信息;此模块的主要功能是用于商家删除一些书籍信息;此模块的主要功能是用于商家查询自己书店的书籍;此模块的主要功能是用于商家查询自己书店卖书的记录;(2)客户:此模块的主要功能是用于商家注册账号;此模块的主要功能是对拥有客户账号的用户登录;此模块的主要功能是用于客户查看所有商家的书籍信息;商家注册登录书籍查询书籍上传书籍修改书籍删除订单查询客户注册登录书籍查询购买书籍订单查询商家注册登录书籍查询书籍上传书籍修改书籍删除订单查询客户注册登录书籍查询购买书籍订单查询能用于客户购买书籍此模块的主要功能是用于客户查询自己的购书记录;能模块图上述的功能,可以设计出系统的总体功能模块,如图2.1所示,息管理系统 buyer_id库设计概念结构设计得该系统的E-R图,ER所示, pwdaddressbuyer_namebuyer_namebuyer pwdaddressamidamidumdd pricediscountnumyeridER得到总E-R图,如图3.5所示。逻辑结构设计根据上述的概念结构设计出逻辑结构,将E-R图转换为关系模型。r(1)商家信息表seller所示,varchar20)varchar20)pwdvarchar20)书店地址varchar200)所示,buyer_idvarchar20)buyer_namevarchar20)pwdvarchar20)客户住址varchar200)3-3所示,sidvarchar0)namevarchar0)price价格tum订单信息表order用来保存订单号、书籍编名等信息。表order的结构如表3-4所示,idsidvarchar0)varchar0)buyer_idum量数据库表的建立据tablesellerlleridvarcharprimarykeyernamevarcharpwdvarchar2(20),dressvarchartablebuyerbuyer_idvarchar(20)primarykey,buyer_namevarchar(20),pwdvarchar2(20),ressvarcharetablegoodsodsidintprimarykeyridvarcharoodsnamevarcharpriceint,ntintnumintconstraintfkselleridforeignkeyselleridreferencesseller(seller_id)tableorderseridintprimarykeydsidintridvarcharbuyer_idvarchar(20),numintconstraintfkgoodsidforeignkeygoodsidreferencesgoods(goods_id),constraintfksellersidforeignkeyselleridreferencesseller(seller_id),constraintfkbuyeridforeignkeybuyeridreferencesbuyer(buyer_id)该程序实现了网上书店信息管理系统应有的功能,即账号注册、登录功能、书籍查询、书籍添加、书籍删除、书籍修改、书籍购买功能。界面成功,如图4.1所示,图4.1注册界面实现注册功能的核心代码如下:/构建客户对象BuyerbuyernewBuyer();/设置客户的信息buyer.setId(fieldCus0.getText());buyer.setName(fieldCus1.getText());buyer.setPwd(fieldCus2.getText());buyer.setAddress(fieldCus3.getText());/构建BuyerDao对象BuyerDaodaonewBuyerDao();/把该客户插入到数据库中录界面成功,如图4.2所示,图4.2登录界面功时,进入主界面,实现登录功能的核心代码如下:/通过输入姓名和密码获取一个用户对象SellersellerSellerDaogetSelleruseNameTextgetTextpwsgetText));/判断队形是否为空/隐藏当前窗口blefalse/构建用户主窗口,并显示出来newSellerFramesetVisibletrue界面登录成功后商家和客户分别进入两个不同的主界面,如图4.3所示,图4.3主界面图4.3主界面界面主界面里面商家可以查看到自己的商品信息及商品出售后生成的订单信息,客户则可以浏览所有商家的商品信息和自己的购物记录。添加图4.4书籍添加界面心代码如下:/构建GoodsDao对象GoodsDaodaonewGoodsDao;/设置goods的属性goodssetDiscountIntegervalueOffieldDiscountgetText)));goodssetNamefieldNamegetText;goodssetNumIntegervalueOffieldNumgetText)));goodssetPriceIntegervalueOffieldPricegetText)));//调用dao.insertGoods()方法,把商品插入到数据库中insertGoodsgoods籍修改要用于商家修改自己的书籍的信息,如图4.5所示,图4.4书籍修改界面以对商品进行修改,实现修改功能的核心代码如下:odsDaoGoodsDaodaonewGoodsDao;/读取对应文本框的信息并设置到goods里面goodssetDiscountIntegervalueOffieldDiscountgetText)));goodssetNamefieldNamegetText;goodssetNumIntegervalueOffieldNumgetText)));goodssetPriceIntegervalueOffieldPricegetText)));/修改goods信息updateGoodsgoods6图书删除要用于商家对书籍进行删除操作,如图4.6所示,图4.6书籍删除界面当商家往文本框里输入书籍编号后,点击删除,则可以对书籍进行删除,下:/获取文本框中输入的书籍编号intidIntegerparseInt(field.getText());/构建GoodsDaoGoodsDaodaonewGoodsDao;/调用//调用deleteById方法,删除书籍eleteByIdid7图书删除要用于客户购买书籍,如图4.7所示,图4.7图书购买现客户对书籍的购买。如果书籍编号错误或商品数量不够时,系统会弹出提示,实现购书功能的核心代码如下:/构建GoodsDao对象GoodsDaodaonewGoodsDao;/构建goods对象GoodsgoodsnewGoods;/减少库存数量goodssetNumgoodsgetNumnum);/修改商品信息updateGoodsgoods/构建订单对象OrderDaoordernewOrderDao;/插入一条订单数据rderinserOerderByGoodsgoodsnum订单查询修改要用于客户查看生成的订单,如图4.8所示,序设计语言,它继承了C++语言面向对象技术的核心,Java舍弃了C++语言中容易引起错误的指针(以引用取代)、运算符重载(operatoroverloading)、多重继承(以接口取代)等特性,增加了垃圾回收器功能用于回收不再被引用的对象所占据的内存空间,使得程序员不用再为内存管理而担忧。在JavaSE1.5版本中,Java又引入了泛型编程(GenericProgramming)、类型安全的枚举、不定长参数和自动装/拆箱等语言特性。代码编译成二进制字节码(bytecode),然后依赖各种不同平台上的虚拟机来解释执行字节码,从而实现了“一次编译、到处执行”的跨平台特性[2]。leOracle数据库包括Oracle数据库服务器和客户端。Oracle数据库服务器:OracleServer是一个对象一关系数据库管理系统。它提供开放的、全面的、和集成的信息管理方法。每个Server由一个OracleDB和一个OracleServer实例组成。它具有场地自治性(SiteAutonomy)和提供数据存储透明机制,以此可实现数据存储透明性。每个Oracle数据库对应唯一的一个实例名SID,Oracle数据库服务器启动后,一般至少有以下几个用户:Internal,它不是一个真实的用户名,而是具有务,包括启动和关闭数据库;Sys,它是一个DBA用户名,具有最大的数据库System一个DBA用户名,权限仅次于Sys用户。客户端:必须连接到一服务器,该数据库称为本地数据库(LocalDB)。在网络环境下其它服务器上的DB称为远程数据库(RemoteDB)。用户要存取远程DB上的数据时,必须建立数据库链。Oracle结构。由于它们是相分离的,所以在管理数据的物理存储结构时并不会影响对逻辑存储结构的存取。存储结构模式对象是直接引用数据库数据的逻辑结构。模式对象包括这样一些结构:表、表关系形成了数据库的关系设计。数据块(Block):是数据库进行UO操作的最小单位,它与操作系统的块不Oracle数据库块为单位。段(Segment):是表空间中一个指定类型的逻辑存储结构,它由一个或多个范围组成,段将占用并增长存储空间。其中包括:数据段:用来存放表数据;索引段:用来存放表索引;用来存放中间结果;回滚段:用于出现异常时,恢复事务。范围(Extent):是数据库存储空间分配的逻辑单位,一个范围由许多连续范围[3]。一步学习了Java的基础语法以及熟悉了用Java编次再去做类似的东西我觉得我一定会做的更好。[1]萨师煊,王珊.数据库系统概论(第三版)[M].北京:高等教育出版社.YDanielLiangJavaM北京:机械工业出版社.2006.[3]夏帮贵,刘凡馨.JDBCAP数据库编程实材作教.北京:北京希望电子出版2001.[4]王立福.软件工程(第二版)[M].北京:北京大学出版社.2002.附录全部源代码packagecom.shoeShop.db;ortjavasqlConnectionortjavasqlDriverManagerortjavasqlSQLExceptionpublicclassConnect{privatestaticConnectioncon=null;privatestaticStringurl="jdbc:oracle:thin:@localhost:1521:ORCL";privatestaticStringdriver="oracle.jdbc.driver.OracleDriver";privatestaticStringuser="scott";privatestaticStringpwd="tiger";publicstaticConnectiongetConnection(){try{forNamedriverconDriverManagergetConnectionurluserpwd);}catch(ClassNotFoundExceptione){}catch(SQLExceptione){}returncon;}publicstaticvoidmain(String[]args){ctgetConnection}}packagecom.shoeShop.action;portjavaawteventActionEventportjavaawteventActionListenerortjavaxswingJPanelportcomshoeShopviewRegisterFramepublicclassdocMenuActionimplementsActionListener{RegisterFrameregisternullJPanelcusPanelnullJPaneldocPanelnullpublicdocMenuAction(RegisterFrameregister){thisregisterregister;thiscusPanel=register.cusPanel;thisdocPanelregister.docPanel;}publicvoidactionPerformed(ActionEvente){//TODOAuto-generatedmethodstubregister.flag=1;//System.out.println(register.flag);registerremovecusPanel);registeradddocPanel);anelupdateUI}}packagecom.shoeShop.dao;ortjavasqlConnectionortjavasqlResultSetortjavasqlSQLExceptionortjavasqlStatementportcomshoeShopdbConnectportcomshoeShopentityBuyerportcomshoeShopentitySellerpublicclassBuyerDao{privatestaticConnectionconn;privatestaticStatementstatement;privatestaticResultSetresultSet;/插入数据,用于注册publicintinsertBuyer(Buyerbuyer){intflag0;nnConnectgetConnectiontry{mentconncreateStatementStringsql="insertintobuyervalues+buyer.getId()+"','"+buyer.getName()+"','"+buyer.getPwd()+"','"+buyer.getAddress+"')";System.out.println("buyer"+sql);gstatementexecuteUpdatesqlntcloseclose}catch(SQLExceptione){//TODOAuto-generatedcatchblocktStackTrace}System.out.println(flag);returnflag}/通过用户名和密码查询,用于登录publicstaticBuyergetBuyer(Stringname,Stringpwd){nnConnectgetConnectionBuyerbuyernewBuyer();try{mentconncreateStatementStringsql="select*frombuyerwherebuyer_id='"+name+"'andpwd=dresultSetstatement.executeQuery(sql);whileresultSetnext()){buyer.setId(resultSet.getString("buyer_id"));buyer.setName(resultSet.getString("buyer_name"));buyer.setPwd(resultSet.getString("pwd"));buyer.setAddress(resultSet.getString("address"));}resultSetclose);ntcloseclose}catch(SQLExceptione){//TODOAuto-generatedcatchblocktStackTrace}returnbuyer}publicstaticvoidmain(String[]args){BuyerDaodaonewBuyerDao();SystemoutprintlndaogetBuyerzxk1"));////BuyerbuyernewBuyer();buyer.setId("lily");//buyer.setName("长理专卖");//buyer.setPwd("123456");//buyer.setAddress("湖南长沙");//dao.insertBuyer(buyer);}}packagecom.shoeShop.dao;ortjavasqlConnectionortjavasqlResultSetortjavasqlSQLExceptionortjavasqlStatementortjavautilArrayListportcomshoeShopdbConnectportcomshoeShopentityGoodsportcomshoeShopentitySellerportcomshoeShopimpUserpublicclassGoodsDao{privatestaticConnectionconn;privatestaticStatementstatement;privatestaticResultSetresultSet;/查询登录商家的所有商品,用于商家管理自己的商品publicArrayListgetAllGoods(){ArrayListlist=newArrayList();nnConnectgetConnectiontry{mentconncreateStatementStringsql="select*fromgoodsa,sellerbwherea.seller_id=b.seller_idandbselleridUsergetUserName)+"'";resultSetstatement.executeQuery(sql);whileresultSetnext()){sellernewSellerllersetNameresultSetgetStringsellernamelersetAddressresultSetgetStringaddressoodsgoodsnewGoodsssetSellersellergoodssetIdresultSetgetIntgoodsid));goodssetNameresultSetgetStringgoodsname);goodssetSelleridresultSetgetStringsellerid));goodssetDiscountresultSetgetIntdiscount;goodssetNumresultSetgetIntnum;goodssetPriceresultSetgetIntprice;//tprintlngoodstoStringtaddgoods}}catch(SQLExceptione){//TODOAuto-generatedcatchblocktStackTracetry{resultSetclose);ntcloseclose}catch(SQLExceptione){//TODOAuto-generatedcatchblocktStackTrace}}returnlist}/查询所有商家的所有商品.用于用户搜索商品publicArrayListgetAllSellerGoods(){ArrayListlist=newArrayList();nnConnectgetConnectiontry{mentconncreateStatementStringsql="select*fromgoodsa,sellerbwhereelleridbselleridresultSetstatement.executeQuery(sql);whileresultSetnext()){sellernewSellerllersetNameresultSetgetStringsellernamelersetAddressresultSetgetStringaddressoodsgoodsnewGoodsssetSellersellergoodssetIdresultSetgetIntgoodsid));goodssetNameresultSetgetStringgoodsname);goodssetSelleridresultSetgetStringsellerid));goodssetDiscountresultSetgetIntdiscount;goodssetNumresultSetgetIntnum;goodssetPriceresultSetgetIntprice;//}tprintlngoodstoStringtaddgoods}}catch(SQLExceptione){//TODOAuto-generatedcatchblocktStackTracetry{resultSetclose);ntcloseclose}catch(SQLExceptione){//TODOAuto-generatedcatchblocktStackTrace}}returnlist/根据商品号查询商品信息publicGoodsgetOneGoods(intid){oodsgoodsnewGoodsnnConnectgetConnectiontry{mentconncreateStatementStringsqlselectfromgoodswheregoodsid+id;resultSetstatement.executeQuery(sql);whileresultSetnext()){dssetIdidgoodssetNameresultSetgetStringgoodsname);goodssetPriceresultSetgetIntprice;goodssetNumresultSetgetIntnum;goodssetDiscountresultSetgetIntdiscount;goodssetSelleridresultSetgetStringsellerid"));goodssetNumresultSetgetIntnum;}}catch(SQLExceptione){//TODOAuto-generatedcatchblocktStackTracetry{resultSetclose);ntcloseclose}catch(SQLExceptione){//TODOAuto-generatedcatchblocktStackTrace}}returngoods;}/修改商品信息publicintupdateGoods(Goodsgoods){intflag0;nnConnectgetConnectiontry{mentconncreateStatementStringsqlupdategoodssetgoodsname'"+goods.getName()+"',pricegoodsgetPrice)iscount="+goods.getDiscount()+",num="+goods.getNum()+"wheregoodsidgoodsgetIdgstatementexecuteUpdatesql}catch(SQLExceptione){//TODOAuto-generatedcatchblocktStackTracetry{ntcloseclose}catch(SQLExceptione){//TODOAuto-generatedcatchblocktStackTrace}}returnflag}dpublicintdeleteById(intid){intflag0;nnConnectgetConnectiontry{mentconncreateStatementStringsqldeletegoodswheregoodsid+id;gstatementexecuteUpdatesql}catch(SQLExceptione){//TODOAuto-generatedcatchblocktStackTracetry{ntcloseclose}catch(SQLExceptione){//TODOAuto-generatedcatchblocktStackTrace}}returnflag}//添加publicintinsertGoods(Goodsgoods){intflag0;nnConnectgetConnectiontry{mentconncreateStatementStringsql="insertintogoodsvalues((selectmax(goods_id+1)fromgoodsUsergetUserName+"','"+goods.getName()+"',"+goods.getPrice()+","+goodsgetDiscountgoods.getNum()+")";gstatementexecuteUpdatesql}catch(SQLExceptione){//TODOAuto-generatedcatchblocktStackTracetry{ntcloseclose}catch(SQLExceptione){//TODOAuto-generatedcatchblocktStackTrace}}returnflag}publicstaticvoidmain(String[]args){oodsDaodaonewGoodsDao////////////////oodsgoodsnewGoodsgoodssetNamec;oodssetPriceUsersetUserName"niclascage");odssetDiscountoodssetNumprintlnmainmoutprintlniidaoinsertGoodsgoodsSystem.out.println(dao.deleteById(4));//Goodsgoods=newGoods();//goods.setId(1);//goods.setName("oracle");//goods.setPrice(50);//goods.setDiscount(8);//goods.setNum(5);System.out.println(dao.updateGoods(goods));etAllSellerGoodsSystem.out.println(dao.getOneGoods(1));}}packagecom.shoeShop.dao;ortjavasqlConnectionortjavasqlResultSetortjavasqlSQLExceptionortjavasqlStatementortjavautilArrayListportcomshoeShopdbConnectportcomshoeShopentityGoodsmportcomshoeShopentityOrderportcomshoeShopentitySellerportcomshoeShopimpUserpublicclassOrderDao{privatestaticConnectionconn;privatestaticStatementstatement;privatestaticResultSetresultSet;//插入publicintinserOerderByGoods(Goodsgoods,intnum){intflag0;nnConnectgetConnectiontry{mentconncreateStatementStringsql="insertintoordersvalues((selectmax(order_id+1)fromorders"+goods.getId()+",'"+goods.getSeller_id()+"','"+User.getUserName()+"',"+num)";gstatementexecuteUpdatesql}catch(SQLExceptione){//TODOAuto-generatedcatchblocktStackTracetry{ntcloseclose}catch(SQLExceptione){//TODOAuto-generatedcatchblocktStackTrace}}returnflag}/查询登录用户的所有订单publicArrayListgetOrder(){ArrayListlist=newArrayList();nnConnectgetConnectiontry{mentconncreateStatementStringsql="select*fromordersa,sellerb,goodscwhereaselleridbselleridanda.goods_id=c.goods_idanda.buyer_id=UsergetUserName";resultSetstatement.executeQuery(sql);whileresultSetnext()){OrderordernewOrderoodsgoodsnewGoodssellernewSellerordersetIdresultSetgetIntorderid);ordersetNumresultSetgetIntnumordersetGoodsidresultSetgetIntgoodsid));goodssetIdresultSetgetIntgoodsid));goodssetPriceresultSetgetShortprice;goodssetPriceresultSetgetIntprice;goodssetDiscountresultSetgetIntdiscount;goodssetNameresultSetgetStringgoodsname);llersetNameresultSetgetStringsellernamelersetAddressresultSetgetStringaddresssetSellersellerrsetGoodsgoods//tprintlnordertoString//addorder}}catch(SQLExceptione){//TODOAuto-generatedcatchblocktStackTracetry{resultSetclose);ntcloseclose}catch(SQLExceptione){//TODOAuto-generatedcatchblocktStackTrace}}returnlist}/查询登录商家的所有订单publicArrayListgetSellerOrder(){ArrayListlist=newArrayList();nnConnectgetConnectiontry{mentconncreateStatementStringsql="select*fromordersa,sellerb,goodscwhereaselleridbsellerid"+"anda.goods_id=c.goods_idanda.seller_id=UsergetUserName;resultSetstatement.executeQuery(sql);whileresultSetnext()){OrderordernewOrderoodsgoodsnewGoodssellernewSellerordersetIdresultSetgetIntorderid);ordersetNumresultSetgetIntnumordersetGoodsidresultSetgetIntgoodsid));ordersetBuyeridresultSetgetStringbuyerid);goodssetIdresultSetgetIntgoodsid));goodssetPriceresultSetgetShortprice;goodssetPriceresultSetgetIntprice;goodssetDiscountresultSetgetIntdiscount;goodssetNameresultSetgetStringgoodsname);llersetNameresultSetgetStringsellernamelersetAddressresultSetgetStringaddresssetSellersellerrsetGoodsgoodsaddorder}}catch(SQLExceptione){//TODOAuto-generatedcatchblocktStackTracetry{resultSetclose);ntcloseclose}catch(SQLExceptione){//TODOAuto-generatedcatchblocktStackTrace}}returnlist}publicstaticvoidmain(String[]args){OrderDaodaonewOrderDaoetOrder}}packagecom.shoeShop.dao;ortjavasqlConnectionortjavasqlResultSetortjavasqlSQLExceptionortjavasqlStatementportcomshoeShopdbConnectportcomshoeShopentitySellerpublicclassSellerDao{privatestaticConnectionconn;privatestaticStatementstatement;privatestaticResultSetresultSet;/插入数据,用于注册publicintinsertSeller(Sellerseller){intflag0;nnConnectgetConnectiontry{mentconncreateStatementStringsql="insertintosellervalues"+seller.getId()+"','"+seller.getName()+"','"+seller.getPwd()+"','"+seller.getAddress+"')";gstatementexecuteUpdatesqlntcloseclose}catch(SQLExceptione){//TODOAuto-generatedcatchblocktStackTrace}returnflag}/通过用户名和密码查询,用于登录publicstaticSellergetSeller(Stringname,Stringpwd){nnConnectgetConnectionsellernewSellertry{mentconncreateStatementStringsql="select*fromsellerwhereseller_id='"+name+"'andpwd='"+pwd+"'";resultSetstatement.executeQuery(sql);whileresultSetnext()){llersetIdresultSetgetStringselleridllersetNameresultSetgetStringsellernamelersetPwdresultSetgetStringpwdlersetAddressresultSetgetStringaddress}resultSetclose);ntcloseclose}catch(SQLExceptione){//TODOAuto-generatedcatchblocktStackTrace}returnseller}publicstaticvoidmain(String[]args){aodaonewSellerDaoSystem.out.println(dao.getSeller("蒋斌","654321"));Sellerseller=newSeller();//seller.setId("lily");//seller.setName("长理专卖");//seller.setPwd("123456");//seller.setAddress("湖南长沙");//dao.insertSeller(seller);}}packagecom.shoeShop.entity;**publicclassBuyer{privateStringid;privateStringname;privateStringaddress;privateStringpwd;publicStringgetPwd(){returnpwd}publicvoidsetPwd(Stringpwd){thispwdpwd;}publicStringgetId(){returnid}publicvoidsetId(Stringid){this.id=id;}publicStringgetName(){returnname}publicvoidsetName(Stringname){thisnamename;}publicStringgetAddress(){returnaddress}publicvoidsetAddress(Stringaddress){thisaddress=address;}publicStringtoString(){returnBuyer[id="+id+",name="+name+",address="+address"]";}}packagecom.shoeShop.entity;***publicclassGoods{privateintid;privateStringseller_id;privateSellerseller;privateStringname;privateintprice;privateintdiscount;privateintnum;publicSellergetSeller(){returnseller}publicvoidsetSeller(Sellerseller){thisseller=seller;}publicintgetDiscount(){returndiscount}publicvoidsetDiscount(intdiscount){this.discount=discount;}publicintgetNum(){returnnum}publicvoidsetNum(intnum){thisnumnum;}publicintgetId(){returnid}publicvoidsetId(intid){this.id=id;}publicStringgetSeller_id(){returnseller_id;}publicvoidsetSeller_id(Stringseller_id){thissellerid=seller_id;}publicStringgetName(){returnname}publicvoidsetName(Stringname){thisnamename;}publicintgetPrice(){returnprice}publicvoidsetPrice(intprice){thispriceprice;}publicStringtoString(){returnGoods[id="+id+",seller_id="+seller_id+",seller="seller",name="+name+",price="+price",discount="+discount+",num="+num+"]";}}packagecom.shoeShop.entity;***publicclassOrder{privateintid;privateintgoods_id;privateStringseller_id;privateStringbuyer_id;privateGoodsgoods;privateSellerseller;privateBuyerbuyer;privateintnum;publicintgetNum(){returnnum}publicvoidsetNum(intnum){thisnumnum;}publicGoodsgetGoods(){returngoods;}publicvoidsetGoods(Goodsgoods){thisgoods=goods;}publicSellergetSeller(){returnseller}publicvoidsetSeller(Sellerseller){thisseller=seller;}publicBuyergetBuyer(){returnbuyer}publicvoidsetBuyer(Buyerbuyer){thisbuyerbuyer;}publicintgetId(){returnid}publicvoidsetId(intid){this.id=id;}publicintgetGoods_id(){returngoods_id;}publicvoidsetGoods_id(intgoods_id){thisgoodsid=goods_id;}publicStringgetSeller_id(){returnseller_id;}packagecom.shoeShop.entity;publicvoidsetSeller_id(Stringseller_id){thissellerid=seller_id;}publicStringgetBuyer_id(){returnbuyerid;}publicvoidsetBuyer_id(Stringbuyer_id){thisbuyerid=buyer_id;}publicStringtoString(){returnOrder[id="+id+",goods_id="+goods_id+",seller_id="sellerid",buyer_id="+buyer_id+",goods="+goodsseller="+seller+",buyer="+buyer+",num="+num"]";}}**publicclassSeller{privateStringid;privateStringname;privateStringpwd;privateStringaddress;publicStringgetPwd(){returnpwd}publicvoidsetPwd(Stringpwd){thispwdpwd;}publicStringgetId(){returnid}publicvoidsetId(Stringid){this.id=id;}publicStringgetName(){returnname}publicvoidsetName(Stringname){thisnamename;}publicStringgetAddress(){returnaddress}publicvoidsetAddress(Stringaddress){thisaddress=address;}publicStringtoString(){returnSeller[id="+id+",name="+name+",pwd="+pwdaddress="+address+"]";}}packagecom.shoeShop.imp;publicclassUser{privatestaticintflag=0;privatestaticStringuserName;privatestaticStringpwd;publicstaticStringgetPwd(){returnpwd}publicstaticvoidsetPwd(Stringpwd){Userpwd=pwd;}publicstaticStringgetUserName(){returnuserName}publicstaticvoidsetUserName(StringuserName){UseruserName=userName;}publicstaticintgetFlag(){returnflag}publicstaticvoidsetFlag(intflag){User.flag=flag;}}packagecom.shoeShop.view;portjavaawteventActionEventportjavaawteventActionListenerortjavaxswingImageIconortjavaxswingJButtonortjavaxswingJFrameortjavaxswingJLabelortjavaxswingJOptionPaneortjavaxswingJTextFieldportcomshoeShopdaoGoodsDaoportcomshoeShopentityGoodspublicclassAddGoodsFrameextendsJFrame{privatestaticfinalGoodsGoods=null;privateJTextFieldfieldName=newJTextField(20);privateJTextFieldfieldPrice=newJTextField(20);privateJTextFieldfieldDiscount=newJTextField(20);privateJTextFieldfieldNum=newJTextField(20);privateJButtonbtSure=newJButton("确定");privateJButtonbtCancel=newJButton("取消");privateGoodsgoods=newGoods();publicAddGoodsFrame(){}privatevoidinit(){thissetSize320,330);thissetTitle商品添加");thissetIconImagenewImageIcon("images/1.png").getImage());thissetLayoutnull;thissetLocationRelativeTonull;thissetResizablefalse;//this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);thissetLayoutnull;tPanel}privatevoidsetContentPanel(){lbNamesetBounds,80,30);fieldNamesetBounds0,150,30);lbPricesetBounds90,80,30);fieldPricesetBounds0,150,30);lbDiscountsetBounds150,80,30);fieldDiscountsetBounds50,150,30);lbNumsetBounds200,80,30);fieldNumsetBounds00,150,30);btCancel.setBounds(30,250,70,30);btSure.setBounds(210,250,70,30);thisaddlbName;thisaddfieldName;thisaddlbPrice;thisaddfieldPrice;thisaddlbDiscount;thisaddfieldDiscount;thisaddlbNum);thisaddfieldNum;thisaddbtCancel;thisaddbtSure);btCancel.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){//TODOAuto-generatedmethodstubefalse}btSure.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){//TODOAuto-generatedmethodstuboodsDaodaonewGoodsDaogoodssetDiscountIntegervalueOffieldDiscountgetText);oodssetNamefieldNamegetTextgoodssetNumIntegervalueOffieldNumgetText);goodssetPriceIntegervalueOffieldPricegetText);nsertGoodsgoodsefalse//}}}publicGoodsgetGoods(){returngoods;}publicvoidsetGoods(Goodsgoods){thisgoods=goods;}publicstaticvoidmain(String[]args){UpdateFrameframe=newUpdateFrame();etVisibletrue}}packagecom.shoeShop.view;ortjavaawtBorderLayoutportjavaawtColorportjavaawteventActionEventportjavaawteventActionListenerortjavautilArrayListortjavaxswingImageIconortjavaxswingJButtonortjavaxswingJComboBoxortjavaxswingJFrameortjavaxswingJLabelortjavaxswingJMenuortjavaxswingJMenuBarortjavaxswingJMenuItemortjavaxswingJOptionPaneortjavaxswingJPanelortjavaxswingJScrollPaneortjavaxswingJTableortjavaxswingJTextFieldportcomshoeShopdaoGoodsDaoportcomshoeShopdaoOrderDaoportcomshoeShopentityGoodsmportcomshoeShopentityOrderpublicclassBuyerFrameextendsJFrame{privateJPanelgoodsPanel=newJPanel();//中间面板privateJPanelorderPanel=newJPanel();//订单面板privateJPanelsouthPanel=newJPanel();//南边用于方按钮的面板privateJMenuBarmenuBar=newJMenuBar();privateJMenugoodsMenu=newJMenu("商品管理");privateJMenuorderMenu=newJMenu("订单管理");privateJMenuItemgoodsMenuItem=newJMenuItem("商品购买");privateJMenuItemorderMenuItem=newJMenuItem("订单管理");//privateJButtonbtDelet=newJButton("删除");privateJButtonbtAdd=newJButton("购买");privateJComboBoxnumBox=newJComboBox(newString4","5","6","7","8","9"});//privateJButtonbtUpdate=newJButton("修改");privateJTextFieldfieldId=newJTextField(15);ObjectarnewObject80][8];ObjectornewObject80][9];publicBuyerFrame(){}privatevoidinit(){rthissetTitle网上鞋购系统");thissetIconImagenewImageIcon("images/1.png").getImage());thissetSize600,400);thissetDefaultCloseOperationJFrameEXIT_ON_CLOSE);thissetLocationRelativeTonull;thisaddmenuBarBorderLayout.NORTH);aneldsPanelsetBackgroundColorGRAYthisaddgoodsPanel,BorderLayout.CENTER);erPanelsetBackgroundColorLIGHTGRAYanelanelthisaddsouthPanel,BorderLayout.SOUTH);}//borderlayout北边面板设置privatevoidsetMenuBar(){menuBaraddgoodsMenu);dsMenuaddgoodsMenuItemgoodsMenuItem.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){//TODOAuto-generatedmethodstubremoveorderPanel;dsPanelsPanelupdateUI}menuBaraddorderMenu);MenuaddorderMenuItemorderMenuItem.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){//TODOAuto-generatedmethodstubremovegoodsPanel;erPanelPanelupdateUI}}//borderlayout南边面板设置privatevoidsetSouthPanel(){eladdfieldIdeladdnumBox//修改eladdbtAddbtAdd.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){//TODOAuto-generatedmethodstuboodsDaodaonewGoodsDaooodsgoodsnewGoodsifequalsfieldIdgetText))){JOptionPane.showMessageDialog(null,"请输入商品编号或商intidIntegerparseIntfieldIdgetText());intnumIntegerparseIntString)numBox.getSelectedItem());oodsdaogetOneGoodsidif(JOptionPane.showConfirmDialog(null,"您确定要购买吗?ifgoodsgetId){llifgoodsgetNumnumJOptionPane.showMessageDialog(null,"商品数量goodssetNumgoodsgetNumnumpdateGoodsgoodsOrderDaoordernewOrderDaoerinserOerderByGoodsgoodsnumJOptionPane.showMessageDialog(null,"购买成sPanelupdateUI}}}}}}//borderlayout中间商品面板设置privatevoidsetGoodsPanel(

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论