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

📄 useinpanel.java~12~

📁 网吧计费系统 通过程序实现网吧计费系统的过程
💻 JAVA~12~
字号:
package com.jbaptech.accp.netbar.client;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.text.*;
import java.util.*;
import com.jbaptech.accp.netbar.server.entity.*;
import com.jbaptech.accp.netbar.server.action.BusinessAction;

public class UseInPanel extends JPanel {
  JLabel computerIdDescLabel = new JLabel();
  JLabel cardIdDescLabel = new JLabel();
  JTextField cardIdTextField = new JTextField();
  JLabel pwdDescLabel = new JLabel();
  JLabel nowTimeDescLabel = new JLabel();
  JTextField nowTimeTextField = new JTextField();
  JButton confirmButton = new JButton();
  JButton resetButton = new JButton();
  JPasswordField passwordFiled = new JPasswordField();
  JComboBox computerIdCombox = new JComboBox();

  public UseInPanel(NetBarFeeMangementFrame mFrame) {
    try {
      mainFrame = mFrame;
      jbInit();
    }
    catch(Exception ex) {
      ex.printStackTrace();
    }
  }
  void jbInit() throws Exception {
    this.setLayout(null);

    computerIdDescLabel.setFont(new java.awt.Font("Serif", 0, 13));
    computerIdDescLabel.setHorizontalAlignment(SwingConstants.CENTER);
    computerIdDescLabel.setText("机器号码:");
    computerIdDescLabel.setBounds(new Rectangle(95, 30, 70, 25));

    computerIdCombox.setBounds(new Rectangle(175, 30, 110, 25));

    cardIdDescLabel.setFont(new java.awt.Font("Serif", 0, 13));
    cardIdDescLabel.setHorizontalAlignment(SwingConstants.CENTER);
    cardIdDescLabel.setText("卡        号:");
    cardIdDescLabel.setBounds(new Rectangle(95, 75, 70, 25));

    cardIdTextField.setText("");
    cardIdTextField.setBounds(new Rectangle(175, 75, 110, 25));

    pwdDescLabel.setFont(new java.awt.Font("Serif", 0, 13));
    pwdDescLabel.setHorizontalAlignment(SwingConstants.CENTER);
    pwdDescLabel.setText("密        码:");
    pwdDescLabel.setBounds(new Rectangle(95, 120, 70, 25));

    passwordFiled.setText("");
    passwordFiled.setBounds(new Rectangle(175, 120, 110, 25));

    nowTimeDescLabel.setFont(new java.awt.Font("Serif", 0, 13));
    nowTimeDescLabel.setHorizontalAlignment(SwingConstants.CENTER);
    nowTimeDescLabel.setText("开始时间:");
    nowTimeDescLabel.setBounds(new Rectangle(95, 165, 70, 25));

    java.util.Date today = new java.util.Date();
    SimpleDateFormat HMFromat = new SimpleDateFormat("HH:mm");
    String nowTime = HMFromat.format(today);
    nowTimeTextField.setText(nowTime);
    nowTimeTextField.setBounds(new Rectangle(175, 165, 110, 25));
//    nowTimeTextField.setEnabled(false);


    confirmButton.setBounds(new Rectangle(115, 215, 65, 25));
    confirmButton.setText("确认");
    confirmButton.addActionListener(new UseInPanel_confirmButton_actionAdapter(this));

    resetButton.setBounds(new Rectangle(200, 215, 65, 25));
    resetButton.setText("重置");
    resetButton.addActionListener(new UseInPanel_resetButton_actionAdapter(this));


    this.add(cardIdTextField, null);
    this.add(cardIdDescLabel, null);
    this.add(pwdDescLabel, null);
    this.add(nowTimeDescLabel, null);
    this.add(nowTimeTextField, null);
    this.add(passwordFiled, null);
    this.add(computerIdDescLabel, null);
    this.add(confirmButton, null);
    this.add(resetButton, null);
    this.add(computerIdCombox, null);

//    con = barConnect.getconn();
//    Statement stmt = con.createStatement();
//    ResultSet boxRs = stmt.executeQuery("select * from CompuetIDView");

    computerIdCombox.addItem("");
    ArrayList list =BusinessAction.getNotUsedComputeList();
    for(int i=0;i<list.size();i++){
        Computer computer = (Computer) list.get(i);
        computerIdCombox.addItem(computer.getId());
    }
//    while(boxRs.next()){
//      computerIdCombox.addItem(boxRs.getString("ComputerID"));
//    }
  }

  void resetButton_actionPerformed(ActionEvent e) {
    computerIdCombox.setSelectedIndex(0);
    cardIdTextField.setText("");
    passwordFiled.setText("");
    nowTimeTextField.setText("");
  }

  void confirmButton_actionPerformed(ActionEvent e) {
    String cardId="";
    String passwordtemp = "";
    String computerId ="";
    cardId = cardIdTextField.getText().trim();
    for(int i=0;i<passwordFiled.getPassword().length;i++){
      passwordtemp += passwordFiled.getPassword()[i];
    }
    computerId = computerIdCombox.getSelectedItem().toString();
    if(computerId==null || computerId.trim().length()==0){
      JOptionPane.showMessageDialog(this,"请选择机器号!","警告",
				                                JOptionPane.WARNING_MESSAGE ,null );
      return ;
    }
    if(cardId==null || cardId.length()==0){
      JOptionPane.showMessageDialog(this,"请输入卡号!","警告",
                                                             JOptionPane.WARNING_MESSAGE ,null );
       return ;

    }
    if(passwordtemp==null || passwordtemp.length()==0){
     JOptionPane.showMessageDialog(this,"请输入密码!","警告",
                                                         JOptionPane.WARNING_MESSAGE ,null );
   return ;

}

    String nowTime = nowTimeTextField.getText() + ":00";

    Card card = new Card();
    card.setId(cardId);
    card.setPassword(passwordtemp);

    Record record = new Record();
    record.setCardId(cardId);
    record.setComputerId(computerId);

    if(BusinessAction.cardIsValid(card)){
       BusinessAction.addRecord(record);
    }else{
      cardIdTextField.setText("卡号或者密码不对 ");
      System.out.println("卡号或者密码不对");
      return;
    }




   WelcomePanel welcomePanel2 = new WelcomePanel();
   mainFrame.remove(mainFrame.getContentPane());
   mainFrame.getContentPane().add(welcomePanel2);
   mainFrame.setContentPane(welcomePanel2);
   mainFrame.show();
  }

//  private Statement queryStmt;
//  private Statement insertStmt;
//  private String loginQuery;
//  private String insertString;
//  private Connection con;
  private NetBarFeeMangementFrame mainFrame;
}

class UseInPanel_resetButton_actionAdapter implements java.awt.event.ActionListener {
  UseInPanel adaptee;

  UseInPanel_resetButton_actionAdapter(UseInPanel adaptee) {
    this.adaptee = adaptee;
  }
  public void actionPerformed(ActionEvent e) {
    adaptee.resetButton_actionPerformed(e);
  }
}

class UseInPanel_confirmButton_actionAdapter implements java.awt.event.ActionListener {
  UseInPanel adaptee;

  UseInPanel_confirmButton_actionAdapter(UseInPanel adaptee) {
    this.adaptee = adaptee;
  }
  public void actionPerformed(ActionEvent e) {
    adaptee.confirmButton_actionPerformed(e);
  }
}

⌨️ 快捷键说明

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