stockjdialog.java.netbeans-base

来自「Store Manager」· NETBEANS-BASE 代码 · 共 642 行 · 第 1/2 页

NETBEANS-BASE
642
字号
/* * StockJDialog.java * * Created on 2007年6月5日, 上午12:23 */package com.studio009.store.ui;import com.studio009.store.StoreApp;import com.studio009.store.entity.Goods;import com.studio009.store.entity.Operator;import com.studio009.store.entity.StockItem;import com.studio009.store.entity.Store;import com.studio009.store.entity.StoreGoods;import com.studio009.store.entity.Supplier;import com.studio009.store.entity.Stock;import java.lang.String;import java.math.BigDecimal;import java.text.ParseException;import java.util.Date;import java.util.List;import java.util.Vector;import javax.persistence.EntityManager;import javax.persistence.NoResultException;import javax.persistence.Query;import javax.swing.DefaultComboBoxModel;import javax.swing.DefaultComboBoxModel;import javax.swing.DefaultComboBoxModel;import javax.swing.JOptionPane;import javax.swing.table.DefaultTableModel;/** * 进货对话框 * @see Stock * @see StockItem * @author  wangs */public class StockJDialog extends javax.swing.JDialog {        /** Creates new form StockJDialog     * @param parent     * @param operator     * @param modal     */    public StockJDialog(java.awt.Window parent, Operator operator, boolean modal) {        super(parent, java.awt.Dialog.ModalityType.APPLICATION_MODAL);                // 初始化实体管理器em        em = StoreApp.getSingleEntityManager();                initComponents();                // 初始化stock        stock.setSupplierName(em.find(Supplier.class, supplierJComboBox.getSelectedItem()));        stock.setStoreName(em.find(Store.class, storeJComboBox.getSelectedItem()));        stock.setStockTime(new Date());        stock.setStockState(1);        stock.setOperatorName(operator);        stock.setStockItemCollection(stockItemList);                // 打开实体管理器事务        //em.getTransaction().begin();                // 设置对话框大小        //this.setSize(parent.getSize());        // 设置对话框居中        this.setLocationRelativeTo(parent);    }        /** 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=" Generated Code ">//GEN-BEGIN:initComponents    private void initComponents() {        // 初始化stock        stock = new com.studio009.store.entity.Stock();        stockItemList = new Vector<StockItem>();        jPanel1 = new javax.swing.JPanel();        supplierJComboBox = new javax.swing.JComboBox();        jLabel2 = new javax.swing.JLabel();        jLabel3 = new javax.swing.JLabel();        storeJComboBox = new javax.swing.JComboBox();        jLabel4 = new javax.swing.JLabel();        jDatePicker = new com.sunking.swing.JDatePicker();        jButton5 = new javax.swing.JButton();        jButton8 = new javax.swing.JButton();        jLabel1 = new javax.swing.JLabel();        jPanel2 = new javax.swing.JPanel();        jButton3 = new javax.swing.JButton();        jButton4 = new javax.swing.JButton();        jButton6 = new javax.swing.JButton();        jButton7 = new javax.swing.JButton();        jScrollPane1 = new javax.swing.JScrollPane();        jTable1 = new javax.swing.JTable();        jButton1 = new javax.swing.JButton();        jButton2 = new javax.swing.JButton();        jLabel5 = new javax.swing.JLabel();        jNumberField1 = new com.sunking.swing.JNumberField(12, 2);        jNumberField2 = new com.sunking.swing.JNumberField(12, 2);        jLabel6 = new javax.swing.JLabel();        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);        setTitle("\u91c7\u8d2d\u8fdb\u8d27");        addWindowListener(new java.awt.event.WindowAdapter() {            public void windowClosed(java.awt.event.WindowEvent evt) {                formWindowClosed(evt);            }            public void windowClosing(java.awt.event.WindowEvent evt) {                formWindowClosing(evt);            }        });        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());        supplierJComboBox.setFont(new java.awt.Font("Dialog", 1, 18));        supplierJComboBox.setModel(getSupplierComboBoxModel());        supplierJComboBox.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                supplierJComboBoxActionPerformed(evt);            }        });        jLabel2.setFont(new java.awt.Font("Dialog", 1, 18));        jLabel2.setText("\u4f9b\u5e94\u5546:");        jLabel3.setFont(new java.awt.Font("Dialog", 1, 18));        jLabel3.setText("\u6536\u8d27\u4ed3\u5e93:");        storeJComboBox.setFont(new java.awt.Font("Dialog", 1, 18));        storeJComboBox.setModel(getStoreComboBoxModel());        storeJComboBox.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                storeJComboBoxActionPerformed(evt);            }        });        jLabel4.setFont(new java.awt.Font("Dialog", 1, 18));        jLabel4.setText("\u6536\u8d27\u65e5\u671f:");        jDatePicker.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jDatePickerActionPerformed(evt);            }        });        jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/studio009/store/ui/resources/magnifier.gif"))); // NOI18N        jButton5.setToolTipText("\u70b9\u51fb\u7f16\u8f91\u4f9b\u5e94\u5546");        jButton5.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jButton5ActionPerformed(evt);            }        });        jButton8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/studio009/store/ui/resources/magnifier.gif"))); // NOI18N        jButton8.setToolTipText("\u70b9\u51fb\u7f16\u8f91\u4ed3\u5e93");        jButton8.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jButton8ActionPerformed(evt);            }        });        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);        jPanel1.setLayout(jPanel1Layout);        jPanel1Layout.setHorizontalGroup(            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(jPanel1Layout.createSequentialGroup()                .addContainerGap()                .addComponent(jLabel2)                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                .addComponent(supplierJComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)                .addGap(18, 18, 18)                .addComponent(jLabel3)                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                .addComponent(storeJComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                .addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)                .addGap(39, 39, 39)                .addComponent(jLabel4)                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                .addComponent(jDatePicker, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))        );        jPanel1Layout.setVerticalGroup(            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(jPanel1Layout.createSequentialGroup()                .addGap(12, 12, 12)                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(jLabel2)                    .addComponent(jDatePicker, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)                    .addComponent(jLabel4)                    .addComponent(jLabel3)                    .addComponent(supplierJComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)                    .addComponent(storeJComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()                .addContainerGap(13, Short.MAX_VALUE)                .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)                .addContainerGap())            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()                .addContainerGap(13, Short.MAX_VALUE)                .addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)                .addContainerGap())        );        jLabel1.setFont(new java.awt.Font("Dialog", 1, 24));        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("com/studio009/store/language"); // NOI18N        jLabel1.setText(bundle.getString("StockTitle")); // NOI18N        jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());        jButton3.setText("\u6dfb\u52a0\u5df2\u6709\u5546\u54c1");        jButton3.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jButton3ActionPerformed(evt);            }        });        jButton4.setText("\u6dfb\u52a0\u65b0\u5546\u54c1");        jButton4.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jButton4ActionPerformed(evt);            }        });        jButton6.setText("\u7f16\u8f91");        jButton6.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jButton6ActionPerformed(evt);            }        });        jButton7.setText("\u5220\u9664");        jButton7.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jButton7ActionPerformed(evt);            }        });        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);        jPanel2.setLayout(jPanel2Layout);        jPanel2Layout.setHorizontalGroup(            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(jPanel2Layout.createSequentialGroup()                .addContainerGap()                .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)                .addGap(18, 18, 18)                .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)                .addGap(18, 18, 18)                .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)                .addGap(18, 18, 18)                .addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)                .addContainerGap(96, Short.MAX_VALUE))        );        jPanel2Layout.setVerticalGroup(            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(jPanel2Layout.createSequentialGroup()                .addContainerGap()                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)                    .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)                    .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)                    .addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE))                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))        );        jTable1.setModel(getStockItemTableModel());        jScrollPane1.setViewportView(jTable1);        jButton1.setText("\u4fdd\u5b58");        jButton1.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jButton1ActionPerformed(evt);            }        });        jButton2.setText("\u9000\u51fa");        jButton2.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jButton2ActionPerformed(evt);            }        });        jLabel5.setText("\u603b\u8ba1\u91d1\u989d:");        jNumberField1.setEditable(false);        jNumberField1.setText("0");        jNumberField2.setText("0");        jLabel6.setText("\u5b9e\u4ed8\u91d1\u989d:");        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());        getContentPane().setLayout(layout);        layout.setHorizontalGroup(            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(layout.createSequentialGroup()                .addContainerGap()                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                    .addGroup(layout.createSequentialGroup()                        .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                        .addContainerGap())                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()                        .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 818, Short.MAX_VALUE)                        .addContainerGap())                    .addGroup(layout.createSequentialGroup()                        .addComponent(jLabel5)                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                        .addComponent(jNumberField1, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)                        .addGap(27, 27, 27)                        .addComponent(jLabel6)                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                        .addComponent(jNumberField2, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)                        .addGap(379, 379, 379))                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()

⌨️ 快捷键说明

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