《Java期末课程设计-超市进销存管理系统.pdf》由会员分享,可在线阅读,更多相关《Java期末课程设计-超市进销存管理系统.pdf(118页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、Java 程序设计 期末课程设计报告 题 目 超市进销存管理系统 班 级:13 级信息安全班 学 号:姓 名:成 绩:完成时间:2014 年 12 月 目 录 一、需求分析.错误!未定义书签。二、系统简介.错误!未定义书签。三数据准备.错误!未定义书签。四、数据库结构.错误!未定义书签。五、系统实现与核心代码.错误!未定义书签。六、系统的运行结果.错误!未定义书签。七、心得与体会.错误!未定义书签。八、参考书目.错误!未定义书签。一。需求分析 企业进销存管理系统的主要工作,是对企业的进货、销售和库存以信息化的方式进行管理,最大限度的减少各个环境中可能出现的错误,有效减少盲目采购,降低采购成本、
2、合理控制库存、减少资金占用并提高市场灵敏度,使企业能够合理安排进、销、存的每个关键步骤,替身企业市场竞争力。针对经营管理中存在的问题,兰州华联超市对产品的进销存合理化提出了更高的要求。通过实际调查,要求企业进销存管理系统具有以下功能。界面设计美观大方,方便、快捷、操作灵活。实现强大的进销存管理,包括基本信息、进货、销售和库存管理.能够在不同的操作系统下运行,不局限于特定的平台.提供数据库备份与恢复功能。提供库存盘点功能。提供技术支持的联系方式,可以使用邮件进行沟通,或者直接连接到技术网站。二。分析与设计:(1)功能模块划分:本进销存管理系统划分为六个模块,分别为系统登陆模块,系统主窗体设计模块
3、,进货单模块,销售单模块,库存盘点模块和数据库备份与恢复模块,(2)数据库结构描述:企业进销存管理系统需要使用数据库存储和管理进销存过程中的所有信息,本企业进销存管理系统使用 Access 数据库系统作为后台数据库,数据库名称为 db_database28。其中包含了 14 张数据表两个视图。以下是系统主要涉及的六个数据库表:1供应商信息表:主要用于存储供应商详细信息,其结构如下表所示:User 表:Handle 表:Product 表:Stuff 表:Yield 表:空表等待插入数据.三.系统详细设计文档:1.系统流程图:(1)系统功能结构图:(2)系统业务流程图:(3)系统中的主要类及功能
4、:1。Item 公共类:Item 公共类是对数据表最常用的 ID 和 name 属性的封装,属于 swing列表,表格,下拉列表框等组件的赋值.该类重写了 toString()方法,在该方法中只输出 name 属性。但是在获取组件的内容时,获取的是 Item类的对象,从该对象中可以获取 ID 的属性,然后通过该属性到数据库中获取唯一的数据。2。数据模型公共类:数据模型公共类对应着数据库中不同的数据表,这些模型将被访问数据库的 Dao 类和程序中各个模块甚至各个组件使用,数据模型是对数据表所有字段的封装,它是纯粹的模型类,他也要重写 toString()方法,另外还要重写 hashCode()方
5、法和 equal()方法.它主要用于存贮数据,并通过相应的 getXXX()方法和 setXXX()实现不同属性的访问原则。3。Dao 公共类:Dao 类实现了数据库的驱动,连接,关闭和多个操作数据库的方法,Dao 类不需要创建对象,可以直接调用类中的所有数据库操作方法.Dao类自定义的主要方法有 getKhlnfo(Item item)方法,主要是获取客户信息,方法的返回值是 tKhlnfo 的对象,及客户信息的数据模型。getGyslnfo(Item item)方法,主要是获取供应商信息,返回值是Gyslnfo 类的对象,及供应商数据表的模型对象。getSplnfo(Item item)方
6、法,主要用于获取商品信息,返回值是 Splnfo 类的对象,及商品数据表的数据模型.getLogin(String name,String password)方法主要适用于判断登录用户的用户名与密码是否正确,返回值是boolean类型。insertSelllnfo(TbSellMain sellMain)方法,主要是添加销售信息到数据库中。restoreOrBackup(String sql)方法,此方法是设置数据库的模式为单用户连接模式,这样可以避免数据库恢复或备份时失败。checkLogin(String userStr,String passStr)方法,用于判断登录用户与密码是否正确。
7、(2)各个模块实现方法描述:1。系统登录模块 实现该模块的主要代码如下 package src;import java。awt.AlphaComposite;import java。awt。GradientPaint;import java。awt.Graphics;import java。awt.Graphics2D;import java。awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt。Image;import java.awt.RenderingHints;import java。awt。Toolk
8、it;import java。awt.event。ActionEvent;import java.awt.event。ActionListener;import java.awt.event.KeyEvent;import java.awt。event。KeyListener;import javax.swing。JComponent;import javax.swing。JFrame;import javax.swing.JOptionPane;import javax.swing.UIManager;public class AddUser private static final Str
9、ing logoon=添加用户”;private static final String helpt=添加”;private static final String logooff=”退出”;private static final String user=”用 户:;private static final String password=密 码:”;private static final String enterpwd=再次输入密码:;private javax。swing。JTextField userText=null;private javax.swing.JPasswordFie
10、ld userpwd=null;private javax。swing。JPasswordField enterpassword=null;private javax。swing.JPanel jp=new javax.swing.JPanel()final static long serialVersionUID=2309585L;public void paintComponent(Graphics g)super.paintComponent(g);if(!isOpaque()return;Graphics2D g2d=(Graphics2D)g;/int rule=AlphaCompo
11、site。SRC_OVER;AlphaComposite opaque=AlphaComposite.SrcOver;/AlphaComposite blend=AlphaComposite.getInstance(rule,0.6f);/AlphaComposite set=AlphaComposite.Src;int width=getWidth();int height=getHeight();GradientPaint gradientPaint=new GradientPaint(0,0,java.awt。Color。green,width/2,height/2,java。awt。C
12、olor。yellow,false);g2d.setComposite(opaque);g2d。setPaint(gradientPaint);g2d。fillRect(0,0,width,height);g2d。setRenderingHint(RenderingHints。KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);private javax。swing.JButton add=new javax。swing。JButton(helpt);private javax.swing。JButton cancle=new javax。
13、swing.JButton(logooff);private JFrame logo_Frame=new JFrame(logoon);public AddUser()/TODO 自动生成构造函数存根 try UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());catch(Exception exe)System。err.print(exe。getMessage());JFrame.setDefaultLookAndFeelDecorated(true);Toolkit tools=logo_Fr
14、ame。getToolkit();Image logo=tools。getImage(”res/logo.jpg”);logo_Frame=new JFrame(logoon);logo_Frame.setIconImage(logo);jp.setLayout(new GridBagLayout();javax.swing。ImageIcon pic=new javax。swing.ImageIcon(”res/logo1。jpg);javax.swing.JLabel picture=new javax.swing.JLabel(pic);setupComponent(picture,0,
15、0,GridBagConstraints.ABOVE_BASELINE_LEADING,1,true);javax.swing.JLabel users=new javax。swing.JLabel(user);setupComponent(users,0,1,1,1,false);javax.swing.JLabel pas=new javax。swing.JLabel(password);setupComponent(pas,0,2,1,1,false);javax.swing。JLabel enpas=new javax.swing.JLabel(enterpwd);setupCompo
16、nent(enpas,0,3,1,1,false);userText=new javax.swing。JTextField(12);userText.requestFocus();userText。addKeyListener(new KeyListener()public void keyTyped(KeyEvent e)public void keyReleased(KeyEvent e)public void keyPressed(KeyEvent e)if(e。getKeyChar()=KeyEvent.VK_ENTER)&(userText.getText().trim()!=)us
17、erpwd.requestFocus(););setupComponent(userText,1,1,1,1,false);userpwd=new javax。swing.JPasswordField(12);userpwd.addKeyListener(new KeyListener()public void keyTyped(KeyEvent e)public void keyPressed(KeyEvent e)if(e.getKeyChar()=KeyEvent.VK_ENTER)&(!userpwd.getPassword()。toString().trim().isEmpty()e
18、nterpassword。requestFocus();else userpwd。requestFocus();public void keyReleased(KeyEvent e));setupComponent(userpwd,1,2,1,1,false);enterpassword=new javax。swing.JPasswordField(12);enterpassword。addKeyListener(new KeyListener()public void keyTyped(KeyEvent e)public void keyReleased(KeyEvent e)public
19、void keyPressed(KeyEvent e)/String pwd=userpwd。getPassword()。toString().trim();/String epwd=enterpassword。getPassword().toString()。trim();if((e.getKeyChar()=KeyEvent.VK_ENTER)&((userpwd.getPassword()。toString().trim())=(enterpassword。getPassword().toString().trim()))add。requestFocus();else if(e。getK
20、eyChar()=(KeyEvent.VK_ENTER))&((userpwd。getPassword().toString().trim())!=(enterpassword.getPassword()。toString()。trim())userpwd.setText(”);enterpassword.setText(”);userpwd.requestFocus(););setupComponent(enterpassword,1,3,1,1,false);/logoin=new javax。swing.JButton(logoon);add。addKeyListener(new Key
21、Listener()public void keyTyped(KeyEvent e)public void keyReleased(KeyEvent e)public void keyPressed(KeyEvent e)if((e。getKeyChar()=KeyEvent.VK_ENTER))String users=userText.getText()。trim();String pwd=userpwd.getPassword()。toString().trim();String epwd=enterpassword。getPassword()。toString().trim();if(
22、users。isEmpty())javax。swing。JOptionPane.showMessageDialog(logo_Frame,”必须输入用户名!”,”输入用户名,JOptionPane.ERROR_MESSAGE);userText。requestFocus();if(pwd.isEmpty())javax.swing.JOptionPane.showMessageDialog(logo_Frame,”必须输入密码!”,输入密码,JOptionPane.ERROR_MESSAGE);userpwd.requestFocus();if(epwd.isEmpty())javax.swi
23、ng。JOptionPane.showMessageDialog(logo_Frame,第二个输入密码必须与第一个密码相同!”,”密码不一致,JOptionPane。ERROR_MESSAGE);enterpassword。requestFocus();boolean b=DBUtil.isExist(select user_name from user where user_name=+”+users+);if(b)javax。swing。JOptionPane.showMessageDialog(logo_Frame,”用户已经存在,请另外输入!,不能添加”,JOptionPane。ERR
24、OR_MESSAGE);userText。setText(”);userpwd.setText();enterpassword。setText();userText.requestFocus();int vale=DBUtil.getValue(select user_name from user where user_name=”+users+)+1;if(vale0)String sql=insert into user values(+vale+”,”+users+,”+pwd+”);boolean bo=USeDB.Update(sql);if(bo)JOptionPane.showC
25、onfirmDialog(logo_Frame,用户名添加成功!”););add.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e)String users=userText.getText().trim();String pwd=userpwd.getPassword()。toString()。trim();String epwd=enterpassword.getPassword()。toString()。trim();if(users.isEmpty())javax.swing.
26、JOptionPane。showMessageDialog(null,”必须输入用户名!”,输入用户名”,JOptionPane.ERROR_MESSAGE);userText。requestFocus();if(pwd。isEmpty())javax.swing.JOptionPane。showMessageDialog(null,”必须输入密码!,输入密码,JOptionPane.ERROR_MESSAGE);userpwd。requestFocus();if(epwd。isEmpty()javax。swing。JOptionPane.showMessageDialog(null,第二个输
27、入密码必须与第一个密码相同!”,”密码不一致”,JOptionPane.ERROR_MESSAGE);enterpassword。requestFocus();boolean b=DBUtil.isExist(select user_name from user where user_name=”+users+”);if(b)javax.swing.JOptionPane.showMessageDialog(logo_Frame,”用户已经存在,请另外输入!”,”不能添加,JOptionPane.ERROR_MESSAGE);userText。setText(”);userpwd。setTex
28、t();enterpassword.setText(”);userText.requestFocus();int vale=DBUtil。getValue(select user_name from user where user_name=+users+”)+1;if(vale0)String sql=”insert into user values(”+vale+”,”+users+,”+pwd+”);USeDB.UpdateDB(sql);boolean bo=DBUtil.isExist(select user_name from user where id=vale”);if(bo)
29、JOptionPane.showConfirmDialog(null,”用户名添加成功!”);JOptionPane.showConfirmDialog(null,用户名已经存在!);userText。setText(”);userpwd。setText(”);enterpassword.setText();userText。requestFocus(););setupComponent(add,0,4,1,1,true);/javax.swing。JButton exit=new javax.swing.JButton(logooff);cancle。addActionListener(ne
30、w ActionListener()public void actionPerformed(ActionEvent e2)logo_Frame。dispose();/System.exit(0););setupComponent(cancle,1,4,1,1,true);java.awt.Dimension d=tools.getScreenSize();int width=(int)(d.getWidth()-350)/2;int height=(int)(d.getHeight()240)/2;logo_Frame。add(jp);logo_Frame。setAlwaysOnTop(tru
31、e);logo_Frame。setLocation(width,height);logo_Frame。setSize(350,240);logo_Frame.pack();logo_Frame。validate();logo_Frame.setVisible(true);private void setupComponent(JComponent component,int gridx,int gridy,int gridwidth,int ipadx,boolean fill)final GridBagConstraints gridBagConstrains=new GridBagCons
32、traints();gridBagConstrains。gridx=gridx;gridBagConstrains。gridy=gridy;gridBagConstrains.insets=new java.awt.Insets(5,3,3,3);if(gridwidth1)gridBagConstrains。gridwidth=gridwidth;if(ipadx 0)gridBagConstrains。ipadx=ipadx;if(fill)gridBagConstrains。fill=GridBagConstraints.HORIZONTAL;jp。add(component,gridB
33、agConstrains);package src;import java。awt。AlphaComposite;import java。awt.GradientPaint;import java。awt.Graphics;import java。awt.Graphics2D;import java.awt.GridBagConstraints;import java。awt。GridBagLayout;import java.awt.RenderingHints;import java.awt。event.ActionEvent;import java。awt.event.ActionLis
34、tener;import java.awt。event.KeyEvent;import java。awt。event.KeyListener;import java.util。regex。Matcher;import java.util。regex。Pattern;import javax.swing。JPanel;import javax.swing。JComponent;public class createStuffQuitInterFace extends JPanel private final static long serialVersionUID=230000123423L;p
35、rivate javax。swing。JTextField stuff_id=null;private javax.swing.JTextField stuff_name=null;private javax.swing.JTextField stuff_company=null;private javax.swing。JTextField stuff_people=null;private javax。swing.JTextField check_people=null;private javax.swing。JTextField stuff_unit=null;private javax。
36、swing.JTextField stuff_value=null;private javax。swing.JTextField stuff_spec=null;private javax。swing。JTextField stuff_color=null;private javax。swing.JTextField stuff_place=null;private javax。swing。JTextField stock_date=null;private javax.swing.JTextField stuff_text=null;private javax。swing。JButton e
37、nter=null;private javax。swing。JButton clean=null;private javax。swing。JButton cancle=null;private String sql=null;public createStuffQuitInterFace()/TODO 自动生成构造函数存根 this.setLayout(new GridBagLayout();this.setBackground(java.awt.Color。PINK);javax.swing。JLabel stuff_id_label=new javax.swing.JLabel(”编 号:
38、”);setupComponent(stuff_id_label,0,0,1,1,true);stuff_id=new javax。swing.JTextField(10);stuff_id.requestFocus();stuff_id.addKeyListener(new KeyListener()public void keyReleased(KeyEvent e)if((e。getKeyChar()=KeyEvent。VK_ENTER)((stuff_id。getText().trim()!=)stuff_name。requestFocus();public void keyTyped
39、(KeyEvent e)public void keyPressed(KeyEvent e));setupComponent(stuff_id,1,0,1,1,true);javax.swing.JLabel stuff_name_label=new javax。swing.JLabel(原料名:”);setupComponent(stuff_name_label,2,0,1,1,true);stuff_name=new javax.swing。JTextField(10);stuff_name。addKeyListener(new KeyListener()public void keyTy
40、ped(KeyEvent e)public void keyPressed(KeyEvent e)public void keyReleased(KeyEvent e)if(e.getKeyChar()=KeyEvent。VK_ENTER)&(stuff_name。getText().trim()!=”))stuff_company。requestFocus(););setupComponent(stuff_name,3,0,1,1,true);javax.swing.JLabel stuff_company_label=new javax。swing。JLabel(生产商:);setupCo
41、mponent(stuff_company_label,4,0,1,1,true);stuff_company=new javax.swing.JTextField(10);stuff_company.addKeyListener(new KeyListener()public void keyTyped(KeyEvent e)public void keyPressed(KeyEvent e)public void keyReleased(KeyEvent e)if(e。getKeyChar()=KeyEvent。VK_ENTER)&(stuff_company.getText().trim
42、()!=))stuff_people。requestFocus(););setupComponent(stuff_company,5,0,1,1,true);javax。swing.JLabel stuff_people_label=new javax.swing.JLabel(”收货员:);setupComponent(stuff_people_label,6,0,1,1,true);stuff_people=new javax.swing.JTextField(10);stuff_people.addKeyListener(new KeyListener()public void keyT
43、yped(KeyEvent e)public void keyPressed(KeyEvent e)public void keyReleased(KeyEvent e)if((e.getKeyChar()=KeyEvent.VK_ENTER)(stuff_people。getText()。trim()!=”))check_people。requestFocus(););setupComponent(stuff_people,7,0,1,1,true);javax.swing。JLabel check_people_label=new javax。swing.JLabel(检验员:”);set
44、upComponent(check_people_label,0,1,1,1,true);check_people=new javax。swing。JTextField(10);check_people。addKeyListener(new KeyListener()public void keyTyped(KeyEvent e)public void keyPressed(KeyEvent e)public void keyReleased(KeyEvent e)if(e。getKeyChar()=KeyEvent。VK_ENTER)&(check_people.getText()。trim
45、()!=)stuff_unit。requestFocus(););setupComponent(check_people,1,1,1,1,true);javax。swing。JLabel stuff_unit_label=new javax。swing。JLabel(单 位:”);setupComponent(stuff_unit_label,2,1,1,1,true);stuff_unit=new javax。swing。JTextField(10);stuff_unit.addKeyListener(new KeyListener()public void keyTyped(KeyEven
46、t e)public void keyPressed(KeyEvent e)public void keyReleased(KeyEvent e)if(e。getKeyChar()=KeyEvent.VK_ENTER)&(stuff_unit。getText().trim()!=)stuff_value.requestFocus(););setupComponent(stuff_unit,3,1,1,1,true);javax.swing.JLabel stuff_value_label=new javax.swing.JLabel(”数 量:);setupComponent(stuff_va
47、lue_label,4,1,1,1,true);stuff_value=new javax.swing。JTextField(10);stuff_value。addKeyListener(new KeyListener()public void keyTyped(KeyEvent e)public void keyPressed(KeyEvent e)public void keyReleased(KeyEvent e)if((e.getKeyChar()=KeyEvent。VK_ENTER)&(stuff_value.getText()。trim()!=”))if(CheckValue(st
48、uff_value。getText().trim()stuff_spec.requestFocus();else javax.swing。JOptionPane。showMessageDialog(null,你的录入有误,请录入 0-9 的数值!”,”录入错误”,javax。swing。JOptionPane。ERROR_MESSAGE);stuff_value。setText();stuff_value。requestFocus(););setupComponent(stuff_value,5,1,1,1,true);javax。swing.JLabel stuff_spec_label=n
49、ew javax。swing。JLabel(”规 格:”);setupComponent(stuff_spec_label,6,1,1,1,true);stuff_spec=new javax。swing。JTextField(10);stuff_spec.addKeyListener(new KeyListener()public void keyTyped(KeyEvent e)public void keyPressed(KeyEvent e)public void keyReleased(KeyEvent e)if((e。getKeyChar()=KeyEvent。VK_ENTER)&
50、(stuff_spec.getText()。trim()!=)stuff_color.requestFocus(););setupComponent(stuff_spec,7,1,1,1,true);javax。swing.JLabel stuff_color_label=new javax。swing。JLabel(颜 色:”);setupComponent(stuff_color_label,0,2,1,1,true);stuff_color=new javax.swing.JTextField(10);stuff_color。addKeyListener(new KeyListener(