超市商品管理系统源代码.doc
《超市商品管理系统源代码.doc》由会员分享,可在线阅读,更多相关《超市商品管理系统源代码.doc(19页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、如有侵权,请联系网站删除,仅供学习与交流超市商品管理系统源代码【精品文档】第 19 页超市商品管理系统源代码 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
2、button1,button2;String num=null,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
3、("销售管理"),new JButton("商品管理"),new JButton("用户管理");/personty 按钮private JLabel CD=new JLabel("清单号",JLabel.CENTER),new JLabel("编号",JLabel.CENTER),new JLabel("名称",JLabel.CENTER),new JLabel("价格",JLabel.CENTER),new JLabel("生产日期"
4、;,JLabel.CENTER),new JLabel("产地",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(
5、"查询1");button2=new JButton("查询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)
6、;button2.addActionListener(this);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);
7、jsp.setBounds(100,180,800,500);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 ac
8、tionPerformed(ActionEvent p)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 (
9、ClassNotFoundException f)System.out.println(""+f);trycon=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(cou
10、ntBG);rs=sql.executeQuery("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(" (物品销售量查询) &q
11、uot;+num+" "+name+" "+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.W
12、ARNING_MESSAGE);if(p.getSource()=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
13、.jdbc.odbc.JdbcOdbcDriver");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");wh
14、ile(rs.next() con1=DriverManager.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()
15、name=rs1.getString(2);price=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
16、)System.out.println(g);/ goodsShow.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=nu
17、ll,time=null,add=null,t1=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=n
18、ew JTextArea(), searchShow=new JTextArea(); /文本区private JScrollPane jsp=new JScrollPane(goodsShow); /滚动区域 设定内容为 商品显示的文本区private JTextField numSearch=new JTextField(),showGoods=new JTextField(); /商品查询/显示商品private JButton searchGoods=new JButton("搜索"),buyGoods=new JButton("购买"), cl
19、ean=new JButton("清空"), ok=new JButton("提交"),print=new JButton("打印并提交"); /查询按钮private JLabel goodsInformation=new JLabel("商品编码",JLabel.CENTER),new JLabel("商品名称",JLabel.CENTER),new JLabel("商品价格",JLabel.CENTER),new JLabel("生产日期",JLab
20、el.CENTER),new JLabel("生产地",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
21、JLabel allPrice=new JLabel("商品总价: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.setBou
22、nds(100,180,800,500);goodsShow.setLineWrap(true);numSearch.setBounds(100,50,150,22);searchGoods.setBounds(260,50,60,22);searchGoods.addActionListener(this);buyGoods.setBounds(330,50,60,22);buyGoods.addActionListener(this);showGoods.setBounds(100,120,800,22);for (int b=0;b<5 ;b+ )goodsInformationb
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 超市 商品 管理 系统 源代码
限制150内