📄 inoutframe.java~31~
字号:
package parkingsystem;
import javax.swing.*;
import java.awt.*;
import com.borland.jbcl.layout.*;
import java.awt.event.*;
import com.borland.dx.sql.dataset.*;
import com.borland.dx.dataset.*;
public class InOutFrame extends JFrame {
BorderLayout borderLayout1 = new BorderLayout();
ButtonGroup buttonGroup1 = new ButtonGroup();
JPanel jPanel1 = new JPanel();
XYLayout xYLayout3 = new XYLayout();
JButton jButton2 = new JButton();
JLabel jLabel3 = new JLabel();
JButton jButton1 = new JButton();
JRadioButton jRadioButton1 = new JRadioButton();
JComboBox jComboBox1 = new JComboBox();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JTextField jTextField1 = new JTextField();
JRadioButton jRadioButton2 = new JRadioButton();
Database database1 = new Database();
ParameterRow cardparameter = new ParameterRow();
Column column1 = new Column();
Column column2 = new Column();
QueryDataSet queryDataSet1 = new QueryDataSet();
public InOutFrame() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
this.setTitle("欢迎使用停车场进出管理系统");
this.getContentPane().setLayout(borderLayout1);
jPanel1.setLayout(xYLayout3);
jButton2.setFont(new java.awt.Font("Dialog", 0, 14));
jButton2.setText("重 置");
jButton2.addActionListener(new InOutFrame_jButton2_actionAdapter(this));
jLabel3.setText("请输入卡号:");
jLabel3.setFont(new java.awt.Font("Dialog", 0, 14));
jLabel3.setText("选择卡类型:");
jButton1.setText("确 定");
jButton1.addActionListener(new InOutFrame_jButton1_actionAdapter(this));
jButton1.setFont(new java.awt.Font("Dialog", 0, 14));
jRadioButton1.setText(" 入 场");
jRadioButton1.setSelected(true);
jRadioButton1.setFont(new java.awt.Font("Dialog", 0, 14));
jRadioButton2.setText("出 场");
jRadioButton2.setFont(new java.awt.Font("Dialog", 0, 14));
buttonGroup1.add(jRadioButton1);
buttonGroup1.add(jRadioButton2);
jLabel1.setText("选择操作类型:");
jLabel1.setFont(new java.awt.Font("Dialog", 0, 14));
jLabel1.setText("选择操作类型:");
jLabel2.setText("选择卡类型:");
jLabel2.setFont(new java.awt.Font("Dialog", 0, 14));
jLabel2.setText("请输入卡号:");
jTextField1.setText(" ");
jTextField1.setFont(new java.awt.Font("Dialog", 0, 14));
jComboBox1.setFont(new java.awt.Font("Dialog", 0, 14));
jPanel1.setFont(new java.awt.Font("Dialog", 0, 14));
database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor("jdbc:microsoft:sqlserver://localhost:1433;DataBaseName=carparkingdb", "sa", "", false, "com.microsoft.jdbc.sqlserver.SQLServerDriver"));
column1.setColumnName("CardID");
column1.setDataType(com.borland.dx.dataset.Variant.INT);
column1.setDefault("0");
column1.setServerColumnName("NewColumn1");
column1.setSqlType(0);
column2.setColumnName("CardType");
column2.setDataType(com.borland.dx.dataset.Variant.STRING);
column2.setDefault("\"\"");
column2.setServerColumnName("NewColumn2");
column2.setSqlType(0);
cardparameter.setColumns(new Column[] {column1, column2});
queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "select * from card where CardID=:CardID and CardType=:Cardtype", cardparameter, true, Load.ALL));
this.getContentPane().add(jPanel1, BorderLayout.CENTER);
jPanel1.add(jLabel3, new XYConstraints(62, 154, 99, 31));
jPanel1.add(jComboBox1, new XYConstraints(171, 152, 149, 29));
jPanel1.add(jRadioButton1, new XYConstraints(169, 27, 78, 28));
jPanel1.add(jLabel1, new XYConstraints(62, 26, 102, 31));
jPanel1.add(jRadioButton2, new XYConstraints(267, 27, 78, 28));
jPanel1.add(jLabel2, new XYConstraints(62, 90, 92, 31));
jPanel1.add(jTextField1, new XYConstraints(171, 90, 148, 29));
jPanel1.add(jButton2, new XYConstraints(237, 215, 71, 26));
jPanel1.add(jButton1, new XYConstraints(111, 214, 71, 26));
//卡类型的显示
jComboBox1.addItem("");
jComboBox1.addItem("长期卡");
jComboBox1.addItem("次卡");
}
void jButton1_actionPerformed(ActionEvent e) {
/*如未输入卡号或未选择卡类型,给出提示信息并结束按钮事件处理*/
if(jTextField1.getText().equals("")||jComboBox1.getSelectedIndex()==0){
JOptionPane.showMessageDialog(this,"请输入卡号和卡类型的完整信息!");
return;
}
/*以下代码获取选择的操作类型*/
String oper="";
if(jRadioButton1.isSelected()){
oper="入场";
}
else if(jRadioButton2.isSelected()){
oper="出场";
}
/*使用输入的卡号和卡类型设置cardparameter的值*/
int cardID=Integer.parseInt(jTextField1.getText().trim());
String cardType=jComboBox1.getSelectedItem().toString();
cardparameter.setInt("CardID",cardID);
cardparameter.setString("CardType",cardType);
queryDataSet1.refresh();//
if(queryDataSet1.rowCount()!=0){
if(cardType.equals("长期卡")){
// 显示长期卡管理页面,并传进cardID和oper参数
LongTermInOutDialog inOutDialog=new LongTermInOutDialog(this,"长期卡用户进出管理",false,cardID,oper);
inOutDialog.show();
}
else if(cardType.equals("次卡") && oper.equals("入场")){
//显示次卡管理页面,并
ShortTermInDialog shortTermIn=new ShortTermInDialog(this,"次卡用户进出进入管理",false,cardID);
shortTermIn.show();
}
else if(cardType.equals("次卡") && oper.equals("出场")){
ShortTermOutDialog shortTermOut=new ShortTermOutDialog(this,"次卡用户出车场管理",false,cardID);
shortTermOut.show();
}
}
else {
jTextField1.setText("该卡不存在!");
}
}
void jButton2_actionPerformed(ActionEvent e) {
jTextField1.setText("");
jComboBox1.setSelectedIndex(0);
}
}
class InOutFrame_jButton1_actionAdapter implements java.awt.event.ActionListener {
InOutFrame adaptee;
InOutFrame_jButton1_actionAdapter(InOutFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
class InOutFrame_jButton2_actionAdapter implements java.awt.event.ActionListener {
InOutFrame adaptee;
InOutFrame_jButton2_actionAdapter(InOutFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -