📄 answer.java
字号:
package building;
import java.lang.*;
import java.util.*;
import java.sql.*;
import javax.sql.*;
public final class Answer {
private int answerId = 0 ;
private int questionId = 0 ;
private int workerId = 0 ;
private String contents = null ;
private String subtime = null ;
public Answer(){
}
/*
* 答复Id的 set and get
*/
public void setAnswerId(int answerId){
this.answerId = answerId ;
}
public int getAnswerId(){
return (answerId) ;
}
/*
* 问题Id的 set and get
*/
public void setQuestioneId(int questionId){
this.questionId = questionId ;
}
public int getQuestionId(){
return (questionId) ;
}
/*
* 回复员工Id set and get
*/
public void setWorkerId(int workerId){
this.workerId = workerId ;
}
public int getWorkerId(){
return (workerId) ;
}
/*
* 答复内容(contents) set and get
*/
public void setContents(String contents){
this.contents = contents ;
}
public String getContents(){
return (contents) ;
}
/*
* 答复时间(subtime) set and get
*/
public void setSubTime(String subtime){
this.subtime = subtime ;
}
public String getSubTime(){
return (subtime) ;
}
/**
* 数据库操作方法
*/
/**
*按问题编号(ID)查询相应的答复信息
*/
public static Vector getAnswerByQTID(DB db,int questionid)
throws SQLException
{
String strSql = null;
ResultSet rs = null;
Vector awList = new Vector();
strSql = "select * from Answer where questionid="
+ questionid
+ " order by answerid desc";
rs = db.OpenSql(strSql);
while (rs.next())
{
Answer aw = new Answer();
aw.setAnswerId(rs.getInt("answerid"));
aw.setQuestioneId(rs.getInt("questionid"));
aw.setWorkerId(rs.getInt("workerid"));
aw.setContents(rs.getString("contents"));
aw.setSubTime(rs.getString("subtime"));
awList.add(aw);
}//End of while
return(awList);
}//End of getAnswerByQTID
/**
* 添加新的咨询问题
*/
public boolean addNewAnswer(DB db)
throws SQLException
{
String strSql = null;
ResultSet rs = null;
int iMax = 0;
strSql = "select max(answerid) from Answer";
rs = db.OpenSql(strSql);
if (rs.next())
{
iMax = rs.getInt(1);
iMax++;
}//End of if
else
{
iMax = 1;
}//End of else
strSql = "insert into Answer values("
+ iMax + ","
+ questionId + ","
+ workerId + ",'"
+ contents + "','"
+ subtime + "')";
if ( db.ExecSql(strSql) == 0 )
{
//添加失败
return(false);
}//End of if
else
{
//添加成功
return(true);
}//End of else
}//End of addNewQuestion
}//End of class Answer
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -