超市商品管理系统源代码(共23页).docx
《超市商品管理系统源代码(共23页).docx》由会员分享,可在线阅读,更多相关《超市商品管理系统源代码(共23页).docx(23页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、精选优质文档-倾情为你奉上超市商品管理系统源代码 import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.sql.*;public class sale2 extends JFrame implements ActionListener /销售界面private JPanel sM=new JPanel();/supermarket面板JLabel label1,label2;JTextField field1,field2;JButton button1,button2;String num=nul
2、l,name=null,time=null,add=null,t1=null,t2=null,t3=null;int price=0,countBG,n1;/ 价格/商品的卖出数量private JTextArea goodsShow=new JTextArea();/文本区private JScrollPane jsp=new JScrollPane(goodsShow); /滚动区域 设定内容为 商品显示的文本区private JButton pS=new JButton("销售界面"),new JButton("销售管理"),new JButton
3、("商品管理"),new JButton("用户管理");/personty 按钮private JLabel CD=new JLabel("清单号",JLabel.CENTER),new JLabel("编号",JLabel.CENTER),new JLabel("名称",JLabel.CENTER),new JLabel("价格",JLabel.CENTER),new JLabel("生产日期",JLabel.CENTER),new JLabel(&q
4、uot;产地",JLabel.CENTER),new JLabel("数量",JLabel.CENTER);/帐单查询时的商品显示标签public sale2()label1=new JLabel("按编号查询",JLabel.CENTER);label2=new JLabel("按帐单查询",JLabel.CENTER);field1=new JTextField(30);field2=new JTextField(30);button1=new JButton("查询1");button2=new J
5、Button("查询2");sM.setLayout(null);field1.setBounds(100,120,150,22);field2.setBounds(600,120,150,22);label1.setBounds(100,90,150,30);label2.setBounds(600,90,150,30);button1.setBounds(260,120,80,22);button2.setBounds(760,120,80,22);button1.addActionListener(this);button2.addActionListener(thi
6、s);sM.add(label1);sM.add(label2);sM.add(field1);sM.add(field2);sM.add(button1);sM.add(button2);for(int i=0;i<4;i+)pSi.setBounds(550+i*110,50,100,22);sM.add(pSi);pSi.addActionListener(this);for(int i=0;i<7;i+)/6个标签的绘制CDi.setBounds(100+i*115,160,115,20);sM.add(CDi);jsp.setBounds(100,180,800,500)
7、;goodsShow.setLineWrap(true);addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent e) System.exit(0););sM.add(jsp);this.add(sM);this.setTitle("销售窗口");this.setResizable(false);this.setBounds(0,0,1024,768);this.setVisible(true);public void actionPerformed(ActionEvent p)
8、Connection con,con1;Statement sql,sql1;String url = "jdbc:odbc:driver=Microsoft Access Driver (*.mdb);DBQ=D:supermarket.mdb"ResultSet rs,rs1;if (p.getSource()=button1)String num=field1.getText();try Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");catch (ClassNotFoundException f)Sys
9、tem.out.println(""+f);try con=DriverManager.getConnection(url);sql=con.createStatement();rs=sql.executeQuery("SELECT count(goodsnum) FROM information where goodsnum='"+num+"'");while(rs.next()countBG=rs.getInt(1);System.out.println(countBG);rs=sql.executeQuery(&
10、quot;SELECT * FROM goods where num='"+num+"'");while(rs.next()name=rs.getString(2);price=rs.getInt(3);time=rs.getString(4);add=rs.getString(5);n1=1;con.close();catch (SQLException g)System.out.println(g);if (n1=1) goodsShow.append(" (物品销售量查询) "+num+" "+name
11、+" "+price+" "+time+" "+add+" "+countBG+"n");n1=0;else /goodsShow.setText(" ");num=null;name=null;price=0;time=null;add=null;JOptionPane.showMessageDialog(this," 输入错误n 请重新输入","提示",JOptionPane.WARNING_MESSAGE);if(p.getSou
12、rce()=pS0)View2 frame=new View2();dispose();if(p.getSource()=pS2)Frm_Main frame=new Frm_Main();dispose();if(p.getSource()=pS3)View3 frame=new View3();dispose();if (p.getSource()=button2)String numb=field2.getText();int num=Integer.parseInt(numb);try Class.forName("sun.jdbc.odbc.JdbcOdbcDriver&q
13、uot;);catch (ClassNotFoundException f)System.out.println(""+f);trycon=DriverManager.getConnection(url);sql=con.createStatement();rs=sql.executeQuery("SELECT goodsnum,count(goodsnum) FROM information where listnum="+num+" group by goodsnum");while(rs.next() con1=DriverMa
14、nager.getConnection(url);sql1=con1.createStatement();String number=rs.getString(1); countBG=rs.getInt(2);System.out.println(countBG+number+name+time+price+add);rs1=sql1.executeQuery("SELECT * FROM goods where num='"+number+"'");while (rs1.next()name=rs1.getString(2);price
15、=rs1.getint(3);time=rs1.getString(4);add=rs1.getString(5);goodsShow.append(" "+num+" "+number+" "+name+" "+price+" "+time+" "+add+" "+countBG+"n"); con1.close();con.close();catch (SQLException g)System.out.println(g);/ g
16、oodsShow.setText(" ");/ num=null;name=null;price=0;time=null;add=null;/ JOptionPane.showMessageDialog(this," 输入错误n 请重新输入","提示",JOptionPane.WARNING_MESSAGE);/ public class View2 extends JFrame implements ActionListener /销售界面String num=null,name=null,time=null,add=null,t1
17、=null,t2=null,t3=null;int price=0;int n1,n2,ap,n3;private JPanel sM=new JPanel(); /supermarket面板private JButton pS=new JButton("销售界面"),new JButton("销售管理"),new JButton("商品管理"),new JButton("权限管理");/personty 按钮private JTextArea goodsShow=new JTextArea(), searchSh
18、ow=new JTextArea(); /文本区private JScrollPane jsp=new JScrollPane(goodsShow); /滚动区域 设定内容为 商品显示的文本区private JTextField numSearch=new JTextField(),showGoods=new JTextField(); /商品查询/显示商品private JButton searchGoods=new JButton("搜索"),buyGoods=new JButton("购买"), clean=new JButton("清空
19、"), ok=new JButton("提交"),print=new JButton("打印并提交"); /查询按钮private JLabel goodsInformation=new JLabel("商品编码",JLabel.CENTER),new JLabel("商品名称",JLabel.CENTER),new JLabel("商品价格",JLabel.CENTER),new JLabel("生产日期",JLabel.CENTER),new JLabel(&q
20、uot;生产地",JLabel.CENTER) ;private JLabel goodsI=new JLabel("商品编码",JLabel.CENTER),new JLabel("商品名称",JLabel.CENTER),new JLabel("商品价格",JLabel.CENTER),new JLabel("生产日期",JLabel.CENTER),new JLabel("生产地",JLabel.CENTER) ; private JLabel allPrice=new JLab
21、el("商品总价:n ",JLabel.LEFT),label1=new JLabel("商品信息 ",JLabel.RIGHT),label2=new JLabel("购物信息 ",JLabel.RIGHT);public View2()sM.setLayout(null);for(int i=0;i<4;i+)pSi.setBounds(550+i*110,50,100,22);sM.add(pSi);pSi.addActionListener(this);jsp.setBounds(100,180,800,500);goo
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 超市 商品 管理 系统 源代码 23
限制150内