数据库系统课程设计-仓库管理系统-java_第1页
数据库系统课程设计-仓库管理系统-java_第2页
数据库系统课程设计-仓库管理系统-java_第3页
数据库系统课程设计-仓库管理系统-java_第4页
数据库系统课程设计-仓库管理系统-java_第5页
已阅读5页,还剩37页未读 继续免费阅读

下载本文档

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

文档简介

1、实验报告仓库管理系统实验课程数据库实验实验者1姓名班级学号实验者2姓名班级学号实验时间指导老师目录p3 要求 p4 参考资料阅读心得p6概述(设计思路、实现功能、运用技术)p7 实现及操作(关键代码解析、运行结果、类方法的介绍)p17存在问题和需要改善的地方p18附录(完整代码 包括 分布调试代码)要求:使用access、sql server、oracle、mysql等作后台数据库,选择asp、vb、vc、java等作为前台开发工具设计一个小型管理系统。所设计的小型管理系统应包含输入输出、查询、插入、删除等基本功能,功能越强大越好。根据题目的基本需求,设计数据库、编写程序,并写出详细的设计说明

2、书。每班以2人为一组自由分组,由班长将分组情况报到指导教师处;需要提交的文档资料:设计说明书每人一份(包括:参考资料的阅读心得,功能需求说明,设计思路,数据表结构及作用,数据关系图,存储过程代码及相关注释,设计体会);电子文档:可运行的,能实现全部或者主要基本功能的小型系统。课程设计说明书编写规范 : a. 需求分析:题目要求达到的功能,所提供的原始数据,需要输出的数据及样式等。b. 数据库设计:根据要求设计数据库的结构,包括:表、数据完整性、关系、视图。c. 开发方案选择:主要是前端开发平台的选择与方案的比较,至少比较两套方案。d. 安全性设计:登录用户、数据库用户、数据库角色、命令许可等方

3、面。e. 前台应用程序设计:要求至少完成通过前台程序实现对后台数据库的数据查询、插入、删除与更新。涉及到数据的所有操作要求采用存储过程的方式进行。f. 附录或参考资料:参考资料来源,阅读心得。参考资料阅读心得:参考资料(老师提供):2、 教材信息数据库高校的教材管理需要相应的数据库环境,请根据如下系统需求定义数据表结构及关系,并通过编写存储过程来实现其中的两项功能:1)、教材出入库(1)教材入库将教材内部识别号、入库时间,入库数,适用对象等信息输入到教材入库记录表中,并更新在库教材信息表。教材入库后把教材征订单相应项目做教材收到标记。(暂不处理订单中某教材只入库其中一部分的情况,即缺货情况。)

4、(2)教材出库教师或学生或班级或其它人员领用教材,需要把教材内部编号,教材代号,出库时间,出库数量,使用单位(指班级或教师,可多个班级或教师),用途,经办人等信息输入到教材出库记录表中。并同时更新教材信息表中的在库数量。为便于教材信息的录入,可通过班级名称、课程名称或教材名称查询到要出库的教材信息表中相应教材的内部编号。(3)教材信息录入将教材的内部识别号(由本系统自动维护),代号,书名,编著者,出版社,版次,定价,入库时间,入库数,适用对象等信息录入到系统的数据库中。2)、教材查询(1)在库教材查询查询教材在库情况:可按书名、代号等查询, 可查询某班级使用的教材及在库数量,可查询某课程使用的

5、教材及在库数量。可查询指定教材的在库数量,价值总额。可查询教材在库的统计信息:在库教材总数、种类总数、价值总额。(2)教材出库查询教材出库信息查询:按教材代号等信息查询教材出库情况,可查询某使用对象(包括班级、教师、部门、其他人员)的教材出库情况。可查询某时间范围内(学期、学年等)的教材出库情况。(3)教材历史查询查询指定书的在库及出入库的历史信息,也可按时间或时间范围查询教材入库情况。便于管理员掌握教材出入库情况。3)、教材订购(1)、生成教材订单根据输入的各专业班级课程教材选用信息、教材出版社信息生成订单。(2)、教材订单状态管理订单状态管理:可标记各订单为有效(款项发出),图书入库后标记

6、订单为到货,图书退回标记为退换货。4)、教材订单查询可查询指定学期教材订单的到货、缺货情况,查询订单未到教材的订货公司信息包括它的银行帐号、地址、联系人、联系方法等,以便与其联系。5)、其他相关数据:学生相关、课程相关、教师相关、班级相关、系部相关阅读心得 :我们的选题是仓库管理系统,和教材信息数据库大致相同,实现的功能略作添加;我们需要完成的任务:(1).这个实验本质就是设置合理的操作界面,实现对数据库的数据读取、修改、删除、更新等操作;(2). 系统的完备性和操作的安全性,是完善软件的关键,其中包括:插入相同信息 ;数据库中物品数量不足 ;管理员编号不存在 ;安全登录 ;不同角色的对数据库

7、的操作权限 ;等等问题,都是我们需要解决的基本问题;(3) 界面的美化和操作的快捷性和正确性 ;界面是给客户的第一感触,尽量的新颖并且符合客户要求 :(这里我们是学习,争取掌握多一点处理界面的函数,没有系统的规划) 如果美化界面是尽量的完善,那么操作的快捷性和正确性是必须要实现的,给客户一个合理的操作是成功的必备条件;(4) 分工与合作我们两个人都是java的初级学习者,不断的学习,分别设计不同的界面,相互交流实现效果的的经验;关于数据库的知识和sql语言的学习,都是我们要重新学习的;(5) 文档的处理和制作,也是我们要完成的重要任务,我们也是分工完成;概述1.设计思路:(1)仓库管理系统,实

8、现功能:入库登记 : 商品入库记录;出库登记 : 库存商品出库;在库商品查询 : 库存物品查询;出库入库信息查询 : 按时间,操作管理员查询操作信息;管理员信息管理 : 管理员的登记,查询,删除;(2).附加实现功能:登录界面 : 实现管理员员和客户的不同角色登录;界面的转换 : 分别创建不同的窗口,并及时删除浏览过的窗口;分角色设定使用权限: 管理员和客户的使用权限不同;(3).异常处理:操作错误 : 信息输入错误等;常规错误 : 仓库物品数量不足等;2.运用技术:(1) 界面实现 : java语言;(2) 数据路操作实现 :使用access2003,运用sql语言进行操作;实现及操作根据分

9、析,一共设计9个类,如下图,其中:数据库操作类:dbaccess :实现连接,查询修改等分步操作 ;getdbinfo :实现查询结果集的返回 ;操作界面类:enter :登录界面select : 功能选择界面instorehouse : 物品入库操作界面outstorehouse : 物品出库操作界面searchgoods : 物品查询界面outin :出入库查询界面managerinfo : 管理员信息管理界面分步实现说明:1. dbaccess类public statement getstatement(string dbpath) throws exception:返回连接数据库的状态

10、 ;public resultset executequery(statement stmt,string query) throws exception :返回查询结果集;public void executeupdate(statement stmt,string query) throws sqlexception :更新数据库 ;public void close() throws sqlexception :关闭数据库的连接 ;2. getdbinfo类private vectorvector rows ; 记录查询返回元组private vector columnheads ; 记

11、录查询返回结果的标题 /获取表头volumnheadspublic vector getcolumnheads() ;/获取表中内容public vector getrows() ;/ 更新数据库 public void executeupdate(statement stmt,string query) throws sqlexception ; 3. enter类private jframe frame ;private jbutton enterbutton ;private jbutton resetbutton;用于标识登陆角色的单选按钮private jradiobutton ra

12、diobutton1 ;private jradiobutton radiobutton2 ;private jtextfield nametext ;private jpasswordfield passwordtext ;表示登录身份:public static boolean ismanager = false ;实现效果:基本实现:(1)图片载入:jlabel label4 = new jlabel(); imageicon icon = new imageicon(e:studyjavaworkspacestorehouseabc.jpg);label4.seticon(icon);

13、(2)单选按钮:buttongroup group = new buttongroup();radiobutton1 = new jradiobutton(管理员,false);radiobutton2 = new jradiobutton(客户,true);group.add(radiobutton1) ;group.add(radiobutton2) ;4. instorehouse类基本成员变量:private jframe frame ;输入信息的11个文本框:private jtextfield text1 - 11; private jtextfield infotext ;pri

14、vate jbutton okbutton ;private jbutton backbutton ;设置日期格式:private static final string yyymmddhhmmss = yyyy/mm/dd hh:mm:ss;基本函数:/sql语句生成public string getsql()/自动生成插入时间 public string inserttime()/自动生成入库idpublic string inhouseid()/清除文本框public void clear()实现效果:基本功能实现:监听器的设定:public void actionperformed(a

15、ctionevent e) object source = e.getsource() ; if(source = okbutton) try dbaccess db=new dbaccess(); string dbpath=e:studyjavaworkspacestorehousestorehouse.mdb; statement stmt=db.getstatement(dbpath); string query = getsql(); db.executeupdate(stmt,query) ; query = insertsql() ; db.executeupdate(stmt,

16、query) ; stmt.close(); db.close() ; infotext.settext(存储成功); clear() ; catch (exception ex) ex.printstacktrace() ; else if(source = backbutton) frame.dispose() ; new select() ; 5. outstorehouse类基本成员变量:private jframe frame ;private jbutton okbutton ;private jbutton backbutton ;private jtextfield text1

17、;private jtextfield text2;private jtextfield text3;private jtextfield text4;private static final string yyymmddhhmmss = yyyy/mm/dd hh:mm:ss;private integer num ; /修改数据里中数量的临时变量基本函数:同instorehouse雷同实现效果:基本功能实现:处理物品编号不存在,以及数量不足的问题:public void actionperformed(actionevent e)object source = e.getsource()

18、;if(source = okbutton)trydbaccess db=new dbaccess(); string dbpath=e:studyjavaworkspacestorehousestorehouse.mdb; string query=getgoodssql(); statement stmt=db.getstatement(dbpath); resultset rs=db.executequery(stmt, query); if(!(rs.next()/判断数据库中是否有内容joptionpane.showmessagedialog(null, 输入货物编号不存在, 提示信

19、息,joptionpane.information_message);text3.settext(操作失败);clear() ;else/判断仓库物品是否够/这里实验了很多次 为什么 只有num = 放在这里才可以呢if(num = integer.valueof(rs.getstring(1).intvalue() - integer.valueof(text2.gettext().intvalue() 0)joptionpane.showmessagedialog(null, 仓库货物不足, 提示信息,joptionpane.information_message);clear() ;te

20、xt3.settext(操作失败);elsequery = getsendoutsql() ;db.executeupdate(stmt, query) ;query = updategoodssql(num) ;db.executeupdate(stmt, query) ;text3.settext(操作成功); stmt.close() ; db.close() ; catch (exception ex) ex.printstacktrace() ; else if(source = backbutton)frame.dispose() ;new select() ;解析:这里应用到数据

21、类型的转变,string 到int double的转化;还可以应用其他方法:如: rs.getint(3); 直接读取数据库中的 int类型; rs.getdouble(4) :直接读取double类型6. searchgoods类基本成员函数:private jframe frame ;private jscrollpane jsp ;private jcombobox namelist ;private jcombobox typelist ;private jcombobox productlist ;private jtextfield counttext ;private jtext

22、field valuetext ;private jbutton okbutton ;private jtable table ;private defaulttablemodel model ;private jbutton backbutton ;private vector rows; /表行值private vector columnheads;/ 表列名/查询使用 :string str1,str2,str3 ;基本函数实现相同;实现效果:7. outin类基本函数变量:private jframe frame ;private jradiobutton inbutton ;priv

23、ate jradiobutton outbutton;private jbutton okbutton ;private jbutton backbutton ;private jcombobox combox1 ;private jcombobox combox2 ;private jtable table ;private vector rows; /表行值private vector columnheads;/ 表列名private defaulttablemodel model ;private jscrollpane jsp ;privatestring str1 = null ,s

24、tr2 = null ; /查询使用private boolean flag = false ;private int tmp = 0 ;private static final string yyymmddhhmmss = yyyy/mm/dd;实现效果:基本实现:时间字符创的分割处理 ;8. select类基本成员变量private jbutton button1 ;private jbutton button2 ;private jbutton button3 ;private jbutton button4;private jbutton button5 ;private jbutto

25、n button6 ;private jtextfield text ;private jframe frame ;实现效果:基本实现:界面效果实现:infolabel.sethorizontalalignment(swingconstants.center); infolabel.setbackground(color.gray) ;text.setbackground(color.gray) ;text.setforeground(color.cyan) ;text.setfont(new font(宋体,font.hanging_baseline,20);9. managerinfo 类

26、 基本函数:private jframe frame ;private jtabbedpane tabbedpane ;private jlabel label1 ;private jlabel label2 ;private jlabel label3 ;private jpanel panel1 ;private jpanel panel2 ;private jpanel panel3 ;private jcombobox agebox ;private jcombobox workagebox ;private jcombobox postionbox ;private jtextfie

27、ld text21 ;private jtextfield text22 ;private jtextfield text23 ;private jtextfield text24 ;private jtextfield text25 ;private jtextfield text26 ;private jtextfield text27 ;private jtextfield text28 ;private jtextfield text31 ;private jtextfield text32 ;private jbutton button11 ;private jbutton butt

28、on12 ;private jbutton button21 ;private jbutton button31 ;private jbutton backbutton ;private jtable table ;private vector rows; /表行值private vector columnheads;/ 表列名private defaulttablemodel model ;private jscrollpane jsp ;privatestring str1= null,str2 = null ,str3 = null ; /查询使用基本功能函数:这里的函数处理和上面的相同

29、,只是在布局上采用了jtablepanle面板,将三个功能加在同一个窗口里;实现效果:处理问题:要删除的管理员信息不存在:if(source = button31)boolean deletestate = false ;try dbaccess db=new dbaccess(); string dbpath=e:studyjavaworkspacestorehousestorehouse.mdb; string query = select * from manager where 编号 = + + text31.gettext() + ; statement stmt=db.getsta

30、tement(dbpath); resultset rs=db.executequery(stmt, query); while(rs.next() if(rs.getstring(1).equals(text31.gettext() query = delete from manager where 编号 = + + text31.gettext() + ; db.executeupdate(stmt,query) ; text31.settext(); text32.settext(删除成功); deletestate = true ; stmt.close(); db.close() ;

31、 catch (exception ex) ex.printstacktrace() ; if(deletestate = false) text32.settext(输入编号不存在); text31.settext(); 解析:在删除之前,对数据库进行检查,判断 管理员编号 是否存在 ;存在问题和需要完善的问题附录 : 代码实现 42dbaccess.java文件import java.sql.connection;import java.sql.drivermanager;import java.sql.resultset;import java.sql.sqlexception;impo

32、rt java.sql.statement;public class dbaccess public connection conn=null; / 连接未加密的数据库 public statement getstatement(string dbpath) throws exception class.forname(sun.jdbc.odbc.jdbcodbcdriver); string dburl = jdbc:odbc:driver= microsoft access driver (*.mdb); + dbq=+dbpath;/ 此为no-dsn方式 / string dburl

33、=jdbc:odbc:odbcname;/此为odbc连接方式 conn = drivermanager.getconnection(dburl); return conn.createstatement(); /连接加密的数据库 public statement getstatement(string dbpath,string password) throws exception class.forname(sun.jdbc.odbc.jdbcodbcdriver); string dburl =jdbc:odbc:driver=microsoft access driver (*.mdb

34、); + pwd=+password+;dbq=+dbpath;/ 此为no-dsn方式 / string dburl =jdbc:odbc:odbcname;/此为odbc连接方式 conn = drivermanager.getconnection(dburl); return conn.createstatement(); /* 查询数据库 */ public resultset executequery(statement stmt,string query) throws exception resultset rs=stmt.executequery(query); return

35、rs; /* * 更新数据库 */ public void executeupdate(statement stmt,string query) throws sqlexception stmt.executeupdate(query); /* * 关闭链接 */ public void close() throws sqlexception if(conn!=null) conn.close(); public static void main(string args) throws exception dbaccess db=new dbaccess(); string dbpath=e:

36、studyjavaworkspacestorehousestorehouse.mdb; string query=select * from manager; statement stmt=db.getstatement(dbpath); resultset rs=db.executequery(stmt, query); while(rs.next() system.out.println(rs.getstring(1) + t + rs.getstring(2) + t + rs.getstring(3) + t + rs.getstring(4) + t + rs.getstring(5

37、) + rs.getstring(6) + rs.getstring(7); enter.java文件import javax.swing.*;import java.awt.event.*;import java.awt.*;import java.sql.resultset;import java.sql.statement;public class enter implements actionlistenerprivate jframe frame ;private jbutton enterbutton ;private jbutton resetbutton;private jra

38、diobutton radiobutton1 ;private jradiobutton radiobutton2 ;private jtextfield nametext ;private jpasswordfield passwordtext ;public static boolean ismanager = false ;public enter()frame = new jframe(仓库管理系统登录界面);enterbutton = new jbutton(登录);resetbutton = new jbutton(重置);jlabel label1 = new jlabel(用户

39、名 :);jlabel label2 = new jlabel(密 码 :);jlabel label3 = new jlabel(登录方式 :);jlabel label4 = new jlabel();jlabel label5 = new jlabel();jlabel label6 = new jlabel();jlabel label7 = new jlabel();imageicon icon = new imageicon(e:studyjavaworkspacestorehouseabc.jpg);label4.seticon(icon);label5.settext(华润品牌

40、);label7.settext(追求卓越);label6.settext(中心软件,让您选择无悔的软件,感谢支持 晓伟o(_)o制作);nametext = new jtextfield();passwordtext = new jpasswordfield();/单选按钮buttongroup group = new buttongroup();radiobutton1 = new jradiobutton(管理员,false);radiobutton2 = new jradiobutton(客户,true);group.add(radiobutton1) ;group.add(radio

41、button2) ;/* * 字体等格式设置 */label1.sethorizontalalignment(swingconstants.center); label2.sethorizontalalignment(swingconstants.center);label3.sethorizontalalignment(swingconstants.center);label5.sethorizontalalignment(swingconstants.center) ;label6.sethorizontalalignment(swingconstants.center) ;label1.

42、setfont(new font(宋体,font.hanging_baseline,30);label2.setfont(new font(宋体,font.hanging_baseline,30);label5.setfont(new font(华文行楷,font.hanging_baseline,40);label7.setfont(new font(华文行楷,font.hanging_baseline,40);label5.setforeground(color.red);label7.setforeground(color.red);/* * 局部布局 */label4.setbound

43、s(0,0,800,90);label5.setbounds(0,100,200,100);label7.setbounds(0,200,200,100);label6.setbounds(0,300,800,100) ;label1.setbounds(220,110,150,60);label2.setbounds(220,180,150,60);nametext.setbounds(400,120,200,40);passwordtext.setbounds(400,190,200,40);label3.setbounds(200,250,150,40);radiobutton1.set

44、bounds(350,250,100,40);radiobutton2.setbounds(350,300,100,40);enterbutton.setbounds(460,270,150,40);resetbutton.setbounds(620,270,150,40) ;/* * 增加监听器 */enterbutton.addactionlistener(this);resetbutton.addactionlistener(this);/* * 整体布局 */container ctn = frame.getcontentpane();ctn.setlayout(null);ctn.a

45、dd(label1) ;ctn.add(label2) ;ctn.add(nametext) ;ctn.add(passwordtext) ;ctn.add(label3) ;ctn.add(label4);ctn.add(label5);ctn.add(label6);ctn.add(label7);ctn.add(radiobutton1);ctn.add(radiobutton2) ;ctn.add(enterbutton) ;ctn.add(resetbutton) ;frame.setvisible(true);frame.setbounds(400,200,800,400);fra

46、me.setdefaultcloseoperation(jframe.exit_on_close);public void actionperformed(actionevent e)boolean tmp = false ;object source = e.getsource();if(source = enterbutton)trydbaccess db=new dbaccess(); string dbpath=e:studyjavaworkspacestorehousestorehouse.mdb; string query=select * from host; statement

47、 stmt=db.getstatement(dbpath); resultset rs=db.executequery(stmt, query); while(rs.next() if(nametext.gettext().equals(rs.getstring(1) & passwordtext.gettext().equals(rs.getstring(2) tmp = true ; select select = new select(); this.dispose() ; break ; stmt.close() ; db.close() ; catch (exception ex)

48、ex.printstacktrace() ; if(tmp = false ) joptionpane.showmessagedialog(null, 输入密码或用户名错误, 登录信息,joptionpane.information_message); nametext.settext(); passwordtext.settext() ; else if(source = resetbutton)nametext.settext();passwordtext.settext() ;else if(source = radiobutton1)ismanager = true ;else if(source = radiobutton2)ismanager = false ;public void dispose()this.frame.dispose();public static boolean ismanager()return ismanager ;public static void main(string args)enter test = new enter();getdbinfo.java 文件import java.sql.*;import java.util.vector;import java.sql.drivermanager;im

温馨提示

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

评论

0/150

提交评论