📄 shorttermoutdialog.java~54~
字号:
package parkingsystem;
import java.awt.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
import java.sql.*;
import java.text.*;
import java.awt.event.*;
import com.borland.dx.sql.dataset.*;
import com.borland.dx.dataset.*;
import com.borland.dbswing.*;
public class ShortTermOutDialog extends JDialog {
JPanel panel1 = new JPanel();
XYLayout xYLayout1 = new XYLayout();
JLabel jLabel2 = new JLabel();
JLabel jLabel1 = new JLabel();
JLabel jLabel3 = new JLabel();
JLabel jLabel4 = new JLabel();
JLabel jLabel5 = new JLabel();
JLabel jLabel9 = new JLabel();
JLabel jLabel7 = new JLabel();
JLabel jLabel6 = new JLabel();
JLabel jLabel8 = new JLabel();
JLabel jLabel10 = new JLabel();
JButton jButton1 = new JButton();
JLabel jLabel11 = new JLabel();
JLabel jLabel12 = new JLabel();
private int cardID;
String outOrNotType;
private java.util.Date now;
Database database1 = new Database();
QueryDataSet queryDataSet2 = new QueryDataSet();
ParameterRow cardparameter = new ParameterRow();
QueryDataSet queryDataSet1 = new QueryDataSet();
Column column1 = new Column();
Column column2 = new Column();
public ShortTermOutDialog(Frame frame, String title, boolean modal,int cardID) {
super(frame, title, modal);
this.cardID=cardID;
try {
jbInit();
pack();
}
catch(Exception ex) {
ex.printStackTrace();
}
}
public ShortTermOutDialog() {
this(null, "", false,0);
}
private void jbInit() throws Exception {
panel1.setLayout(xYLayout1);
jLabel2.setText("选择卡类型:");
jLabel2.setFont(new java.awt.Font("Dialog", 0, 14));
jLabel2.setText("车 牌 号:");
jLabel1.setText("选择操作类型:");
jLabel1.setFont(new java.awt.Font("Dialog", 0, 14));
jLabel1.setText("卡 号:");
jLabel3.setText("车 牌 号:");
jLabel3.setFont(new java.awt.Font("Dialog", 0, 14));
jLabel3.setText("入 场 时 间:");
jLabel4.setText("车 牌 号:");
jLabel4.setText("入 场 时 间:");
jLabel4.setFont(new java.awt.Font("Dialog", 0, 14));
jLabel4.setText("出 场 时 间:");
jLabel5.setText("车 牌 号:");
jLabel5.setFont(new java.awt.Font("Dialog", 0, 14));
jLabel5.setText("应 收 费:");
jLabel9.setText("出 场 时 间:");
jLabel9.setFont(new java.awt.Font("Dialog", 0, 14));
jLabel9.setForeground(SystemColor.activeCaption);
jLabel9.setText("");
jLabel9.setText("");
jLabel7.setText("车 牌 号:");
jLabel7.setFont(new java.awt.Font("Dialog", 0, 14));
jLabel7.setForeground(SystemColor.activeCaption);
jLabel7.setText("");
jLabel6.setText("卡 号:");
jLabel6.setFont(new java.awt.Font("Dialog", 0, 14));
jLabel6.setForeground(SystemColor.activeCaption);
jLabel6.setText("");
jLabel6.setText("");
jLabel8.setText("入 场 时 间:");
jLabel8.setFont(new java.awt.Font("Dialog", 0, 14));
jLabel8.setForeground(SystemColor.activeCaption);
jLabel8.setText("");
jLabel10.setFont(new java.awt.Font("Dialog", 0, 14));
jLabel10.setForeground(SystemColor.activeCaption);
jLabel10.setToolTipText("");
jLabel10.setText("");
jButton1.setFont(new java.awt.Font("Dialog", 0, 14));
jButton1.setText("确 定");
jButton1.addActionListener(new ShortTermOutDialog_jButton1_actionAdapter(this));
panel1.setForeground(SystemColor.activeCaption);
panel1.setPreferredSize(new Dimension(400, 300));
jLabel11.setText("卡 号:");
jLabel11.setFont(new java.awt.Font("Dialog", 0, 14));
jLabel11.setText("操 作 类 型:");
jLabel12.setText(cardID+"");
jLabel12.setText("");
jLabel12.setForeground(SystemColor.activeCaption);
jLabel12.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"));
queryDataSet2.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "select price from cardType where CardType=\'次卡\'", null, true, Load.ALL));
queryDataSet1.setMetaDataUpdate(MetaDataUpdate.TABLENAME+MetaDataUpdate.PRECISION+MetaDataUpdate.SCALE+MetaDataUpdate.SEARCHABLE);
queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "select * from event where CardID=:CardID and OutTime is null order " +
"by EventID", cardparameter, true, Load.ALL));
column1.setColumnName("CardID");
column1.setDataType(com.borland.dx.dataset.Variant.INT);
column1.setDefault("0");
column1.setServerColumnName("NewColumn1");
column1.setSqlType(0);
cardparameter.setColumns(new Column[]{column1});
column2.setColumnName("EventID");
column2.setDataType(com.borland.dx.dataset.Variant.INT);
column2.setRowId(true);
column2.setTableName("event");
column2.setServerColumnName("EventID");
column2.setSqlType(4);
panel1.add(jButton1, new XYConstraints(145, 244, 104, 33));
panel1.add(jLabel1, new XYConstraints(95, 14, 94, 31));
panel1.add(jLabel6, new XYConstraints(217, 14, 94, 31));
panel1.add(jLabel7, new XYConstraints(217, 51, 94, 31));
panel1.add(jLabel8, new XYConstraints(217, 88, 173, 31));
panel1.add(jLabel4, new XYConstraints(95, 124, 94, 31));
panel1.add(jLabel5, new XYConstraints(95, 161, 94, 31));
panel1.add(jLabel9, new XYConstraints(217, 124, 147, 31));
panel1.add(jLabel10, new XYConstraints(217, 161, 94, 31));
panel1.add(jLabel12, new XYConstraints(217, 198, 94, 31));
panel1.add(jLabel11, new XYConstraints(95, 198, 94, 31));
panel1.add(jLabel3, new XYConstraints(95, 88, 94, 31));
panel1.add(jLabel2, new XYConstraints(95, 51, 94, 31));
this.getContentPane().add(panel1, BorderLayout.WEST);
//显示是否允许出车场、进入的时间、车牌号
jLabel6.setText(cardID+"");
cardparameter.setInt("CardID",cardID);
queryDataSet1.open();
if(queryDataSet1.rowCount()!=0){
outOrNotType="允许出车场";
String carNum=queryDataSet1.getString("CarNum");
String inTime=queryDataSet1.getTimestamp("InTime").toString();
jLabel7.setText(carNum);
jLabel8.setText(inTime);
}
SimpleDateFormat timeFormat=new SimpleDateFormat("yy-MM-dd HH:mm");
now=new java.util.Date();
String nowFormat=timeFormat.format(now);
jLabel9.setText(nowFormat);
jLabel12.setText(outOrNotType);
cardparameter.setColumns(new Column[] {column1});
queryDataSet1.setColumns(new Column[] {column2});
//查询并显示应收费
queryDataSet2.open();
if(queryDataSet2.rowCount()!=0){
jLabel10.setText(queryDataSet2.getBigDecimal("Price")+"");
}
queryDataSet2.close();
}
void jButton1_actionPerformed(ActionEvent e) {
if(outOrNotType.equals("允许出车场")){
long lTime = now.getTime();
Timestamp t = new Timestamp(lTime);
queryDataSet1.setTimestamp("OutTime", t);
database1.saveChanges(queryDataSet1);
JOptionPane.showMessageDialog(this,"成功修改记录!");
}
this.hide();
}
}
class ShortTermOutDialog_jButton1_actionAdapter implements java.awt.event.ActionListener {
ShortTermOutDialog adaptee;
ShortTermOutDialog_jButton1_actionAdapter(ShortTermOutDialog adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -