仓库管理系统实训报告

时间:2024.3.31

郑州轻工业学院

实 训 报 告

实训名称:         仓库管理系统                     

姓    名:                 

院 (系):                    

专业班级:                

学    号:               

指导教师:                            

成    绩:                            

时间:

任务书

目 录

1 系统简介.............................................................................................................. 1

1.1需求说明............................................................................................................. 2

   1.2系统说明............................................................................................................. 3

2 系统设计.............................................................................................................. 4

2.1思路.................................................................................................................... 5

2.2 框架................................................................................................................... 6

3 功能模块的实现思路.................................................................................... 7

3.1产品管理............................................................................................................. 5

3.2供应商管理......................................................................................................... 5

3.3产品视图............................................................................................................. 5

3.4系统管理............................................................................................................. 5

3.5显示当前时间..................................................................................................... 5

4 系统设计结果................................................................................................... 7

5 实训感想.............................................................................................................. 7

6 附件........................................................................................................................ 7

1 系统简介

1.1需求说明

随着社会经济的迅速发展和科学技术的全面进步,计算机事业的飞速发展,以计算机与通信技术为基础的信息系统正处于蓬勃发展的时期。随着经济文化水平的显著提高,人们对生活质量及工作环境的要求也越来越高。如何通过计算机为我们完成更多的事情,进而达到办公自动化和优化日常工作的目的,也就成了一个大众化课题。

仓库管理是与我们日常生活息息相关的问题。大到公司、超市的仓库管理,小到图书馆的藏书管理,都可以认为是各种各样的仓库管理需求。随着我国改革开放的不断深入,经济飞速发展,企业要想生存、发展,要想在激烈的市场竞争中立于不败之地,没有现代化的管理是万万不行的,仓库管理的全面自动化、信息化则是其中极其重要的部分。为了加快仓库管理自动化的步伐,提高仓库的管理业务处理效率,建立仓库管理系统,尽可能地减少仓库管理的重复性和低效性,一边的十分重要。

通过对部分超市仓库管理进行调研、分析开发本系统的目的在于代替手工管理、统计报表等工作,具体要求包括添加、修改和删除供应商,添加、修改和删除商品,进货单,销售单,商品信息管理,供应商查询,操作员管理,更改密码等。

1.2系统说明

整体界面美观,有清晰的层次感,布局简洁合理,同时保证后台的管理页面和前台的服务保持。系统采用大型数据库系统,能够满足五年以内的数据增长需求,并且保证大容量数据库的可操作性。由于各业务的数据量非常大,并且数据记录的增长速度非常快,需要有高性能服务器的支撑,并设计出合理的数据库结构和查询算法,以保证查询的响应速度,且响应速度不随记录数的增长急速下降。一般情况下,信息栏查询响应不超过三秒,并发五十个用户数下信息栏目查询响应不超过五秒。应用系统保证稳定、可靠、实用满足业务处理流程的要求,人机界面友好,输入输出方便!

2 系统设计

2.1思路

产品管理:由于本公司所需产品众多,靠传统的手工管理方式很不方便,需要一个信息系统进行管理。目前,产品的信息有产品编号,名称,价格,库存量,类别等。每个产品对应一个供应商,供应商的信息有供应商编号,名称,城市等。产品通过供应商编号得知该产品由哪个供应商提供,用户可以添加产品、删除产品、产品进货、产品出货。

供应商管理:供应商的信息有供应商编号,名称,城市等,用户可以添加供应商、删除供应商、 修改供应商。

产品视图:用户可以根据条件查询产品、导出查询结果集、导入文件数据。

系统管理:提供密码修改功能, 提供系统参数设置功能,如界面风格改变成  Windows  风格,背景颜色,背景画面, 字体等设定。

显示当前时间:这个功能不需提供菜单,在主界面的右下角(也可以是其它位置),利用多线程技术,提供一个时钟的功能。时钟以字符串形式实时显示当前时间,即体现时、分、秒的变化。

2.2框架

 

3 功能模块的实现思路

3.1产品管理

     public AddProductPanel() {

     setLayout(new GridBagLayout());

     setBounds(10, 10, 600, 400);

  

     setupComponent(new JLabel(" Id "), 0, 0, 1, 1, false);

  

       this.fieldProductId = new JTextField();

       this.fieldProductId.addKeyListener(new InputKeyListener());

       setupComponent(this.fieldProductId, 1, 0, 3, 1, true);

  

     setupComponent(new JLabel(" 名称:"), 0, 1, 1, 1, false);

     this.fieldProductName = new JTextField();

     setupComponent(this.fieldProductName, 1, 1, 3, 10, true);

  

     setupComponent(new JLabel(" 价格:"), 0, 2, 1, 1, false);

     this.fieldPrice = new JTextField();

     this.fieldPrice.addKeyListener(new InputKeyListener());

     setupComponent(this.fieldPrice, 1, 2, 3, 350, true);

  

     setupComponent(new JLabel(" 种类:"), 0, 3, 1, 1, false);

     this.fieldType = new JTextField();

     setupComponent(this.fieldType, 1, 3, 3, 350, true);

  

     setupComponent(new JLabel(" 数量:"), 0, 4, 1, 1, false);

     this.fieldQuantity = new JTextField();

     this.fieldQuantity.addKeyListener(new InputKeyListener());

     setupComponent(this.fieldQuantity, 1, 4, 3, 1, true);

  

     setupComponent(new JLabel("供应商 :"), 0, 5, 1, 1, false);

     this.box = new JComboBox();

     this.box.setMaximumRowCount(5);

     setupComponent(this.box, 1, 5, 3, 1, true);

  

     this.productHandler = new ProductDao();

  

     this.mapSuppliers = this.productHandler.getSuppliers();

  

     Set setKey = this.mapSuppliers.keySet();

     Iterator it = setKey.iterator();

     while (it.hasNext()) {

       String name = (String)it.next();

       this.box.addItem(name);

       }

  

     JButton buttonOk = new JButton("添加");

     setupComponent(buttonOk, 1, 6, 1, 1, false);

  

     ProductListener productListener = new ProductListener();

     buttonOk.addActionListener(productListener);

  

     GridBagConstraints gridBagConstraints_20 = new GridBagConstraints();

     gridBagConstraints_20.weighty = 1.0D;

     gridBagConstraints_20.insets = new Insets(0, 65, 0, 15);

     gridBagConstraints_20.gridy = 8;

     gridBagConstraints_20.gridx = 1;

  

     this.resetButton = new JButton("重置");

     setupComponent(this.resetButton, 3, 6, 1, 1, false);

  

     this.resetButton.addActionListener(new ActionListener()

       {

         publicvoid actionPerformed(ActionEvent e) {

         AddProductPanel.this.fieldProductId.setText("");

         AddProductPanel.this.fieldProductName.setText("");

         AddProductPanel.this.fieldPrice.setText("");

         AddProductPanel.this.fieldType.setText("");

         AddProductPanel.this.fieldQuantity.setText("");

         }

       });

     }

建立产品管理界面,从而可以实现人机交互。

publicclass ProductListener

       implements ActionListener

     {

       public ProductListener()

       {

       }

  

       publicvoid actionPerformed(ActionEvent e)

       {

       SupplierDao supplierHandler = new SupplierDao();

       boolean flagZero = supplierHandler.isExistSupplierData();

       if (!flagZero) {

         JOptionPane.showMessageDialog(null, "没有相应的供应商", "结果",

           2);

         return;

         }

  

       if ("".equals(AddProductPanel.this.fieldProductId.getText().trim()))

         AddProductPanel.this.flagProId = false;

         else {

         AddProductPanel.this.flagProId = true;

         }

       if ("".equals(AddProductPanel.this.fieldProductName.getText().trim()))

         AddProductPanel.this.flagProName = false;

         else {

         AddProductPanel.this.flagProName = true;

         }

       if ("".equals(AddProductPanel.this.fieldPrice.getText().trim()))

         AddProductPanel.this.flagProPrice = false;

         else {

         AddProductPanel.this.flagProPrice = true;

         }

       if ("".equals(AddProductPanel.this.fieldType.getText().trim()))

         AddProductPanel.this.flagProType = false;

         else {

         AddProductPanel.this.flagProType = true;

         }

       if ("".equals(AddProductPanel.this.fieldQuantity.getText().trim()))

         AddProductPanel.this.flagProQuantity = false;

         else {

         AddProductPanel.this.flagProQuantity = true;

         }

  

       if ((AddProductPanel.this.flagProId) && (AddProductPanel.this.flagProName) && (AddProductPanel.this.flagProPrice) && (AddProductPanel.this.flagProType) &&

         (AddProductPanel.this.flagProQuantity)) {

         if (!AddProductPanel.this.fieldProductId.getText().trim().matches("\\d*")) {

           JOptionPane.showMessageDialog(null, "请输入正确的id!", "结果",

             2);

           AddProductPanel.this.fieldProductId.setText("");

         } elseif (AddProductPanel.this.productHandler.isExistProductById(

           Integer.parseInt(AddProductPanel.this.fieldProductId.getText()))) {

           JOptionPane.showMessageDialog(null, "No. " +

             AddProductPanel.this.fieldProductId.getText() + " 商品id已经存在", "结果",

             2);

           AddProductPanel.this.fieldProductId.setText("");

         } elseif (!AddProductPanel.this.fieldPrice.getText().trim().matches("\\d*[.]?\\d*")) {

           JOptionPane.showMessageDialog(null, "请输入正确的价格", "结果",

             2);

           AddProductPanel.this.fieldPrice.setText("");

         } elseif (!AddProductPanel.this.fieldQuantity.getText().trim().matches(

           "[-]?\\d*[.]?\\d*")) {

           JOptionPane.showMessageDialog(null, "请输入正确的数量", "结果",

             2);

           AddProductPanel.this.fieldQuantity.setText("");

         } elseif (!AddProductPanel.this.fieldQuantity.getText().trim().matches(

           "\\d*[.]?\\d*")) {

           JOptionPane.showMessageDialog(null,

             "请输入正确的数量", "结果",

             2);

           AddProductPanel.this.fieldQuantity.setText("");

           } else {

           String strId = AddProductPanel.this.fieldProductId.getText();

           String strName = AddProductPanel.this.fieldProductName.getText();

           String strPrice = AddProductPanel.this.fieldPrice.getText();

           String strType = AddProductPanel.this.fieldType.getText();

           String strqutity = AddProductPanel.this.fieldQuantity.getText();

           String strSupName = (String)AddProductPanel.this.box.getSelectedItem();

  

           int intId = Integer.parseInt(strId);

           float fltPrice = Float.parseFloat(strPrice);

           float fltqutity = Float.parseFloat(strqutity);

           int intSupid = ((Integer)AddProductPanel.this.mapSuppliers.get(strSupName)).intValue();

  

           ProductData p = new ProductData(intId, strName, fltPrice,

             strType, fltqutity, intSupid);

           booleanflag = AddProductPanel.this.productHandler.addProduct(p);

           JOptionPane.showMessageDialog(AddProductPanel.this,

             "添加商品成功", "添加商品",

             1);

           AddProductPanel.this.resetButton.doClick();

           }

         }

       else JOptionPane.showMessageDialog(AddProductPanel.this, "请填写所有信息",

           "结果", 2);

       }

     }

   }

制作添加商品信息面板并通过数据库添加商品信息

public ModifyProductPanel()//构造方法

     {

     setLayout(new GridBagLayout());

     setBounds(10, 10, 600, 350);

  

     setupComponent(new JLabel(" 商品id :"), 0, 0, 1, 1, true);

  

     this.comboProdBox = new JComboBox();

     setupComponent(this.comboProdBox, 1, 0, 3, 1, true);

     addItemToBox();// 执行一个加载数据库相应数据的方法-->和数据库进行交互

  

     ComboBoxListener comboBoxListener = new ComboBoxListener();

     this.comboProdBox.addActionListener(comboBoxListener);//如果组合框可编辑,则在编辑停止时将触发 ActionEvent

  

     setupComponent(new JLabel(" 名称:"), 0, 1, 1, 1, false);

     this.labelProNameView = new JTextField();

     this.labelProNameView.setEditable(false);

     setupComponent(this.labelProNameView, 1, 1, 3, 10, true);

  

     setupComponent(new JLabel(" 价格:"), 0, 2, 1, 1, false);

     this.labelProPriceView = new JTextField();

     this.labelProPriceView.setEditable(false);//开始时,设置JTextField为不可编辑

     setupComponent(this.labelProPriceView, 1, 2, 3, 350, true);

  

     setupComponent(new JLabel(" 种类:"), 0, 3, 1, 1, false);

     this.labelProTypeView = new JTextField();

     this.labelProTypeView.setEditable(false);

     setupComponent(this.labelProTypeView, 1, 3, 3, 350, true);

  

     setupComponent(new JLabel(" 数量:"), 0, 4, 1, 1, false);

     this.labelProQuentityView = new JTextField();

     this.labelProQuentityView.setEditable(false);

     setupComponent(this.labelProQuentityView, 1, 4, 3, 1, true);

  

     setupComponent(new JLabel(" 供应商:"), 0, 5, 1, 1, false);

     this.box = new JComboBox();

  

     this.box.setEditable(false);

     this.box.setEnabled(false);

     setupComponent(this.box, 1, 5, 3, 1, true);

     //以下为四个Button的设置

     this.modifycheckButton = new JButton(" 核实 ");//核实按钮-->action

     this.modifycheckButton.setEnabled(false);

     setupComponent(this.modifycheckButton, 1, 6, 1, 1, false);

     checkModifyActionListener checkModifyActionListener = new checkModifyActionListener();

     this.modifycheckButton.addActionListener(checkModifyActionListener);

  

     this.resetButton = new JButton(" 重置 ");

     setupComponent(this.resetButton, 2, 6, 1, 1, false);

     this.resetButton.setEnabled(false);

  

     ResetmodifyActionListener resetmodifyActionListener = new ResetmodifyActionListener();

     this.resetButton.addActionListener(resetmodifyActionListener);

  

     this.modifyButton = new JButton(" 修改 ");

     setupComponent(this.modifyButton, 1, 7, 1, 1, false);

     this.modifyButton.setEnabled(false);

     ModifyActionListener modifyActionListener = new ModifyActionListener();//修改按钮-->action

     this.modifyButton.addActionListener(modifyActionListener);

  

     this.removeButton = new JButton(" 删除 ");//删除按钮-->action

     setupComponent(this.removeButton, 2, 7, 1, 1, false);

     this.removeButton.setEnabled(false);

     RemoveActionlistener removeActionlistener = new RemoveActionlistener();

     this.removeButton.addActionListener(removeActionlistener);

     setVisible(true);

     }

制作修改与删除商品信息面板

privatevoid setupComponent(JComponent component, int gridx, int gridy, int gridwidth, int ipadx, boolean fill)

     {

     GridBagConstraints gridBagConstrains = new GridBagConstraints();

     gridBagConstrains.gridx = gridx;

     gridBagConstrains.gridy = gridy;

     gridBagConstrains.insets = new Insets(5, 1, 3, 1);

     if (gridwidth > 1)

       gridBagConstrains.gridwidth = gridwidth;

     if (ipadx > 0)

       gridBagConstrains.ipadx = ipadx;

     if (fill)

       gridBagConstrains.fill = 2;

     add(component, gridBagConstrains);

     }

  

     publicvoid addItemToBox()

     {

     this.comboProdBox.removeAllItems();

     this.comboProdBox.addItem("请选择");

     this.productHandler = new ProductDao();

     List listAllProd = this.productHandler.getFindAllProductId();

     Iterator it = listAllProd.iterator();

     while (it.hasNext())

       this.comboProdBox.addItem(it.next());

     }

  

     publicclass ComboBoxListener

       implements ActionListener

     {

       public ComboBoxListener()

       {

       }

  

       publicvoid actionPerformed(ActionEvent e)

       {

       if (ModifyProductPanel.this.comboProdBox.getSelectedIndex() == 0) {

         ModifyProductPanel.this.modifycheckButton.setEnabled(false);

         ModifyProductPanel.this.labelProNameView.setText("");

         ModifyProductPanel.this.labelProPriceView.setText("");

         ModifyProductPanel.this.labelProTypeView.setText("");

         ModifyProductPanel.this.labelProQuentityView.setText("");

         ModifyProductPanel.this.box.removeAllItems();

         ModifyProductPanel.this.box.setEnabled(false);

         ModifyProductPanel.this.resetButton.setEnabled(false);

         ModifyProductPanel.this.removeButton.setEnabled(false);

         ModifyProductPanel.this.modifyButton.setEnabled(false);

         ModifyProductPanel.this.labelProNameView.setEditable(false);

         ModifyProductPanel.this.labelProPriceView.setEditable(false);

         ModifyProductPanel.this.labelProTypeView.setEditable(false);

         ModifyProductPanel.this.labelProQuentityView.setEditable(false);

         } else {

         ModifyProductPanel.this.box.removeAllItems();

         ModifyProductPanel.this.box.setEnabled(false);

         ModifyProductPanel.this.modifycheckButton.setEnabled(true);

         ModifyProductPanel.this.labelProNameView.setText("");

         ModifyProductPanel.this.labelProPriceView.setText("");

         ModifyProductPanel.this.labelProTypeView.setText("");

         ModifyProductPanel.this.labelProQuentityView.setText("");

         ModifyProductPanel.this.labelProNameView.setEditable(false);

         ModifyProductPanel.this.labelProPriceView.setEditable(false);

         ModifyProductPanel.this.labelProTypeView.setEditable(false);

         ModifyProductPanel.this.labelProQuentityView.setEditable(false);

         ModifyProductPanel.this.resetButton.setEnabled(false);

         ModifyProductPanel.this.removeButton.setEnabled(false);

         ModifyProductPanel.this.modifyButton.setEnabled(false);

         }

       }

     }

  

     publicclass ModifyActionListener

       implements ActionListener

     {

       public ModifyActionListener()

       {

       }

  

       publicvoid actionPerformed(ActionEvent e)

       {

       SupplierDao supplierHandler = new SupplierDao();

       boolean flagZero = supplierHandler.isExistSupplierData();

       if (!flagZero) {

         JOptionPane.showMessageDialog(null, "没有相应的供应商", "结果",

           2);

         return;

         }

  

       if ((ModifyProductPanel.this.labelProNameView.getText().equals("")) ||

         (ModifyProductPanel.this.labelProPriceView.getText().equals("")) ||

         (ModifyProductPanel.this.labelProTypeView.getText().equals("")) ||

         (ModifyProductPanel.this.labelProQuentityView.getText().equals("")))

         {

         JOptionPane.showMessageDialog(ModifyProductPanel.this,

           "请输入所有信息", "结果", 2);

         return;

         }

  

       if (!ModifyProductPanel.this.labelProPriceView.getText().trim().matches("\\d*[.]?\\d*")) {

         JOptionPane.showMessageDialog(null, "请输入正确的价格", "结果",

           2);

         ModifyProductPanel.this.labelProPriceView.setText("");

         return;

       }if (!ModifyProductPanel.this.labelProQuentityView.getText().trim().matches(

         "[-]?\\d*[.]?\\d*")) {

         JOptionPane.showMessageDialog(null, "请输入正确的数量", "结果",

           2);

         ModifyProductPanel.this.labelProQuentityView.setText("");

         return;

       }if (!ModifyProductPanel.this.labelProQuentityView.getText().trim().matches(

         "\\d*[.]?\\d*")) {

         JOptionPane.showMessageDialog(null,"请输入正确的数量", "结果",

           2);

         ModifyProductPanel.this.labelProQuentityView.setText("");

         return;

         }

  

       String strProId = String.valueOf(ModifyProductPanel.this.comboProdBox.getSelectedItem());

       ModifyProductPanel.this.productHandler = new ProductDao();

  

       ProductData productData = ModifyProductPanel.this.productHandler.getProductByNumber(Integer.parseInt(strProId));

       productData.setPodName(ModifyProductPanel.this.labelProNameView.getText());

       productData.setPrice(Float.parseFloat(ModifyProductPanel.this.labelProPriceView.getText()));

       productData.setType(ModifyProductPanel.this.labelProTypeView.getText());

  

       

       SupplierData supplier = supplierHandler.getSupplierbySupplierName(String.valueOf(ModifyProductPanel.this.box.getSelectedItem()));

       //System.out.println(String.valueOf(ModifyProductPanel.this.box.getSelectedItem()));

       /////////////////////////////

       //System.out.println(supplier);

       productData.setSupId(supplier.getSupplierId());

       /////////////////////////////

       ModifyProductPanel.this.productHandler.updateProductById(productData);//执行更新操作

  

       JOptionPane.showMessageDialog(ModifyProductPanel.this, "修改商品成功",

         "结果", 1);

       ModifyProductPanel.this.resetButton.doClick();

       }

     }

通过与数据库交互实现商品修改功能

publicclass RemoveActionlistener

       implements ActionListener

     {

       public RemoveActionlistener()

       {

       }

  

       publicvoid actionPerformed(ActionEvent e)

       {

       ModifyProductPanel.this.productHandler = new ProductDao();

       String strProOkId = String.valueOf(ModifyProductPanel.this.comboProdBox.getSelectedItem());

       int intProOkId = Integer.parseInt(strProOkId);

       float floatProQuentity = ModifyProductPanel.this.productHandler.getProductByNumber(

         intProOkId).getQuantity();

       if (floatProQuentity > 0.0F) {

         JOptionPane.showMessageDialog(null,

           "仓库中还有该商品的库存,不能删除", "结果",

           1);

         ModifyProductPanel.this.resetButton.doClick();

         } else {

         ModifyProductPanel.this.productHandler.deleteProductById(intProOkId);

         JOptionPane.showMessageDialog(null, "删除成功",

           "结果", 1);

         ModifyProductPanel.this.resetButton.doClick();

         }

       }

     }

通过与数据库交互实现商品删除功能

3.2供应商管理

publicclass SupplierManagePanel extends JInternalFrame

 {

   privatestaticfinallongserialVersionUID = 1L;

   public SupplierManagePanel()

   {

     setIconifiable(true);

     setClosable(true);

     setTitle("供应商管理");

     JTabbedPane tabPane = new JTabbedPane();

     AddSupplierPanel addSupplierPanel = new AddSupplierPanel();

     ModifySupplierPanel modifySupplierPanel = new ModifySupplierPanel();

     tabPane.addTab("添加供应商", null, addSupplierPanel, "添加供应商");

     tabPane.addTab("修改与删除供应商", null, modifySupplierPanel, "修改与删除供应商");

     getContentPane().add(tabPane);

     pack();

     setVisible(true);

   }

 }

制作供应商管理面板

public AddSupplierPanel()

    {

     setLayout(null);

     setBounds(10, 10, 600, 350);

 

     this.addPanel = new JPanel();

     this.addPanel.setLayout(null);

     this.addPanel.setBounds(40, 30, 520, 260);

     this.addPanel.setBorder(BorderFactory.createTitledBorder("添加供应商信息"));

 

     JLabel lblId = new JLabel(" Id: ");

     lblId.setBounds(20, 20, 100, 30);

 

     this.addSupplierId = new JTextField();

     this.addSupplierId.setBounds(100, 20, 160, 20);

     this.addSupplierId.addKeyListener(new InputKeyListener());

 

     JLabel lblCode = new JLabel(" 邮编:");

     lblCode.setBounds(270, 20, 100, 30);

 

     this.addSupplierPostcode = new JTextField();

     this.addSupplierPostcode.setBounds(340, 20, 160, 20);

     this.addSupplierPostcode.addKeyListener(new InputKeyListener());

 

     JLabel lblSupName = new JLabel(" 名称: ");

     lblSupName.setBounds(20, 50, 100, 30);

 

     this.addSupplierName = new JTextField();

     this.addSupplierName.setBounds(100, 50, 400, 20);

 

     JLabel lblAddress = new JLabel(" 地址:");

     lblAddress.setBounds(20, 80, 100, 30);

 

     this.addSupplierAddress = new JTextField();

     this.addSupplierAddress.setBounds(100, 80, 400, 20);

 

     JLabel lblTel = new JLabel(" 电话:");

     lblTel.setBounds(20, 110, 100, 30);

 

     this.addSupplierTelephone = new JTextField();

     this.addSupplierTelephone.setBounds(100, 110, 160, 20);

     this.addSupplierTelephone.addKeyListener(new InputKeyListener());

 

     JLabel lblFax = new JLabel(" 传真:");

     lblFax.setBounds(270, 110, 100, 30);

 

     this.addSupplierFax = new JTextField();

     this.addSupplierFax.setBounds(340, 110, 160, 20);

     this.addSupplierFax.addKeyListener(new InputKeyListener());

 

     JLabel lblConnec = new JLabel(" 联系人:");

     lblConnec.setBounds(20, 140, 100, 30);

 

     this.addSupplierRelationer = new JTextField();

     this.addSupplierRelationer.setBounds(100, 140, 160, 20);

 

     JLabel lblEmail = new JLabel(" E-Mail:");

     lblEmail.setBounds(270, 140, 100, 30);

 

     this.addSupplierEmail = new JTextField();

     this.addSupplierEmail.setBounds(340, 140, 160, 20);

 

     JButton addSupplierButton = new JButton(" 添加 ");

     addSupplierButton.setBounds(100, 200, 100, 20);

     addSupplierButton.addActionListener(new AddSupplierActionListener());

 

     this.resetButton = new JButton("重置");

     this.resetButton.setBounds(270, 200, 100, 20);

     this.resetButton.addActionListener(new ResetActionListener());

 

     this.addPanel.add(lblId);

     this.addPanel.add(this.addSupplierId);

     this.addPanel.add(lblCode);

     this.addPanel.add(this.addSupplierPostcode);

     this.addPanel.add(lblSupName);

     this.addPanel.add(this.addSupplierName);

 

     this.addPanel.add(lblAddress);

     this.addPanel.add(this.addSupplierAddress);

     this.addPanel.add(lblTel);

 

     this.addPanel.add(this.addSupplierTelephone);

     this.addPanel.add(lblFax);

     this.addPanel.add(this.addSupplierFax);

 

     this.addPanel.add(lblConnec);

     this.addPanel.add(this.addSupplierRelationer);

     this.addPanel.add(lblEmail);

 

     this.addPanel.add(this.addSupplierEmail);

     this.addPanel.add(addSupplierButton);

     this.addPanel.add(this.resetButton);

 

     add(this.addPanel);

     setVisible(true);

    }

 

    class AddSupplierActionListener

      implements ActionListener

    {

      AddSupplierActionListener()

      {

      }

 

      publicvoid actionPerformed(ActionEvent e)

      {

       if ((AddSupplierPanel.this.addSupplierId.getText().equals("")) || (AddSupplierPanel.this.addSupplierPostcode.getText().equals("")) ||

         (AddSupplierPanel.this.addSupplierName.getText().equals("")) ||

         (AddSupplierPanel.this.addSupplierAddress.getText().equals("")) ||

         (AddSupplierPanel.this.addSupplierTelephone.getText().equals("")) ||

         (AddSupplierPanel.this.addSupplierFax.getText().equals("")) ||

         (AddSupplierPanel.this.addSupplierRelationer.getText().equals("")) ||

         (AddSupplierPanel.this.addSupplierEmail.getText().equals("")))

        {

         JOptionPane.showMessageDialog(AddSupplierPanel.this, "请输入所有信息", "结果", 2);

         return;

        }

 

       if (!AddSupplierPanel.this.addSupplierEmail.getText().matches("\\w+[@]\\w+\\.\\S+")) {

         JOptionPane.showMessageDialog(AddSupplierPanel.this, "请核实您的E-mail地址", "结果", 2);

         return;

        }

 

       SupplierDao supplierHandler = new SupplierDao();

 

       String strSupId = AddSupplierPanel.this.addSupplierId.getText();

       int intSupId = Integer.parseInt(strSupId);

 

       if (supplierHandler.isExistSupplierById(intSupId)) {

         JOptionPane.showMessageDialog(AddSupplierPanel.this,

           "No. " + intSupId + " 供应商已经存在,请重新输入",

           "Results!", 2);

         AddSupplierPanel.this.resetButton.doClick();

        } else {

         String strSupplierPostcode = AddSupplierPanel.this.addSupplierPostcode.getText().trim();

         String strSupplierName = AddSupplierPanel.this.addSupplierName.getText().trim();

         String strSupplierAddress = AddSupplierPanel.this.addSupplierAddress.getText().trim();

         String strSupplierTelephone = AddSupplierPanel.this.addSupplierTelephone.getText().trim();

         String strSupplierFax = AddSupplierPanel.this.addSupplierFax.getText().trim();

         String strSupplierRelationer = AddSupplierPanel.this.addSupplierRelationer.getText().trim();

         String strSupplierEmail = AddSupplierPanel.this.addSupplierEmail.getText().trim();

 

         intSupId = Integer.parseInt(strSupId);

 

         SupplierData s = new SupplierData(intSupId,

           strSupplierName, strSupplierAddress,

           strSupplierPostcode, strSupplierTelephone, strSupplierFax,

           strSupplierRelationer, strSupplierEmail);

         boolean flag = supplierHandler.addSupplier(s);

 

         if (flag) {

           JOptionPane.showMessageDialog(AddSupplierPanel.this, "供应商成功添加,请继续添加", "结果", 1);

           AddSupplierPanel.this.resetButton.doClick();

          } else {

           JOptionPane.showMessageDialog(AddSupplierPanel.this, "系统错误!");

          }

        }

      }

}

制作添加供应商面板并通过与数据库交互实现添加供应商功能

public ModifySupplierPanel()

    {

     setLayout(null);

     setBounds(10, 10, 600, 350);

 

     this.removePanel = new JPanel();

     this.removePanel.setLayout(null);

     this.removePanel.setBounds(40, 30, 520, 260);

     this.removePanel.setBorder(BorderFactory.createTitledBorder("修改与删除供应商信息"));

 

     JLabel lblId = new JLabel(" Id:");

     lblId.setBounds(20, 20, 100, 30);

 

     this.comboBox = new JComboBox();

     this.comboBox.setBounds(100, 20, 160, 20);

     addItemToBox();

 

     ComboBoxListener comboBoxListener = new ComboBoxListener();

     this.comboBox.addActionListener(comboBoxListener);

 

     JLabel lblCode = new JLabel(" 邮编:");

     lblCode.setBounds(270, 20, 100, 30);

 

     this.modifySupplierPostcode = new JTextField();

     this.modifySupplierPostcode.setBounds(340, 20, 160, 20);

     this.modifySupplierPostcode.setEditable(false);

     this.modifySupplierPostcode.addKeyListener(new InputKeyListener());

 

     JLabel lblSupName = new JLabel(" 姓名:");

     lblSupName.setBounds(20, 50, 100, 30);

 

     this.modifySupplierName = new JTextField();

     this.modifySupplierName.setBounds(100, 50, 400, 20);

     this.modifySupplierName.setEditable(false);

 

     JLabel lblAddress = new JLabel(" 地址:");

     lblAddress.setBounds(20, 80, 100, 30);

 

     this.modifySupplierAddress = new JTextField();

     this.modifySupplierAddress.setBounds(100, 80, 400, 20);

     this.modifySupplierAddress.setEditable(false);

 

     JLabel lblTel = new JLabel(" 电话:");

     lblTel.setBounds(20, 110, 100, 30);

 

     this.modifySupplierTelephone = new JTextField();

     this.modifySupplierTelephone.setBounds(100, 110, 160, 20);

     this.modifySupplierTelephone.setEditable(false);

     this.modifySupplierTelephone.addKeyListener(new InputKeyListener());

 

     JLabel lblFax = new JLabel(" 传真:");

     lblFax.setBounds(270, 110, 100, 30);

 

     this.modifySupplierFax = new JTextField();

     this.modifySupplierFax.setBounds(340, 110, 160, 20);

     this.modifySupplierFax.setEditable(false);

     this.modifySupplierFax.addKeyListener(new InputKeyListener());

 

     JLabel lblConnec = new JLabel(" 联系人:");

     lblConnec.setBounds(20, 140, 100, 30);

 

     this.modifySupplierRelationer = new JTextField();

     this.modifySupplierRelationer.setBounds(100, 140, 160, 20);

     this.modifySupplierRelationer.setEditable(false);

 

     JLabel lblEmail = new JLabel(" E-Mail:");

     lblEmail.setBounds(270, 140, 100, 30);

 

     this.modifySupplierEmail = new JTextField();

     this.modifySupplierEmail.setBounds(340, 140, 160, 20);

     this.modifySupplierEmail.setEditable(false);

 

     this.checkModifyButton = new JButton(" 核实 ");

     this.checkModifyButton.setBounds(40, 200, 100, 20);

     this.checkModifyButton.setEnabled(false);

 

     CheckSupplierListener checkSupplierListener = new CheckSupplierListener();

     this.checkModifyButton.addActionListener(checkSupplierListener);

 

     this.resetButton = new JButton(" 重置 ");

     this.resetButton.setBounds(160, 200, 100, 20);

     this.resetButton.setEnabled(false);

     ResetModifyListener resetModifyListener = new ResetModifyListener();

     this.resetButton.addActionListener(resetModifyListener);

 

     this.modifyButton = new JButton("修改");

     this.modifyButton.setBounds(280, 200, 100, 20);

     this.modifyButton.setEnabled(false);

     this.delButton = new JButton("删除");

     this.delButton.setBounds(400, 200, 100, 20);

     this.delButton.setEnabled(false);

制作修改与删除供应商面板

publicvoid addItemToBox()

    {

     this.comboBox.removeAllItems();

     this.comboBox.addItem("Choose");

     this.supplierHandler = new SupplierDao();

     List listAllId = this.supplierHandler.getFindAllSupplierId();

 

     Iterator it = listAllId.iterator();

     while (it.hasNext())

       this.comboBox.addItem(it.next());

    }

 

    privatevoidsetupComponent(JComponent component, int gridx, int gridy, int gridwidth, int ipadx, boolean fill)

    {

     GridBagConstraints gridBagConstrains = new GridBagConstraints();

     gridBagConstrains.gridx = gridx;

     gridBagConstrains.gridy = gridy;

     if (gridwidth > 1)

       gridBagConstrains.gridwidth = gridwidth;

     if (ipadx > 0)

       gridBagConstrains.ipadx = ipadx;

     gridBagConstrains.insets = new Insets(5, 1, 3, 1);

     if (fill)

       gridBagConstrains.fill = 2;

     add(component, gridBagConstrains);

    }

    publicclass CheckSupplierListener implements ActionListener {

      public CheckSupplierListener() {

      }

      publicvoid actionPerformed(ActionEvent e) {

       ModifySupplierPanel.this.supplierHandler = new SupplierDao();

       ModifySupplierPanel.this.strSupId = String.valueOf(ModifySupplierPanel.this.comboBox.getSelectedItem());

       SupplierData supplierData = ModifySupplierPanel.this.supplierHandler

         .getSupplierbySupplierId(ModifySupplierPanel.this.strSupId);

 

       ModifySupplierPanel.this.modifySupplierPostcode.setText(supplierData.getPostCode());

       ModifySupplierPanel.this.modifySupplierName.setText(supplierData.getSupplierName());

       ModifySupplierPanel.this.modifySupplierAddress.setText(supplierData.getSupplierAddress());

       ModifySupplierPanel.this.modifySupplierTelephone

         .setText(supplierData.getSupplierTelephone());

       ModifySupplierPanel.this.modifySupplierFax.setText(supplierData.getSupplierFax());

       ModifySupplierPanel.this.modifySupplierRelationer.setText(supplierData

         .getSupplierRelationer());

       ModifySupplierPanel.this.modifySupplierEmail.setText(supplierData.getSupplierEmail());

 

       ModifySupplierPanel.this.modifySupplierPostcode.setEditable(true);

       ModifySupplierPanel.this.modifySupplierName.setEditable(true);

       ModifySupplierPanel.this.modifySupplierAddress.setEditable(true);

       ModifySupplierPanel.this.modifySupplierTelephone.setEditable(true);

       ModifySupplierPanel.this.modifySupplierFax.setEditable(true);

       ModifySupplierPanel.this.modifySupplierRelationer.setEditable(true);

       ModifySupplierPanel.this.modifySupplierEmail.setEditable(true);

 

       ModifySupplierPanel.this.checkModifyButton.setEnabled(false);

 

       ModifySupplierPanel.this.resetButton.setEnabled(true);

       ModifySupplierPanel.this.modifyButton.setEnabled(true);

       ModifySupplierPanel.this.delButton.setEnabled(true);

      }

    }

 

    publicclass ComboBoxListener

      implements ActionListener

    {

      public ComboBoxListener()

      {

      }

 

      publicvoid actionPerformed(ActionEvent e)

      {

       if (ModifySupplierPanel.this.comboBox.getSelectedIndex() == 0) {

         ModifySupplierPanel.this.checkModifyButton.setEnabled(false);

         ModifySupplierPanel.this.resetButton.doClick();

        }

        else {

         ModifySupplierPanel.this.checkModifyButton.setEnabled(true);

         ModifySupplierPanel.this.resetButton.doClick();

        }

      }

    }

 

    publicclass ModifyActionListener

      implements ActionListener

    {

      public ModifyActionListener()

      {

      }

 

      publicvoid actionPerformed(ActionEvent e)

      {

       if ((ModifySupplierPanel.this.modifySupplierPostcode.getText().equals("")) ||

         (ModifySupplierPanel.this.modifySupplierName.getText().equals("")) ||

         (ModifySupplierPanel.this.modifySupplierAddress.getText().equals("")) ||

         (ModifySupplierPanel.this.modifySupplierTelephone.getText().equals("")) ||

         (ModifySupplierPanel.this.modifySupplierFax.getText().equals("")) ||

         (ModifySupplierPanel.this.modifySupplierRelationer.getText().equals("")) ||

         (ModifySupplierPanel.this.modifySupplierEmail.getText().equals(""))) {

         JOptionPane.showMessageDialog(ModifySupplierPanel.this,

           "请输入所有信息", "结果", 2);

         return;

        }

       if (!ModifySupplierPanel.this.modifySupplierEmail.getText().matches("\\w+[@]\\w+\\.\\S+")) {

         JOptionPane.showMessageDialog(ModifySupplierPanel.this,

           "请核实您的E-mail地址", "结果", 2);

         return;

        }

       ModifySupplierPanel.this.strSupId = String.valueOf(ModifySupplierPanel.this.comboBox.getSelectedItem());

       ModifySupplierPanel.this.supplierHandler = new SupplierDao();

 

       SupplierData supplierData = ModifySupplierPanel.this.supplierHandler

         .getSupplierbySupplierId(ModifySupplierPanel.this.strSupId);

       supplierData.setPostCode(ModifySupplierPanel.this.modifySupplierPostcode.getText());

       supplierData.setSupplierAddress(ModifySupplierPanel.this.modifySupplierAddress.getText());

       supplierData.setSupplierName(ModifySupplierPanel.this.modifySupplierName.getText());

       supplierData.setSupplierTelephone(ModifySupplierPanel.this.modifySupplierTelephone.getText());

       supplierData.setSupplierFax(ModifySupplierPanel.this.modifySupplierFax.getText());

       supplierData.setSupplierRelationer(ModifySupplierPanel.this.modifySupplierRelationer.getText());

       supplierData.setSupplierEmail(ModifySupplierPanel.this.modifySupplierEmail.getText());

 

       ModifySupplierPanel.this.supplierHandler.updateSupplierById(supplierData);

 

       JOptionPane.showMessageDialog(ModifySupplierPanel.this, "修改供应商成功",

         "结果", 1);

       ModifySupplierPanel.this.resetButton.doClick();

      }

    }

    publicclass RemoveActionListener implements ActionListener {

      public RemoveActionListener() {

      }

      publicvoid actionPerformed(ActionEvent e) {

       ModifySupplierPanel.this.strSupId = String.valueOf(ModifySupplierPanel.this.comboBox.getSelectedItem());

       int intSupId = Integer.parseInt(ModifySupplierPanel.this.strSupId);

       ModifySupplierPanel.this.productHandler = new ProductDao();

       int a = ModifySupplierPanel.this.productHandler.numberofProductDataBySupId(intSupId);

 

       if (a == 0) {

         int c = JOptionPane.showConfirmDialog(ModifySupplierPanel.this,

           "删除供应商 " + intSupId + " 吗?", "删除",

           0);

         if (c == 0) {

           ModifySupplierPanel.this.supplierHandler = new SupplierDao();

           ModifySupplierPanel.this.supplierHandler.deleteSupplierById(intSupId);

           JOptionPane.showMessageDialog(null, "删除供应商成功", "结果",

             1);

           ModifySupplierPanel.this.resetButton.doClick();

 

           ModifySupplierPanel.this.comboBox.removeAllItems();

           ModifySupplierPanel.this.comboBox.addItem("请选择");

           ModifySupplierPanel.this.listAllId = ModifySupplierPanel.this.supplierHandler.getFindAllSupplierId();

 

           Iterator it = ModifySupplierPanel.this.listAllId.iterator();

           while (it.hasNext())

             ModifySupplierPanel.this.comboBox.addItem(it.next());

          }

        }

        else {

         intprodNum = ModifySupplierPanel.this.productHandler

           .numberofProductDataBySupId(intSupId);

         JOptionPane.showMessageDialog(null, "仓库中还存在该供应商的产品,不能删除", "结果",

           2);

         ModifySupplierPanel.this.resetButton.doClick();

        }

      }

    }

实现修改与删除供应商功能

3.3产品视图

public CheckProductPanel()

   {

     setIconifiable(true);

     setClosable(true);

     setTitle("商品视图");

     getContentPane().setLayout(null);

     ((JComponent)getContentPane()).setBorder(

       BorderFactory.createTitledBorder("商品查询视图"));

     setBounds(10, 0, 760, 450);

     this.tablePanel = new JPanel();

     this.tablePanel.setLayout(new BorderLayout());

     this.tablePanel.setBounds(0, 20, 520, 320);

     this.tablePanel.setBorder(BorderFactory.createTitledBorder("查询结果表"));

     this.mt = new MyTable();

     this.t = new JTable(this.mt);

     JScrollPane s = new JScrollPane(this.t);

     this.tablePanel.add(s, "Center");

     this.combinationPanel = new JPanel();

     this.combinationPanel.setBorder(BorderFactory.createTitledBorder("查找条件"));

     this.combinationPanel.setBounds(521, 20, 210, 240);

     this.combinationPanel.setLayout(null);

     this.labId = new JLabel();

     this.labId.setText(" Id ");

     this.labId.setBounds(10, 30, 60, 20);

     this.combinationPanel.add(this.labId);

     this.boxId = new JComboBox();

     this.boxId.setBounds(80, 30, 40, 20);

     this.boxId.addItem(">");

     this.boxId.addItem("=");

     this.boxId.addItem("<");

     this.combinationPanel.add(this.boxId);

     this.fieldId = new JTextField(10);

     this.fieldId.setBounds(130, 30, 60, 20);

     this.fieldId.addKeyListener(new InputKeyListener());

     this.combinationPanel.add(this.fieldId);

     this.labName = new JLabel();

     this.labName.setText(" 名称 ");

     this.labName.setBounds(10, 60, 60, 20);

     this.combinationPanel.add(this.labName);

     this.fieldName = new JTextField(10);

     this.fieldName.setBounds(130, 60, 60, 20);

     this.combinationPanel.add(this.fieldName);

     this.labPrice = new JLabel();

     this.labPrice.setText(" 价格 ");

     this.labPrice.setBounds(10, 90, 60, 20);

     this.combinationPanel.add(this.labPrice);

     this.boxPrice = new JComboBox();

     this.boxPrice.setBounds(80, 90, 40, 20);

     this.boxPrice.addItem(">");

     this.boxPrice.addItem("=");

     this.boxPrice.addItem("<");

     this.combinationPanel.add(this.boxPrice);

     this.fieldPriceCheck = new JTextField(10);

     this.fieldPriceCheck.setBounds(130, 90, 60, 20);

     this.fieldPriceCheck.addKeyListener(new InputKeyListener());

     this.combinationPanel.add(this.fieldPriceCheck);

     this.labQuentity = new JLabel();

     this.labQuentity.setText(" 数量 ");

     this.labQuentity.setBounds(10, 120, 60, 20);

     this.combinationPanel.add(this.labQuentity);

     this.boxQuentity = new JComboBox();

     this.boxQuentity.setBounds(80, 120, 40, 20);

     this.boxQuentity.addItem(">");

     this.boxQuentity.addItem("=");

     this.boxQuentity.addItem("<");

     this.combinationPanel.add(this.boxQuentity);

     this.fieldQuentity = new JTextField(10);

     this.fieldQuentity.setBounds(130, 120, 60, 20);

     this.fieldQuentity.addKeyListener(new InputKeyListener());

     this.combinationPanel.add(this.fieldQuentity);

     this.labType = new JLabel();

     this.labType.setText(" 种类 ");

     this.labType.setBounds(10, 150, 60, 20);

     this.combinationPanel.add(this.labType);

     this.fieldTypeCheck = new JTextField(10);

     this.fieldTypeCheck.setBounds(130, 150, 60, 20);

     this.combinationPanel.add(this.fieldTypeCheck);

     this.labSupplier = new JLabel();

     this.labSupplier.setText("供应商");

     this.labSupplier.setBounds(10, 180, 60, 20);

     this.combinationPanel.add(this.labSupplier);

     this.boxSupplier = new JComboBox();

     this.boxSupplier.setBounds(80, 180, 40, 20);

     this.boxSupplier.addItem(">");

     this.boxSupplier.addItem("=");

     this.boxSupplier.addItem("<");

     this.combinationPanel.add(this.boxSupplier);

     this.fieldSupplier = new JTextField(10);

     this.fieldSupplier.setBounds(130, 180, 60, 20);

     this.fieldSupplier.addKeyListener(new InputKeyListener());

     this.combinationPanel.add(this.fieldSupplier);

     this.btnQuery = new JButton();

     this.btnQuery.setText(" 查找 ");

     this.btnQuery.setBounds(10, 210, 85, 20);

     this.combinationPanel.add(this.btnQuery);

制作商品视图面板

this.btnQuery.addActionListener(new ActionListener()

     {

       publicvoid actionPerformed(ActionEvent e)

       {

         String str = "select * from products where " + (

           CheckProductPanel.this.fieldId.getText().equals("") ? " prod_id  like '%%' " :

           new StringBuilder(" prod_id ")

           .append((String)CheckProductPanel.this.boxId.getSelectedItem())

           .append("'").append(CheckProductPanel.this.fieldId.getText()).append("'").toString()) +

           " and " + (

           CheckProductPanel.this.fieldName.getText().equals("") ? " prod_name like '%%' " :

           new StringBuilder("prod_name = '")

           .append(CheckProductPanel.this.fieldName.getText()).append("'").toString()) +

           " and " + (

           CheckProductPanel.this.fieldPriceCheck.getText().equals("") ? " price like '%%' " :

           new StringBuilder(" price")

           .append((String)CheckProductPanel.this.boxPrice.getSelectedItem())

           .append("'")

           .append(CheckProductPanel.this.fieldPriceCheck.getText())

           .append("'").toString()) +

           " and " + (

           CheckProductPanel.this.fieldQuentity.getText().equals("") ? " quantity like '%%' " :

           new StringBuilder(" quantity")

           .append((String)CheckProductPanel.this.boxQuentity

           .getSelectedItem()).append("'")

           .append(CheckProductPanel.this.fieldQuentity.getText()).append("'").toString()) +

           " and " + (

           CheckProductPanel.this.fieldTypeCheck.getText().equals("") ? " type  like '%%' " :

           new StringBuilder(" type = '")

           .append(CheckProductPanel.this.fieldTypeCheck.getText())

           .append("'").toString()) +

           " and " + (

           CheckProductPanel.this.fieldSupplier.getText().equals("") ? " sup_id  like '%%' " :

           new StringBuilder(" sup_id ")

           .append((String)CheckProductPanel.this.boxSupplier

           .getSelectedItem()).append("'")

           .append(CheckProductPanel.this.fieldSupplier.getText())

           .append("'").toString());

         ProductDao productHandler = new ProductDao();

         try {

           List lstProducts = productHandler.getFoundProducts(str);

           CheckProductPanel.this.mt.clearTable();

           CheckProductPanel.this.mt.setList(lstProducts);

           CheckProductPanel.this.mt.fireTableStructureChanged();

         }

         catch (Exception localException)

         {

         }

       }

     });

     this.btnCancel = new JButton();

     this.btnCancel.setText("清空");

     this.btnCancel.setBounds(105, 210, 80, 20);

     this.combinationPanel.add(this.btnCancel);

     this.btnCancel.addActionListener(new ActionListener()

     {

       publicvoid actionPerformed(ActionEvent e)

       {

         CheckProductPanel.this.fieldId.setText("");

         CheckProductPanel.this.fieldName.setText("");

         CheckProductPanel.this.fieldPriceCheck.setText("");

         CheckProductPanel.this.fieldQuentity.setText("");

         CheckProductPanel.this.fieldTypeCheck.setText("");

         CheckProductPanel.this.fieldSupplier.setText("");

         try {

           CheckProductPanel.this.mt.clearTable();

           CheckProductPanel.this.mt.fireTableStructureChanged();

         }

         catch (Exception localException)

         {

         }

       }

     });

     this.importandOutputButton = new JPanel();

     this.importandOutputButton.setBounds(521, 260, 210, 80);

     this.importandOutputButton.setBorder(

       BorderFactory.createTitledBorder("导入和导出数据"));

     this.importandOutputButton.setLayout(null);

     JButton importButton = new JButton("数据导入");

     importButton.setBounds(10, 30, 90, 25);

     ImprotProduct improtProduct = new ImprotProduct();

     importButton.addActionListener(improtProduct);

     JButton outportButton = new JButton("数据导出");

     outportButton.setBounds(110, 30, 90, 25);

     OutputProductListener qutputProductListener = new OutputProductListener();

     outportButton.addActionListener(qutputProductListener);

     this.importandOutputButton.add(importButton);

     this.importandOutputButton.add(outportButton);

     ((JComponent)getContentPane()).add(this.tablePanel);

     ((JComponent)getContentPane()).add(this.combinationPanel);

     ((JComponent)getContentPane()).add(this.importandOutputButton);

   }

   publicclass ImprotProduct implements ActionListener {

     public ImprotProduct() {

     }

     publicvoid actionPerformed(ActionEvent e) {

       try {

         ProductIO productIO = new ProductIO();

         List lstProduct = productIO.inport();

         if (lstProduct != null) {

           CheckProductPanel.this.mt.clearTable();

           CheckProductPanel.this.mt.setList(lstProduct);

           CheckProductPanel.this.mt.fireTableStructureChanged();

         } } catch (Exception localException) {

       }

     }

   }

   publicclass OutputProductListener implements ActionListener {

     public OutputProductListener() {

     }

     publicvoid actionPerformed(ActionEvent e) {

       ProductDao productHandler = new ProductDao();

       ProductIO productIO = new ProductIO();

       try {

         List lstProduct = productHandler.getFindProducts();

         productIO.export(lstProduct);

       }

       catch (Exception localException)

       {

       }

     }

   }

实现商品信息的模糊查询功能和导入导出功能

public CheckSupplierPanel()

   {

     setMaximizable(true);

     setIconifiable(true);

     setClosable(true);

     setTitle("供应商视图");

     getContentPane().setLayout(null);

     ((JComponent)getContentPane()).setBorder(

       BorderFactory.createTitledBorder("供应商查询视图"));

     setBounds(10, 0, 760, 450);

     this.checkSupplierPanel = new JPanel();

     this.checkSupplierPanel.setLayout(null);

     this.checkSupplierPanel.setBounds(10, 30, 750, 100);

     this.checkSupplierPanel.setBorder(

       BorderFactory.createTitledBorder("查询结果表"));

     this.checkSupplierName = new JLabel("供应商 id");

     this.checkSupplierName.setBounds(30, 30, 120, 25);

     this.comboBox = new JComboBox();

     this.comboBox.setBounds(150, 30, 120, 25);

     this.comboBox.setMaximumRowCount(5);

     addSupplierIdtoBox();

     this.comboBox.addActionListener(new ComboBoxListener());

     this.checkSupButton = new JButton("核实");

     this.checkSupButton.setBounds(300, 30, 100, 25);

     this.checkSupButton.setEnabled(false);

     CheckSupplierById checkSupplierById = new CheckSupplierById();

     this.checkSupButton.addActionListener(checkSupplierById);

     this.allSupButton = new JButton("所有供应商");

     this.allSupButton.setBounds(430, 30, 100, 25);

     AllSupplierCheck AllSupplierCheck = new AllSupplierCheck();

     this.allSupButton.addActionListener(AllSupplierCheck);

     this.checkSupplierPanel.add(this.checkSupplierName);

     this.checkSupplierPanel.add(this.comboBox);

     this.checkSupplierPanel.add(this.allSupButton);

     this.supplierTablepanel = new JPanel();

     this.supplierTablepanel.setLayout(new BorderLayout());

     this.supplierTablepanel.setBorder(

       BorderFactory.createTitledBorder("供应商表"));

     this.supplierTablepanel.setBounds(10, 140, 740, 260);

     this.mySupplierTable = new MySupplierTable();

     this.table = new JTable(this.mySupplierTable);

     JScrollPane s = new JScrollPane(this.table);

     this.supplierTablepanel.add(s, "Center");

     ((JComponent)getContentPane()).add(this.checkSupplierPanel);

     ((JComponent)getContentPane()).add(this.supplierTablepanel);

   }

制作供应商查询面板

publicvoid addSupplierIdtoBox()

   {

     this.comboBox.addItem("请选择");

     this.supplierHandler = new SupplierDao();

     List listAllId = this.supplierHandler.getFindAllSupplierId();

     Iterator it = listAllId.iterator();

     while (it.hasNext())

       this.comboBox.addItem(it.next());

   }

   publicclass AllSupplierCheck

     implements ActionListener

   {

     public AllSupplierCheck()

     {

     }

     publicvoid actionPerformed(ActionEvent e)

     {

       CheckSupplierPanel.this.comboBox.setSelectedIndex(0);

       CheckSupplierPanel.this.supplierHandler = new SupplierDao();

       try

       {

         List listAllSupplier = CheckSupplierPanel.this.supplierHandler.getFindSupplier();

         CheckSupplierPanel.this.mySupplierTable.clearTable();

         CheckSupplierPanel.this.mySupplierTable.setList(listAllSupplier);

         CheckSupplierPanel.this.mySupplierTable.fireTableStructureChanged();

       }

       catch (Exception e1)

       {

         e1.getStackTrace();

       }

     }

   }

   publicclass CheckSupplierById implements ActionListener

   {

     public CheckSupplierById()

     {

     }

     publicvoid actionPerformed(ActionEvent e) {

       String str = "select * from suppliers where sup_id = " +

         String.valueOf(CheckSupplierPanel.this.comboBox.getSelectedItem());

       CheckSupplierPanel.this.supplierHandler = new SupplierDao();

       try {

         List lstProducts = CheckSupplierPanel.this.supplierHandler.getFoundSuppliers(str);

         CheckSupplierPanel.this.mySupplierTable.clearTable();

         CheckSupplierPanel.this.mySupplierTable.setList(lstProducts);

         CheckSupplierPanel.this.mySupplierTable.fireTableStructureChanged();

       }

       catch (Exception localException)

       {

       }

     }

   }

   publicclass ComboBoxListener

     implements ActionListener

   {

     public ComboBoxListener()

     {

     }

     publicvoid actionPerformed(ActionEvent e)

     {

       if (CheckSupplierPanel.this.comboBox.getSelectedIndex() == 0) {

         CheckSupplierPanel.this.checkSupButton.setEnabled(false);

         CheckSupplierPanel.this.mySupplierTable.clearTable();

         CheckSupplierPanel.this.mySupplierTable.fireTableStructureChanged();

       } else {

         CheckSupplierPanel.this.checkSupButton.setEnabled(true);

         String str = "select * from suppliers where sup_id = " +

           String.valueOf(CheckSupplierPanel.this.comboBox.getSelectedItem());

         CheckSupplierPanel.this.supplierHandler = new SupplierDao();

         try {

           List lstProducts = CheckSupplierPanel.this.supplierHandler.getFoundSuppliers(str);

           CheckSupplierPanel.this.mySupplierTable.clearTable();

           CheckSupplierPanel.this.mySupplierTable.setList(lstProducts);

           CheckSupplierPanel.this.mySupplierTable.fireTableStructureChanged();

         }

         catch (Exception localException)

         {

         }

       }

实现供应商的查询功能

3.4系统管理

publicclassOperatorManageextends JFrame

{

    private JDesktopPane desktopPane;

    private JLabel backLabel;

    private Preferences prefernces;

    private Container container=this.getContentPane();

    private JMenuBar menuBar=new JMenuBar();

    private JFrame frame;

    private JMenu basicData,productManage,queryView,systemManage;

    publicvoidOperatorManage()

    {  

       frame = new JFrame("仓库管理系统");

       frame.addComponentListener(new ComponentListener(){

              publicvoid componentHidden(ComponentEvent e)

              {}

              publicvoid componentMoved(ComponentEvent e)

              {}

              publicvoid componentResized(ComponentEvent e)

              {}

              publicvoid componentShown(ComponentEvent e)

              {}

         });

       frame.getContentPane().setLayout(new BorderLayout());

       frame.setBounds(100, 100, 800, 600);

       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

       backLabel = new JLabel();

       backLabel.setVerticalAlignment(SwingConstants.CENTER);

       updateBackImage();

       desktopPane = new JDesktopPane();

       desktopPane.add(backLabel,new Integer(Integer.MIN_VALUE));

       frame.getContentPane().add(desktopPane);

       JTabbedPane navigationPanel = createNavigationPanel();

       frame.getContentPane().add(navigationPanel,BorderLayout.NORTH );

       frame.setVisible(true);    

    }

   

    privatevoid updateBackImage()

    {

       if(backLabel != null)

       {

           int backw = OperatorManage.this.frame.getWidth();

           int backh = OperatorManage.this.frame.getHeight();

           backLabel.setSize(backw, backh);

           backLabel.setText("<html><body><image width='" +backw+

                  "'height='" +(backh-110)+" 'src="

                  +OperatorManage.this.getClass()

                  .getResource("welcome.jpg")+"'></img></body></html>");

       }

    }

    static{

       try{

           UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

       }catch(Exception e){

           e.printStackTrace();

       }

    }

制作仓库管理面板

publicclass OperatorManage extends JInternalFrame

 {

   privatestaticfinallongserialVersionUID = 1L;

   public OperatorManage()

   {

     setIconifiable(true);

     setClosable(true);

     setBounds(30, 30, 491, 287);

     setTitle("操作员管理");

     JTabbedPane tabPane = new JTabbedPane();

     AddOperatorPanel addOperatorPanel = new AddOperatorPanel();

     RemoveOperatorPanel removeOperatorPanel = new RemoveOperatorPanel();

     tabPane.addTab("添加操作员", null, addOperatorPanel, "添加操作员");

     tabPane.addTab("删除操作员", null, removeOperatorPanel, "删除操作员");

     getContentPane().add(tabPane);

     pack();

     setVisible(true);

   }

 }

建立管理员管理面板

ublic AddOperatorPanel()

   {

     setLayout(null);

     setBounds(0, 0, 400, 300);

     this.addUserpanel = new JPanel();

     this.addUserpanel.setLayout(null);

     this.addUserpanel.setBounds(25, 35, 340, 200);

     this.addUserpanel.setBorder(BorderFactory.createTitledBorder("添加操作员"));

     this.loginameLable = new JLabel("用户名:");

     this.loginameLable.setBounds(30, 30, 120, 25);

     this.loginName = new JTextField();

     this.loginName.setBounds(150, 30, 120, 25);

     this.passwordFLabel = new JLabel("密码:");

     this.passwordFLabel.setBounds(30, 60, 120, 25);

     this.passwordFField = new JPasswordField();

     this.passwordFField.setBounds(150, 60, 120, 25);

     this.passwordSLabel = new JLabel("再密码");

     this.passwordSLabel.setBounds(30, 90, 120, 25);

     this.passwordSField = new JPasswordField();

     this.passwordSField.setBounds(150, 90, 120, 25);

     this.addOperater = new JButton("添加");

     this.addOperater.setBounds(30, 130, 100, 25);

     AddOperatorListener addOperatorListener = new AddOperatorListener();

     this.addOperater.addActionListener(addOperatorListener);

     this.addReset = new JButton("重置");

     this.addReset.setBounds(150, 130, 100, 25);

     this.addReset.addActionListener(new ActionListener()

     {

       publicvoid actionPerformed(ActionEvent e) {

         AddOperatorPanel.this.loginName.setText("");

         AddOperatorPanel.this.passwordFField.setText("");

         AddOperatorPanel.this.passwordSField.setText("");

       }

     });

     this.addUserpanel.add(this.loginameLable);

     this.addUserpanel.add(this.loginName);

     this.addUserpanel.add(this.passwordFLabel);

     this.addUserpanel.add(this.passwordFField);

     this.addUserpanel.add(this.passwordSLabel);

     this.addUserpanel.add(this.passwordSField);

     this.addUserpanel.add(this.addOperater);

     this.addUserpanel.add(this.addReset);

     add(this.addUserpanel);

     setVisible(true);

   }

制作增加管理员面板

publicclass AddOperatorListener implements ActionListener {

     public AddOperatorListener() {

     }

     publicvoid actionPerformed(ActionEvent e) {

       char[] chrpwds = AddOperatorPanel.this.passwordFField.getPassword();

       char[] chrpwdF = AddOperatorPanel.this.passwordSField.getPassword();

       String pwdS = new String(chrpwds);

       String pwdF = new String(chrpwdF);

       AddOperatorPanel.this.userHandler = new UserDao();

       String currentname = AddOperatorPanel.this.user.getUserName();

       int userrole = AddOperatorPanel.this.userHandler.getUserRoleByName(currentname);

       if (userrole == 1) {

         JOptionPane.showMessageDialog(AddOperatorPanel.this,

           "您的权限不够", "结果", 2);

         AddOperatorPanel.this.addReset.doClick();

       }

         if ((AddOperatorPanel.this.loginName.getText().equals("")) || (pwdS.equals("")) ||

           (pwdF.equals("")))

         {

           JOptionPane.showMessageDialog(AddOperatorPanel.this,

             "请输入所有信息", "结果", 2);

           return;

         }

         if (!pwdS.equals(pwdF))

         {

           JOptionPane.showMessageDialog(AddOperatorPanel.this,

             "两次密码输入错误", "结果", 2);

           AddOperatorPanel.this.addReset.doClick();

         }

         else {

           boolean flag = AddOperatorPanel.this.userHandler.isExistOperaterByName(AddOperatorPanel.this.loginName

             .getText());

           if (flag) {

             JOptionPane.showMessageDialog(AddOperatorPanel.this,

               "操作员已经存在", "结果",

               2);

             AddOperatorPanel.this.addReset.doClick();

           }

           else {

             UserData userData = new UserData();

             userData.setUserName(AddOperatorPanel.this.loginName.getText().trim());

             userData.setUserPassword(pwdS);

             AddOperatorPanel.this.userHandler.addCommonUser(userData);

             JOptionPane.showMessageDialog(AddOperatorPanel.this,

               "添加成功", "结果", 1);

             AddOperatorPanel.this.addReset.doClick();

           }

         }

       }

     }

实现增加管理员功能

public RemoveOperatorPanel()

   {

     setLayout(null);

     setBounds(0, 0, 400, 300);

     this.removeUserpanel = new JPanel();

     this.removeUserpanel.setLayout(null);

     this.removeUserpanel.setBounds(25, 35, 340, 200);

     this.removeUserpanel.setBorder(BorderFactory.createTitledBorder("删除操作员"));

     this.removeUserlabel = new JLabel("操作员姓名");

     this.removeUserlabel.setBounds(30, 30, 120, 25);

     this.fieldUserName = new JTextField();

     this.fieldUserName.setBounds(150, 30, 120, 25);

     this.removebutton = new JButton("删除");

     this.removebutton.setBounds(30, 110, 100, 25);

     RemoveOperatorListener removeOperatorListener = new RemoveOperatorListener();

     this.removebutton.addActionListener(removeOperatorListener);

     this.removeReset = new JButton("重置");

     this.removeReset.setBounds(150, 110, 100, 25);

     this.removeReset.addActionListener(new ActionListener()

     {

       publicvoid actionPerformed(ActionEvent e) {

         RemoveOperatorPanel.this.fieldUserName.setText("");

       }

     });

     this.removeUserpanel.add(this.removeUserlabel);

     this.removeUserpanel.add(this.fieldUserName);

     this.removeUserpanel.add(this.removebutton);

     this.removeUserpanel.add(this.removeReset);

     add(this.removeUserpanel);

   }

制作删除管理员面板

publicclass RemoveOperatorListener implements ActionListener

   {

     public RemoveOperatorListener() {

     }

     publicvoid actionPerformed(ActionEvent e) {

       UserDao userHandler = new UserDao();

       String currentname = RemoveOperatorPanel.this.user.getUserName();

       int userrole = userHandler.getUserRoleByName(currentname);

       if (userrole == 1)

       {

         JOptionPane.showMessageDialog(RemoveOperatorPanel.this,

           "您的权限不够", "结果", 2);

         RemoveOperatorPanel.this.removeReset.doClick();

       }

       else

       {

         if (("".equals(RemoveOperatorPanel.this.fieldUserName.getText())) ||

           (RemoveOperatorPanel.this.fieldUserName.getText().equals(""))) {

           JOptionPane.showMessageDialog(RemoveOperatorPanel.this,

             "请输入所有的信息", "结果",

             2);

           RemoveOperatorPanel.this.removeReset.doClick();

           return;

         }if (!userHandler.isExistOperaterByName(RemoveOperatorPanel.this.fieldUserName

           .getText())) {

           JOptionPane.showMessageDialog(RemoveOperatorPanel.this,

             "操作员不存在", "结果", 2);

           RemoveOperatorPanel.this.removeReset.doClick();

         } elseif (RemoveOperatorPanel.this.user.getUserName().equals(RemoveOperatorPanel.this.fieldUserName.getText()))

         {

           JOptionPane.showMessageDialog(RemoveOperatorPanel.this,

             "你不能删除自己", "Results",

             2);

           RemoveOperatorPanel.this.removeReset.doClick();

         }

         else

         {

           boolean flag = userHandler.deleteCommenUserByName(RemoveOperatorPanel.this.fieldUserName.getText());

           if (flag)

           {

             JOptionPane.showMessageDialog(RemoveOperatorPanel.this,

               "你已经删除  " + RemoveOperatorPanel.this.fieldUserName.getText(), "结果", 1);

             RemoveOperatorPanel.this.removeReset.doClick();

           }

         }

       }

     }

   }

实现删除管理员功能

3.5显示当前时间

  publicclass TimeDemo extends Thread

  {

   private String string = "";

    private JLabel label;

 

    public TimeDemo(JLabel label)

    {

     this.label = label;

    }

 

    publicvoid run() {

      while (true) {

       Calendar rightNowTime = Calendar.getInstance();

       DateFormat dateformat = DateFormat.getDateTimeInstance();

       this.string = dateformat.format(rightNowTime.getTime());

       this.label.setText("System Time??" + this.string);

        try {

         Thread.sleep(1000L);

        } catch (InterruptedException e) {

         e.printStackTrace();

        }

      }

    }

  }

实现动态显示当前时间

4 系统设计结果

登陆界面

主界面

供应商信息界面

商品信息管理界面

进货单

出货单

商品信息查询

供应商信息查询

操作员管理

更改密码

5 实训感想

刚开始实训时,让我感到很兴奋,毕竟自己的主攻技术是java,所以自然也就非常的亢奋。当然编代码也并非是想象中那样顺利,开始的实习让我异常感到任务的艰巨,因为编程中我遇到了很多以前未曾遇到的难点,有时难免冥思苦想也无济于事,这让我对编程技术又有了新的认识:编写代码时中我们必须边总结边思考,开始阶段对老师所给的任何方法和类都不要放过,不管是否简单与否都要乐于地研究,因为老师走过的路比我们长,那么其经验也就肯定比我们丰富。

在刚开始的几天里,当家都开始忙着动手做自己的项目!就是在刚开始的几天里,大家在做项目的过程中,就已经遇到了很多很多的问题,把大家难倒了! 包括我自己!有些问题不是立刻就能发现原因,不能立刻就解决,在这个时候,我感到很烦恼,有些放弃的念头。但是,我知道解决问题不是一件很难的事,只要找出原因,有不懂的就问同学,问老师,向他们领教,问题就解决了! 在往后实训的日子里,我不断地遇到难题,甚至有些难题简直令人烦恼,但是,在自己的努力下,在老师和同学的帮助下,我所遇到的问题不断地得到解决,项目开发的进度没有受阻!所以要依靠老师的模板努力提高自己的代码编写能力。

在我自己开发项目的过程中,我最深刻的一个难题是用JAVA连接数据库实现增删查改功能的这一个过程,这是我遇到的问题中最棘手一个问题了! JAVA文件里,代码很多,一不小心就弄错,多一个符号,少一个符号,打错一个单词,这些错误都让文件运行不了,所以在测试的过程中不断出错,要不断的修改! 在这个问题当中,也发现了自己的弱点,就是对JAVA不熟悉,所以,在这一方面要加强!我们所学的知识还是很少的,是很基础的,还有很多很多的更深奥的知识等着我们去学习,这样,我们才能得到更大的进步,得到更大的提高!

 我不能满足于现状,更重要的是我要继续学习更多的知识,知识是学不完的,只有学得更多的知识。参加更多的实践也是十分重要的,实践就是经历,增加经历,才能得到更多的经验,经验是宝贵的,将来可以运用到真正的工作当中。

6 附件

更多相关推荐:
仓库管理系统实训报告

题目姓名学号班级时间数据库技术课程设计1目录1需求分析111仓库管理系统的功能分析112仓库管理系统的功能图22概念结构设计33逻辑结构设计54数据库设计541数据库和各表的创建6411数据表结构设计6412创...

仓库管理系统实验报告

仓库管理系统数据库设计与实现一.实验时间、地点时间:第十三周(11月21日25日)地点:软件楼305二.实验目的通过本次课程设计让学生能够综合运用所学的关系数据库原理知识解决并能设计一个实际问题,进一步掌握数据…

仓库管理系统报告

计算机工程学院Project2GUISQL20xx实习报告选题名称专业计算机科学与技术软件工程方向班级软件1092姓名王伟剑学号1091305220指导教师冯万利于长辉高尚兵庄军20xx年06月11日Proje...

数据库课程设计报告(仓库管理系统)

数据库课程设计报告(仓库管理系统)三概要设计3.1ER图和相关说明类别(类别编号,类别名称,上级类别)仓库(仓库编号,隶属单位,备注)用户(用户名,密码,权限类型);客户(客户编号,联系人,单位,联系电话,传真…

仓库管理系统的实习报告

学院班级姓名学号实习报告电气工程学院09计控一班吕振翰090103010071实习时间20xx年9月12日实习地点秦皇岛烟草机械有限责任公司实习目的加深同学对课内知识的理解和对工厂实践的认识理论联系实际实习单位...

仓库管理系统设计报告-软件工程

软件工程课程设计报告题目:仓库管理系统班级:计算机科学与技术组员(学号):指导教师:完成日期:目录报告编写规范(1)正文:包括标题,统一用宋体小四号字,行距为1.5倍。(2)标题序号从大到小的顺序理工科为:11…

仓库管理系统课程设计报告

湖北文理学院程序设计课程设计报告项目名称仓库管理系统学生姓名张三学号20xx19xx17班级物联网1311日期20xx19xx17年9月9日一需求分析1项目描述仓库管理系统用于仓库的货物管理实现货物信息的维护等...

仓库管理系统实训报告

郑州轻工业学院实训报告实训名称:仓库管理系统摘要:仓储是现代物流的一个重要组成部分,在物流系统中起着至关重要的作用,是厂商研究和规划的重点。高效合理的仓储系统可以帮助厂商加快物资流动的速度,降低成本,保障生产的…

数据库设计报告—仓库管理系统

仓库管理系统仓库管理是整个物资供应管理系统的核心本实例着重讲解仓库管理模块给出数据库设计和程序实现过程1系统设计11系统设计目标系统开发的总统任务是实现企业物资设备管理的系统化规范化和自动化从而达到仓库管理效率...

仓库管理系统总体设计报告

仓库管理系统总体设计报告1概述1系统设计的目标仓库管理是企业管理的重要组成部分企业的生产经营需要库存保证各种材料的及时供应仓库管理对生产效率的提高有着极其重要的影响所有企业的经营活动都离不开物流的活动仓库管理的...

仓库管理系统C++课程设计报告

高级语言程序设计课程设计报告设计题目图书管理系统专业计算机科学与技术班级姓名学号20xx年6月5日目录1设计目的32设计思想33类及对象设计44程序源代码55调试记录166总结18共19页2页2仓库管理系统1设...

仓库管理系统设计报告

仓库管理系统设计报告,内容附图。

仓库管理系统实验报告(15篇)