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

📄 systemconfigmanager.java

📁 OA典型例子
💻 JAVA
字号:
package com.sure.oa.config;

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;
import java.util.NoSuchElementException;
import java.io.*;
/**
 * <p>Title: OA</p>
 * <p>Description: 国办项目</p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: sure</p>
 * @author mengzy
 * @version 1.0
 */

public class systemConfigManager {

  public systemConfigManager() {
  }
  /**
     * 根据Id获得配置详情
     * @param Id
     */
  public static  systemConfig getConfig(int unitId) throws SQLException,DBPoolException, NotFoundException {
        Connection cn = DBManager.getConnection();
        try {
            String where = "Where unitId = " + unitId;
            Vector beans = systemConfigPersistent.load(cn, where);
            systemConfig bean = (systemConfig)beans.firstElement();
            return bean;
        }catch (SQLException sqle) {
            throw new  NotFoundException();
        } finally {
            cn.close();
        }
    }

    /**
     * 根据Id获得配置详情
     * @param Id
     */
    public  static  systemConfig getConfig(String unitId) throws SQLException,DBPoolException, NotFoundException{
      return getConfig(Integer.parseInt(unitId));
    }

    /**
     * 根据单位Id获得单位是否已经做过系统配置
     * @param Id
     */
    public static boolean  getHaveConfig(int unitId) throws SQLException,DBPoolException, NotFoundException {
        Connection cn = DBManager.getConnection();
        try {
            String where = "Where unitId = " + unitId;
            Vector beans = systemConfigPersistent.load(cn, where);
           return  beans.size()>0;
        }catch (SQLException sqle) {
            sqle.printStackTrace();
           throw new  NotFoundException();
        } finally {
            cn.close();
        }
    }

    /**
     * 保存单位配置信息
     */
    public int saveConfig(systemConfig d) throws SQLException, DBPoolException, UpdateException, NotFoundException {
       Connection cn = DBManager.getConnection();
       String sendbackup=d.getSendbackup();
       sendbackup=StringUtils.replaceAll(sendbackup,"\\\\","$");
       String recvbackup=d.getRecvbackup();
       recvbackup=StringUtils.replaceAll(recvbackup,"\\\\","$");
       d.setSendbackup(sendbackup);
       d.setRecvbackup(recvbackup);
       int Id = d.getConfigId().intValue();
       int retval = 0;
       try{
            systemConfigPersistent config = new systemConfigPersistent(d);
            if (Id == 0){
              retval = 2;
            }else{
              config.setRecordExists(true);
              retval = 3;
            }
            config.persist(cn);
       }
       finally {
            cn.close();
       }
       return retval;
    }

 }

⌨️ 快捷键说明

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