📄 mainframe.java~747~
字号:
if ((String)dlgxiaji.cbojiqihao.getSelectedItem()!=null){
Up.setVisible(false);
jLabel1.setVisible(false);
Author.setVisible(false);
jLabel2.setVisible(false);
Kaika.setVisible(false);
Down.setVisible(true);
Congzhi.setVisible(false);
Tuika.setVisible(false);
Selectqian.setVisible(false);
Changepassword.setVisible(false);
lbl1.setText((String) dlgxiaji.cbo);
PreparedStatement pStatement10 = null;
Connection con = null;
try {
con = DriverManager.getConnection(DATASOURCE);
String sql4 =
"select CardId from Record where ComputerId=?";
pStatement10 = con.prepareStatement(sql4);
pStatement10.setString(1, (String) dlgxiaji.cbo);
ResultSet rs = pStatement10.executeQuery();
while (rs.next()) {
lbl2.setText(rs.getString(1));
}
rs.close();
pStatement10.close();
con.close();
} catch (SQLException v) {
v.printStackTrace();
}
try {
PreparedStatement pStatement12 = null;
con = DriverManager.getConnection(DATASOURCE);
Card card = new Card();
String str6 =
"select CardId from Record where ComputerId=?";
pStatement12 = con.prepareStatement(str6);
pStatement12.setString(1, (String) dlgxiaji.cbo);
ResultSet rs = pStatement12.executeQuery();
while (rs.next()) {
card.setCardId(rs.getString(1));
}
String str7 = "select BeginTime from Record where CardId=?";
pStatement12 = con.prepareStatement(str7);
pStatement12.setString(1, card.getCardId());
rs = pStatement12.executeQuery();
while (rs.next()) {
lbl3.setText(rs.getString(1));
}
rs.close();
pStatement12.close();
con.close();
} catch (SQLException v) {
v.printStackTrace();
}
try {
PreparedStatement pStatement13 = null;
con = DriverManager.getConnection(DATASOURCE);
Card card = new Card();
String str6 =
"select CardId from Record where ComputerId=?";
pStatement13 = con.prepareStatement(str6);
pStatement13.setString(1, (String) dlgxiaji.cbo);
ResultSet rs = pStatement13.executeQuery();
while (rs.next()) {
card.setCardId(rs.getString(1));
}
String str7 = "select EndTime from Record where CardId=?";
pStatement13 = con.prepareStatement(str7);
pStatement13.setString(1, card.getCardId());
rs = pStatement13.executeQuery();
while (rs.next()) {
lbl4.setText(rs.getString(1));
}
rs.close();
pStatement13.close();
con.close();
} catch (SQLException v) {
v.printStackTrace();
}
int fee = 0;
int beginYear = year;
int beginMonth = month;
int beginDay = day;
int beginHour = hour;
int beginMinute = min;
int endYear = ryear;
int endMonth = rmonth;
int endDay = rday;
int endHour = rhour;
int endMinute = rmin;
int playMinutes = 0;
playMinutes = (endYear - beginYear) * 365 * 24 * 60 +
(endMonth - beginMonth) * 30 * 24 * 60 +
(endDay - beginDay) * 24 * 60 +
(endHour - beginHour) * 60 +
(endMinute - beginMinute);
int modNum = playMinutes % 60;
int playHours = 0;
playHours = playMinutes / 60;
if (playHours == 0 || (modNum > 5 && playHours > 0)) {
playHours++;
}
fee = playHours * 2;
String f = fee + "";
lbl5.setText(f);
PreparedStatement pStatement3 = null;
PreparedStatement pStatement4 = null;
PreparedStatement pStatement9 = null;
PreparedStatement pStatement11 = null;
try {
con = DriverManager.getConnection(DATASOURCE);
Computer computer = new Computer();
computer.setComputerId((String) dlgxiaji.cbo);
Card card = new Card();
String str1 = "update Record set Fee=? where ComputerId=?";
pStatement3 = con.prepareStatement(str1);
pStatement3.setString(1, f);
pStatement3.setString(2, computer.getComputerId());
pStatement3.executeUpdate();
String str2 = "update Computer set OnUse=0 where Id=(?)";
pStatement4 = con.prepareStatement(str2);
pStatement4.setObject(1, computer.getComputerId());
pStatement4.executeUpdate();
String str6 =
"select CardId from Record where ComputerId=?";
pStatement11 = con.prepareStatement(str6);
pStatement11.setString(1, (String) dlgxiaji.cbo);
ResultSet rs = pStatement11.executeQuery();
while (rs.next()) {
card.setCardId(rs.getString(1));
}
String str3 = "update Card set OnUse=0 where Id=(?)";
pStatement9 = con.prepareStatement(str3);
pStatement9.setObject(1, card.getCardId());
pStatement9.executeUpdate();
rs.close();
} catch (SQLException ee) {
ee.printStackTrace();
} finally {
try {
pStatement3.close();
pStatement4.close();
pStatement9.close();
pStatement11.close();
con.close();
} catch (SQLException de) {
de.printStackTrace();
}
}
PreparedStatement pStatement5 = null;
PreparedStatement pStatement6 = null;
PreparedStatement pStatement7 = null;
try {
con = DriverManager.getConnection(DATASOURCE);
Card card = new Card();
String str6 =
"select CardId from Record where ComputerId=?";
pStatement7 = con.prepareStatement(str6);
pStatement7.setString(1, (String) dlgxiaji.cbo);
ResultSet rs = pStatement7.executeQuery();
while (rs.next()) {
card.setCardId(rs.getString(1));
}
String str3 =
"update Card set balance=balance-? where Id=?";
pStatement5 = con.prepareStatement(str3);
pStatement5.setInt(1, fee);
pStatement5.setString(2, card.getCardId());
pStatement5.executeUpdate();
String str4 = "select balance from Card where Id=?";
pStatement6 = con.prepareStatement(str4);
pStatement6.setString(1, card.getCardId());
rs = pStatement6.executeQuery();
while (rs.next()) {
lbl6.setText(rs.getString(1));
}
rs.close();
} catch (SQLException v) {
v.printStackTrace();
} finally {
try {
pStatement5.close();
pStatement6.close();
pStatement7.close();
con.close();
} catch (SQLException de) {
de.printStackTrace();
}
}
}else{
dlgMessage.showMessageDialog(this,"你没有下机!","消息",JOptionPane.INFORMATION_MESSAGE);
Up.setVisible(false);
jLabel1.setVisible(true);
Author.setVisible(true);
jLabel2.setVisible(true);
Kaika.setVisible(false);
Down.setVisible(true);
Congzhi.setVisible(false);
Tuika.setVisible(false);
Selectqian.setVisible(false);
Changepassword.setVisible(false);
}
}
public void btncz_actionPerformed(ActionEvent e) {
Pcid.setSelectedIndex(0);
id.setText("");
password.setText("");
begintime.setText("");
id.requestFocus();
}
public void btnok_actionPerformed(ActionEvent e) {
String kahao = id.getText();
String v = "";
int t=0,p=0,q=0;
char d[]= password.getPassword();
for(int j=0;j<d.length;j++)
v=v+d[j];
try{
Connection con=DriverManager.getConnection(DATASOURCE);
Statement s=con.createStatement();
ResultSet rs=s.executeQuery("Select Id,Password from Card where OnUse='0'");
while(rs.next()){
if(kahao.equals(rs.getString(1).trim())){
t=1;
if (v.equals(rs.getString(2).trim())){
q=1;
}
}
}
rs.close();
s.close();
con.close();
}catch(SQLException ce){
System.out.println(ce);
}
if(t==1 && q==1){
try{
PreparedStatement pStatement=null;
Connection con=DriverManager.getConnection(DATASOURCE);
String sql="select balance from Card where Id=?";
pStatement = con.prepareStatement(sql);
pStatement.setString(1,kahao);
ResultSet rs = pStatement.executeQuery();
while (rs.next()) {
if (rs.getInt(1) < 2) {
p = 1;
dlgMessage.showMessageDialog(this,"此卡余额不足请尽快充值!","错误",JOptionPane.ERROR_MESSAGE);
Up.setVisible(false);
Down.setVisible(false);
Kaika.setVisible(false);
Congzhi.setVisible(false);
Tuika.setVisible(false);
Selectqian.setVisible(false);
Changepassword.setVisible(false);
jLabel1.setVisible(true);
jLabel2.setVisible(true);
Author.setVisible(true);
}
}
rs.close();
pStatement.close();
con.close();
}catch(SQLException ce){
System.out.println(ce);
}
if(p==0){
dlgMessage.showMessageDialog(this, "授权用户", "经验证用户",JOptionPane.INFORMATION_MESSAGE);
PreparedStatement pStatement1 = null;
PreparedStatement pStatement2 = null;
PreparedStatement pStatement3 = null;
Connection con = null;
Up.setVisible(false);
Down.setVisible(false);
Kaika.setVisible(false);
Congzhi.setVisible(false);
Tuika.setVisible(false);
Selectqian.setVisible(false);
Changepassword.setVisible(false);
jLabel1.setVisible(true);
jLabel2.setVisible(true);
Author.setVisible(true);
try {
Card card = new Card();
Computer computer = new Computer();
String beginTime = begintime.getText();
con = DriverManager.getConnection(DATASOURCE);
card.setCardId(id.getText());
computer.setComputerId((String) Pcid.getSelectedItem());
String str1 =
"insert into Record(CardId,ComputerId,BeginTime) values(?,?,?)";
pStatement1 = con.prepareStatement(str1);
pStatement1.setString(1, card.getCardId());
pStatement1.setString(2, computer.getComputerId());
pStatement1.setString(3, beginTime);
pStatement1.executeUpdate();
String str2 = "update Computer set OnUse=1 where Id=(?)";
pStatement2 = con.prepareStatement(str2);
pStatement2.setObject(1, computer.getComputerId());
pStatement2.executeUpdate();
String str3 = "update Card set OnUse=1 where Id=(?)";
pStatement3 = con.prepareStatement(str3);
pStatement3.setObject(1, card.getCardId());
pStatement3.executeUpdate();
} catch (SQLException ce) {
ce.printStackTrace();
} finally {
try {
pStatement1.close();
pStatement2.close();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -