网吧计费系统
源代码在线查看: checkoutdialog.java~6~
package com.jbaptech.accp.netbar.client;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.text.*;
import com.jbaptech.accp.netbar.server.action.BusinessAction;
import java.util.ArrayList;
import com.jbaptech.accp.netbar.server.entity.Record;
/**
* Title:
* Description:
* Copyright: Copyright (c) 2003
* Company:
* @author not attributable
* @version 1.0
*/
public class CheckOutDialog
extends JDialog {
JPanel panel1 = new JPanel();
BorderLayout borderLayout1 = new BorderLayout();
JLabel computerIdLabel = new JLabel();
JLabel checkOutTimeLabel = new JLabel();
JTextField checkOutTimeTextField = new JTextField();
JButton confirmButton = new JButton();
JButton resetButton = new JButton();
JComboBox computerIdCombox = new JComboBox();
java.util.Date nowTime;
public CheckOutDialog(NetBarFeeMangementFrame frame, String title,
boolean modal) {
super(frame, title, modal);
mainFrame = frame;
this.setLocation(250, 200);
try {
jbInit();
pack();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
public CheckOutDialog() {
this(null, "", false);
}
private void jbInit() throws Exception {
this.getContentPane().setLayout(borderLayout1);
panel1.setPreferredSize(new Dimension(300, 200));
panel1.setLayout(null);
computerIdLabel.setFont(new java.awt.Font("Serif", 0, 16));
computerIdLabel.setText("机 器 号:");
computerIdLabel.setBounds(new Rectangle(50, 30, 80, 25));
computerIdCombox.setBounds(new Rectangle(130, 30, 100, 25));
checkOutTimeLabel.setFont(new java.awt.Font("Serif", 0, 16));
checkOutTimeLabel.setText("结束时间:");
checkOutTimeLabel.setBounds(new Rectangle(50, 100, 80, 25));
nowTime = new java.util.Date();
SimpleDateFormat HMFromat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String strNowTime = HMFromat.format(nowTime);
checkOutTimeTextField.setText(strNowTime);
checkOutTimeTextField.setBounds(new Rectangle(130, 100, 100, 25));
confirmButton.setBounds(new Rectangle(60, 150, 70, 25));
confirmButton.setText("确定");
confirmButton.addActionListener(new CheckOutDialog_confirmButton_ActionAdapter(this));
resetButton.setBounds(new Rectangle(150, 150, 70, 25));
resetButton.setText("重置");
resetButton.addActionListener(new CheckOutDialog_resetButton_ActionAdapter(this));
panel1.add(computerIdLabel, null);
panel1.add(checkOutTimeLabel, null);
panel1.add(checkOutTimeTextField, null);
panel1.add(confirmButton, null);
panel1.add(resetButton, null);
panel1.add(computerIdCombox, null);
this.getContentPane().add(panel1, BorderLayout.CENTER);
ArrayList list = BusinessAction.getNotStopComputer();
for (int i = 0; i < list.size(); i++) {
Record computer = (Record) list.get(i);
computerIdCombox.addItem(computer.getComputerId());
}
}
void resetButton_actionPerformed(ActionEvent e) {
computerIdCombox.setSelectedIndex(0);
checkOutTimeTextField.setText("");
}
void confirmButton_actionPerformed(ActionEvent e) {
String stopTime = checkOutTimeTextField.getText() + ":00";
String computerId = computerIdCombox.getSelectedItem().toString().trim();
if (computerId == null || computerId.length() == 0) {
return;
}
Record record = new Record();
record.setComputerId(computerId);
record.setEndTime(stopTime);
ComsumeDisplayData data = BusinessAction.doStopUseComputerBusiness(record);
mainFrame.consumeDisplayData = data;
this.hide();
}
private NetBarFeeMangementFrame mainFrame;
}
class CheckOutDialog_ResetButton_ActionAdapter
implements java.awt.event.ActionListener {
CheckOutDialog adaptee;
CheckOutDialog_ResetButton_ActionAdapter(CheckOutDialog adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.resetButton_actionPerformed(e);
}
}
class CheckOutDialog_ConfirmButton_ActionAdapter
implements java.awt.event.ActionListener {
CheckOutDialog adaptee;
CheckOutDialog_ConfirmButton_ActionAdapter(CheckOutDialog adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.confirmButton_actionPerformed(e);
}
}