📄 updateservice.java
字号:
/**
*
*/
package edu.yinhe.mis.services;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;
import edu.yinhe.mis.dto.GradeDTO;
import edu.yinhe.mis.dto.ModScoreDTO;
import edu.yinhe.mis.dto.SummarizeGradeDTO;
import edu.yinhe.mis.model.DAOFactory;
import edu.yinhe.mis.vo.GradeVO;
import edu.yinhe.system.common.AppException;
import edu.yinhe.system.model.IBaseDAO;
import edu.yinhe.system.services.Service;
/**
* @author 何亮
*
*/
public class UpdateService extends Service{
private IBaseDAO GradeManagerDAO=null;
public Object alllist() throws AppException {
ArrayList alist1=new ArrayList();
GradeManagerDAO=DAOFactory.getGradeMangerDAO(conn);
try {
alist1=(ArrayList) GradeManagerDAO.find();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
this.closeConnection();
}
return alist1;
}
public Object alllist(Object arg0) throws AppException {
// TODO Auto-generated method stub
return null;
}
public Object create(Object arg0) throws AppException {
ModScoreDTO msdto=new ModScoreDTO();
msdto=(ModScoreDTO) arg0;
Integer index=0;
GradeManagerDAO=DAOFactory.getGradeMangerDAO(conn);
try {
index=(Integer) GradeManagerDAO.insert(msdto);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return index;
}
public Object findAll() throws AppException {
// TODO Auto-generated method stub
return null;
}
/**
* @param
* @return
*/
public Object findAll(Object arg0) throws AppException {
GradeDTO gdto = (GradeDTO) arg0;
GradeManagerDAO = DAOFactory.getGradeMangerDAO(conn);
GradeVO gvo=null;
ArrayList list=new ArrayList();
Integer count=0;
Object[] objt=new Object[2];
try {
ArrayList alist2=new ArrayList();
ArrayList alist1=new ArrayList();
ArrayList alist=new ArrayList();
alist1=(ArrayList) GradeManagerDAO.findById(gdto);//得到考生考号
Iterator it1=alist1.iterator();
while(it1.hasNext()){
gvo=(GradeVO) it1.next();
gdto.setExam_no(gvo.getExamno());
alist2=(ArrayList) GradeManagerDAO.findByObject(gdto);//通过考号,得到科目
Iterator it2=alist2.iterator();
while(it2.hasNext()){
gvo=(GradeVO) it2.next();
gdto.setObject_name(gvo.getObjectname());
if(gvo.getObjectname()==null){
System.out.println("考号为:"+gdto.getExam_no()+"的考生没有成绩记录");
}else{
alist=(ArrayList) GradeManagerDAO.findAll(gdto);
objt[0]=alist;
objt[1]=count;
}
}
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return objt;
}
public Object findById(Object arg0) throws AppException {
GradeDTO gdto=new GradeDTO();
gdto=(GradeDTO) arg0;
GradeVO gvo=new GradeVO();
GradeManagerDAO=DAOFactory.getGradeMangerDAO(conn);
ArrayList alist=new ArrayList();
try {
alist= (ArrayList) GradeManagerDAO.delete(gdto);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
this.closeConnection();
}
return alist;
}
public Object findByObject(Object arg0) throws AppException {
GradeDTO gdto=new GradeDTO();
gdto=(GradeDTO) arg0;
ArrayList alist=null;
GradeManagerDAO=DAOFactory.getGradeMangerDAO(conn);
try {
alist=new ArrayList();
alist = (ArrayList) GradeManagerDAO.find(gdto);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
this.closeConnection();
}
return alist;
}
public int getcount() throws AppException {
// TODO Auto-generated method stub
return 0;
}
public int getcount(Object arg0) throws AppException {
// TODO Auto-generated method stub
return 0;
}
public Object list() throws AppException {
// TODO Auto-generated method stub
return null;
}
public Object list(Object arg0) throws AppException {
// TODO Auto-generated method stub
return null;
}
public Object load(Object arg0) throws AppException {
SummarizeGradeDTO sdto=new SummarizeGradeDTO();
sdto=(SummarizeGradeDTO) arg0;
Integer flag=0;
GradeManagerDAO =DAOFactory.getGradeMangerDAO(conn);
try {
flag=(Integer) GradeManagerDAO.getMaxId(sdto);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
this.closeConnection();
}
return flag;
}
public Object modify(Object arg0) throws AppException {
GradeDTO gdto=new GradeDTO();
GradeManagerDAO=DAOFactory.getGradeMangerDAO(conn);
Integer flag=0;
gdto=(GradeDTO) arg0;
try {
flag = (Integer) GradeManagerDAO.update(gdto);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
this.closeConnection();
}
return flag;
}
public Object remove(Object arg0) throws AppException {
// TODO Auto-generated method stub
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -