//------------------------------------------------------------------
CheckOutPanel COP = new CheckOutPanel();
String computerID = null;
String endTime = null;
Statement stmtObj = null;
String cardID = null;
String beginTime = null;
String str1 = null;
String str2 = null;
String str3 = null;
String str4 = null;
String str5 = null;
int balance = 0;
int fee = 0; computerID = ComputerID.getSelectedItem().toString();
endTime = EndTime.getText() + ":00";
stmtObj = Connect.getStatement(); //停掉当前使用计算机的状态
str1 = "update Computer set OnUse = 0 where ID like '" + computerID +
"'";
stmtObj.executeUpdate(str1); //得到卡号和上机时间
ResultSet rs1 = stmtObj.executeQuery(
"select CardID,BeginTime from Record where ComputerID like '" +
computerID + "' and EndTime is null");
if (rs1.next()) {
cardID = rs1.getString(1);
beginTime = rs1.getString(2);
} //插入停用时间
str2 = "update Record set EndTime = '" + endTime +
"' where ComputerID like '" + computerID +
"' and EndTime is null";
stmtObj.executeUpdate(str2); //插入使用金额
fee = Account.calFee(beginTime, endTime);
str4 = "update Record set fee = " + fee + "where ComputerID like '" +
computerID + "' and fee is null";
stmtObj.executeUpdate(str4); //计算余额
str3 = "update Card set Balance = Balance - " + fee +
"where ID like '" + cardID + "'";
stmtObj.executeUpdate(str3);
jOptionPane1.showMessageDialog(this, "下机成功", "提示",
jOptionPane1.WARNING_MESSAGE);
this.dispose();
//搜索本金
String str7 = "select balance from Card where ID like '" + cardID +
"'";
ResultSet rs7 = stmtObj.executeQuery(str7);
if (rs7.next()) {
balance = rs7.getInt(1);
COP.Balance.setText(String.valueOf(balance));
}
//搜索Record表中最新的数据
String str6 = "select top 1 * from Record where ComputerID like '" + computerID + "' order by ID desc";
ResultSet rs6 = stmtObj.executeQuery(str6);
if(rs6.next())
{
COP.CardID.setText(rs6.getString(2));
COP.ComputerID.setText(rs6.getString(3));
COP.BeginTime.setText(rs6.getString(4));
COP.EndTime.setText(rs6.getString(5));
COP.Consume.setText(rs6.getString(6));
} System.out.println(computerID);
System.out.println(cardID);
System.out.println(beginTime);
System.out.println(endTime);
System.out.println(fee);
System.out.println(balance); /*COP.CardID.setText(computerID);
COP.ComputerID.setText(cardID);
COP.BeginTime.setText(beginTime);
COP.EndTime.setText(endTime);
COP.Consume.setText(String.valueOf(fee));
COP.Balance.setText(String.valueOf(balance));*/
//----------------------------------------------------------------------
在JB的消息窗格那输出来的值都没错....但为什么setText不起作用..导致我那些组件都是空白的....
CheckOutPanel COP = new CheckOutPanel();
String computerID = null;
String endTime = null;
Statement stmtObj = null;
String cardID = null;
String beginTime = null;
String str1 = null;
String str2 = null;
String str3 = null;
String str4 = null;
String str5 = null;
int balance = 0;
int fee = 0; computerID = ComputerID.getSelectedItem().toString();
endTime = EndTime.getText() + ":00";
stmtObj = Connect.getStatement(); //停掉当前使用计算机的状态
str1 = "update Computer set OnUse = 0 where ID like '" + computerID +
"'";
stmtObj.executeUpdate(str1); //得到卡号和上机时间
ResultSet rs1 = stmtObj.executeQuery(
"select CardID,BeginTime from Record where ComputerID like '" +
computerID + "' and EndTime is null");
if (rs1.next()) {
cardID = rs1.getString(1);
beginTime = rs1.getString(2);
} //插入停用时间
str2 = "update Record set EndTime = '" + endTime +
"' where ComputerID like '" + computerID +
"' and EndTime is null";
stmtObj.executeUpdate(str2); //插入使用金额
fee = Account.calFee(beginTime, endTime);
str4 = "update Record set fee = " + fee + "where ComputerID like '" +
computerID + "' and fee is null";
stmtObj.executeUpdate(str4); //计算余额
str3 = "update Card set Balance = Balance - " + fee +
"where ID like '" + cardID + "'";
stmtObj.executeUpdate(str3);
jOptionPane1.showMessageDialog(this, "下机成功", "提示",
jOptionPane1.WARNING_MESSAGE);
this.dispose();
//搜索本金
String str7 = "select balance from Card where ID like '" + cardID +
"'";
ResultSet rs7 = stmtObj.executeQuery(str7);
if (rs7.next()) {
balance = rs7.getInt(1);
COP.Balance.setText(String.valueOf(balance));
}
//搜索Record表中最新的数据
String str6 = "select top 1 * from Record where ComputerID like '" + computerID + "' order by ID desc";
ResultSet rs6 = stmtObj.executeQuery(str6);
if(rs6.next())
{
COP.CardID.setText(rs6.getString(2));
COP.ComputerID.setText(rs6.getString(3));
COP.BeginTime.setText(rs6.getString(4));
COP.EndTime.setText(rs6.getString(5));
COP.Consume.setText(rs6.getString(6));
} System.out.println(computerID);
System.out.println(cardID);
System.out.println(beginTime);
System.out.println(endTime);
System.out.println(fee);
System.out.println(balance); /*COP.CardID.setText(computerID);
COP.ComputerID.setText(cardID);
COP.BeginTime.setText(beginTime);
COP.EndTime.setText(endTime);
COP.Consume.setText(String.valueOf(fee));
COP.Balance.setText(String.valueOf(balance));*/
//----------------------------------------------------------------------
在JB的消息窗格那输出来的值都没错....但为什么setText不起作用..导致我那些组件都是空白的....
楼主【xianxin8888】截止到2008-07-17 12:48:50的历史汇总数据(不包括此帖):
发帖的总数量:0 发帖的总分数:0 每贴平均分数:0
回帖的总数量:0 得分贴总数量:0 回帖的得分率:0%
结贴的总数量:0 结贴的总分数:0
无满意结贴数:0 无满意结贴分:0
未结的帖子数:0 未结的总分数:0
结贴的百分比:---------------------结分的百分比:---------------------
无满意结贴率:---------------------无满意结分率:---------------------
如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html
我记得我刚学java的时候跟你一样;
每天敲十几个小时代码,两个星期做了一个网吧系统;
那时候感觉非常满足,觉得程序也不过如此. :)
现在回想起来真是一个不错的经历.
还有给你一个小小的建议,试着考虑一下程序效率方面的问题;
少用JBuilder拖来拖去.多看看别人的代码...