⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sendunitmanager.java

📁 OA典型例子
💻 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 sendUnitManager {

  public sendUnitManager() {
  }

  /**
   * 根据docnoId获得主送单位详情
   */
  public sendUnit getSendUnit(int pId) throws SQLException,DBPoolException, NotFoundException {
      Connection cn = DBManager.getConnection();
      try {
          String where = "Where pId = " + pId;
          Vector beans = sendUnitPersistent.load(cn, where);
          sendUnit bean = (sendUnit)beans.firstElement();
          return bean;
      }catch (SQLException sqle) {
          throw new NotFoundException();
      } finally {
          cn.close();
      }
  }



  public Page getSendUnitList(int start,int unitId) throws SQLException,DBPoolException {
      Connection cn = DBManager.getConnection();
      try{
          String where = "where  unitId=" + unitId + "  order by sendUnitName";
          Page p = sendUnitPersistent.load(cn, start, 10, where);
          return p;
      }finally {
          cn.close();
      }
  }


  /**
   * 显示某个单位的所有主送单位(不是分页形式)
   */
  public static  Vector getSendUnitList(int unitId) throws SQLException,
          DBPoolException {
      Connection cn = DBManager.getConnection();
      try{
          String where = "where  unitId=" + unitId + "";
          Vector v = sendUnitPersistent.load(cn, where);
          return v;
      }finally {
          cn.close();
      }
  }

  /**
   * 保存主送单位信息
   */
  public int saveSendUnit(sendUnit p) throws SQLException,DBPoolException, UpdateException, NotFoundException {
      Connection cn = DBManager.getConnection();
      String sendUnitName = StringUtils.getSQLencode(p.getSendUnitName());
      String where = "Where  sendUnitName = '" + sendUnitName + "'  and unitId=" +
                     p.getUnitId() + " and pId<>" + p.getPId() ;
      int intResult = sendUnitPersistent.getCount(cn, where);
      if (intResult > 0){
          throw new UpdateException("本单位中已经存在" + sendUnitName + "这个主送单位!");
      }
      int pId = p.getPId().intValue();
      int retval = 0;
      try{
          sendUnitPersistent pb = new sendUnitPersistent(p);
          if (pId == 0){
            retval = 2;
          }else{
            pb.setRecordExists(true);
            retval = 3;
          }
          pb.persist(cn);
      }finally {
          cn.close();
      }
    return retval;
  }
  /**
   * 删除主送单位
   */
  public void  delSendUnit(int pId) throws SQLException, DBPoolException, NotFoundException {
	Connection cn = DBManager.getConnection();
	try {
	   String where = "Where pId = " + pId;
           sendUnitPersistent.delete(cn, where);
	}catch (SQLException sqle) {
	    throw new  NotFoundException();
	} finally {
	    cn.close();
	}
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -