📄 xiaofeiframe.java~27~
字号:
package cn.com.S1t55.killer.view;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DateFormat;
import java.util.Date;
import javax.swing.*;
import cn.com.S1t55.killer.business.ComBusiness;
import cn.com.S1t55.killer.business.RecordBuiness;
import cn.com.S1t55.killer.entity.Computer;
import cn.com.S1t55.killer.entity.Record;
import cn.com.S1t55.killer.business.CardBusiness;
import cn.com.S1t55.killer.entity.Card;
import java.text.SimpleDateFormat;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class XiaoFeiFrame extends JFrame {
JPanel contentPane;
JLabel txtCard = new JLabel();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JLabel txtComputer = new JLabel();
JLabel jLabel5 = new JLabel();
JLabel txtShangTime = new JLabel();
JLabel jLabel7 = new JLabel();
JLabel txtXiao = new JLabel();
JLabel jLabel9 = new JLabel();
JLabel txtYu = new JLabel();
JButton btnCha = new JButton();
JButton btnXia = new JButton();
public XiaoFeiFrame() {
try {
setDefaultCloseOperation(EXIT_ON_CLOSE);
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
/**
* Component initialization.
*
* @throws java.lang.Exception
*/
private void jbInit() throws Exception {
contentPane = (JPanel) getContentPane();
contentPane.setLayout(null);
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
setSize(new Dimension(400, 400));
setTitle("消费信息");
txtCard.setText("");
txtCard.setBounds(new Rectangle(148, 30, 205, 33));
jLabel2.setFont(new java.awt.Font("Dialog", Font.PLAIN, 13));
jLabel2.setText("卡ID");
jLabel2.setBounds(new Rectangle(81, 30, 53, 35));
jLabel3.setFont(new java.awt.Font("Dialog", Font.PLAIN, 13));
jLabel3.setText("机器ID");
jLabel3.setBounds(new Rectangle(78, 79, 56, 26));
txtComputer.setText("");
txtComputer.setBounds(new Rectangle(146, 75, 162, 31));
jLabel5.setFont(new java.awt.Font("Dialog", Font.PLAIN, 13));
jLabel5.setText("上机时间");
jLabel5.setBounds(new Rectangle(73, 120, 59, 27));
txtShangTime.setText("");
txtShangTime.setBounds(new Rectangle(143, 113, 151, 38));
jLabel7.setFont(new java.awt.Font("Dialog", Font.PLAIN, 13));
jLabel7.setText("消费金额");
jLabel7.setBounds(new Rectangle(74, 159, 59, 32));
txtXiao.setText("");
txtXiao.setBounds(new Rectangle(147, 158, 130, 33));
jLabel9.setFont(new java.awt.Font("Dialog", Font.PLAIN, 13));
jLabel9.setText("余额");
jLabel9.setBounds(new Rectangle(83, 204, 33, 28));
txtYu.setText("");
txtYu.setBounds(new Rectangle(144, 202, 127, 27));
btnCha.setBounds(new Rectangle(83, 256, 75, 26));
btnCha.setFont(new java.awt.Font("Dialog", Font.PLAIN, 13));
btnCha.setText("查询");
btnCha.addActionListener(new XiaoFeiFrame_btnCha_actionAdapter(this));
btnXia.setBounds(new Rectangle(251, 256, 73, 26));
btnXia.setFont(new java.awt.Font("Dialog", Font.PLAIN, 13));
btnXia.setText("下机");
btnXia.addActionListener(new XiaoFeiFrame_btnXia_actionAdapter(this));
contentPane.add(txtCard);
contentPane.add(jLabel2);
contentPane.add(jLabel3);
contentPane.add(txtComputer);
contentPane.add(txtXiao);
contentPane.add(jLabel5);
contentPane.add(txtShangTime);
contentPane.add(jLabel7);
contentPane.add(jLabel9);
contentPane.add(txtYu);
contentPane.add(btnCha);
contentPane.add(btnXia);
}
public void btnCha_actionPerformed(ActionEvent e) {
txtCard.setText(Record.cardId);
txtComputer.setText(Record.computerId);
txtShangTime.setText(Record.beginTime);
Date Time=new Date();
SimpleDateFormat df;
df=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String bs=df.format(Time);
int fee=JiSuan.FeiYong(bs);
double yu=Record.balance-fee;
txtXiao.setText(""+fee);
txtYu.setText(""+yu);
}
public void btnXia_actionPerformed(ActionEvent e) {
txtCard.setText(Record.cardId);
txtComputer.setText(Record.computerId);
txtShangTime.setText(Record.beginTime);
Date Time=new Date();
SimpleDateFormat df;
df=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String as=df.format(Time);
int fee=JiSuan.FeiYong(as);
double yu=Record.balance-fee;
txtXiao.setText(""+fee);
txtYu.setText(""+yu);
Record Cha=new Record();
Cha.setCardId(Record.cardId);
Cha.setComputerId(Record.computerId);
Cha.setBeginTime(Record.beginTime);
Cha.setBeginTime(Record.beginTime);
Cha.setEndTime(as);
Cha.setBalance(yu);
RecordBuiness.insert(Cha);
Card s=new Card();
s.setId(Record.cardId);
s.setBalance(yu);
CardBusiness.GengXin(s);
Computer gen=new Computer();
gen.setId(Record.computerId);
gen.setOnUse(0);
gen.setNotes("闲置");
ComBusiness.update(gen);
this.setVisible(false);
}
}
class XiaoFeiFrame_btnXia_actionAdapter implements ActionListener {
private XiaoFeiFrame adaptee;
XiaoFeiFrame_btnXia_actionAdapter(XiaoFeiFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btnXia_actionPerformed(e);
}
}
class XiaoFeiFrame_btnCha_actionAdapter implements ActionListener {
private XiaoFeiFrame adaptee;
XiaoFeiFrame_btnCha_actionAdapter(XiaoFeiFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btnCha_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -