📄 carnumsearchdialog.java~1~
字号:
package parkingsystem;import java.awt.*;import javax.swing.*;import javax.swing.border.*;import com.borland.dbswing.*;import com.borland.jbcl.layout.*;import com.borland.dx.sql.dataset.*;import java.awt.event.*;public class CarNumSearchDialog extends JDialog { JPanel panel1 = new JPanel(); BorderLayout borderLayout1 = new BorderLayout(); JSplitPane jSplitPane1 = new JSplitPane(); JPanel jPanel1 = new JPanel(); JPanel jPanel2 = new JPanel(); TitledBorder titledBorder1; TitledBorder titledBorder2; BorderLayout borderLayout2 = new BorderLayout(); TableScrollPane tableScrollPane1 = new TableScrollPane(); JPanel jPanel3 = new JPanel(); JdbTable jdbTable1 = new JdbTable(); XYLayout xYLayout1 = new XYLayout(); JdbLabel jdbLabel1 = new JdbLabel(); JLabel jLabel1 = new JLabel(); JTextField jTextField1 = new JTextField(); JButton jButton1 = new JButton(); BorderLayout borderLayout3 = new BorderLayout(); TableScrollPane tableScrollPane2 = new TableScrollPane(); JdbTable jdbTable2 = new JdbTable(); Database database1 = new Database(); QueryDataSet queryDataSet1 = new QueryDataSet(); QueryDataSet queryDataSet2 = new QueryDataSet(); TitledBorder titledBorder8; TitledBorder titledBorder9; JComboBox jComboBox1 = new JComboBox(); public CarNumSearchDialog(Frame frame, String title, boolean modal) { super(frame, title, modal); try { jbInit(); pack(); } catch(Exception ex) { ex.printStackTrace(); } } public CarNumSearchDialog() { this(null, "", false); } private void jbInit() throws Exception { titledBorder1 = new TitledBorder("车主信息"); titledBorder2 = new TitledBorder("停车信息"); titledBorder9 = new TitledBorder(""); panel1.setLayout(borderLayout1); panel1.setPreferredSize(new Dimension(500, 400)); jSplitPane1.setOrientation(JSplitPane.VERTICAL_SPLIT); jPanel1.setLayout(borderLayout2); jPanel2.setBorder(titledBorder1); jPanel2.setLayout(borderLayout3); jPanel3.setPreferredSize(new Dimension(500, 50)); jPanel3.setLayout(xYLayout1); jdbLabel1.setFont(new java.awt.Font("Dialog", 0, 12)); jdbLabel1.setText("查询条件:"); jLabel1.setFont(new java.awt.Font("Dialog", 0, 12)); jLabel1.setText("关键字:"); jTextField1.setFont(new java.awt.Font("Dialog", 0, 12)); jTextField1.setText(""); jButton1.setFont(new java.awt.Font("Dialog", 0, 12)); jButton1.setText("执行查询"); jButton1.addActionListener(new CarNumSearchDialog_jButton1_actionAdapter(this)); database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor("jdbc:microsoft:sqlserver://localhost:1433;DataBaseName=carparkingdb", "sa", "", false, "com.microsoft.jdbc.sqlserver.SQLServerDriver")); tableScrollPane1.setBorder(titledBorder2); queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "select * from event where InTime is null", null, true, Load.ALL)); queryDataSet2.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "select * from CarOwer ", null, true, Load.ALL)); jdbTable1.setDataSet(queryDataSet1); jdbTable2.setDataSet(queryDataSet2); jComboBox1.setFont(new java.awt.Font("Dialog", 0, 12)); getContentPane().add(panel1); panel1.add(jSplitPane1, BorderLayout.CENTER); jSplitPane1.add(jPanel1, JSplitPane.TOP); jPanel1.add(tableScrollPane1, BorderLayout.CENTER); tableScrollPane1.getViewport().add(jdbTable1, null); jPanel1.add(jPanel3, BorderLayout.NORTH); jPanel3.add(jdbLabel1, new XYConstraints(26, 11, 63, 26)); jPanel3.add(jLabel1, new XYConstraints(218, 11, 62, 23)); jPanel3.add(jTextField1, new XYConstraints(275, 11, 85, 25)); jPanel3.add(jButton1, new XYConstraints(389, 11, 82, -1)); jPanel3.add(jComboBox1, new XYConstraints(98, 11, 94, 27)); jSplitPane1.add(jPanel2, JSplitPane.BOTTOM); jPanel2.add(tableScrollPane2, BorderLayout.CENTER); tableScrollPane2.getViewport().add(jdbTable2, null); jSplitPane1.setDividerLocation(200); queryDataSet2.setMasterLink(new com.borland.dx.dataset.MasterLinkDescriptor(queryDataSet1, new String[] {"CardID"}, new String[] {"CardID"}, false, false, false)); jComboBox1.addItem(""); jComboBox1.addItem("按车牌查"); jComboBox1.addItem("按卡号查"); } void jButton1_actionPerformed(ActionEvent e) { queryDataSet1.close(); queryDataSet2.close(); String keywords=jTextField1.getText().trim(); String query=""; if(jComboBox1.getSelectedItem().equals("按车牌查")){ query="select * from event where CarNum like '%"+keywords+"%'"; } else if(jComboBox1.getSelectedItem().equals("按卡号查")){ query="select * from event where CardID like '%"+keywords+"%'"; } queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, query, null, true, Load.ALL)); queryDataSet1.refresh(); }}class CarNumSearchDialog_jButton1_actionAdapter implements java.awt.event.ActionListener { CarNumSearchDialog adaptee; CarNumSearchDialog_jButton1_actionAdapter(CarNumSearchDialog adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jButton1_actionPerformed(e); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -