📄 upcomputerfrm.java
字号:
package src.netbar;
import java.awt.*;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import src.Bean.UpComputerCardBean;
import src.Bean.UpComputerComputerBean;
import src.Bean.UpComputerRecordBean;
import src.Rule.UpComputerRule;
import java.util.Vector;
import javax.swing.ComboBoxModel;
import java.sql.*;
import src.Bean.UpComputerComputerBean;
import src.Bean.UpComputerRecordBean;
import java.util.Date;
import javax.swing.border.TitledBorder;
/**
* 这是上机操作界面!
*/
public class UpComputerFrm
extends JFrame {
UpComputerComputerBean objUpComputerComputerBean = new UpComputerComputerBean();
UpComputerRule objUpComputerRule;
UpComputerCardBean objUpComputerCardBean = new UpComputerCardBean();
UpComputerRecordBean objUpComputerRecordBean = new UpComputerRecordBean();
public UpComputerFrm() {
try {
jbInit();
}
catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
objUpComputerRule = new UpComputerRule();
getContentPane().setLayout(null);
this.setBounds(440, 250, 570, 390);
this.setResizable(false);
setSize(new Dimension(400, 300));
this.setTitle("机房管理系统 -- 上机操作");
labUpComputerMain.setFont(new java.awt.Font("黑体", Font.PLAIN, 25));
labUpComputerMain.setForeground(Color.blue);
labUpComputerMain.setText("上机操作");
labUpComputerMain.setBounds(new Rectangle(128, 23, 109, 38));
labUpComputerID.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
labUpComputerUserID.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
labUpComputerUserID.setText("用户帐号");
labUpComputerUserID.setBounds(new Rectangle(64, 119, 60, 19));
labUpComputerUserPwd.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
labUpComputerUserPwd.setText("用户密码");
labUpComputerUserPwd.setBounds(new Rectangle(64, 153, 61, 18));
cobUpComputer.setBounds(new Rectangle(148, 85, 126, 21));
//这是设制上机的COMBOBOX模型
ComboBoxModel objJCBMolde = new DefaultComboBoxModel(objUpComputerRule.
getCardInfo(objUpComputerComputerBean));
cobUpComputer.setModel(objJCBMolde);
txtUpComputerUserID.setBounds(new Rectangle(148, 116, 126, 21));
txtUpComputerbTime.setBackground(Color.white);
txtUpComputerbTime.setEnabled(false);
txtUpComputerbTime.setForeground(Color.black);
txtUpComputerbTime.setBorder(BorderFactory.createLineBorder(Color.black));
txtUpComputerbTime.setCaretColor(Color.black);
txtUpComputerbTime.setEditable(false);
txtUpComputerbTime.setHorizontalAlignment(SwingConstants.CENTER);
txtUpComputerbTime.setBounds(new Rectangle(145, 179, 129, 22));
labUpComputerbTIME.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
labUpComputerbTIME.setText("开始时间");
labUpComputerbTIME.setBounds(new Rectangle(62, 183, 67, 19));
pwfUpComputerUserPwd.setBounds(new Rectangle(146, 149, 128, 22));
butUpComputerOK.setBounds(new Rectangle(107, 224, 65, 25));
butUpComputerOK.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
butUpComputerOK.setText("确定");
butUpComputerOK.addActionListener(new
UpComputerFrm_butUpComputerOK_actionAdapter(this));
butUpComputerClear.setBounds(new Rectangle(224, 223, 65, 24));
butUpComputerClear.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
butUpComputerClear.setText("清空");
butUpComputerClear.addActionListener(new
UpComputerFrm_butUpComputerClear_actionAdapter(this));
this.getContentPane().add(labUpComputerMain);
this.getContentPane().add(txtUpComputerUserID);
this.getContentPane().add(pwfUpComputerUserPwd);
this.getContentPane().add(butUpComputerOK);
this.getContentPane().add(butUpComputerClear);
this.getContentPane().add(labUpComputerUserID);
this.getContentPane().add(labUpComputerUserPwd);
this.getContentPane().add(labUpComputerbTIME);
this.getContentPane().add(labUpComputerID);
this.getContentPane().add(cobUpComputer);
this.getContentPane().add(txtUpComputerbTime);
labUpComputerID.setText("机器编号");
labUpComputerID.setBounds(new Rectangle(65, 86, 61, 25));
this.txtUpComputerbTime.setText(objUpComputerRule.getBtime()); // 调用系统时间~
}
JLabel labUpComputerMain = new JLabel();
JLabel labUpComputerID = new JLabel();
JLabel labUpComputerUserID = new JLabel();
JLabel labUpComputerUserPwd = new JLabel();
JComboBox cobUpComputer = new JComboBox();
JTextField txtUpComputerUserID = new JTextField();
JTextField txtUpComputerbTime = new JTextField();
JLabel labUpComputerbTIME = new JLabel();
JPasswordField pwfUpComputerUserPwd = new JPasswordField();
JButton butUpComputerOK = new JButton();
JButton butUpComputerClear = new JButton();
TitledBorder titledBorder1 = new TitledBorder("");
public void butUpComputerClear_actionPerformed(ActionEvent e) throws
SQLException {
cobUpComputer.removeAllItems();
ComboBoxModel objJCBMolde = new DefaultComboBoxModel(
objUpComputerRule.
getCardInfo(objUpComputerComputerBean));
cobUpComputer.setModel(objJCBMolde);
this.txtUpComputerUserID.setText("");
this.pwfUpComputerUserPwd.setText("");
this.txtUpComputerbTime.setText(objUpComputerRule.getBtime());
}
public void butUpComputerOK_actionPerformed(ActionEvent e) {
String computerID = this.cobUpComputer.getSelectedItem().toString();
String UserName = this.txtUpComputerUserID.getText();
char getpass[] = this.pwfUpComputerUserPwd.getPassword();
String Password = String.valueOf(getpass);
String Btime = this.txtUpComputerbTime.getText();
//这层IF用于验证用户名和密码是否为空
if ( (UserName.length() == 0) && (Password.length() == 0)) {
JOptionPane.showMessageDialog(this, "用户名或密码不能为空", "提示",
JOptionPane.PLAIN_MESSAGE,
new ImageIcon("imags\\baichi.gif"));
}
else {
try {
objUpComputerComputerBean = new UpComputerComputerBean();
objUpComputerComputerBean.setID(computerID);
objUpComputerCardBean.setUserName(UserName);
objUpComputerCardBean.setPassword(Password);
//这层IF用于验证用户名和密码是否正确
if (objUpComputerRule.upComputer_CardCheck(objUpComputerCardBean)) {
if (objUpComputerRule.upComputerUseCardChick(objUpComputerCardBean)) {
JOptionPane.showMessageDialog(this, "该上网卡已在使用!!", "提示",
JOptionPane.PLAIN_MESSAGE,
new ImageIcon("imags\\jingya.gif"));
//清空所有资料.并重新加载下拉菜单
cobUpComputer.removeAllItems();
ComboBoxModel objJCBMolde = new DefaultComboBoxModel(
objUpComputerRule.
getCardInfo(objUpComputerComputerBean));
cobUpComputer.setModel(objJCBMolde);
this.txtUpComputerUserID.setText("");
this.pwfUpComputerUserPwd.setText("");
this.txtUpComputerbTime.setText(objUpComputerRule.getBtime());
}
else {
//这层IF验证用户余额是否充足
if (objUpComputerRule.upComputerUseBalanceChick(
objUpComputerCardBean)) {
objUpComputerRule.upCometersetOnCard(objUpComputerCardBean);
objUpComputerRule.upCometersetOnComputer(
objUpComputerComputerBean);
this.txtUpComputerbTime.setText(objUpComputerRule.getBtime()); // 调用系统时间~
//在这里添加写入RECORD表的事件
objUpComputerRecordBean.setCardID(UserName);
objUpComputerRecordBean.setComputerID(computerID);
objUpComputerRecordBean.setBeginTime(Btime);
objUpComputerRule.setupintert(objUpComputerCardBean,
objUpComputerComputerBean,
objUpComputerRecordBean);
JOptionPane.showMessageDialog(this, "上网卡登陆成功!!", "提示",
JOptionPane.PLAIN_MESSAGE,
new ImageIcon("imags\\kawayi.gif"));
//上机完成后清空所有项目.并重新加载COMBOBOX.
cobUpComputer.removeAllItems();
ComboBoxModel objJCBMolde = new DefaultComboBoxModel(
objUpComputerRule.
getCardInfo(objUpComputerComputerBean));
cobUpComputer.setModel(objJCBMolde);
this.txtUpComputerUserID.setText("");
this.pwfUpComputerUserPwd.setText("");
this.txtUpComputerbTime.setText(objUpComputerRule.getBtime());
}
else {
JOptionPane.showMessageDialog(this, "该用户余额低于2元,费用不足!\n请尽快充值!!",
"提示", JOptionPane.PLAIN_MESSAGE,
new ImageIcon("imags\\gaida.gif"));
//清空所有资料.并重新加载下拉菜单
cobUpComputer.removeAllItems();
ComboBoxModel objJCBMolde = new DefaultComboBoxModel(
objUpComputerRule.
getCardInfo(objUpComputerComputerBean));
cobUpComputer.setModel(objJCBMolde);
this.txtUpComputerUserID.setText("");
this.pwfUpComputerUserPwd.setText("");
this.txtUpComputerbTime.setText(objUpComputerRule.getBtime());
}
}
}
else {
JOptionPane.showMessageDialog(this, "用户名或密码不正确!\n请确认后再输入!!", "提示",
JOptionPane.PLAIN_MESSAGE,
new ImageIcon("imags\\daizi.gif"));
//清空所有资料,并重新加载下拉菜单
cobUpComputer.removeAllItems();
ComboBoxModel objJCBMolde = new DefaultComboBoxModel(
objUpComputerRule.
getCardInfo(objUpComputerComputerBean));
cobUpComputer.setModel(objJCBMolde);
this.txtUpComputerUserID.setText("");
this.pwfUpComputerUserPwd.setText("");
this.txtUpComputerbTime.setText(objUpComputerRule.getBtime());
}
}
catch (HeadlessException ex) {
}
catch (SQLException ex) {
}
}
}
}
class UpComputerFrm_butUpComputerOK_actionAdapter
implements ActionListener {
private UpComputerFrm adaptee;
UpComputerFrm_butUpComputerOK_actionAdapter(UpComputerFrm adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.butUpComputerOK_actionPerformed(e);
}
}
class UpComputerFrm_butUpComputerClear_actionAdapter
implements ActionListener {
private UpComputerFrm adaptee;
UpComputerFrm_butUpComputerClear_actionAdapter(UpComputerFrm adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
try {
adaptee.butUpComputerClear_actionPerformed(e);
}
catch (SQLException ex) {
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -