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

📄 chaxunframe.java

📁 超市管理系统 运行环境JDK1.4以上 JB2006 源代码公开
💻 JAVA
字号:
package com.aptech.view;
import com.aptech.connection.*;

import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.Rectangle;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JTextArea;
import javax.swing.JList;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.*;
import com.aptech.classmarket.*;
import com.aptech.classmarket.*;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JOptionPane;
import javax.swing.JRadioButton;
import javax.swing.ButtonGroup;
import java.awt.Dimension;
import java.awt.Color;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class chaxunFrame extends JFrame {
    int i=0;
    public chaxunFrame() {
        try {
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        getContentPane().setLayout(null);
        jLabel1.setFont(new java.awt.Font("黑体", Font.BOLD, 18));
        jLabel1.setForeground(Color.red);
        jLabel1.setText("选择查询类别:");
        this.getContentPane().setBackground(new Color(0, 250, 190));
        setSize(new Dimension(800, 600));
        jLabel1.setBounds(new Rectangle(124, 7, 154, 35));
        jButton1.setBounds(new Rectangle(474, 85, 77, 24));
        jButton1.setText("查询");
        jButton1.addActionListener(new chaxunFrame_jButton1_actionAdapter(this));
        jScrollPane1.setBounds(new Rectangle(27, 138, 692, 183));
        jop.setBounds(new Rectangle(74, 459, 117, 14));
        jbtn1.setBackground(new Color(0, 250, 190));
        jbtn1.setText("入库查询");
        setTitle("一切为了顾客");
        jbtn1.setBounds(new Rectangle(122, 43, 88, 27));
        jbtn2.setBackground(new Color(0, 250, 190));
        jbtn2.setText("出库查询");
        jbtn2.setBounds(new Rectangle(235, 44, 83, 27));
        jTextField1.setBounds(new Rectangle(268, 85, 160, 24));
        jTextField1.addActionListener(new chaxunFrame_jTextField1_actionAdapter(this));
        jButton3.setBackground(Color.cyan);
        jButton3.setBounds(new Rectangle(304, 326, 114, 26));
        jButton3.setText("返回管理界面");
        jButton3.addActionListener(new chaxunFrame_jButton3_actionAdapter(this));
        this.getContentPane().add(jop);
        this.getContentPane().add(jScrollPane1);
        this.getContentPane().add(jbtn2);
        this.getContentPane().add(jbtn1);
        this.getContentPane().add(jLabel1);
        this.getContentPane().add(jButton1);
        this.getContentPane().add(jLabel2);
        this.getContentPane().add(jTextField1);
        this.getContentPane().add(jButton3);
        jScrollPane1.getViewport().add(jTable1);
        jLabel2.setText("请输入商品单据号:");
        jLabel2.setBounds(new Rectangle(123, 83, 133, 26));
        buttonGroup1.add(jbtn1);
        buttonGroup1.add(jbtn2);
    }

    JLabel jLabel1 = new JLabel();
    JLabel jLabel2 = new JLabel();
    JTextField jTextField1 = new JTextField();
    JButton jButton1 = new JButton();
    JScrollPane jScrollPane1 = new JScrollPane();
    Object[][] cells = { {"", "", "", "", "", "", "", "", "", }, {"", "", "", "", "",
                       "", "", "", "", }, {"", "", "", "", "", "", "", "", "", },{"", "", "", "", "", "", "", "", "", },
    {"", "", "", "", "", "", "", "", "", },{"", "", "", "", "", "", "", "", "", },{"", "", "", "", "", "", "", "", "", },
    {"", "", "", "", "", "", "", "", "", },{"", "", "", "", "", "", "", "", "", },{"", "", "", "", "", "", "", "", "", },
    {"", "", "", "", "", "", "", "", "", },{"", "", "", "", "", "", "", "", "", },{"", "", "", "", "", "", "", "", "", },
    {"", "", "", "", "", "", "", "", "", },{"", "", "", "", "", "", "", "", "", },{"", "", "", "", "", "", "", "", "", },
    {"", "", "", "", "", "", "", "", "", },{"", "", "", "", "", "", "", "", "", },{"", "", "", "", "", "", "", "", "", },
    {"", "", "", "", "", "", "", "", "", },{"", "", "", "", "", "", "", "", "", },{"", "", "", "", "", "", "", "", "", },
    {"", "", "", "", "", "", "", "", "", },};
    String[] colnames = {"单据", "商品编号","商品名称", "商品类别","单位","进价","数量","生产厂商", "供应商"};

    JTable jTable1 = new JTable(cells,colnames);
    JOptionPane jop = new JOptionPane();
    JRadioButton jbtn1 = new JRadioButton();
    JRadioButton jbtn2 = new JRadioButton();
    ButtonGroup buttonGroup1 = new ButtonGroup();
    JButton jButton3 = new JButton();
    public void jButton1_actionPerformed(ActionEvent e) {
    Tosql ts=new Tosql();
    Connection con=ts.tosql();
    selectstockid sg=new selectstockid();
    Selectoutgoods sg1=new Selectoutgoods();
    Ingoods g=new Ingoods();
    Outgoods a=new Outgoods();
    g.setstocksid(jTextField1.getText());
    a.setstocksid(jTextField1.getText());
   boolean flag2=false;
    boolean flag1=false;
    flag2=sg1.select(a);
    flag1=sg.select(g);
    try {
        if (flag1 == true&&jbtn1.isSelected()==true) {


            PreparedStatement ps = con.prepareStatement("select StocksId,GoodsId,Goodsname,Goodssort,unit,inPrice,amount,vent,address from ingoods where stocksid=? ");
            ps.setString(1, jTextField1.getText());
            ResultSet rs = ps.executeQuery();
            while (rs.next()) {

                jTable1.setValueAt(rs.getString(1),i,0);
                jTable1.setValueAt(rs.getString(2), i, 1);
                jTable1.setValueAt(rs.getString(3), i, 2);
                jTable1.setValueAt(rs.getString(4), i,3);
                jTable1.setValueAt(rs.getString(5), i, 4);
                jTable1.setValueAt(rs.getFloat(6), i, 5);
                jTable1.setValueAt(rs.getInt(7),i,6);
                jTable1.setValueAt(rs.getString(8),i,7);
                jTable1.setValueAt(rs.getString(9), i, 8);


                i++;
            }
            }

        else if(flag2 == true&&jbtn2.isSelected()==true){
            PreparedStatement ps = con.prepareStatement("select StocksId,GoodsId,Goodsname,Goodssort,unit,inPrice,amount,vent,address from outgoods where stocksid=? ");
            ps.setString(1, jTextField1.getText());
            ResultSet rs = ps.executeQuery();
            while (rs.next()) {

                jTable1.setValueAt(rs.getString(1),i,0);
                jTable1.setValueAt(rs.getString(2), i, 1);
                jTable1.setValueAt(rs.getString(3), i, 2);
                jTable1.setValueAt(rs.getString(4), i,3);
                jTable1.setValueAt(rs.getString(5), i, 4);
                jTable1.setValueAt(rs.getFloat(6), i, 5);
                jTable1.setValueAt(rs.getInt(7),i,6);
                jTable1.setValueAt(rs.getString(8),i,7);
                jTable1.setValueAt(rs.getString(9), i, 8);
               i++;
            }
            }




        else{
            jop.showMessageDialog(this, "无此进货单据", "系统提示",
                                  JOptionPane.ERROR_MESSAGE);
        }
    } catch (SQLException ex) {
    }
    }

    public void jTextField1_actionPerformed(ActionEvent e) {

    }

    public void jButton3_actionPerformed(ActionEvent e) {
        MainFrame mm=new MainFrame();
        mm.setSize(500,400);
        mm.setVisible(true);
        this.dispose();
        mm.setLocationRelativeTo(this);

    }
}


class chaxunFrame_jButton3_actionAdapter implements ActionListener {
    private chaxunFrame adaptee;
    chaxunFrame_jButton3_actionAdapter(chaxunFrame adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton3_actionPerformed(e);
    }
}


class chaxunFrame_jTextField1_actionAdapter implements ActionListener {
    private chaxunFrame adaptee;
    chaxunFrame_jTextField1_actionAdapter(chaxunFrame adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jTextField1_actionPerformed(e);
    }
}


class chaxunFrame_jButton1_actionAdapter implements ActionListener {
    private chaxunFrame adaptee;
    chaxunFrame_jButton1_actionAdapter(chaxunFrame adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton1_actionPerformed(e);
    }
}

⌨️ 快捷键说明

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