📄 overuse.java
字号:
package com.jbaptech.accp.netbar.client;
import java.sql.*;
public class OverUse {
public OverUse() {
}
public String getBeginTime(String ComputerId){
//获取上机时间
String BeginTime="";
try{
Connection con = ConnectionManager.getConnection();
String sql = "select BeginTime from Record where ComputerId ='"+ComputerId+"'";
Statement s =con.createStatement();
ResultSet rs = s.executeQuery(sql);
while(rs.next()){
BeginTime = rs.getString(1);
}
}catch (SQLException ce){
ce.printStackTrace();
}
return BeginTime;
}
//下机界面CheckOutDialog按下确定时调用此方法
public void update(String ComputerId,String EndTime,int fee){
Connection con =ConnectionManager.getConnection();
try{
//更新Record表中的下机时间EndTime和消费金额Fee
String sql
= "update Record set EndTime = ?,Fee = ? where ComputerId ='"+ComputerId+"'";
PreparedStatement ps = con.prepareStatement(sql);
ps.setString(1,EndTime);
ps.setInt(2,fee);
ps.executeUpdate();
//更新Computer表中已下机的机器使用状态OnUse为0
String sql2 =
"update computer set OnUse = \'0\' where id ='"+ComputerId+"'";
Statement s = con.createStatement();
s.executeUpdate(sql2);
con.close();
}catch (SQLException ce){
ce.printStackTrace();
}
}
//下机界面CheckOutDialog按下确定时调用此方法
public void update(String CardId,int fee){
//更新Card表中指定卡号的余额
try{
Connection con =ConnectionManager.getConnection();
String sql3 =
"update Card set balance=balance-'" + fee + "' where id ='" +
CardId + "'";
Statement ps2 = con.createStatement();
ps2.executeUpdate(sql3);
}catch (SQLException ce){
ce.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -