package com.wei.action.dao.impl;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.ServletActionContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.wei.action.dao.ScoreDao;
import com.wei.entity.FinalScore;
import com.wei.entity.FinalScoreCount;
import com.wei.entity.ManyScore;
import com.wei.entity.Paper;
import com.wei.entity.Score;
import com.wei.entity.Student;
import com.wei.util.DBUtil;
import com.wei.util.ExcelFileGenerator;
public class ScoreDaoImpl extends HibernateDaoSupport implements ScoreDao{
public void saveStudentScore(Score score) throws SQLException {
System.out.println("score save succeess!");
this.getHibernateTemplate().save(score);
}
public Score findStudentScorebyStuId(String StuNumber) throws SQLException {
String hql="from Score where stuNumber=?";
Object[] params={StuNumber};
List<Score> scorelist=this.getHibernateTemplate().find(hql,params);
if(!scorelist.isEmpty()){
Score s=scorelist.get(0);
return s;
}
return null;
}
public List<FinalScore> findall() throws SQLException {
String hql="from FinalScore";
List<FinalScore> list=this.getHibernateTemplate().find(hql);
return list;
}
public void saveManyChooseScore(ManyScore manyscore) throws SQLException {
System.out.println("manyscore save succeess!");
this.getHibernateTemplate().save(manyscore);
Score single=findStudentScorebyStuId(manyscore.getStuNumber());
FinalScore finalscore=new FinalScore();
finalscore.setStuScore(single.getStuScore());
finalscore.setStuManyscore(manyscore.getStuManyscore());
finalscore.setStuName(manyscore.getStuName());
finalscore.setStuNumber(manyscore.getStuNumber());
this.getHibernateTemplate().save(finalscore);
}
public void saveFinalScore(FinalScore finalscore) throws SQLException {
System.out.println("finalscore save succeess!");
//this.getHibernateTemplate().save(finalscore);
}
public void saveFinalScoreCount(FinalScoreCount finalscorecount)
throws SQLException {
// TODO Auto-generated method stub
this.getHibernateTemplate().save(finalscorecount);
}
public List<FinalScoreCount> findallfinalcount() throws SQLException {
String hql="from FinalScoreCount f order by f.sumScore desc";
List<FinalScoreCount> list=this.getHibernateTemplate().find(hql);
return list;
}
public FinalScoreCount findfinalScorecountbyStuId(String StuNumber)
throws SQLException {
String hql="from FinalScoreCount f where f.stuNumber=?";
Object[] params={StuNumber};
List<FinalScoreCount> scorelist=this.getHibernateTemplate().find(hql,params);
if(!scorelist.isEmpty()){
FinalScoreCount s=scorelist.get(0);
return s;
}
return null;
}
public void deleteallrowsfromFinalScoreCount() throws SQLException {
Connection conn=DBUtil.getConnection();
String sql = "DROP TABLE IF EXISTS finalscorecount";
String sql2="create table `onlinexam`.`finalscorecount`(`stuNumber` VARCHAR(255) not null,`stuName` VARCHAR(255) not null,`singleScore` DOUBLE,`manyScore` DOUBLE,`sumScore` DOUBLE,primary key (`stuNumber`))";
PreparedStatement pst = conn.prepareStatement(sql);
pst.execute();
System.out.println(sql);
pst=conn.prepareStatement(sql2);
pst.execute();
System.out.println(sql2);
conn.close();
}
public void exportExcel(List<FinalScoreCount> users) throws Exception {
HttpServletResponse response=ServletActionContext.getResponse();
response.setContentType("application/vnd.ms-excel");
ArrayList<String> fieldName=new ArrayList<String>();
fieldName.add("学号");
fieldName.add("姓名");
fieldName.add("单选题");
fieldName.add("多选题");
fieldName.add("总分");
ArrayList<List<Object>> fieldData=new ArrayList<List<Object>>();
for(FinalScoreCount user:users){
ArrayList<Object> udata=new ArrayList<Object>();
udata.add(user.getStuNumber());
udata.add(user.getStuName());
udata.add(user.getSingleScore());
udata.add(user.getManyScore());
udata.add(user.getSumScore());
fieldData.add(udata);
}
ExcelFileGenerator excelFileGenerator=new ExcelFileGenerator(fieldName, fieldData);
excelFileGenerator.exportExcel(response.getOutputStream());
}
public void deleteallscoreinfo(String studentnum) throws Exception {
FinalScoreCount n1=findFinalScoreCountbyStuNumber(studentnum);
if(n1!=null){
this.getHibernateTemplate().delete(n1);
}
FinalScore n2=findFinalScorebyStuNumber(studentnum);
if(n2!=null){
this.getHibernateTemplate().delete(n2);
}
ManyScore n3=findManyScorebyStuNumber(studentnum);
if(n3!=null){
this.getHibernateTemplate().delete(n3);
}
Score n4=findScorebyStuNumber(studentnum);
if(n4!=null){
this.getHibernateTemplate().delete(n4);
}
}
public FinalScoreCount findFinalScoreCountbyStuNumber(String StuNumber)
throws SQLException {
String hql="from FinalScoreCount where stuNumber=?";
Object[] params={StuNumber};
List<FinalScoreCount> scorelist=this.getHibernateTemplate().find(hql,params);
if(!scorelist.isEmpty()){
FinalScoreCount s=scorelist.get(0);
return s;
}
return null;
}
public FinalScore findFinalScorebyStuNumber(String StuNumber)
throws SQLException {
String hql="from FinalScore where stuNumber=?";
Object[] params={StuNumber};
List<FinalScore> scorelist=this.getHibernateTemplate().find(hql,params);
if(!scorelist.isEmpty()){
FinalScore s=scorelist.get(0);
return s;
}
return null;
}
public ManyScore findManyScorebyStuNumber(String StuNumber)
throws SQLException {
String hql="from ManyScore where stuNumber=?";
Object[] params={StuNumber};
List<ManyScore> scorelist=this.getHibernateTemplate().find(hql,params);
if(!scorelist.isEmpty()){
ManyScore s=scorelist.get(0);
return s;
}
return null;
}
public Score findScorebyStuNumber(String StuNumber) throws SQLException {
String hql="from Score where stuNumber=?";
Object[] params={StuNumber};
List<Score> scorelist=this.getHibernateTemplate().find(hql,params);
if(!scorelist.isEmpty()){
Score s=scorelist.get(0);
return s;
}
return null;
}
public void examenddeleteAllscoreinfor() throws SQLException {
String hql="from Score";
List<Score> list1=this.getHibernateTemplate().find(hql);
String hql1="from ManyScore";
List<ManyScore> list2=this.getHibernateTemplate().find(hql1);
String hql2="from FinalScore";
List<FinalScore> list3=this.getHibernateTemplate().find(hql2);
String hql3="from FinalScoreCount";
List<FinalScoreCount> list4=this.getHibernateTemplate().find(hql3);
String hql4="from Student";
List<FinalScoreCount> list5=this.getHibernateTemplate().find(hql4);
this.getHibernateTemplate().deleteAll(list1);
this.getHibernateTemplate().deleteAll(list2);
this.getHibernateTemplate().deleteAll(list3);
this.getHibernateTemplate().deleteAll(list4);
this.getHibernateTemplate().deleteAll(list5);
}
public void examenddeleteAllscoreinforExceptStudentInfo()
throws SQLException {
String hql="from Score";
List<Score> list1=this.getHibernateTemplate().find(hql);
String hql1="from ManyScore";
List<ManyScore> list2=this.getHibernateTemplate().find(hql1);
String hql2="from F
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
JAVAWEB在线考试系统项目毕业设计 (314个子文件)
ScoreDaoImpl.class 9KB
LoadQuestionDaoImpl.class 6KB
GetFinalScoreAction.class 4KB
FileManager.class 4KB
UploadManyQuestionAction.class 4KB
CountScoreAction.class 4KB
ScoreServiceImpl.class 4KB
CheckLoginAction.class 4KB
UploadQuestionsAction.class 3KB
ImageUtil.class 3KB
ListManyChooseQuestionAciton.class 3KB
ExcelFileGenerator.class 3KB
Student.class 3KB
SaveTeacherDaoImpl.class 3KB
CountManyScoreAction.class 3KB
ListQuestionAciton.class 3KB
StudentDaoImpl.class 3KB
CheckLoginServiceImpl.class 3KB
AdaminDaoImpl.class 2KB
StudentServiceImpl.class 2KB
SetExamPaperAction.class 2KB
TeacherDaoImpl.class 2KB
DeletePaperAction.class 2KB
GetQuestionServiceImpl.class 2KB
Question.class 2KB
LoadTeacherAction.class 2KB
ControlAction.class 2KB
FinalScoreCount.class 2KB
DBUtil.class 2KB
ImageAction.class 2KB
SaveTeacherServiceImpl.class 2KB
ModifyTeacherAction.class 2KB
Paper.class 2KB
MakeExcelAction.class 2KB
BaseAction.class 2KB
ScoreDao.class 2KB
DeleteTeacherAction.class 1KB
Teacher.class 1KB
CheckCodeAction.class 1KB
StudentInterceptor.class 1KB
TeacherInterceptor.class 1KB
CheckTeacherAction.class 1KB
AdminInterceptor.class 1KB
SaveTeacherAction.class 1KB
LoadStudentAction.class 1KB
CheckAllPaperAction.class 1KB
FinalScore.class 1KB
CheckStudentAction.class 1KB
SaveTeacherDaoImpl$2.class 1KB
CheckScoreAction.class 1KB
TeacherDaoImpl$1.class 1KB
DeleteStudentAction.class 1KB
AddPaperAction.class 1KB
DeleteAllPaperInfoAction.class 1KB
Score.class 1KB
ModifyStudentAction.class 1KB
ScoreService.class 1KB
SaveNewStudentAction.class 1KB
Admin.class 1KB
test1.class 1KB
LoginOutAction.class 1KB
SaveTeacherDaoImpl$1.class 1KB
SaveTeacherDaoImpl$3.class 1KB
AdminSetTimeAction.class 1KB
StudentDaoImpl$1.class 1KB
ManyScore.class 1KB
DeleteAllInfoExceptStudentInfoAction.class 992B
SetQuestionScoreAction.class 988B
TeacherControlAction.class 982B
DeleteAllInfoAction.class 924B
AdminControlAction.class 906B
FileTypeNotAllowException.class 832B
FileOversizedException.class 823B
LoadUplodePath.class 760B
Option.class 735B
GetQuestionService.class 729B
LoadQuestionDao.class 707B
test2.class 665B
StudentService.class 576B
StudentDao.class 556B
SaveTeacherService.class 529B
SaveTeacherDao.class 505B
RegisterTeacherAction.class 432B
Contant.class 407B
TeacherDao.class 367B
CheckLoginService.class 343B
AdaminDao.class 324B
.classpath 3KB
org.eclipse.wst.jsdt.ui.superType.container 49B
style.css 2KB
Thumbs.db 90KB
jacob.dll 104KB
seedPwd.gif 3KB
step3.gif 1KB
step2.gif 1KB
step1.gif 1KB
add.gif 587B
f_ico.gif 173B
m_ico.gif 65B
m_ico1.gif 59B
共 314 条
- 1
- 2
- 3
- 4
资源评论
- weixin_357744802019-09-05坑人的别下载。里面不含有 项目需求,就一个垃圾SSH项目这东西谁要啊!
技术很渣
- 粉丝: 1w+
- 资源: 36
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功