overuse.java
来自「一个java+sql2000开发的网吧管理系统」· Java 代码 · 共 80 行
JAVA
80 行
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 + =
减小字号Ctrl + -
显示快捷键?