📄 workinfo.java~85~
字号:
package work.info;
import java.util.*;
import work.tools.*;
import java.sql.PreparedStatement;
import java.io.Serializable;
public class WorkInfo implements Serializable{
private int wid;
private String title;
private String wtime;
private int tid;
private String subject;
private String status="操作成功!";
private PreparedStatement ps;
private String score;
private ConnectBean cb=new ConnectBean();
private String tName;
private int stuNo;
private int countStu;
public WorkInfo() {
}
public void setWid(int wid) {
this.wid = wid;
}
public void setTitle(String title) {
this.title = title;
}
public void setWtime(String wtime) {
this.wtime = wtime;
}
public void setTid(int tid) {
this.tid = tid;
}
public void setSubject(String subject) {
this.subject = subject;
}
public void setStatus(String status) {
this.status = status;
}
public void setScore(String score) {
this.score = score;
}
public void settName(String tName) {
this.tName = tName;
}
public void setStuNo(int stuNo) {
this.stuNo = stuNo;
}
public void setCountStu(int countStu) {
this.countStu = countStu;
}
public int getWid() {
return wid;
}
public String getTitle() {
return title;
}
public String getWtime() {
return wtime;
}
public int getTid() {
return tid;
}
public String getSubject() {
return subject;
}
public String getStatus() {
return status;
}
public String getScore() {
return score;
}
public String gettName() {
return tName;
}
public int getStuNo() {
return stuNo;
}
public int getCountStu() {
return countStu;
}
public ArrayList getAllwork() {
ArrayList allWork=null;
cb=new ConnectBean();
try {
cb.openConnection();
String query = "select work.*,teachermessage.subject,teachermessage.tname from work,teachermessage where work.tid=teachermessage.tid";
cb.createPreparedStatement(query);
cb.executeQuery();
allWork=new ArrayList();
while(cb.next()){
WorkInfo newWork=new WorkInfo();
newWork.wid=cb.getIntData(1);
newWork.title=cb.getData(2);
newWork.wtime=cb.getData(3);
newWork.tid=cb.getIntData(4);
newWork.subject=cb.getData(5);
newWork.tName=cb.getData(6);
allWork.add(newWork);
}
} catch (Exception se) {
status = "写入数据发生错误!!!" + se;
} finally {
try {
cb.close();
} catch (Exception es) {
status = "后台发生错误" + es;
}
}
return allWork;
}
public WorkInfo getOneWork(String swid,int thisStuNo){
WorkInfo tempWork = null;
int wid = Integer.parseInt(swid);
cb = new ConnectBean();
try {
cb.openConnection();
String query =
"select teachermessage.*,work.title from teachermessage,work where work.wid="+wid+"&&work.tid=teachermessage.tid";
System.out.println(query);
cb.createPreparedStatement(query);
cb.executeQuery();
if (cb.next()) {
this.tid = cb.getIntData(1);
this.tName = cb.getData(2);
this.subject = cb.getData(3);
this.title = cb.getData(5);
tempWork = this;
}
} catch (Exception se) {
status = "写入数据发生错误!!!" + se;
} finally {
try {
cb.close();
} catch (Exception es) {
status = "后台发生错误" + es;
}
}
return tempWork;
}
public String getOneWorkScore(String swid,int thisStuNo){
int swid1=Integer.parseInt(swid);
cb = new ConnectBean();
try {
cb.openConnection();
String query1 ="select score,stuno from dowork where stuno="+thisStuNo+"&&wid="+swid1;
System.out.println(query1);
cb.createPreparedStatement(query1);
cb.executeQuery();
if (cb.next()) {
int score2 = cb.getIntData(1);
int stuno1=cb.getIntData(2);
if(score2==0){
score="未阅";
}else{
score=score2+"分";
}
System.out.println("sdasdasdasdasdasdasddddddddd" +
score);
}else{
score="未做";
}
}
catch (Exception se) {
status = "写入数据发生错误!!!" + se;
} finally {
try {
cb.close();
} catch (Exception es) {
status = "后台发生错误" + es;
}
}
return score;
}
public ArrayList getStuMessage(){
ArrayList stuMessage = null;
cb = new ConnectBean();
try {
cb.openConnection();
String query = "select ";
cb.createPreparedStatement(query);
cb.executeQuery();
stuMessage = new ArrayList();
while (cb.next()) {
WorkInfo newWork = new WorkInfo();
newWork.wid = cb.getIntData(1);
newWork.title = cb.getData(2);
newWork.wtime = cb.getData(3);
newWork.tid = cb.getIntData(4);
newWork.subject = cb.getData(5);
newWork.tName = cb.getData(6);
stuMessage.add(newWork);
}
} catch (Exception se) {
status = "写入数据发生错误!!!" + se;
} finally {
try {
cb.close();
} catch (Exception es) {
status = "后台发生错误" + es;
}
}
return stuMessage;
}
public ArrayList getOneTeacherWork(){
ArrayList oneTeacherWork=null;
cb=new ConnectBean();
try {
cb.openConnection();
String query = "SELECT work.*,count(dowork.stuno) FROM work,dowork where work.wid=dowork.wid&&tid="+this.tid+" group by wid ";
cb.createPreparedStatement(query);
cb.executeQuery();
oneTeacherWork = new ArrayList();
while (cb.next()) {
WorkInfo newWork = new WorkInfo();
newWork.wid = cb.getIntData(1);
newWork.title = cb.getData(2);
newWork.wtime = cb.getData(3);
newWork.tid = cb.getIntData(4);
newWork.countStu = cb.getIntData(5);
oneTeacherWork.add(newWork);
}
} catch (Exception se) {
status = "写入数据发生错误!!!" + se;
} finally {
try {
cb.close();
} catch (Exception es) {
status = "后台发生错误" + es;
}
}
return oneTeacherWork;
}
public boolean setWork(){
boolean bl = false;
status = "添加失败";
cb = new ConnectBean();
cb.openConnection();
try {
ps = cb.createPreparedStatement(
"insert into work values(null,?,?,?)");
ps.setString(1, this.title);
ps.setString(2, this.wtime);
ps.setInt(3, this.tid);
// System.out.println("ddssasasddfsffffffffffffffffffffff"+this.wid+this.content+this.dTime+this.stuNo);
ps.executeUpdate();
bl = true;
status = "添加成功";
} catch (Exception se) {
status = "写入数据发生错误!!!" + se;
} finally {
try {
cb.close();
} catch (Exception es) {
status = "后台发生错误" + es;
}
}
return bl;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -