⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 goodsframe.java

📁 超市管理系统 运行环境JDK1.4以上 JB2006 源代码公开
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package com.aptech.view;

import java.awt.BorderLayout;

import javax.swing.*;
import javax.swing.JLabel;
import java.awt.*;
import java.awt.Font;
import javax.swing.JTabbedPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JButton;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import com.aptech.classmarket.*;
import java.awt.Rectangle;
import java.sql.*;
import com.aptech.connection.*;
import javax.swing.BorderFactory;

public class GoodsFrame extends JFrame {


    public GoodsFrame() {
        try {
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        getContentPane().setLayout(null);
        jLabel1.setFont(new java.awt.Font("黑体", Font.BOLD, 20));
        jLabel1.setForeground(Color.red);
        jLabel1.setText("商品管理");
        jLabel1.setBounds(new Rectangle(208, 21, 123, 43));
        jButton1.setBackground(Color.cyan);
        jButton1.setBounds(new Rectangle(9, 232, 112, 22));
        jButton1.setBorder(BorderFactory.createRaisedBevelBorder());
        jButton1.setText("添加");
        jButton1.addActionListener(new GoodsFrame_jButton1_actionAdapter(this));
        jButton2.setBackground(Color.cyan);
        jButton2.setBounds(new Rectangle(378, 233, 115, 21));
        jButton2.setBorder(BorderFactory.createRaisedBevelBorder());
        jButton2.setText("退出");
        jButton2.addActionListener(new GoodsFrame_jButton2_actionAdapter(this));
        jButton3.setBackground(Color.cyan);
        jButton3.setBounds(new Rectangle(188, 233, 129, 21));
        jButton3.setBorder(BorderFactory.createRaisedBevelBorder());
        jButton3.setText("重置");
        jLabel2.setText("商品名称:");
        jLabel2.setBounds(new Rectangle(21, 15, 88, 30));
        txtname.setBounds(new Rectangle(128, 15, 102, 30));
        jLabel3.setText("商品编号:");
        jLabel3.setBounds(new Rectangle(279, 16, 89, 30));
        txtid.setBounds(new Rectangle(371, 16, 104, 28));
        jLabel4.setText("商品进价:");
        jLabel4.setBounds(new Rectangle(21, 99, 87, 27));
        jLabel5.setText("计量单位:");
        jLabel5.setBounds(new Rectangle(279, 61, 87, 27));
        jLabel6.setText("商品类别:");
        jLabel6.setBounds(new Rectangle(21, 58, 87, 27));
        cbosort.setBounds(new Rectangle(128, 59, 102, 28));
        jLabel7.setText("生产厂商:");
        jLabel7.setBounds(new Rectangle(280, 99, 77, 27));
        jLabel8.setText("供应商:");
        jLabel8.setBounds(new Rectangle(21, 140, 79, 27));
        jLabel9.setText("数量:");
        jLabel9.setBounds(new Rectangle(282, 138, 89, 25));
        jLabel10.setText("预设销售金额:");
        jLabel10.setBounds(new Rectangle(21, 181, 96, 26));
        txtmoney.setBounds(new Rectangle(126, 181, 104, 29));
        txtinprice.setBounds(new Rectangle(128, 102, 101, 28));
        txtvent.setBounds(new Rectangle(128, 142, 100, 25));
        txtamount.setBounds(new Rectangle(370, 141, 104, 29));
        txtunit.setBounds(new Rectangle(370, 58, 104, 29));
        txtaddress.setBounds(new Rectangle(370, 102, 104, 29));
        jScrollPane1.setBounds(new Rectangle(7, 4, 489, 218));
        jButton4.setBackground(Color.cyan);
        jButton4.setBounds(new Rectangle(79, 230, 122, 23));
        jButton4.setBorder(BorderFactory.createRaisedBevelBorder());
        jButton4.setText("浏览商品");
        jButton4.addActionListener(new GoodsFrame_jButton4_actionAdapter(this));
        jButton5.setBackground(Color.cyan);
        jButton5.setBounds(new Rectangle(320, 230, 121, 23));
        jButton5.setBorder(BorderFactory.createRaisedBevelBorder());
        jButton5.setText("删除");
        jButton5.addActionListener(new GoodsFrame_jButton5_actionAdapter(this));
        jScrollPane2.setBounds(new Rectangle(7, 6, 489, 213));
        jButton6.setBackground(Color.cyan);
        jButton6.setBounds(new Rectangle(79, 230, 120, 23));
        jButton6.setBorder(BorderFactory.createRaisedBevelBorder());
        jButton6.setText("浏览商品");
        jButton6.addActionListener(new GoodsFrame_jButton6_actionAdapter(this));
        this.getContentPane().setBackground(new Color(0, 255, 190));
        this.setTitle("一切为了顾客");
        jop.setBounds(new Rectangle(39, 442, 262, 90));
        jTabbedPane1.setBackground(Color.cyan);
        jPanel1.setBackground(new Color(0, 255, 190));
        jPanel2.setBackground(new Color(0, 255, 190));
        jPanel3.setBackground(new Color(0, 255, 190));
        jPanel4.setBackground(new Color(0, 255, 190));
        jButton7.setBackground(Color.cyan);
        jButton7.setBounds(new Rectangle(334, 230, 108, 22));
        jButton7.setBorder(BorderFactory.createRaisedBevelBorder());
        jButton7.setText("修改");
        jButton7.addActionListener(new GoodsFrame_jButton7_actionAdapter(this));
        jTable1.setBackground(Color.yellow);
        jTable2.setBackground(Color.yellow);
        jScrollPane3.setBounds(new Rectangle(4, 42, 494, 179));
        jRadioButton1.setBackground(new Color(0, 255, 190));
        jRadioButton1.setText("按商品种类分类");
        jRadioButton1.setBounds(new Rectangle(22, 11, 128, 21));
        jRadioButton2.setBackground(new Color(0, 255, 190));
        jRadioButton2.setText("按商品编号分类");
        jRadioButton2.setBounds(new Rectangle(193, 11, 128, 21));
        jRadioButton3.setBackground(new Color(0, 255, 190));
        jRadioButton3.setText("按商品名称分类");
        jRadioButton3.setBounds(new Rectangle(360, 11, 128, 21));
        jButton8.setBackground(Color.cyan);
        jButton8.setBounds(new Rectangle(54, 228, 124, 22));
        jButton8.setBorder(BorderFactory.createRaisedBevelBorder());
        jButton8.setText("确定");
        jButton8.addActionListener(new GoodsFrame_jButton8_actionAdapter(this));
        jButton9.setBackground(Color.cyan);
        jButton9.setBounds(new Rectangle(310, 228, 123, 22));
        jButton9.setBorder(BorderFactory.createRaisedBevelBorder());
        jButton9.setText("退出");
        jButton9.addActionListener(new GoodsFrame_jButton9_actionAdapter(this));
        jTable3.setBackground(Color.yellow);
        this.getContentPane().add(jTabbedPane1);
        jPanel1.setLayout(null);
        jPanel2.setLayout(null);
        jPanel3.setLayout(null);
        jPanel4.setLayout(null);
        jTabbedPane1.add(jPanel1, "添加商品");
        jPanel1.add(jButton2);
        jPanel1.add(jButton1);
        jPanel1.add(jButton3);
        jPanel1.add(jLabel2);
        jPanel1.add(txtname);
        jPanel1.add(jLabel3);
        jPanel1.add(txtid);
        jPanel1.add(jLabel6);
        jPanel1.add(jLabel5);
        jPanel1.add(jLabel4);
        jPanel1.add(cbosort);
        jPanel1.add(jLabel7);
        jPanel1.add(jLabel8);
        jPanel1.add(jLabel10);
        jPanel1.add(jLabel9);
        jPanel1.add(txtmoney);
        jPanel1.add(txtinprice);
        jPanel1.add(txtvent);
        jPanel1.add(txtaddress);
        jPanel1.add(txtunit);
        jPanel1.add(txtamount);
        jTabbedPane1.add(jPanel2, "删除商品");
        jPanel2.add(jScrollPane1);
        jScrollPane1.getViewport().add(jTable1);
        jPanel2.add(jButton4);
        jPanel2.add(jButton5);
        jTabbedPane1.add(jPanel3, "修改商品");
        jPanel3.add(jScrollPane2);
        jScrollPane2.getViewport().add(jTable2);
        jPanel3.add(jButton6);
        jPanel3.add(jButton7);
        jTabbedPane1.add(jPanel4, "查询商品");
        jPanel4.add(jScrollPane3);
        jPanel4.add(jRadioButton1);
        jPanel4.add(jRadioButton2);
        jPanel4.add(jRadioButton3);
        jPanel4.add(jButton8);
        jPanel4.add(jButton9);
        jScrollPane3.getViewport().add(jTable3);
        this.getContentPane().add(jLabel1);
        this.getContentPane().add(jop);
        jTabbedPane1.setBounds(new Rectangle(1, 64, 509, 291));
        cbosort.addItem("百货");
        buttonGroup1.add(jRadioButton1);
        buttonGroup1.add(jRadioButton2);
        buttonGroup1.add(jRadioButton3);
    }

    JLabel jLabel1 = new JLabel();
    JTabbedPane jTabbedPane1 = new JTabbedPane();
    JPanel jPanel1 = new JPanel();
    JPanel jPanel2 = new JPanel();
    JPanel jPanel3 = new JPanel();
    JPanel jPanel4 = new JPanel();
    JButton jButton1 = new JButton();
    JButton jButton2 = new JButton();
    JButton jButton3 = new JButton();
    JLabel jLabel2 = new JLabel();
    JTextField txtname = new JTextField();
    JLabel jLabel3 = new JLabel();
    JTextField txtid = new JTextField();
    JLabel jLabel4 = new JLabel();
    JLabel jLabel5 = new JLabel();
    JLabel jLabel6 = new JLabel();
    JComboBox cbosort = new JComboBox();
    JLabel jLabel7 = new JLabel();
    JLabel jLabel8 = new JLabel();
    JLabel jLabel9 = new JLabel();
    JLabel jLabel10 = new JLabel();
    JTextField txtmoney = new JTextField();
    JTextField txtinprice = new JTextField();
    JTextField txtvent = new JTextField();
    JTextField txtamount = new JTextField();
    JTextField txtunit = new JTextField();
    JTextField txtaddress = new JTextField();
    JScrollPane jScrollPane1 = new JScrollPane();
    JButton jButton4 = new JButton();
    JButton jButton5 = new JButton();
    Object[][] cells = { {"", "", "", "", "", "", "", ""}, {"", "", "", "", "",
                       "", "", ""}, {"", "", "", "", "", "", "", ""}, {"", "",
                       "", "", "", "", "", ""}, {"", "", "", "", "", "", "", ""},
                       {"", "", "", "", "", "", "", ""}, {"", "", "", "", "",
                       "", "", ""}, {"", "", "", "", "", "", "", ""}, {"", "",
                       "", "", "", "", "", ""}, {"", "", "", "", "", "", "", ""},
                       {"", "", "", "", "", "", "", ""}, {"", "", "", "", "",
                       "", "", ""}, {"", "", "", "", "", "", "", ""}, {"", "",
                       "", "", "", "", "", ""}, {"", "", "", "", "", "", "", ""},
                       {"", "", "", "", "", "", "", ""}, {"", "", "", "", "",
                       "", "", ""}, {"", "", "", "", "", "", "", ""}
    };
    String[] colnames = {"商品编号", "商品名称", "生产厂商", "供应商", "商品种类", "进价", "数量"};
    JTable jTable1 = new JTable(cells, colnames);
    JScrollPane jScrollPane2 = new JScrollPane();
    JButton jButton6 = new JButton();
    Object[][] cells1 = { {"", "", "", "", "", "", "", ""}, {"", "", "", "", "",
                        "", "", ""}, {"", "", "", "", "", "", "", ""}, {"", "",
                        "", "", "", "", "", ""}, {"", "", "", "", "", "", "",
                        ""}, {"", "", "", "", "", "", "", ""}, {"", "", "", "",
                        "", "", "", ""}, {"", "", "", "", "", "", "", ""}, {"",
                        "", "", "", "", "", "", ""}, {"", "", "", "", "", "",
                        "", ""}, {"", "", "", "", "", "", "", ""}, {"", "", "",
                        "", "", "", "", ""}, {"", "", "", "", "", "", "", ""},
                        {"", "", "", "", "", "", "", ""}, {"", "", "", "", "",
                        "", "", ""}, {"", "", "", "", "", "", "", ""}, {"", "",
                        "", "", "", "", "", ""}, {"", "", "", "", "", "", "",
                        ""}
    };
    String[] colnames1 = {"商品编号", "商品名称", "生产厂商", "供应商", "商品种类", "进价", "数量"};
    JTable jTable2 = new JTable(cells1, colnames1);
    JOptionPane jop = new JOptionPane();
    JButton jButton7 = new JButton();
    JScrollPane jScrollPane3 = new JScrollPane();
    Object[][] cells2 = { {"", "", "", "", "", "", "", ""}, {"", "", "", "", "",
                        "", "", ""}, {"", "", "", "", "", "", "", ""}, {"", "",
                        "", "", "", "", "", ""}, {"", "", "", "", "", "", "",
                        ""}, {"", "", "", "", "", "", "", ""}, {"", "", "", "",
                        "", "", "", ""}, {"", "", "", "", "", "", "", ""}, {"",
                        "", "", "", "", "", "", ""}, {"", "", "", "", "", "",
                        "", ""}, {"", "", "", "", "", "", "", ""}, {"", "", "",
                        "", "", "", "", ""}, {"", "", "", "", "", "", "", ""},
                        {"", "", "", "", "", "", "", ""}, {"", "", "", "", "",
                        "", "", ""}, {"", "", "", "", "", "", "", ""}, {"", "",
                        "", "", "", "", "", ""}, {"", "", "", "", "", "", "",
                        ""}
    };
    String[] colnames2 = {"商品编号", "商品名称", "生产厂商", "供应商", "商品种类", "进价", "数量"};
    JTable jTable3 = new JTable(cells2, colnames2);
    Icon mag = new ImageIcon("06.jpg");
    JRadioButton jRadioButton1 = new JRadioButton();
    JRadioButton jRadioButton2 = new JRadioButton();
    JRadioButton jRadioButton3 = new JRadioButton();
    ButtonGroup buttonGroup1 = new ButtonGroup();
    JButton jButton8 = new JButton();
    JButton jButton9 = new JButton();
    public void jButton1_actionPerformed(ActionEvent e) {
        Goods good = new Goods();
        good.setgoodsid(txtid.getText());
        good.setgoodsname(txtname.getText());
        good.setgoodssort((String) cbosort.getSelectedItem());
        good.setaddress(txtaddress.getText());
        good.setvent(txtvent.getText());
        good.setunit(txtunit.getText());
        good.setinprice(Float.parseFloat(txtinprice.getText()));
        good.setmoney(Float.parseFloat(txtmoney.getText()));
        good.setamount(Integer.parseInt(txtamount.getText()));
        Addgoods add = new Addgoods();
        boolean flag = false;
        Selectgoodsid ss = new Selectgoodsid();
        flag = ss.select(good);
        if (flag == false) {
            add.add(good);
            jop.showMessageDialog(this, "添加成功", "系统提示",
                                  JOptionPane.INFORMATION_MESSAGE);
        } else {
            jop.showMessageDialog(this, "商品已存在", "系统提示",
                                  JOptionPane.ERROR_MESSAGE);
        }
    }

    public void jButton7_actionPerformed(ActionEvent e) {

        int row = 0;
        row = jTable2.getSelectedRow();
        Object id = jTable2.getValueAt(row, 0);
        Goods g = new Goods();
        g.setgoodsid(id.toString());
        boolean flag = false;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -