java商品管理系统Word版.doc

上传人:rrsccc 文档编号:9420068 上传时间:2021-02-24 格式:DOC 页数:16 大小:66KB
返回 下载 相关 举报
java商品管理系统Word版.doc_第1页
第1页 / 共16页
java商品管理系统Word版.doc_第2页
第2页 / 共16页
java商品管理系统Word版.doc_第3页
第3页 / 共16页
java商品管理系统Word版.doc_第4页
第4页 / 共16页
java商品管理系统Word版.doc_第5页
第5页 / 共16页
点击查看更多>>
资源描述

《java商品管理系统Word版.doc》由会员分享,可在线阅读,更多相关《java商品管理系统Word版.doc(16页珍藏版)》请在三一文库上搜索。

1、传播优秀Word版文档 ,希望对您有帮助,可双击去除!/代表各的主页面package com.gui;import java.awt.*;import javax.swing.*;import java.awt.event.*;import java.io.*;import java.nio.channels.ClosedSelectorException;import java.sql.*;import javax.swing.JFileChooser;import javax.swing.plaf.ScrollBarUI;import javax.swing.table.DefaultTa

2、bleColumnModel;import javax.swing.table.DefaultTableModel;import com.DateSystem.Good_data;import com.DateSystem.Goods;import com.DateSystem.Userdate;import java.util.List;public class Main extends JFrame implements ActionListener,AdjustmentListener/* * param args */主窗体组件MenuBar menuBar; Menu menu_xi

3、tong,menu_guanli,menu_gongju,menu_Help;MenuItem item_up_password, item_reLanding, item_exit;MenuItem item_input, item_find, item_delete;MenuItem item_jisuanqi, item_jishiben, item_beijing;MenuItem item_LookHelp, item_About;/录入界面要用的组件JPanel jp_btn,jp_main,jp_table,jp_text;JLabel lbl_id, lbl_name, lbl

4、_address, lbl_in_price, lbl_out_price, lbl_kucun, lbl_jinhuo, lbl_chuhuo;TextField text_id,text_name,text_address,text_in_price,text_out_price,text_kucun,text_jinhuo,text_chuhuo;JButton submit,reset,delete;JScrollPane jsp;JTable table;DefaultTableModel model;传播优秀Word版文档 ,希望对您有帮助,可双击去除!CardLayout c=n

5、ew CardLayout();JPanel card;/查找页面要用的组件JPanel jp1,jp2,jp3;JPanel jp2_main;JButton find_id,find_name,find_delete,find_all;JTextField text_find;JScrollPane jsp_find;JTable table_find;DefaultTableModel model_find;/背景更改要用的组件int r =255,g=255,b=255;TextField tfr,tfg,tfb;Scrollbar sbr,sbg,sbb;Panel display;

6、JPanel jp3_main;public Main()super(主窗口);menuBar=new MenuBar();menu_gongju=new Menu(工具);menu_guanli=new Menu(管理);menu_Help=new Menu(帮助);menu_xitong=new Menu(系统);item_About=new MenuItem(关于);item_beijing=new MenuItem(背景设置);item_LookHelp=new MenuItem(查看帮助);item_up_password=new MenuItem(修改密码);item_reLand

7、ing=new MenuItem(重新登录);item_exit=new MenuItem(退出系统);item_jishiben=new MenuItem(记事本);item_jisuanqi=new MenuItem(计算器);item_find=new MenuItem(查找);item_input=new MenuItem(录入);item_delete=new MenuItem(删除);/注册监听传播优秀Word版文档 ,希望对您有帮助,可双击去除!item_About.addActionListener(this);item_beijing.addActionListener(th

8、is);item_LookHelp.addActionListener(this);item_up_password.addActionListener(this);item_reLanding.addActionListener(this);item_exit.addActionListener(this);item_jishiben.addActionListener(this);item_jisuanqi.addActionListener(this);item_find.addActionListener(this);item_input.addActionListener(this)

9、;item_delete.addActionListener(this);menu_xitong.add(item_up_password);menu_xitong.add(item_reLanding);menu_xitong.add(item_exit);menu_guanli.add(item_input);menu_guanli.add(item_find);/menu_guanli.add(item_delete);menu_gongju.add(item_jisuanqi);menu_gongju.add(item_jishiben);menu_gongju.add(item_be

10、ijing);menu_Help.add(item_About);menu_Help.add(item_LookHelp);menuBar.add(menu_xitong);menuBar.add(menu_guanli);menuBar.add(menu_gongju);menuBar.add(menu_Help);setMenuBar(menuBar);setResizable(false);initComponents();/调用方法初始化界面Find();change_color();传播优秀Word版文档 ,希望对您有帮助,可双击去除!/查找功能的布局以及组建/this.setLay

11、out(new CardLayout();card=new JPanel();card.setLayout(c);card.add(1, jp_main);card.add(2, jp2_main);card.add(3, jp3_main);/this.getContentPane().add(Center, jp_main);this.add(card);this.setSize(1000, 500);this.setLocationRelativeTo(null);this.setVisible(true);this.setDefaultCloseOperation(JFrame.EXI

12、T_ON_CLOSE);/录入界面初始化private void initComponents() /构造面板System.out.println(pass);lbl_id=new JLabel(商品编号,JLabel.CENTER);lbl_name=new JLabel(商品名称,JLabel.CENTER);lbl_address=new JLabel(商品产地,JLabel.CENTER);lbl_in_price=new JLabel(进价,JLabel.CENTER);lbl_out_price=new JLabel(售价,JLabel.CENTER);lbl_jinhuo=new

13、 JLabel(进货量,JLabel.CENTER);lbl_chuhuo=new JLabel(销售量,JLabel.CENTER);lbl_kucun=new JLabel(库存量,JLabel.CENTER);text_id=new TextField();text_name = new TextField();text_address=new TextField();text_in_price=new TextField();text_out_price=new TextField();text_jinhuo=new TextField();text_chuhuo=new TextFi

14、eld();text_kucun=new TextField();jp_table=new JPanel(new BorderLayout();jp_text =new JPanel(new GridLayout(2,8);jp_text.add(lbl_id);jp_text.add(lbl_name);传播优秀Word版文档 ,希望对您有帮助,可双击去除!jp_text.add(lbl_address);jp_text.add(lbl_in_price);jp_text.add(lbl_out_price);jp_text.add(lbl_jinhuo);jp_text.add(lbl_c

15、huhuo);jp_text.add(lbl_kucun);jp_text.add(text_id);jp_text.add(text_name);jp_text.add(text_address);jp_text.add(text_in_price);jp_text.add(text_out_price);jp_text.add(text_jinhuo);jp_text.add(text_chuhuo);jp_text.add(text_kucun);model = new DefaultTableModel(new Object , new String 商品编号, 商品名称, 商品产地

16、,进价,售价,库存量,进货量,出货量 );table =new JTable(model);jsp=new JScrollPane(table);submit=new JButton(录入商品);reset=new JButton(重置信息);delete=new JButton(删除所选商品);submit.addActionListener(this);reset.addActionListener(this);delete.addActionListener(this);jp_btn=new JPanel(new GridLayout(1,3);jp_btn.add(submit);jp

17、_btn.add(delete);jp_btn.add(reset);jp_table.add(Center,jp_text);jp_table.add(South,jp_btn);jp_main=new JPanel(new BorderLayout(10,10);jp_main.add(Center,jsp);jp_main.add(North,jp_table);System.out.println(pass);传播优秀Word版文档 ,希望对您有帮助,可双击去除!/查找面板初始化面板private void Find() jp1=new JPanel(new GridLayout(1,

18、1);jp2=new JPanel(new GridLayout(1,4);jp3=new JPanel(new BorderLayout();find_id =new JButton(根据商品编号查询);find_name=new JButton(根据商品名称查询);find_all=new JButton(查询所有信息);find_delete=new JButton(删除所选信息);text_find=new JTextField();jsp_find=new JScrollPane();table_find=new JTable();model_find=new DefaultTabl

19、eModel();model_find = new DefaultTableModel(new Object , new String 商品编号, 商品名称, 商品产地 ,进价,售价,库存量,进货量,出货量 );table_find =new JTable(model_find);jsp_find=new JScrollPane(table_find);find_id.addActionListener(this);find_name.addActionListener(this);find_all.addActionListener(this);find_delete.addActionLi

20、stener(this);jp1.add(text_find);jp2.add(find_id);jp2.add(find_name);jp2.add(find_all);jp2.add(find_delete);jp3.add(North,jp1);jp3.add(Center,jp2);传播优秀Word版文档 ,希望对您有帮助,可双击去除!jp2_main=new JPanel(new BorderLayout(10,10);jp2_main.add(Center,jsp_find);jp2_main.add(North,jp3);/背景更改private void change_colo

21、r() jp3_main=new JPanel();display =new Panel();display.setBackground(Color.WHITE);Panel pcolor =new Panel();pcolor.setLayout(new BorderLayout();Panel pw=new Panel();pw.setLayout(new GridLayout(3,2,0,0);jp3_main.setLayout(new BorderLayout();tfr= new TextField(255);tfg=new TextField(255);tfb=new TextF

22、ield(255);tfr.setEditable(false);tfg.setEditable(false);tfb.setEditable(false);sbr=new Scrollbar(Scrollbar.HORIZONTAL,255,0,0,255);sbg=new Scrollbar(Scrollbar.HORIZONTAL,255,0,0,255);sbb=new Scrollbar(Scrollbar.HORIZONTAL,255,0,0,255);sbr.setName(SBR);sbg.setName(SBG);sbb.setName(SBB);sbr.setBackgro

23、und(Color.red);sbg.setBackground(Color.green);sbb.setBackground(Color.blue);sbr.addAdjustmentListener(this);sbg.addAdjustmentListener(this);sbb.addAdjustmentListener(this);pw.add(new Label(红色);pw.add(tfr);传播优秀Word版文档 ,希望对您有帮助,可双击去除!pw.add(new Label(绿色);pw.add(tfg);pw.add(new Label(蓝色);pw.add(tfb);Pa

24、nel pc= new Panel();pc.setLayout(new GridLayout(3, 1, 0, 0);pc.add(sbr);pc.add(sbg);pc.add(sbb);pcolor.add(pw,BorderLayout.WEST);pcolor.add(pc,BorderLayout.CENTER);jp3_main.add(display,BorderLayout.CENTER);jp3_main.add(pcolor,BorderLayout.SOUTH);/查看帮助文档,调用本地的程序,查看帮助文档public void useCMDCommand() thro

25、ws IOException Runtime.getRuntime().exec(new Stringcmd.exe, /c, .BaoDing_Shoop保定商场商品管理系统项目帮助.doc); /主函数public static void main(String args) / TODO Auto-generated method stubjava.awt.EventQueue.invokeLater(new Runnable() public void run() new Main().setVisible(true); );/监听方法public void actionPerforme

26、d(ActionEvent e) 传播优秀Word版文档 ,希望对您有帮助,可双击去除!/得到事件源String btString=e.getActionCommand();/录入功能if (btString.equals(录入商品) /追加到最后一行if(!text_id.getText().equals() & !text_name.getText().equals() & !text_address.getText().equals() & !text_in_price.getText().equals() & !text_out_price.getText().equals() & !

27、text_jinhuo.getText().equals() & !text_chuhuo.getText().equals() & !text_kucun.getText().equals() /获取文本框信息int idString=Integer.parseInt(text_id.getText();String ids=text_id.getText();String nameString=text_name.getText();String addresString=text_address.getText();double in_priceString=Double.parseDo

28、uble(text_in_price.getText();double out_priceString=Double.parseDouble(text_out_price.getText();int jinhuoString=Integer.parseInt(text_jinhuo.getText();int chuhuoString=Integer.parseInt(text_chuhuo.getText();int kucun=Integer.parseInt(text_kucun.getText();if (in_priceString=out_priceString) JOptionP

29、ane.showMessageDialog(this, 亲,要有盈利的,销售价格要大于进价!);else System.out.print(录入商品);if (idString!=0 & !nameString.equals() & !addresString.equals() & in_priceString!=0 & out_priceString!=0 & jinhuoString!=0 & chuhuoString!=0 & kucun!=0) /对数据库的操作 String sql=insert into result values(+ ids +, + nameString+,+

30、addresString+,+ in_priceString+,+ out_priceString+,+传播优秀Word版文档 ,希望对您有帮助,可双击去除! jinhuoString+,+ chuhuoString+,+ kucun+ );Userdate userdate=new Userdate();boolean flag=userdate.add_goods(sql);if (flag) /对表格的操作model.insertRow(model.getRowCount(), new Object ids, nameString,addresString,in_priceString,

31、out_priceString,jinhuoString,chuhuoString,kucun );else JOptionPane.showMessageDialog(this, 商品编号重复!); else JOptionPane.showMessageDialog(this, 请输入商品详细信息!);else JOptionPane.showMessageDialog(this, 请输入商品的详细信息!);/删除功能else if(btString.equals(删除所选商品)/获取要删除的行,没有选择是-1int row=table.getSelectedRow();System.ou

32、t.print(删除商品操作);System.out.print(row);if (row=-1) JOptionPane.showMessageDialog(this,请选择要删除商品的商品名!);else /System.out.print(row);传播优秀Word版文档 ,希望对您有帮助,可双击去除!/数据库删除商品操作/int shangpin_id= Integer.parseInt(String) model.getValueAt(row, 0) ;String shangpin_id=(String) model.getValueAt(row, 0) ;System.out.p

33、rint(row);String sql=delete from result where id=+shangpin_id+;Userdate userdate=new Userdate();boolean flag=userdate.add_goods(sql);if (flag) model.removeRow(row);/重置功能else if(btString.equals(重置信息)text_id.setText();text_name.setText();text_address.setText();text_in_price.setText();text_out_price.se

34、tText();text_jinhuo.setText();text_chuhuo.setText();text_kucun.setText();else if(btString.equals(修改密码)UpData data=new UpData();data.setVisible(true);else if(btString.equals(计算器)Calculator calculator = new Calculator();calculator.setSize(250,350);calculator.setLocationRelativeTo(null);calculator.setV

35、isible(true);calculator.setResizable(false);else if(btString.equals(退出系统)System.exit(0);else if (btString.equals(记事本) NotePad notePad=new NotePad();notePad.setVisible(true);else if(btString.equals(查看帮助)传播优秀Word版文档 ,希望对您有帮助,可双击去除!/System.out.println(help_pss);try useCMDCommand();System.out.println(he

36、lp_pss); catch (IOException e1) / TODO Auto-generated catch blocke1.printStackTrace();else if(btString.equals(关于)About about =new About();about.setVisible(true);else if(btString.equals(重新登录)System.out.print(重新登录);Landing landing = new Landing();landing.setVisible(true);this.dispose();else if(btStrin

37、g.equals(查找)c.show(card,2);else if(btString.equals(录入)c.show(card,1);else if(btString.equals(删除)c.show(card,2);JOptionPane.showMessageDialog(this, 请先查找所要删除的商品信息!);else if(btString.equals(背景设置)c.show(card,3);/查找功能else if(btString.equals(根据商品编号查询)if (text_find.getText().equals() JOptionPane.showMessag

38、eDialog(this, 查询信息为空!);else /int id =Integer.parseInt(text_find.getText().trim();String id =text_find.getText().trim();Good_data data=new Good_data();Goods goods =data.findStudentById(id);传播优秀Word版文档 ,希望对您有帮助,可双击去除!/String id_s=Integer.toString(id);/获取文本框信息/int idString=goods.getId();/String ids=Int

39、eger.toString(goods.getId();String idString=goods.getId();String nameString=goods.getName();String addresString=goods.getAddress();double in_priceString=goods.getIn_price();double out_priceString=goods.getOut_price();int jinhuoString=goods.getJinhuo();int chuhuoString=goods.getChuhuo();int kucun=goods.getKucun();/判断用户所输入的商品编号数据库中是否有if (idString=null) JOptionPane.showMessageDialog(this,对不起,小编没有从数据库中找到商品编号为:+id+的信息!);else

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1