📄 subjectmanager.java
字号:
package com.sure.oa.dict;
import com.sure.businessmodel.Page;
import com.sure.businessmodel.UpdateException;
import com.sure.businesslogic.AlreadyExistsException;
import com.sure.businesslogic.NotFoundException;
import com.sure.dataabstraction.DBManager;
import com.sure.dataabstraction.DBPoolException;
import com.sure.util.StringUtils;
import java.sql.SQLException;
import java.sql.Connection;
import java.util.Vector;
/**
* <p>Title: OA</p>
* <p>Description: 国办项目</p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: sure</p>
* @author mengzy
* @version 1.0
*/
public class subjectManager {
public subjectManager() {
}
/**
* 根据unitId获得主题信息详情
*/
public Subject getSubject(int unitId) throws SQLException,DBPoolException, NotFoundException {
Connection cn = DBManager.getConnection();
try {
String where = "Where subId = " + unitId;
Vector beans = SubjectPersistent.load(cn, where);
Subject bean = (Subject)beans.firstElement();
return bean;
}catch (SQLException sqle) {
throw new NotFoundException();
} finally {
cn.close();
}
}
public Page getSubjectList(int start,int unitId) throws SQLException,DBPoolException {
Connection cn = DBManager.getConnection();
try{
String where = "where unitId=" + unitId + " order by subId";
Page p = SubjectPersistent.load(cn, start, 10, where);
return p;
}finally {
cn.close();
}
}
/**
* 显示某个单位的所有主题信息(不是分页形式)
*/
public static Vector getSubjectList(int unitId) throws SQLException,
DBPoolException {
Connection cn = DBManager.getConnection();
try{
String where = "where unitId=" + unitId + "";
Vector v = SubjectPersistent.load(cn, where);
return v;
}finally {
cn.close();
}
}
/**
* 保存主题信息
*/
public int saveSubject(Subject p) throws SQLException,DBPoolException, UpdateException, NotFoundException {
Connection cn = DBManager.getConnection();
String subject = StringUtils.getSQLencode(p.getSubject());
String where = "Where Subject = '" + subject + "' and unitId=" +
p.getUnitId() + " and subId<>" + p.getSubId();
int intResult = SubjectPersistent.getCount(cn, where);
if (intResult > 0){
throw new UpdateException("本单位中已经存在" + subject + "这个主题信息!");
}
int pId = p.getSubId().intValue();
int retval = 0;
try{
SubjectPersistent pb = new SubjectPersistent(p);
if (pId == 0){
retval = 2;
}else{
pb.setRecordExists(true);
retval = 3;
}
pb.persist(cn);
}finally {
cn.close();
}
return retval;
}
/**
* 删除主题信息
*/
public void delSubject(int subId) throws SQLException, DBPoolException, NotFoundException {
Connection cn = DBManager.getConnection();
try {
String where = "Where subId = " + subId;
SubjectPersistent.delete(cn, where);
}catch (SQLException sqle) {
throw new NotFoundException();
} finally {
cn.close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -