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

📄 shorttermindialog.java~1~

📁 基于数据库组件的系统开发的实例
💻 JAVA~1~
字号:
package parkingsystem;

import java.awt.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;

import java.text.*;
import java.awt.event.*;

import java.sql.*;

public class ShortTermInDialog 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();
  JTextField jTextField1 = new JTextField();
  JLabel jLabel5 = new JLabel();
  JButton jButton1 = new JButton();

  int cardID;
  String nowFormat;

  Connection con;
  Statement st;
  ResultSet rs;


  public ShortTermInDialog(Frame frame, String title, boolean modal,int cardID) {
    super(frame, title, modal);
    this.cardID=cardID;
    try {
      jbInit();
      pack();
    }
    catch(Exception ex) {
      ex.printStackTrace();
    }
  }

  public ShortTermInDialog() {
    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.setFont(new java.awt.Font("Dialog", 0, 14));
    jLabel4.setText("");
    jTextField1.setText(" ");
    jTextField1.setFont(new java.awt.Font("Dialog", 0, 14));
    jLabel5.setFont(new java.awt.Font("Dialog", 0, 14));

    jButton1.setFont(new java.awt.Font("Dialog", 0, 14));
    jButton1.setText("确   定");
    jButton1.addActionListener(new ShortTermInDialog_jButton1_actionAdapter(this));
    panel1.setPreferredSize(new Dimension(400, 300));
    this.setModal(true);
    getContentPane().add(panel1);
    panel1.add(jButton1, new XYConstraints(159, 216, 115, 33));
    panel1.add(jLabel1, new XYConstraints(81, 45, 94, 31));
    panel1.add(jLabel4, new XYConstraints(204, 43, 94, 31));
    panel1.add(jLabel2, new XYConstraints(81, 91, 94, 31));
    panel1.add(jTextField1, new XYConstraints(204, 92, 148, 28));
    panel1.add(jLabel3, new XYConstraints(81, 144, 94, 31));
    panel1.add(jLabel5, new XYConstraints(204, 146, 150, 31));

    jLabel4.setText(cardID+"");
    java.util.Date nowTime=new java.util.Date();
    SimpleDateFormat dateFormat=new SimpleDateFormat("yy-MM-dd HH:mm");
    nowFormat=dateFormat.format(nowTime);
    jLabel5.setText(nowFormat);
  }

  void jButton1_actionPerformed(ActionEvent e) {
    String carNum=jTextField1.getText().trim();
    con=DbConnection.getCon();
    try{
      st = con.createStatement();
      String insertStr="Insert into event (CardID,UserID,CarNum,InOutName,InTime) values("+
              cardID+","+ParkingFrame.userID+",'"+carNum+"','"+ParkingFrame.inOutPlace+"','"+
              nowFormat+"')";
      int result=st.executeUpdate(insertStr);
      if(result>0){
        JOptionPane.showMessageDialog(this,"操作成功!");

      }

    }catch(Exception ex){
      ex.printStackTrace();
    }
    this.hide();

  }
}

class ShortTermInDialog_jButton1_actionAdapter implements java.awt.event.ActionListener {
  ShortTermInDialog adaptee;

  ShortTermInDialog_jButton1_actionAdapter(ShortTermInDialog adaptee) {
    this.adaptee = adaptee;
  }
  public void actionPerformed(ActionEvent e) {
    adaptee.jButton1_actionPerformed(e);
  }
}

⌨️ 快捷键说明

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