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

📄 customersourceframe.java

📁 Athena酒店小组_Athena酒店管理系统
💻 JAVA
字号:
/*
 * CustomerSource.java
 *
 * Created on 2007年3月18日, 下午12:47
 */

package frames;
import plugin.*;
import evan.*;
import helper.*;
import module.*;
import java.util.*;
import javax.swing.*;
/**
 *
 * @author  chenym
 */
public class CustomerSourceFrame extends javax.swing.JInternalFrame {
    /** Creates new form CustomerSource */
    public CustomerSourceFrame() {
        initComponents();
    }
    
    /** 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() {
        jButton1 = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        query1 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        customerIdText = new javax.swing.JTextField();
        jScrollPane2 = new javax.swing.JScrollPane();
        customerTable = new javax.swing.JTable();
        jPanel3 = new javax.swing.JPanel();
        query2 = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        customerTable1 = new javax.swing.JTable();
        sourceCombo = new javax.swing.JComboBox();

        jButton1.setText("jButton1");

        setClosable(true);
        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setIconifiable(true);
        setMaximizable(true);
        setResizable(true);
        setTitle("\u5ba2\u6e90\u5206\u6790\u7edf\u8ba1");
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("宋体", 0, 12), new java.awt.Color(153, 0, 255)), "\u5ba2\u6e90\u5206\u6790\u7edf\u8ba1", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("新宋体", 0, 12)));
        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "\u4e2a\u4eba\u67e5\u8be2", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("新宋体", 0, 12)));
        query1.setFont(new java.awt.Font("新宋体", 0, 12));
        query1.setText("\u67e5\u8be2");
        query1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                query1ActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("新宋体", 0, 12));
        jLabel1.setText("\u5ba2\u6237\u7f16\u53f7\uff1a");

        jScrollPane2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "\u7ed3\u679c\u663e\u793a", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("新宋体", 0, 12)));
        customerTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null}
            },
            new String [] {
                "客户编号", "客户姓名", "来源编号"
            }
        ));
        jScrollPane2.setViewportView(customerTable);

        org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel2Layout.createSequentialGroup()
                        .add(jLabel1)
                        .add(9, 9, 9)
                        .add(customerIdText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 150, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 196, Short.MAX_VALUE)
                        .add(query1))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel2Layout.createSequentialGroup()
                        .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 462, Short.MAX_VALUE)
                        .addContainerGap())))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(query1)
                    .add(customerIdText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel1))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 77, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "\u591a\u4eba\u67e5\u8be2", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("新宋体", 0, 12)));
        query2.setFont(new java.awt.Font("新宋体", 0, 12));
        query2.setText("\u67e5\u8be2");
        query2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                query2ActionPerformed(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("新宋体", 0, 12));
        jLabel2.setText("\u6765\u6e90\u7f16\u53f7\uff1a");

        jScrollPane1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "\u7ed3\u679c\u663e\u793a", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("新宋体", 0, 12)));
        customerTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null},
                {null, null},
                {null, null},
                {null, null}
            },
            new String [] {
                "来源编号", "客户数量"
            }
        ));
        jScrollPane1.setViewportView(customerTable1);

        sourceCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "\u5168\u90e8", "A", "B", "C", "D" }));

        org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .add(jLabel2)
                .add(13, 13, 13)
                .add(sourceCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 147, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 195, Short.MAX_VALUE)
                .add(query2))
            .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 482, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel3Layout.createSequentialGroup()
                .add(20, 20, 20)
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(query2)
                    .add(jLabel2)
                    .add(sourceCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE))
        );

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 141, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(18, Short.MAX_VALUE))
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void query2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_query2ActionPerformed
     //获取查询信息
	ArrayList<String> names = new ArrayList<String>();
	ArrayList<Object> values = new ArrayList<Object>();
        if (!sourceCombo.getSelectedItem().toString().equals("全部"))
	{
	    String source = sourceCombo.getSelectedItem().toString();
	    names.add("SourceId");
	    values.add(source);
	}
         //查询客户信息并将其添加到Table中
	CustomerAccess ea = new CustomerAccess(Resource.getDBResource());
	ArrayList<CustomerInfo>  eis = ea.getCustomersByCondition(names, values);
	for(CustomerInfo ei : eis)
	{
	    Object[] objs = new Object[]
	    {
		ei.getSourceId(),
                //...
	    };
	    TableHelper.addToTable(customerTable1, objs);
	}
    }//GEN-LAST:event_query2ActionPerformed

    private void query1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_query1ActionPerformed
        //获取查询信息
	ArrayList<String> names = new ArrayList<String>();
	ArrayList<Object> values = new ArrayList<Object>();
	if (!customerIdText.getText().equals(""))
	{
	    String customerId = customerIdText.getText();
	    names.add("CustomerId");
	    values.add(customerId);
	}
/*	*/
        //查询客户信息并将其添加到Table中
	CustomerAccess ea = new CustomerAccess(Resource.getDBResource());
	ArrayList<CustomerInfo>  eis = ea.getCustomersByCondition(names, values);
	for(CustomerInfo ei : eis)
	{
	    Object[] objs = new Object[]
	    {
                ei.getCustomerId(),
		ei.getName(),
		ei.getSourceId()
	    };
	    TableHelper.addToTable(customerTable, objs);
	}
    }//GEN-LAST:event_query1ActionPerformed
    
    /**
     * @param args the command line arguments
    
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new CustomerSourceFrame().setVisible(true);
            }
        });
    } */
    
    // 变量声明 - 不进行修改//GEN-BEGIN:variables
    private javax.swing.JTextField customerIdText;
    private javax.swing.JTable customerTable;
    private javax.swing.JTable customerTable1;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JButton query1;
    private javax.swing.JButton query2;
    private javax.swing.JComboBox sourceCombo;
    // 变量声明结束//GEN-END:variables
    
}

⌨️ 快捷键说明

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