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

📄 stockframe.java

📁 基于mvc的java进销存系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
 * StockFrame.java
 *
 * Created on 2007年5月20日, 下午3:24
 */

package form;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Locale;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import table.PurchaseDetail;
import table.PurchaseMaster;
import table.Supplier;
import task.HandlePurchaseDetail;
import task.HandlePurchaseMaster;
import task.HandleSupplier;
import util.ConstentUtil;

/**
 *
 * @author  下雪天
 */
public class StockFrame extends javax.swing.JInternalFrame {
    private static int n=0;
    private int m=0;
    private double sum=0;
    private String str=null;
    /** Creates new form StockFrame */
    public StockFrame() {
        super("采购进货",false,false,false,true);
        initComponents();
        shows();
        showframe();
        cmbSupplier.setEditable(false);
        txtAmount.setEditable(false);
        txtPurchaseID.setEditable(false);
    }
    public void shows(){
        HandleSupplier hu=new HandleSupplier();
        ArrayList v=new ArrayList();
        v=hu.findAll();
        for(int i=0;i<v.size();i++){
            Supplier s=new Supplier();
            s=(Supplier)v.get(i);
            cmbSupplier.addItem(s.getSupplierID());
        }
        
    } 
    public void showframe(){
        HandlePurchaseMaster hu=new HandlePurchaseMaster();
        ArrayList v=new ArrayList();
        v=hu.findAll();
        m=v.size();
        if(v.size()>0)
        {
        PurchaseMaster s=new PurchaseMaster();
        s=(PurchaseMaster)v.get(n);
        cmbSupplier.setSelectedItem(s.getSupplierID());
        txtPurchaseID.setText(s.getPurchaseID());
        //Date date = new Date();
        DateFormat format;
        format = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.CHINA);
        //String nowdate = format.format(date); 
        SimpleDateFormat datetemp = new SimpleDateFormat("yyyy-MM-dd");
        Date temp1=null;
        try {
            temp1 = datetemp.parse(s.getPurchaseDate());
        } catch (ParseException ex) {
            ex.printStackTrace();
        }
        dateChooserJButton1.setDate(temp1);
        
        HandlePurchaseDetail hp=new HandlePurchaseDetail();
        ArrayList a=new ArrayList();
        a=hp.find(s.getPurchaseID());
        String[] theader={"商品编号"," 商品数量","商品价格","总金额"};
        String[][] tdata=new String[a.size()][8];
        for(int i=0;i<a.size();i++){
            PurchaseDetail u=new PurchaseDetail();
            u=(PurchaseDetail)a.get(i);
            tdata[i][0]=u.getProductID();
            tdata[i][1]=Double.toString(u.getQuantity());
            tdata[i][2]=Double.toString(u.getPrice());
            tdata[i][3]=Double.toString(u.getAmount());
            sum+=u.getAmount();
        }
        txtAmount.setText(String.valueOf(sum));
        jTable2.setModel(new DefaultTableModel(tdata,theader));
        }
    }
    public void showout(){
         HandlePurchaseDetail hp=new HandlePurchaseDetail();
        ArrayList a=new ArrayList();
       a=hp.find(txtPurchaseID.getText());
        String[] theader={"商品编号"," 商品数量","商品价格","总金额"};
        String[][] tdata=new String[a.size()][8];
        for(int i=0;i<a.size();i++){
            PurchaseDetail u=new PurchaseDetail();
            u=(PurchaseDetail)a.get(i);
            tdata[i][0]=u.getProductID();
            tdata[i][1]=Double.toString(u.getQuantity());
            tdata[i][2]=Double.toString(u.getPrice());
            tdata[i][3]=Double.toString(u.getAmount());
            sum+=u.getAmount();
        }
        txtAmount.setText(String.valueOf(sum));
        jTable2.setModel(new DefaultTableModel(tdata,theader));
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" 生成的代码 ">//GEN-BEGIN:initComponents
    private void initComponents() {
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel3 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        cmbSupplier = new javax.swing.JComboBox();
        jLabel8 = new javax.swing.JLabel();
        txtPurchaseID = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        txtAmount = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jButton8 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        dateChooserJButton1 = new been.DateChooserJButton();
        jButton6 = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTable2 = new javax.swing.JTable();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();

        jPanel3.setToolTipText("\u8fdb\u8d27\u5165\u5e93");
        jLabel6.setFont(new java.awt.Font("宋体", 1, 24));
        jLabel6.setForeground(new java.awt.Color(102, 102, 255));
        jLabel6.setText("\u91c7\u8d2d\u5355\u6dfb\u52a0 ");

        jPanel4.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 153, 51)));
        jLabel7.setText("\u4f9b\u8d27\u5546\uff1a");

        jLabel8.setText("\u624b\u5de5\u5355\u53f7\uff1a");

        jLabel9.setText("\u91c7\u8d2d\u65e5\u671f\uff1a");

        jLabel10.setText("\u603b\u91d1\u989d\uff1a");

        jLabel1.setText("\uffe5");

        jButton8.setText("\u53d6\u6d88");
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });

        jButton7.setText("\u4fdd\u5b58");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

        jButton6.setText("\u6dfb\u52a0");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel4Layout = new org.jdesktop.layout.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel4Layout.createSequentialGroup()
                .add(22, 22, 22)
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel4Layout.createSequentialGroup()
                        .add(jLabel7)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(cmbSupplier, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 102, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(jPanel4Layout.createSequentialGroup()
                        .add(jLabel9)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(dateChooserJButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .add(43, 43, 43)
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jLabel8)
                    .add(jLabel10))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel4Layout.createSequentialGroup()
                        .add(txtAmount, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 83, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 13, Short.MAX_VALUE)
                        .add(jLabel1))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, txtPurchaseID, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 108, Short.MAX_VALUE))
                .add(64, 64, 64)
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jButton7)
                    .add(jButton6))
                .add(38, 38, 38)
                .add(jButton8)
                .add(111, 111, 111))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel7)
                    .add(jLabel8)
                    .add(txtPurchaseID, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(cmbSupplier, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jButton6))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel10)
                    .add(txtAmount, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)

⌨️ 快捷键说明

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