利用Structs实现企业资源计划(ERP)中涉及到的人事管理系统。

源代码在线查看: typeofwo.jav

软件大小: 15156 K
上传用户: hlwang523
关键词: Structs ERP 资源 管理系统
下载地址: 免注册下载 普通下载 VIP

相关代码

				//---------------------------------------------------------
				// Application: Personal of System
				// Author     : eSingle
				// File       : TypeofworkDAO.java
				//
				// Copyright 2002 LandSoft Corp.
				// Generated at Mon Nov 18 10:18:19 CST 2002
				// Created by caoguangxin
				// mailto:gxcao@mail.tsinghua.edu.cn
				//---------------------------------------------------------
				
				package com.landsoft.personal.dao;
				
				import java.io.*;
				import java.sql.*;
				import java.util.*;
				import javax.sql.*;
				
				import com.landsoft.personal.model.*;
				import com.landsoft.personal.util.CacheManager;
				
				public class TypeofworkDAO extends DAO {
				
				  public TypeofworkDAO(DataSource ds) {
				    super(ds);
				  }
				
				  public void insert(Typeofwork typeofwork) throws SQLException {
				    String sql;
				    sql = "INSERT INTO typeofwork (typeofworkname) VALUES (?)";
				    Connection conn = null;
				    PreparedStatement pstmt = null;
				    ResultSet rs = null;
				    try {
				      conn = ds.getConnection();
				      pstmt = conn.prepareStatement(sql);
				      pstmt.setString(1, typeofwork.getTypeofworkname());
				      pstmt.executeUpdate();
				      pstmt.close();
				      conn.commit();
				    } catch (SQLException sqle) {
				      close(rs);
				      close(pstmt);
				      rollback(conn);
				      sqle.printStackTrace();
				      throw sqle;
				    } finally {
				    	close(conn);
				    }
				  }
				
				  public void update(Typeofwork typeofwork) throws SQLException {
				  	Connection conn = null;
				  	PreparedStatement pstmt = null;
				    try {
				      conn = ds.getConnection();
				      String sql = "UPDATE typeofwork SET  WHERE typeofworkname=?";
				      pstmt = conn.prepareStatement(sql);
				      pstmt.setString(1, typeofwork.getTypeofworkname());
				      pstmt.executeUpdate();
				      close(pstmt);
				      conn.commit();
				    } catch (SQLException e) {
				      close(pstmt);
				      rollback(conn);
				      e.printStackTrace();
				    } finally {
				    	close(conn);
				    }
				  }
				
				  public void delete(String typeofworkname) throws SQLException {
				  	Connection conn = null;
				  	PreparedStatement pstmt = null;
				    try {
				      conn = ds.getConnection();
				      String sql = "DELETE FROM typeofwork WHERE typeofworkname=?";
				      pstmt = conn.prepareStatement(sql);
				      pstmt.setString(1, typeofworkname);
				      pstmt.executeUpdate();
				      close(pstmt);
				      conn.commit();
				    } catch (SQLException e) {
				      close(pstmt);
				      rollback(conn);
				      e.printStackTrace();
				    } finally {
				    	close(conn);
				    }
				    String[] objKeys = {"Typeofwork", String.valueOf(typeofworkname)};
				    String objKey = CacheManager.createKey(objKeys);
				    DAOCacheManager.invalidate(objKey);
				  }
				
				  public Typeofwork retrieve(String typeofworkname) throws SQLException {
				    String[] objKeys = {"Typeofwork", String.valueOf(typeofworkname)};
				    String objKey = CacheManager.createKey(objKeys);
				    Typeofwork typeofwork = (Typeofwork) DAOCacheManager.getCache(objKey);
				    if (typeofwork != null)
				      return typeofwork;
				    Connection conn = null;
				    PreparedStatement pstmt = null;
				    ResultSet rs = null;
				    try {
				      conn = ds.getConnection();
				      String sql = "SELECT * FROM typeofwork WHERE typeofworkname=?";
				      pstmt = conn.prepareStatement(sql);
				      pstmt.setString(1, typeofworkname);
				      rs = pstmt.executeQuery();
				      if (rs.next()) {
				        typeofwork = new Typeofwork();
				        populate(typeofwork, rs);
				      }
				      close(rs);
				      close(pstmt);
				    } catch (SQLException e) {
				      close(rs);
				      close(pstmt);
				      rollback(conn);
				      e.printStackTrace();
				    } finally {
				    	close(conn);
				    }
				    DAOCacheManager.putCache(typeofwork, objKey, 1);
				    return typeofwork;
				  }
				
				  public List list() throws SQLException {
				    String[] objKeys = {"Typeofwork", "list"};
				    String objKey = CacheManager.createKey(objKeys);
				    ArrayList list = (ArrayList) DAOCacheManager.getCache(objKey);
				    if (list != null)
				      return list;
				    list = new ArrayList();
				    Connection conn = null;
				    PreparedStatement pstmt = null;
				    ResultSet rs = null;
				    try {
				      conn = ds.getConnection();
				      String sql = "SELECT typeofworkname FROM typeofwork";
				      pstmt = conn.prepareStatement(sql);
				      rs = pstmt.executeQuery();
				      while(rs.next()) {
				        Typeofwork typeofwork = new Typeofwork();
				        populate(typeofwork, rs);
				        list.add(typeofwork);
				      }
				      close(rs);
				      close(pstmt);
				    } catch (SQLException e) {
				      close(rs);
				      close(pstmt);
				      rollback(conn);
				      e.printStackTrace();
				    } finally {
				    	close(conn);
				    }
				    DAOCacheManager.putCache(list, objKey, 1);
				    return list;
				  }
				
				  public List list(int offset, int limit) throws SQLException {
				    String[] objKeys = {"Typeofwork", "list", String.valueOf(offset), String.valueOf(limit)};
				    String objKey = CacheManager.createKey(objKeys);
				    ArrayList list = (ArrayList) DAOCacheManager.getCache(objKey);
				    if (list != null)
				      return list;
				    list = new ArrayList();
				    Connection conn = null;
				    PreparedStatement pstmt = null;
				    ResultSet rs = null;
				    try {
				      conn = ds.getConnection();
				      String sql = "SELECT typeofworkname FROM typeofwork";
				      pstmt = conn.prepareStatement(sql);
				      rs = pstmt.executeQuery();
				      if(offset > 0) rs.absolute(offset);
				      int recCount = 0;
				      while((recCount++ < limit) && rs.next()) {
				        Typeofwork typeofwork = new Typeofwork();
				        populate(typeofwork, rs);
				        list.add(typeofwork);
				      }
				      close(rs);
				      close(pstmt);
				    } catch (SQLException e) {
				      close(rs);
				      close(pstmt);
				      rollback(conn);
				      e.printStackTrace();
				    } finally {
				    	close(conn);
				    }
				    DAOCacheManager.putCache(list, objKey, 1);
				    return list;
				  }
				
				}			

相关资源