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

📄 supplierediter.java.svn-base

📁 Store Manager
💻 SVN-BASE
字号:
/* * SupplierEditer.java * * Created on 2007年6月4日, 下午11:04 */package com.studio009.store.ui;import com.studio009.store.StoreApp;import com.studio009.store.entity.Supplier;import javax.beans.binding.BindingContext;import javax.persistence.EntityManager;import javax.swing.JOptionPane;/** * 供应商编辑对话框 * @see Supplier * @author  wangs */public class SupplierEditer extends javax.swing.JDialog {        /** Creates new form SupplierEditer     * @param parent 父窗口     * @param SupplierName 供应商名称     * @param modal 模式     */    public SupplierEditer(java.awt.Dialog parent, String SupplierName, boolean modal) {        super(parent, modal);        initComponents();                em = StoreApp.getEntityManagerFactory().createEntityManager();        if (SupplierName == null) SupplierName = "";        supplier = em.find(Supplier.class, SupplierName);        if (supplier == null) {            supplier = new Supplier();            em.persist(supplier);            jTextField1.setEditable(true);            this.setTitle("新建供应商");        }        //bind the operator to the dialog        BindingContext bindingContext = new BindingContext();        bindingContext.addBinding(supplier, "${supplierName}", jTextField1, "text");        bindingContext.addBinding(supplier, "${supplierPhone}", jTextField5, "text");        bindingContext.addBinding(supplier, "${supplierAddress}", jTextField2, "text");        bindingContext.addBinding(supplier, "${supplierNote}", jTextArea1, "text");                bindingContext.bind();                em.getTransaction().begin();        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() {        jPanel1 = new javax.swing.JPanel();        jLabel1 = new javax.swing.JLabel();        jLabel7 = new javax.swing.JLabel();        jTextField1 = new javax.swing.JTextField();        jLabel5 = new javax.swing.JLabel();        jTextField5 = new javax.swing.JTextField();        jScrollPane2 = new javax.swing.JScrollPane();        jTextArea1 = new javax.swing.JTextArea();        jLabel2 = new javax.swing.JLabel();        jTextField2 = new javax.swing.JTextField();        okButton = new javax.swing.JButton();        cancelButton = new javax.swing.JButton();        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);        setTitle("\u7f16\u8f91\u4f9b\u5e94\u5546\u4fe1\u606f");        jLabel1.setText("\u4f9b\u5e94\u5546:");        jLabel7.setText("\u5907\u6ce8:");        jTextField1.setEditable(false);        jLabel5.setText("\u7535\u8bdd:");        jTextArea1.setColumns(20);        jTextArea1.setRows(3);        jScrollPane2.setViewportView(jTextArea1);        jLabel2.setText("\u5730\u5740:");        jTextField2.setText("jTextField2");        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()                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                    .addComponent(jLabel1)                    .addComponent(jLabel5)                    .addComponent(jLabel2)                    .addComponent(jLabel7))                .addGap(35, 35, 35)                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 373, Short.MAX_VALUE)                    .addComponent(jTextField5, javax.swing.GroupLayout.DEFAULT_SIZE, 373, Short.MAX_VALUE)                    .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 373, Short.MAX_VALUE)                    .addComponent(jTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, 373, Short.MAX_VALUE))                .addContainerGap())        );        jPanel1Layout.setVerticalGroup(            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()                .addContainerGap()                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(jLabel1)                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))                .addGap(28, 28, 28)                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(jLabel5)                    .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))                .addGap(18, 18, 18)                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(jLabel2)                    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))                .addGap(18, 18, 18)                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                    .addComponent(jLabel7)                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 91, Short.MAX_VALUE))                .addContainerGap())        );        okButton.setText("\u786e\u5b9a");        okButton.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                okButtonActionPerformed(evt);            }        });        cancelButton.setText("\u53d6\u6d88");        cancelButton.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                cancelButtonActionPerformed(evt);            }        });        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(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                        .addContainerGap())                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()                        .addComponent(okButton, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)                        .addGap(86, 86, 86)                        .addComponent(cancelButton, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)                        .addGap(51, 51, 51))))        );        layout.setVerticalGroup(            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(layout.createSequentialGroup()                .addContainerGap()                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                .addGap(33, 33, 33)                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(cancelButton, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)                    .addComponent(okButton, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))                .addGap(26, 26, 26))        );        pack();    }// </editor-fold>//GEN-END:initComponents    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed    this.dispose();}//GEN-LAST:event_cancelButtonActionPerformedprivate void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed    if (supplier.getSupplierName() == null || supplier.getSupplierName().isEmpty()) {        JOptionPane.showMessageDialog(this, "供应商不能为空!", "错误", JOptionPane.ERROR_MESSAGE);        return;    }    try {        em.getTransaction().commit();    } catch (Exception e) {        JOptionPane.showMessageDialog(this, "该供应商已存在!");        em.getTransaction().begin();    }    this.dispose();}//GEN-LAST:event_okButtonActionPerformed    // Variables declaration - do not modify//GEN-BEGIN:variables    private javax.swing.JButton cancelButton;    private javax.swing.JLabel jLabel1;    private javax.swing.JLabel jLabel2;    private javax.swing.JLabel jLabel5;    private javax.swing.JLabel jLabel7;    private javax.swing.JPanel jPanel1;    private javax.swing.JScrollPane jScrollPane2;    private javax.swing.JTextArea jTextArea1;    private javax.swing.JTextField jTextField1;    private javax.swing.JTextField jTextField2;    private javax.swing.JTextField jTextField5;    private javax.swing.JButton okButton;    // End of variables declaration//GEN-END:variables    private EntityManager em;    private Supplier supplier;}

⌨️ 快捷键说明

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