📄 findjiaofei.java
字号:
package car;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
import javax.swing.*;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import java.awt.Color;
import javax.swing.border.Border;
import java.awt.Font;
import javax.swing.border.EtchedBorder;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowAdapter;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.awt.HeadlessException;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
public class Findjiaofei extends JFrame {
public Findjiaofei() {
try {
jbInit();
} catch (Exception ex) {
ex.printStackTrace();
}
}
// public static void main(String[] args) {
// Findjiaofei findjiaofei = new Findjiaofei();
// }
private void jbInit() throws Exception {
jCheckBox2.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
this.getContentPane().setLayout(xYLayout2);
jPanel1.setBorder(border1);
jPanel1.setLayout(xYLayout3);
jCheckBox1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
jCheckBox1.setText("按车牌号查找");
jCheckBox1.addActionListener(new Findjiaofei_jCheckBox1_actionAdapter(this));
jCheckBox2.setText("按费用种类查找");
jCheckBox2.addActionListener(new Findjiaofei_jCheckBox2_actionAdapter(this));
jPanel2.setLayout(xYLayout4);
jLabel1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
jLabel1.setText("请输入车牌号:");
jLabel2.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
jLabel2.setText("请选择费用种类:");
jComboBox1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
jComboBox1.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
jComboBox1_keyPressed(e);
}
});
findcarid_t.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
findcarid_t.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
findcarid_t_keyPressed(e);
}
});
findcarid_t.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent e) {
findcarid_t_focusLost(e);
}
});
jButton1.setBackground(Color.white);
jButton1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
jButton1.setToolTipText("查 找");
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
jButton1_actionPerformed(actionEvent);
}
});
jCheckBox3.setText("jCheckBox3");
jButton2.setBackground(Color.white);
jButton2.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
jButton2.addActionListener(new Findjiaofei_jButton2_actionAdapter(this));
this.setTitle("沈阳志远出租汽车公司出租车信息管理系统--查看缴费信息窗口");
xYLayout2.setWidth(612);
xYLayout2.setHeight(552);
jPanel1.add(jCheckBox1, new XYConstraints(6, 9, 111, 29));
jPanel1.add(findcarid_t, new XYConstraints(277, 4, 113, 31));
jPanel1.add(jLabel1, new XYConstraints(167, 4, 102, 32));
this.getContentPane().add(jPanel2, new XYConstraints(23, 71, 460, 44));
jPanel2.add(jCheckBox2, new XYConstraints(7, 7, -1, -1));
jPanel2.add(jLabel2, new XYConstraints(169, 3, 117, 35));
this.getContentPane().add(jScrollPane1,
new XYConstraints(23, 121, 460, 404));
this.getContentPane().add(jPanel1, new XYConstraints(23, 22, 460, 45));
jTable1 = te.createTable();
jScrollPane1.getViewport().add(jTable1);
this.getContentPane().add(jButton1, new XYConstraints(496, 23, 99, 41));
jPanel2.add(jComboBox1, new XYConstraints(277, 4, 113, 31));
this.getContentPane().add(jButton2, new XYConstraints(496, 72, 99, 43));
jPanel2.setBorder(border1);
this.setVisible(true);
this.setSize(612, 590);
this.setLocation(170, 50);
addWindowListener(new WindowAdapter() {
public void WindowClosing(WindowEvent e) {
if(db!=null)
db.closeConnection();
if(db2!=null)
db2.closeConnection();
dispose();
}
});
}
DataBaseManager db=null;
DataBaseManager db2=null;
ResultSet r;
TableExample te = new TableExample();
XYLayout xYLayout1 = new XYLayout();
XYLayout xYLayout2 = new XYLayout();
JPanel jPanel1 = new JPanel();
Border border1 = BorderFactory.createEtchedBorder(Color.white,
new Color(165, 163, 151));
JPanel jPanel2 = new JPanel();
XYLayout xYLayout3 = new XYLayout();
JCheckBox jCheckBox1 = new JCheckBox();
JCheckBox jCheckBox2 = new JCheckBox();
XYLayout xYLayout4 = new XYLayout();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JTextField findcarid_t = new JTextField();
JComboBox jComboBox1 = new JComboBox();
JButton jButton1 = new JButton(new ImageIcon("image\\113.gif"));
JCheckBox jCheckBox3 = new JCheckBox();
JButton jButton2 = new JButton(new ImageIcon("image\\back.gif"));
Border border2 = BorderFactory.createEtchedBorder(EtchedBorder.RAISED,
Color.white, new Color(178, 178, 178));
JScrollPane jScrollPane1 = new JScrollPane();
JTable jTable1;
public void jButton2_actionPerformed(ActionEvent e) {
if(db!=null)
db.closeConnection() ;
if(db2!=null)
db2.closeConnection();
dispose();
}
public void jCheckBox1_actionPerformed(ActionEvent e) {
if(jCheckBox1.isSelected() )
{
jButton1.setEnabled(true);
findcarid_t.setEnabled(true);
}
else
{
jButton1.setEnabled(false);
findcarid_t.setEnabled(false);
}
}
public void jCheckBox2_actionPerformed(ActionEvent e) {
if(jCheckBox2.isSelected() )
{
// jButton2.setEnabled(true);
jComboBox1.setEnabled(true) ;
}
else
{
//jButton2.setEnabled(false);
jComboBox1.setEnabled(false) ;
}
}
public void jButton1_actionPerformed(ActionEvent actionEvent) {
String sql = "select * from jiaofei where ";
String str = "";
db = new DataBaseManager();
try {
if(jCheckBox1.isSelected()&&jCheckBox2.isSelected())
{
if (!db.getResult("select * from jiaofei where 车牌号='" +
findcarid_t.getText().trim() + "'").first()) {
String s = "没有编号为" + findcarid_t.getText().trim() +
"车辆的缴费记录,请重新输入车牌号。";
JOptionPane.showMessageDialog(null, s);
findcarid_t.setText("");
} else {
str = "车牌号='" + findcarid_t.getText().trim() +
"' and 费用种类='" + jComboBox1.getSelectedItem() + "'";
}
}
else if (jCheckBox1.isSelected()) {
if (!db.getResult("select * from jiaofei where 车牌号='" +
findcarid_t.getText().trim() + "'").first()) {
String s = "没有编号为" + findcarid_t.getText().trim() +
"车辆的缴费记录,请重新输入车牌号。";
JOptionPane.showMessageDialog(null, s);
findcarid_t.setText("");
} else {
str = "车牌号='" + findcarid_t.getText().trim() + "'";
}
} else if (jCheckBox2.isSelected()) {
if (db.getResult("select * from jiaofei where 费用种类='" +
jComboBox1.getSelectedItem() + "'").first()) {
str = "费用种类='" + jComboBox1.getSelectedItem() + "'";
}
}
te.fetch(sql + str);//
} catch (HeadlessException ex) {
} catch (SQLException ex) {
}
}
public void findcarid_t_focusLost(FocusEvent e) {
if(findcarid_t.getText() .trim() .equals("") )
JOptionPane.showMessageDialog(null, "车号不能为空!");
else{
db2 = new DataBaseManager();
try {
if (!db2.getResult("select * from car where 车牌号='" +
findcarid_t.getText().trim() + "'").first()) {
String s = "没有编号为" + findcarid_t.getText().trim() +
"的车辆!";
JOptionPane.showMessageDialog(null, s);
findcarid_t.setFocusable(true);
}
} catch (HeadlessException ex) {
} catch (SQLException ex) {
}
}
}
public void findcarid_t_keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
String sql = "select * from jiaofei where ";
String str = "";
db = new DataBaseManager();
try {
if(jCheckBox1.isSelected()&&jCheckBox2.isSelected())
{
if (!db.getResult("select * from jiaofei where 车牌号='" +
findcarid_t.getText().trim() + "'").first()) {
String s = "没有编号为" + findcarid_t.getText().trim() +
"车辆的缴费记录,请重新输入车牌号。";
JOptionPane.showMessageDialog(null, s);
findcarid_t.setText("");
} else {
str = "车牌号='" + findcarid_t.getText().trim() +
"' and 费用种类='" + jComboBox1.getSelectedItem() + "'";
}
}
else if (jCheckBox1.isSelected()) {
if (!db.getResult("select * from jiaofei where 车牌号='" +
findcarid_t.getText().trim() + "'").first()) {
String s = "没有编号为" + findcarid_t.getText().trim() +
"车辆的缴费记录,请重新输入车牌号。";
JOptionPane.showMessageDialog(null, s);
findcarid_t.setText("");
} else {
str = "车牌号='" + findcarid_t.getText().trim() + "'";
}
} else if (jCheckBox2.isSelected()) {
if (db.getResult("select * from jiaofei where 费用种类='" +
jComboBox1.getSelectedItem() + "'").first()) {
str = "费用种类='" + jComboBox1.getSelectedItem() + "'";
}
}
te.fetch(sql + str);//
} catch (HeadlessException ex) {
} catch (SQLException ex) {
}
}
}
public void jComboBox1_keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
String sql = "select * from jiaofei where ";
String str = "";
db = new DataBaseManager();
try {
if(jCheckBox1.isSelected()&&jCheckBox2.isSelected())
{
if (!db.getResult("select * from jiaofei where 车牌号='" +
findcarid_t.getText().trim() + "'").first()) {
String s = "没有编号为" + findcarid_t.getText().trim() +
"车辆的缴费记录,请重新输入车牌号。";
JOptionPane.showMessageDialog(null, s);
findcarid_t.setText("");
} else {
str = "车牌号='" + findcarid_t.getText().trim() +
"' and 费用种类='" + jComboBox1.getSelectedItem() + "'";
}
}
else if (jCheckBox1.isSelected()) {
if (!db.getResult("select * from jiaofei where 车牌号='" +
findcarid_t.getText().trim() + "'").first()) {
String s = "没有编号为" + findcarid_t.getText().trim() +
"车辆的缴费记录,请重新输入车牌号。";
JOptionPane.showMessageDialog(null, s);
findcarid_t.setText("");
} else {
str = "车牌号='" + findcarid_t.getText().trim() + "'";
}
} else if (jCheckBox2.isSelected()) {
if (db.getResult("select * from jiaofei where 费用种类='" +
jComboBox1.getSelectedItem() + "'").first()) {
str = "费用种类='" + jComboBox1.getSelectedItem() + "'";
}
}
te.fetch(sql + str);//
} catch (HeadlessException ex) {
} catch (SQLException ex) {
}
}
}
}
class Findjiaofei_jCheckBox2_actionAdapter implements ActionListener {
private Findjiaofei adaptee;
Findjiaofei_jCheckBox2_actionAdapter(Findjiaofei adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jCheckBox2_actionPerformed(e);
}
}
class Findjiaofei_jCheckBox1_actionAdapter implements ActionListener {
private Findjiaofei adaptee;
Findjiaofei_jCheckBox1_actionAdapter(Findjiaofei adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jCheckBox1_actionPerformed(e);
}
}
class Findjiaofei_jButton2_actionAdapter implements ActionListener {
private Findjiaofei adaptee;
Findjiaofei_jButton2_actionAdapter(Findjiaofei adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -