/*
 * MosP - Mind Open Source Project         http://www.mosp.jp/
 * Copyright (C) 1987-2009 MIND Co., Ltd.  http://www.e-mind.co.jp/
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
package jp.mosp.payroll.bonus.dao;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import jp.mosp.payroll.base.PayrollDao;
import jp.mosp.payroll.bonus.BonusConst;
import jp.mosp.payroll.bonus.dto.PdBonusDto;
import jp.mosp.common.common.MospException;
import jp.mosp.payroll.bonus.dao.PmStationDao;

public class PdBonusDao extends PayrollDao {
	
	// テーブル名及びキー列名
	public static final String TABLE = "UD_BONUS";
	public static final String KEY_1 = "K_CODE"   ;	// 社員コード
	public static final String KEY_2 = "CALC_DATE";	// 計算年月
	public static final String KEY_3 = "PAYDAY";	    // 賞与支給日
	
	// 列名
	public static final String COL_K_CODE               = "K_CODE"            ;	// 社員コード
	public static final String COL_CALC_DATE            = "CALC_DATE"         ;	// 計算年月
	public static final String COL_PAYDAY               = "PAYDAY"            ;	// 賞与支給日
	public static final String COL_CALC_STATUS          = "CALC_STATUS"       ;	// 計算ステータス
	public static final String COL_K_NAME               = "K_NAME"            ;	// 社員氏名
	public static final String COL_STATION_CODE         = "STATION_CODE"      ;	// 所属コード
	public static final String COL_POSITION_CODE        = "POSITION_CODE"     ;	// 職位コード
	public static final String COL_EMPLOYMENT_TYPE      = "EMPLOYMENT_TYPE"   ;	// 雇用区分
	public static final String COL_BONUS_ALLOWANCE_01   = "BONUS_ALLOWANCE_01";	// 賞与支給項目01
	public static final String COL_BONUS_ALLOWANCE_02   = "BONUS_ALLOWANCE_02";	// 賞与支給項目02
	public static final String COL_BONUS_ALLOWANCE_03   = "BONUS_ALLOWANCE_03"; 	// 賞与支給項目03
	public static final String COL_BONUS_ALLOWANCE_04   = "BONUS_ALLOWANCE_04"; 	// 賞与支給項目04
	public static final String COL_BONUS_ALLOWANCE_05   = "BONUS_ALLOWANCE_05"; 	// 賞与支給項目05
	public static final String COL_BONUS_ALLOWANCE_06   = "BONUS_ALLOWANCE_06"; 	// 賞与支給項目06
	public static final String COL_BONUS_ALLOWANCE_07   = "BONUS_ALLOWANCE_07"; 	// 賞与支給項目07
	public static final String COL_BONUS_ALLOWANCE_08   = "BONUS_ALLOWANCE_08"; 	// 賞与支給項目08
	public static final String COL_BONUS_ALLOWANCE_09   = "BONUS_ALLOWANCE_09"; 	// 賞与支給項目09
	public static final String COL_BONUS_ALLOWANCE_10   = "BONUS_ALLOWANCE_10"; 	// 賞与支給項目10
	public static final String COL_BONUS_ALLOWANCE_11   = "BONUS_ALLOWANCE_11"; 	// 賞与支給項目11
	public static final String COL_BONUS_ALLOWANCE_12   = "BONUS_ALLOWANCE_12"; 	// 賞与支給項目12
	public static final String COL_BONUS_ALLOWANCE_13   = "BONUS_ALLOWANCE_13"; 	// 賞与支給項目13
	public static final String COL_BONUS_ALLOWANCE_14   = "BONUS_ALLOWANCE_14"; 	// 賞与支給項目14
	public static final String COL_BONUS_ALLOWANCE_15   = "BONUS_ALLOWANCE_15"; 	// 賞与支給項目15
	public static final String COL_BONUS_ALLOWANCE_16   = "BONUS_ALLOWANCE_16"; 	// 賞与支給項目16
	public static final String COL_BONUS_ALLOWANCE_17   = "BONUS_ALLOWANCE_17"; 	// 賞与支給項目17
	public static final String COL_BONUS_ALLOWANCE_18   = "BONUS_ALLOWANCE_18"; 	// 賞与支給項目18
	public static final String COL_BONUS_ALLOWANCE_19   = "BONUS_ALLOWANCE_19"; 	// 賞与支給項目19
	public static final String COL_BONUS_ALLOWANCE_20   = "BONUS_ALLOWANCE_20"; 	// 賞与支給項目20
	public static final String COL_HEALTH_INSURANCE     = "HEALTH_INSURANCE"  ;	// 健康保険料
	public static final String COL_PENSION_INSURANCE    = "PENSION_INSURANCE" ;	// 厚生年金保険
	public static final String COL_EMPLOYEE_INSURANCE   = "EMPLOYEE_INSURANCE";	// 雇用保険料
	public static final String COL_INCOME_TAX           = "INCOME_TAX"        ;	// 所得税
	public static final String COL_NURSING_INSURANCE    = "NURSING_INSURANCE" ;	// 介護保険料
	public static final String COL_BONUS_DEDUCTION_06   = "BONUS_DEDUCTION_06"; 	// 賞与控除項目06
	public static final String COL_BONUS_DEDUCTION_07   = "BONUS_DEDUCTION_07"; 	// 賞与控除項目07
	public static final String COL_BONUS_DEDUCTION_08   = "BONUS_DEDUCTION_08"; 	// 賞与控除項目08
	public static final String COL_BONUS_DEDUCTION_09   = "BONUS_DEDUCTION_09"; 	// 賞与控除項目09
	public static final String COL_BONUS_DEDUCTION_10   = "BONUS_DEDUCTION_10"; 	// 賞与控除項目10
	public static final String COL_BONUS_DEDUCTION_11   = "BONUS_DEDUCTION_11"; 	// 賞与控除項目11
	public static final String COL_BONUS_DEDUCTION_12   = "BONUS_DEDUCTION_12"; 	// 賞与控除項目12
	public static final String COL_BONUS_DEDUCTION_13   = "BONUS_DEDUCTION_13"; 	// 賞与控除項目13
	public static final String COL_BONUS_DEDUCTION_14   = "BONUS_DEDUCTION_14"; 	// 賞与控除項目14
	public static final String COL_BONUS_DEDUCTION_15   = "BONUS_DEDUCTION_15"; 	// 賞与控除項目15
	public static final String COL_BONUS_DEDUCTION_16   = "BONUS_DEDUCTION_16"; 	// 賞与控除項目16
	public static final String COL_BONUS_DEDUCTION_17   = "BONUS_DEDUCTION_17"; 	// 賞与控除項目17
	public static final String COL_BONUS_DEDUCTION_18   = "BONUS_DEDUCTION_18"; 	// 賞与控除項目18
	public static final String COL_BONUS_DEDUCTION_19   = "BONUS_DEDUCTION_19"; 	// 賞与控除項目19
	public static final String COL_BONUS_DEDUCTION_20   = "BONUS_DEDUCTION_20"; 	// 賞与控除項目10
	public static final String COL_ALLOWANCE_TOTAL      = "ALLOWANCE_TOTAL"   ;	// 総支給金額
	public static final String COL_DEDUCTION_TOTAL      = "DEDUCTION_TOTAL"   ;	// 総控除金額
	public static final String COL_PAYMENT_TOTAL        = "PAYMENT_TOTAL"     ;	// 差引支給額
	public static final String COL_BANK1_PAY_AMOUNT     = "BANK1_PAY_AMOUNT"  ;	// 銀行1振込額
	public static final String COL_BANK2_PAY_AMOUNT     = "BANK2_PAY_AMOUNT"  ;	// 銀行2振込額
	public static final String COL_CASH_PAY_AMOUNT      = "CASH_PAY_AMOUNT"   ;	// 現金支給額
	public static final String COL_DEPENDENT_COUNT      = "DEPENDENT_COUNT"   ;	// 扶養等の数
	public static final String COL_LAST_MONTH_TAXATION  = "LAST_MONTH_TAXATION";	// 前月の給与課税対象額
	public static final String COL_TOTAL_YEAR_BONUS     = "TOTAL_YEAR_BONUS"   ;	// 年度累計賞与額
	public static final String COL_INCOME_RATE          = "INCOME_RATE"        ;	// 所得税率
	public static final String COL_EMP_INS_BASIC          = "EMP_INS_BASIC"        ;	// 雇保対象基準額

	
	/**
	 * コンストラクタ
	 */
	public PdBonusDao() {
		super();
	}
	
	/**
	 * 検索結果取得(DTOのList)
	 * @return List 検索リスト
	 * @throws SQLException
	 */
	private List<PdBonusDto> mappingAll() throws SQLException {
		List<PdBonusDto> all = new ArrayList<PdBonusDto>();
		while (rs.next()) {
			all.add(mapping());
		}
		return all;
	}
	
	/**
	 * 検索結果取得(DTO)
	 * @return PdBonusDto UD_PAYMENTレコード
	 * @throws SQLException
	 */
	private PdBonusDto mapping() throws SQLException {
		PdBonusDto dto = new PdBonusDto();
		dto.setKCode            (rs.getString(COL_K_CODE              ));	// 社員コード
		dto.setCalcDate         (rs.getDate  (COL_CALC_DATE           ));	// 計算年月
		dto.setPayday           (rs.getDate  (COL_PAYDAY              ));	// 賞与支給日
		dto.setCalcStatus       (rs.getString(COL_CALC_STATUS         ));	// 計算ステータス
		dto.setKName            (rs.getString(COL_K_NAME              ));	// 社員氏名
		dto.setStationCode      (rs.getString(COL_STATION_CODE        ));	// 所属コード
		dto.setPositionCode     (rs.getString(COL_POSITION_CODE       ));	// 職位コード
		dto.setEmploymentType   (rs.getString(COL_EMPLOYMENT_TYPE     ));	// 雇用区分
		dto.setBonusAllowance01 (rs.getInt(COL_BONUS_ALLOWANCE_01     ));	// 賞与支給項目01
		dto.setBonusAllowance02 (rs.getInt(COL_BONUS_ALLOWANCE_02     ));	// 賞与支給項目02
		dto.setBonusAllowance03 (rs.getInt(COL_BONUS_ALLOWANCE_03     ));	// 賞与支給項目03
		dto.setBonusAllowance04 (rs.getInt(COL_BONUS_ALLOWANCE_04     ));	// 賞与支給項目04
		dto.setBonusAllowance05 (rs.getInt(COL_BONUS_ALLOWANCE_05     ));	// 賞与支給項目05
		dto.setBonusAllowance06 (rs.getInt(COL_BONUS_ALLOWANCE_06     ));	// 賞与支給項目06
		dto.setBonusAllowance07 (rs.getInt(COL_BONUS_ALLOWANCE_07     ));	// 賞与支給項目07
		dto.setBonusAllowance08 (rs.getInt(COL_BONUS_ALLOWANCE_08     ));	// 賞与支給項目08
		dto.setBonusAllowance09 (rs.getInt(COL_BONUS_ALLOWANCE_09     ));	// 賞与支給項目09
		dto.setBonusAllowance10 (rs.getInt(COL_BONUS_ALLOWANCE_10     ));	// 賞与支給項目10
		dto.setBonusAllowance11 (rs.getInt(COL_BONUS_ALLOWANCE_11     ));	// 賞与支給項目11
		dto.setBonusAllowance12 (rs.getInt(COL_BONUS_ALLOWANCE_12     ));	// 賞与支給項目12
		dto.setBonusAllowance13 (rs.getInt(COL_BONUS_ALLOWANCE_13     ));	// 賞与支給項目13
		dto.setBonusAllowance14 (rs.getInt(COL_BONUS_ALLOWANCE_14     ));	// 賞与支給項目14
		dto.setBonusAllowance15 (rs.getInt(COL_BONUS_ALLOWANCE_15     ));	// 賞与支給項目15
		dto.setBonusAllowance16 (rs.getInt(COL_BONUS_ALLOWANCE_16     ));	// 賞与支給項目16
		dto.setBonusAllowance17 (rs.getInt(COL_BONUS_ALLOWANCE_17     ));	// 賞与支給項目17
		dto.setBonusAllowance18 (rs.getInt(COL_BONUS_ALLOWANCE_18     ));	// 賞与支給項目18
		dto.setBonusAllowance19 (rs.getInt(COL_BONUS_ALLOWANCE_19     ));	// 賞与支給項目19
		dto.setBonusAllowance20 (rs.getInt(COL_BONUS_ALLOWANCE_20     ));	// 賞与支給項目20
		dto.setHealthInsurance  (rs.getInt(COL_HEALTH_INSURANCE       ));	// 健康保険料
		dto.setPensionInsurance (rs.getInt(COL_PENSION_INSURANCE      ));	// 厚生年金保険
		dto.setEmployeeInsurance(rs.getInt(COL_EMPLOYEE_INSURANCE     ));	// 雇用保険料
		dto.setIncomeTax        (rs.getInt(COL_INCOME_TAX             ));	// 所得税
		dto.setNursingInsurance (rs.getInt(COL_NURSING_INSURANCE      ));	// 介護保険料
		dto.setBonusDeduction06 (rs.getInt(COL_BONUS_DEDUCTION_06     ));	// 賞与控除項目06
		dto.setBonusDeduction07 (rs.getInt(COL_BONUS_DEDUCTION_07     ));	// 賞与控除項目07
		dto.setBonusDeduction08 (rs.getInt(COL_BONUS_DEDUCTION_08     ));	// 賞与控除項目08
		dto.setBonusDeduction09 (rs.getInt(COL_BONUS_DEDUCTION_09     ));	// 賞与控除項目09
		dto.setBonusDeduction10 (rs.getInt(COL_BONUS_DEDUCTION_10     ));	// 賞与控除項目10
		dto.setBonusDeduction11 (rs.getInt(COL_BONUS_DEDUCTION_11     ));	// 賞与控除項目11
		dto.setBonusDeduction12 (rs.getInt(COL_BONUS_DEDUCTION_12     ));	// 賞与控除項目12
		dto.setBonusDeduction13 (rs.getInt(COL_BONUS_DEDUCTION_13     ));	// 賞与控除項目13
		dto.setBonusDeduction14 (rs.getInt(COL_BONUS_DEDUCTION_14     ));	// 賞与控除項目14
		dto.setBonusDeduction15 (rs.getInt(COL_BONUS_DEDUCTION_15     ));	// 賞与控除項目15
		dto.setBonusDeduction16 (rs.getInt(COL_BONUS_DEDUCTION_16     ));	// 賞与控除項目16
		dto.setBonusDeduction17 (rs.getInt(COL_BONUS_DEDUCTION_17     ));	// 賞与控除項目17
		dto.setBonusDeduction18 (rs.getInt(COL_BONUS_DEDUCTION_18     ));	// 賞与控除項目18
		dto.setBonusDeduction19 (rs.getInt(COL_BONUS_DEDUCTION_19     ));	// 賞与控除項目19
		dto.setBonusDeduction20 (rs.getInt(COL_BONUS_DEDUCTION_20     ));	// 賞与控除項目20
		dto.setAllowanceTotal   (rs.getInt(COL_ALLOWANCE_TOTAL        ));	// 総支給金額
		dto.setDeductionTotal   (rs.getInt(COL_DEDUCTION_TOTAL        ));	// 総控除金額
		dto.setPaymentTotal     (rs.getInt(COL_PAYMENT_TOTAL          ));	// 差引支給額
		dto.setBank1PayAmount   (rs.getInt(COL_BANK1_PAY_AMOUNT       ));	// 銀行1振込額
		dto.setBank2PayAmount   (rs.getInt(COL_BANK2_PAY_AMOUNT       ));	// 銀行2振込額
		dto.setCashPayAmount    (rs.getInt(COL_CASH_PAY_AMOUNT        ));	// 現金支給額
		dto.setDependentCount   (rs.getInt(COL_DEPENDENT_COUNT        ));	// 扶養等の数
		dto.setLastMonthTaxation(rs.getInt(COL_LAST_MONTH_TAXATION    ));	// 前月給与の課税対象額
		dto.setTotalYearBonus   (rs.getInt(COL_TOTAL_YEAR_BONUS       ));	// 年度累計賞与額
		dto.setIncomeRate       (rs.getFloat(COL_INCOME_RATE          ));	// 所得税率
		dto.setEmpInsBasic      (rs.getInt(COL_EMP_INS_BASIC          ));	// 雇保対象基準額
		mappingCommonInfo(dto);
		return dto;
	}

	/**
	 * 全データ取得
	 * @return List 検索結果(DTOのList)
	 * @throws SQLException
	 * @throws IllegalAccessException
	 * @throws NoSuchFieldException
	 */
	public List<PdBonusDto> findAll() throws SQLException, IllegalAccessException, NoSuchFieldException {
		try {
			prepareStatement(getSelectQuery(getClass()) + getOrderForKey(getClass()));
			executeQuery();
			List<PdBonusDto> all = mappingAll();
			return all;
		} catch (SQLException e) {
			throw e;
		} finally {
			releaseResultSet();
			releasePreparedStatement();
		}
	}
	
	/**
	 * キーによるデータ取得
	 * @param kCode 社員コード(検索キー)
	 * @param calcDate 計算年月(検索キー)
	 * @return PdBonusDto 検索結果(DTO)
	 * @throws SQLException
	 * @throws IllegalAccessException
	 * @throws NoSuchFieldException
	 */
	public PdBonusDto findForKey(
			String kCode,
			Date   calcDate,
			Date   payday
	) throws SQLException, IllegalAccessException, NoSuchFieldException {
		try {
			index = 1;
			prepareStatement(getSelectQuery(getClass()) + getConditionForKey(getClass()));
			setParam(index++, kCode);
			setParam(index++, calcDate);
			setParam(index++, payday);
			executeQuery();
			PdBonusDto dto = null;
			if (rs.next()) {
				dto = mapping();
			}
			return dto;
		} catch (SQLException e) {
			throw e;
		} finally {
			releaseResultSet();
			releasePreparedStatement();
		}
	}

	/**
	 * キーによる行ロック取得
	 * @param kCode 社員コード(検索キー)
	 * @param calcDate 計算年月(検索キー)
	 * @return PdBonusDto 検索結果(DTO)
	 * @throws SQLException
	 * @throws IllegalAccessException
	 * @throws NoSuchFieldException
	 */
	public PdBonusDto findForUpdate(
			String kCode,
			Date   calcDate,
			Date   payday
	) throws SQLException, IllegalAccessException, NoSuchFieldException {
		try {
			index = 1;
			prepareStatement(getSelectQuery(getClass()) + getConditionForKey(getClass()) + getForUpdate());
			setParam(index++, kCode);
			setParam(index++, calcDate);
			setParam(index++, payday);
			executeQuery();
			PdBonusDto dto = null;
			if (rs.next()) {
				dto = mapping();
			}
			return dto;
		} catch (SQLException e) {
			throw e;
		} finally {
			releaseResultSet();
			releasePreparedStatement();
		}
	}
	
	/**
	 * 条件文によるデータ取得
	 * @param calcDate 検索計算年月
	 * @return List 検索結果(DTOのList)
	 * @throws SQLException
	 * @throws IllegalAccessException
	 * @throws NoSuchFieldException
	 */
	public List<PdBonusDto> findForCondition(
			Date calcDate
	) throws SQLException, IllegalAccessException, NoSuchFieldException {
		index = 1;
		StringBuffer sb = new StringBuffer();
		sb.append("WHERE ");
		sb.append(COL_CALC_DATE);
		sb.append(" = ? ");
		try {
			prepareStatement(getSelectQuery(getClass()) + sb.toString() + getOrderForKey(getClass()));
			setParam(index++, calcDate);
			executeQuery();
			List<PdBonusDto> list = mappingAll();
			return list;
		} catch (SQLException e) {
			throw e;
		} finally {
			releaseResultSet();
			releasePreparedStatement();
		}
	}
	
	/**
	 * 条件文によるデータ取得
	 * @param startDate 対象開始年月
	 * @param endDate 対象終了年月
	 * @return List 検索結果(DTOのList)
	 * @throws SQLException
	 * @throws IllegalAccessException
	 * @throws NoSuchFieldException
	 */
	public List<PdBonusDto> findForConditionDate(
			String kCode,
			Date startDate,
			Date endDate
	) throws SQLException, IllegalAccessException, NoSuchFieldException {
		index = 1;
		StringBuffer sb = new StringBuffer();
		sb.append("WHERE ");
		sb.append(COL_K_CODE);
		sb.append(" = ? ");
		sb.append(" AND ");
		sb.append(COL_CALC_DATE);
		sb.append(" >= ? ");
		sb.append(" AND ");
		sb.append(COL_CALC_DATE);
		sb.append(" <= ? ");
		try {
			prepareStatement(getSelectQuery(getClass()) + sb.toString() + getOrderForKey(getClass()));
			setParam(index++, kCode);
			setParam(index++, startDate);
			setParam(index++, endDate);
			executeQuery();
			List<PdBonusDto> list = mappingAll();
			return list;
		} catch (SQLException e) {
			throw e;
		} finally {
			releaseResultSet();
			releasePreparedStatement();
		}
	}
	
	
	/**
	 * 条件文によるデータ取得
	 * @param startDate 対象開始年月
	 * @param endDate 対象終了年月
	 * @return List 検索結果(DTOのList)
	 * @throws SQLException
	 * @throws IllegalAccessException
	 * @throws NoSuchFieldException
	 */
	public List<PdBonusDto> findForPaydayOfYear(
			String kCode,
			Date startDate,
			Date endDate
	) throws SQLException, IllegalAccessException, NoSuchFieldException {
		index = 1;
		StringBuffer sb = new StringBuffer();
		sb.append("WHERE ");
		sb.append(COL_K_CODE);
		sb.append(" = ? ");
		sb.append(" AND ");
		sb.append(COL_PAYDAY);
		sb.append(" >= ? ");
		sb.append(" AND ");
		sb.append(COL_PAYDAY);
		sb.append(" <= ? ");
		try {
			prepareStatement(getSelectQuery(getClass()) + sb.toString() + getOrderForKey(getClass()));
			setParam(index++, kCode);
			setParam(index++, startDate);
			setParam(index++, endDate);
			executeQuery();
			List<PdBonusDto> list = mappingAll();
			return list;
		} catch (SQLException e) {
			throw e;
		} finally {
			releaseResultSet();
			releasePreparedStatement();
		}
	}
	
	/**
	 * 条件文によるデータ取得
	 * @param calcDate 検索計算年月
	 * @return List 検索結果(DTOのList)
	 * @throws SQLException
	 * @throws IllegalAccessException
	 * @throws NoSuchFieldException
	 */
	public List<PdBonusDto> findForPayday(
			Date payday
	) throws SQLException, IllegalAccessException, NoSuchFieldException {
		index = 1;
		StringBuffer sb = new StringBuffer();
		sb.append("WHERE ");
		sb.append(COL_PAYDAY);
		sb.append(" = ? ");
		try {
			prepareStatement(getSelectQuery(getClass()) + sb.toString() + getOrderForKey(getClass()));
			setParam(index++, payday);
			executeQuery();
			List<PdBonusDto> list = mappingAll();
			return list;
		} catch (SQLException e) {
			throw e;
		} finally {
			releaseResultSet();
			releasePreparedStatement();
		}
	}
	
	
	/**
	 * 条件文によるデータ取得
	 * @param calcDate 検索計算年月
	 * @return List 検索結果(DTOのList)
	 * @throws SQLException
	 * @throws IllegalAccessException
	 * @throws NoSuchFieldException
	 */
	public List<PdBonusDto> findForDataLineUp(
			String kCode,
			String kName,
			String stationCode,
			Date calcDate
	) throws SQLException, IllegalAccessException, NoSuchFieldException {
		index = 1;
		StringBuffer sb = new StringBuffer();
		sb.append("WHERE ");
		sb.append(COL_CALC_DATE);
		sb.append(" = ? ");
		if (kCode != null && !kCode.equals("")) {
			sb.append(COL_K_CODE + " = ");
			sb.append(" ? ");
			if (
				kName        != null && !kName.equals       ("") ||
				stationCode  != null && !stationCode.equals ("")
			) {
				sb.append("AND ");
			}
		}
		
		if (kName != null && !kName.equals(""))  {
			sb.append(COL_K_NAME + " = ");
			sb.append(" ? ");
			if (
				stationCode  != null && !stationCode.equals ("") 
			) {
				sb.append("AND ");
			}
		}
		
		if (stationCode  != null && !stationCode.equals ("")) {
			sb.append(COL_STATION_CODE + " = ");
			sb.append(" ? ");
		}

		try {
			prepareStatement(getSelectQuery(getClass()) + sb.toString() + getOrderForKey(getClass()));
			setParam(index++, calcDate);
			if (kCode != null && !kCode.equals("")) {
				setParam(index++, kCode);
			}
			
			if (kName != null && !kName.equals(""))  {
				setParam(index++, kName);
			}
			
			if (stationCode  != null && !stationCode.equals ("")) {
				setParam(index++, stationCode);
			}
			executeQuery();
			List<PdBonusDto> list = mappingAll();
			return list;
		} catch (SQLException e) {
			throw e;
		} finally {
			releaseResultSet();
			releasePreparedStatement();
		}
	}
	
	/**
	 * 条件文によるデータ削除
	 * @param calcDate 検索計算年月
	 * @return List 検索結果(DTOのList)
	 * @throws SQLException
	 */
	public int deleteForPayday(
			Date payday
	) throws SQLException {
		index = 1;
		StringBuffer sb = new StringBuffer();
		sb.append("DELETE FROM ");
		sb.append(TABLE + " ");
		sb.append("WHERE ");
		sb.append(COL_PAYDAY);
		sb.append(" = ? ");
		try {
			prepareStatement(sb.toString());
			setParam(index++, payday);
			executeUpdate();
			return cnt;
		} catch (SQLException e) {
			throw e;
		} finally {
			releaseResultSet();
			releasePreparedStatement();
		}
	}
	
	
	/**
	 * 条件文によるデータ削除
	 * @param calcDate 検索計算年月
	 * @return List 検索結果(DTOのList)
	 * @throws SQLException
	 */
	public int deleteForCondition(
			Date calcDate
	) throws SQLException {
		index = 1;
		StringBuffer sb = new StringBuffer();
		sb.append("DELETE FROM ");
		sb.append(TABLE + " ");
		sb.append("WHERE ");
		sb.append(COL_CALC_DATE);
		sb.append(" = ? ");
		try {
			prepareStatement(sb.toString());
			setParam(index++, calcDate);
			executeUpdate();
			return cnt;
		} catch (SQLException e) {
			throw e;
		} finally {
			releaseResultSet();
			releasePreparedStatement();
		}
	}

	/**
	 * データ挿入
	 * @param dto 挿入対象DTO
	 * @return int 挿入結果(件数)
	 * @throws SQLException
	 * @throws IllegalAccessException
	 * @throws NoSuchFieldException
	 * @throws MospException
	 */
	public int insert(PdBonusDto dto) throws SQLException, IllegalAccessException, NoSuchFieldException, MospException {
		try {
			index = 1;
			prepareStatement(getInsertQuery(getClass()));
			setParams(dto, true);
			executeUpdate();
			chkInsert(1);
			return cnt;
		} catch (SQLException e) {
			throw e;
		} finally {
			releaseResultSet();
			releasePreparedStatement();
		}
	}
	
	/**
	 * データ挿入(アップロード)
	 * @param aryCsvDate 挿入対象DTO
	 * @return int 挿入結果(件数)
	 * @throws SQLException
	 */
	public int insertUpload(
			String[] aryHeaderNo,
			String[] aryCsvData,
			Date calcDate,
			Date payday,
			String kName,
			String stationCode,
			String employmentType,
			String positionCode
	) throws SQLException {
		try {
			Date date = new Date();
			index = 1;
			StringBuffer sb = new StringBuffer();
			sb.append("INSERT INTO ");
			sb.append(TABLE);
			sb.append(" ( ");
			sb.append(createCol(aryHeaderNo,true));
			sb.append(COL_CALC_DATE);
			sb.append(", ");
			sb.append(COL_PAYDAY);
			sb.append(", ");
			sb.append(COL_K_NAME);
			sb.append(", ");
			sb.append(COL_STATION_CODE);
			sb.append(", ");			
			sb.append(COL_CALC_STATUS);
			sb.append(", ");
			sb.append(COL_EMPLOYMENT_TYPE);
			sb.append(", ");
			sb.append(COL_POSITION_CODE);
			sb.append(", ");
			if (!INSERT_DATE.equals("")) {
				sb.append(INSERT_DATE + ", ");
			}
			if (!INSERT_USER.equals("")) {
				sb.append(INSERT_USER + ", ");
			}
			if (!UPDATE_DATE.equals("")) {
				sb.append(UPDATE_DATE + ", ");
			}
			if (!UPDATE_USER.equals("")) {
				sb.append(UPDATE_USER + " ");
			}
			sb.append(" ) VALUES ( ");
			sb.append(insertRow(aryCsvData));
			sb.append("?, ");
			sb.append("?, ");
			sb.append("?, ");
			sb.append("?, ");			
			sb.append("?, ");
			sb.append("?, ");			
			sb.append("?, ");
			if (!INSERT_DATE.equals("")) {
				sb.append("?, ");
			}
			if (!INSERT_USER.equals("")) {
				sb.append("?, ");
			}
			if (!UPDATE_DATE.equals("")) {
				sb.append("?, ");
			}
			if (!UPDATE_USER.equals("")) {
				sb.append("?  ");
			}
			sb.append(" ) ");
			prepareStatement(sb.toString());
			for (int i = 0; i < aryCsvData.length; i++) {
				setParam(index++, aryCsvData[i]);
			}
			setParam(index++, calcDate);
			setParam(index++, payday);
			setParam(index++, kName);
			setParam(index++, stationCode);
			setParam(index++, BonusConst.CALC_STATUS_CRE);
			setParam(index++, employmentType);
			setParam(index++, positionCode);
			if (!INSERT_DATE.equals("")) {
				setParam(index++, date);
			}
			if (!INSERT_USER.equals("")) {
				setParam(index++, userId);
			}
			if (!UPDATE_DATE.equals("")) {
				setParam(index++, date);
			}
			if (!UPDATE_USER.equals("")) {
				setParam(index++, userId);
			}
			executeUpdate();
			return cnt;
		} catch (SQLException e) {
			throw e;
		} finally {
			releaseResultSet();
			releasePreparedStatement();
		}
	}
	
	/**
	 * 選択カラムのみSQL作成
	 * @param aryHeaderNo
	 * @param isInsert
	 * @return
	 */

	public String createCol(
			String[] aryHeaderNo,
			boolean isInsert
		) {
			index = 1;
			StringBuffer sb = new StringBuffer();
			for (int i = 0; i < aryHeaderNo.length; i++) {
				sb.append(getColumn(Integer.parseInt(aryHeaderNo[i])));
				if (!isInsert) {
					sb.append(" = ? ");
				}
				sb.append(BonusConst.STR_CSV_SEPARATOR);
			}
			return sb.toString();
		
	}
	/**
	 * 登録パラメータ生成
	 * @param aryCsvData
	 * @return
	 */

	public String insertRow(
			String[] aryCsvData
		) {
			index = 1;
			StringBuffer sb = new StringBuffer();
			for (int i = 0; i < aryCsvData.length; i++) {
				sb.append(" ? ");
				sb.append(BonusConst.STR_CSV_SEPARATOR);
			}
			return sb.toString();
		
	}
	
	/**
	 * データ更新(アップロード)
	 * @param dto 更新対象DTO
	 * @return int 更新結果(件数)
	 * @throws SQLException
	 */
	public int updateUpload(
			String[] aryHeaderNo,
			String[] aryCsvData,
			String   kCode,
			Date   calcDate,
			Date   payday,
			String kName,
			String stationCode,
			String employmentType,
			String positionCode
	) throws SQLException {
		try {
			Date date = new Date();
			index = 1;
			StringBuffer sb = new StringBuffer();
			sb.append("UPDATE ");
			sb.append(TABLE);
			sb.append(" SET ");
			sb.append(createCol(aryHeaderNo,false));
			sb.append(COL_CALC_DATE       + " = ?, ");
			sb.append(COL_PAYDAY          + " = ?, ");
			sb.append(COL_K_NAME          + " = ?, ");
			sb.append(COL_STATION_CODE    + " = ?, ");			
			sb.append(COL_CALC_STATUS     + " = ?, ");
			sb.append(COL_EMPLOYMENT_TYPE + " = ?, ");
			sb.append(COL_POSITION_CODE   + " = ?, ");
			
			sb.append(COL_ALLOWANCE_TOTAL     + " = ?, ");
			sb.append(COL_DEDUCTION_TOTAL     + " = ?, ");
			sb.append(COL_PAYMENT_TOTAL       + " = ?, ");
			sb.append(COL_BANK1_PAY_AMOUNT    + " = ?, ");
			sb.append(COL_BANK2_PAY_AMOUNT    + " = ?, ");
			sb.append(COL_CASH_PAY_AMOUNT     + " = ?, ");
			sb.append(COL_LAST_MONTH_TAXATION + " = ?, ");
			sb.append(COL_TOTAL_YEAR_BONUS    + " = ?, ");
			
			if (!UPDATE_DATE.equals("")) {
				sb.append(UPDATE_DATE + " = ?, ");
			}
			if (!UPDATE_USER.equals("")) {
				sb.append(UPDATE_USER + " = ? ");
			}
			sb.append(" WHERE ");
			sb.append(COL_K_CODE);
			sb.append(" = ? ");
			sb.append(" AND ");
			sb.append(COL_CALC_DATE);
			sb.append(" = ? ");
			sb.append(" AND ");
			sb.append(COL_PAYDAY);
			sb.append(" = ? ");
			prepareStatement(sb.toString());
			for (int i = 0; i < aryCsvData.length; i++) {
				setParam(index++, aryCsvData[i]);
			}
			setParam(index++, calcDate);
			setParam(index++, payday);
			setParam(index++, kName);
			setParam(index++, stationCode);
			setParam(index++, BonusConst.CALC_STATUS_CRE);
			setParam(index++, employmentType);
			setParam(index++, positionCode);
			
			setParam(index++, 0);
			setParam(index++, 0);
			setParam(index++, 0);
			setParam(index++, 0);
			setParam(index++, 0);
			setParam(index++, 0);
			setParam(index++, 0);
			setParam(index++, 0);
			if (!UPDATE_DATE.equals("")) {
				setParam(index++, date);
			}
			if (!UPDATE_USER.equals("")) {
				setParam(index++, userId);
			}
			setParam(index++, kCode);
			setParam(index++, calcDate);
			setParam(index++, payday);
			executeUpdate();
			return cnt;
			
		} catch (SQLException e) {
			throw e;
		} finally {
			releaseResultSet();
			releasePreparedStatement();
		}
	}

	/**
	 * データ更新(アップロード)
	 * @param dto 更新対象DTO
	 * @return int 更新結果(件数)
	 * @throws SQLException
	 * @throws IllegalAccessException 
	 */
	public List<PdBonusDto> selectCalYear(
			String kCode,
			String calYear
	) throws SQLException, IllegalAccessException  {
		try {
			index = 1;
			StringBuffer sb = new StringBuffer();
			sb.append("SELECT ");
			sb.append(" * ");
			sb.append(" FROM ");
			sb.append(TABLE);
			sb.append(" WHERE ");
			sb.append(COL_K_CODE + " = ? ");
			sb.append(" AND YEAR( ");
			sb.append(COL_CALC_DATE);
			sb.append(" ) ");
			sb.append(" = ?  ");
			prepareStatement(sb.toString() + getOrderForKey(getClass()));
			setParam(index++, kCode);
			setParam(index++, calYear);
			executeQuery();
			List<PdBonusDto> all = mappingAll();
			return all;
		} catch (SQLException e) {
			throw e;
		} finally {
			releaseResultSet();
			releasePreparedStatement();
		}
	}
	
	/**
	 * 年度データ検索
	 * @param kCode　対象社員コード
	 * @param startDate 対象年月(開始)
	 * @param endDate 対象年月(終了)
	 * @return
	 * @throws SQLException
	 * @throws IllegalAccessException
	 */
	
	public List<PdBonusDto> selectTheYear(
			String kCode,
			Date startDate,
			Date endDate
	) throws SQLException, IllegalAccessException  {
		try {
			index = 1;
			StringBuffer sb = new StringBuffer();
			sb.append("SELECT ");
			sb.append(" * ");
			sb.append(" FROM ");
			sb.append(TABLE);
			sb.append(" WHERE ");
			sb.append(COL_K_CODE + " = ? ");
			sb.append(" AND  ");
			sb.append(" ? ");
			sb.append(" <= ");
			sb.append(COL_PAYDAY);
			sb.append(" AND  ");
			sb.append(COL_PAYDAY);
			sb.append(" <= ?  ");
			prepareStatement(sb.toString() + getOrderForKey(getClass()));
			setParam(index++, kCode);
			setParam(index++, startDate);
			setParam(index++, endDate);
			executeQuery();
			List<PdBonusDto> all = mappingAll();
			return all;
		} catch (SQLException e) {
			throw e;
		} finally {
			releaseResultSet();
			releasePreparedStatement();
		}
	}

	
	/**
	 * データ更新(アップロード)
	 * @param dto 更新対象DTO
	 * @return int 更新結果(件数)
	 * @throws SQLException
	 * @throws IllegalAccessException 
	 */
	public PdBonusDto selectCalTime(
			String kCode,
			String calYear,
			String calMonth
	) throws SQLException, IllegalAccessException  {
		try {
			index = 1;
			StringBuffer sb = new StringBuffer();
			sb.append("SELECT ");
			sb.append(" * ");
			sb.append(" FROM ");
			sb.append(TABLE);
			sb.append(" WHERE ");
			sb.append(COL_K_CODE + " = ? ");
			sb.append(" AND YEAR( ");
			sb.append(COL_CALC_DATE);
			sb.append(" ) ");
			sb.append(" = ?  ");
			sb.append(" AND MONTH( ");
			sb.append(COL_CALC_DATE);
			sb.append(" ) ");
			sb.append(" = ?  ");
			prepareStatement(sb.toString() + getOrderForKey(getClass()));
			setParam(index++, kCode);
			setParam(index++, calYear);
			setParam(index++, calMonth);
			executeQuery();
			PdBonusDto dto = null;
			if (rs.next()) {
				dto = mapping();
			}
			return dto;

		} catch (SQLException e) {
			throw e;
		} finally {
			releaseResultSet();
			releasePreparedStatement();
		}
	}
	
	/**
	 * データ更新(アップロード)
	 * @param dto 更新対象DTO
	 * @return int 更新結果(件数)
	 * @throws SQLException
	 * @throws IllegalAccessException 
	 */
	public PdBonusDto selectCalTimeForUpdate(
			String kCode,
			String calYear,
			String calMonth
	) throws SQLException, IllegalAccessException  {
		try {
			index = 1;
			StringBuffer sb = new StringBuffer();
			sb.append("SELECT ");
			sb.append(" * ");
			sb.append(" FROM ");
			sb.append(TABLE);
			sb.append(" WHERE ");
			sb.append(COL_K_CODE + " = ? ");
			sb.append(" AND YEAR( ");
			sb.append(COL_CALC_DATE);
			sb.append(" ) ");
			sb.append(" = ?  ");
			sb.append(" AND MONTH( ");
			sb.append(COL_CALC_DATE);
			sb.append(" ) ");
			sb.append(" = ?  ");
			prepareStatement(sb.toString() + getOrderForKey(getClass()) + getForUpdate());
			setParam(index++, kCode);
			setParam(index++, calYear);
			setParam(index++, calMonth);
			executeQuery();
			PdBonusDto dto = null;
			if (rs.next()) {
				dto = mapping();
			}
			return dto;

		} catch (SQLException e) {
			throw e;
		} finally {
			releaseResultSet();
			releasePreparedStatement();
		}
	}
	
	/**
	 * データ挿入
	 * @param dto 挿入対象DTO
	 * @param needLog ログ出力要否
	 * @return int 挿入結果(件数)
	 * @throws SQLException
	 * @throws IllegalAccessException
	 * @throws NoSuchFieldException
	 * @throws MospException
	 */
	public int insert(PdBonusDto dto, boolean needLog) throws SQLException, IllegalAccessException, NoSuchFieldException, MospException {
		try {
			index = 1;
			prepareStatement(getInsertQuery(getClass()));
			setParams(dto, true);
			executeUpdate(needLog);
			chkInsert(1);
			return cnt;
		} catch (SQLException e) {
			throw e;
		} finally {
			releaseResultSet();
			releasePreparedStatement();
		}
	}
	
	
	/**
	 * 条件文によりデータを取得する。<br>
	 * 指定年月における確定済みデータを抽出する。<br>
	 * kCodeをnullにすると、社員コードによる指定を行わない。<br>
	 * 賞与FBデータ出力時に用いる。
	 * @param payday 検索支給日
	 * @param kCode    検索社員コード
	 * @return List 検索結果(DTOのList)
	 * @throws SQLException
	 * @throws IllegalAccessException
	 * @throws NoSuchFieldException
	 */
	public List<PdBonusDto> findForFBDataOutputDetail(
			Date payday, String kCode
	) throws SQLException, IllegalAccessException, NoSuchFieldException {
		index = 1;
		StringBuffer sb = new StringBuffer();
		sb.append("WHERE ");
		if (kCode != null) {
			sb.append(COL_K_CODE + " = ? ");
			sb.append("AND ");
		}
		sb.append(COL_PAYDAY + " = ? ");
		sb.append("AND ");
		sb.append(COL_CALC_STATUS + " = '" + BonusConst.CALC_STATUS_FIX + "' ");
		try {
			prepareStatement(getSelectQuery(getClass()) + sb.toString() + getOrderForKey(getClass()));
			if (kCode != null) {
				setParam(index++, kCode);
			}
			setParam(index++, payday);
			executeQuery();
			return mappingAll();
		} catch (SQLException e) {
			throw e;
		} finally {
			releaseResultSet();
			releasePreparedStatement();
		}
	}
	
	/**
	 * 条件文によりデータを取得する。<br>
	 * 指定年月における確定済みデータを抽出する。<br>
	 * kCodeをnullにすると、社員コードによる指定を行わない。<br>
	 * 賞与FBデータ出力時に用いる。
	 * @param payday 検索支給日
	 * @param kCode    検索社員コード
	 * @return List 検索結果(DTOのList)
	 * @throws SQLException
	 * @throws IllegalAccessException
	 * @throws NoSuchFieldException
	 */
	public List<PdBonusDto> findForCalcDate(
			Date calcDate, String kCode
	) throws SQLException, IllegalAccessException, NoSuchFieldException {
		index = 1;
		StringBuffer sb = new StringBuffer();
		sb.append("WHERE ");
		if (kCode != null) {
			sb.append(COL_K_CODE + " = ? ");
			sb.append("AND ");
		}
		sb.append(COL_CALC_DATE + " = ? ");
		try {
			prepareStatement(getSelectQuery(getClass()) + sb.toString() + getOrderForKey(getClass()));
			if (kCode != null) {
				setParam(index++, kCode);
			}
			setParam(index++, calcDate);
			executeQuery();
			return mappingAll();
		} catch (SQLException e) {
			throw e;
		} finally {
			releaseResultSet();
			releasePreparedStatement();
		}
	}

	
	/**
	 * データ更新
	 * @param dto 更新対象DTO
	 * @param needLog ログ出力要否
	 * @return int 更新結果(件数)
	 * @throws SQLException
	 * @throws IllegalAccessException
	 * @throws NoSuchFieldException
	 * @throws MospException
	 */
	public int update(
			PdBonusDto dto, boolean needLog
	) throws SQLException, IllegalAccessException, NoSuchFieldException, MospException {
		try {
			index = 1;
			prepareStatement(getUpdateQuery(getClass()));
			setParams(dto, false);
			setParam(index++, dto.getKCode());
			setParam(index++, dto.getCalcDate());
			setParam(index++, dto.getPayday());
			executeUpdate(needLog);
			chkUpdate(1);
			return cnt;
		} catch (SQLException e) {
			throw e;
		} finally {
			releaseResultSet();
			releasePreparedStatement();
		}
	}
	
	/**
	 * 条件文によりデータを取得する。<br>
	 * 指定年月における確定済みデータを抽出する。<br>
	 * kCodeをnullにすると、社員コードによる指定を行わない。<br>
	 * 給与明細出力時に用いる。
	 * @param calcDate 検索計算年月
	 * @param kCode    検索社員コード
	 * @param stationCode 検索所属コード(事業所)
	 * @return List 検索結果(DTOのList)
	 * @throws SQLException
	 * @throws IllegalAccessException
	 * @throws NoSuchFieldException
	 */
	public  List<PdBonusDto> findForOutputDetail(
			Date calcDate, Date payday, String kCode, String stationCode
	) throws SQLException, IllegalAccessException, NoSuchFieldException {
		index = 1;
		StringBuffer sb = new StringBuffer();
		sb.append("WHERE ");
		if (kCode != null) {
			sb.append(COL_K_CODE + " = ? ");
			sb.append("AND ");
		}
		sb.append(COL_CALC_DATE + " = ? ");
		sb.append("AND ");
		sb.append(COL_PAYDAY + " = ? ");
		sb.append("AND ");
		sb.append(COL_CALC_STATUS + " IN ('" + BonusConst.CALC_STATUS_FIX + "','" +BonusConst.CALC_STATUS_FB +"')");
		if (stationCode != null) {
			if (!stationCode.equals("")) {
				sb.append("AND ");
				sb.append(COL_STATION_CODE + " IN  ( " + PmStationDao.getStationQuery() + " ) ");
			}
		}
		try {
			prepareStatement(getSelectQuery(getClass()) + sb.toString() + getOrderForKey(getClass()));
			if (kCode != null) {
				setParam(index++, kCode);
			}
			setParam(index++, calcDate);
			setParam(index++, payday);
			if (stationCode != null) {
				if (!stationCode.equals("")) {
					setParam(index++, stationCode);
				}
			}
			executeQuery();
			return mappingAll();
		} catch (SQLException e) {
			throw e;
		} finally {
			releaseResultSet();
			releasePreparedStatement();
		}
	}
	
	/**
	 * データ削除
	 * @param dto 更新対象DTO
	 * @return int 削除結果(件数)
	 * @throws SQLException
	 * @throws IllegalAccessException
	 * @throws NoSuchFieldException
	 * @throws MospException
	 */
	public int delete(PdBonusDto dto) throws SQLException, IllegalAccessException, NoSuchFieldException, MospException {
		try {
			index = 1;
			prepareStatement(getDeleteQuery(getClass()));
			setParam(index++, dto.getKCode   ());
			setParam(index++, dto.getCalcDate());
			setParam(index++, dto.getPayday  ());
			executeUpdate();
			chkDelete(1);
			return cnt;
		} catch (SQLException e) {
			throw e;
		} finally {
			releaseResultSet();
			releasePreparedStatement();
		}
	}
	
	/**
	 * 社員によるデータ削除
	 * @param kCode 削除対象社員コード
	 * @return int 削除結果(件数)
	 * @throws SQLException
	 */
	public int deleteForEmployee(String kCode) throws SQLException {
		try {
			index = 1;
			StringBuffer sb = new StringBuffer();
			sb.append("DELETE FROM " + TABLE + " ");
			sb.append("WHERE ");
			sb.append(COL_K_CODE + " = ? ");
			prepareStatement(sb.toString());
			setParam(index++, kCode);
			executeUpdate();
			return cnt;
		} catch (SQLException e) {
			throw e;
		} finally {
			releaseResultSet();
			releasePreparedStatement();
		}
	}
	
	/**
	 * パラメータ設定
	 * @param dto 更新対象DTO
	 * @param isInsert 挿入文フラグ(true：挿入文、false：更新文)
	 * @throws SQLException
	 */
	private void setParams(PdBonusDto dto, boolean isInsert) throws SQLException {
		setParam(index++, dto.getKCode             ());	// 社員コード
		setParam(index++, dto.getCalcDate          ());	// 計算年月
		setParam(index++, dto.getPayday            ());	// 賞与支給日
		setParam(index++, dto.getCalcStatus        ());	// 計算ステータス
		setParam(index++, dto.getKName             ());	// 社員氏名
		setParam(index++, dto.getStationCode       ());	// 所属コード
		setParam(index++, dto.getPositionCode      ());	// 職位コード
		setParam(index++, dto.getEmploymentType    ());	// 雇用区分
		setParam(index++, dto.getBonusAllowance01  ());	// 賞与支給項目01
		setParam(index++, dto.getBonusAllowance02  ());	// 賞与支給項目02
		setParam(index++, dto.getBonusAllowance03  ());	// 賞与支給項目03
		setParam(index++, dto.getBonusAllowance04  ());	// 賞与支給項目04
		setParam(index++, dto.getBonusAllowance05  ());	// 賞与支給項目05
		setParam(index++, dto.getBonusAllowance06  ());	// 賞与支給項目06
		setParam(index++, dto.getBonusAllowance07  ());	// 賞与支給項目07
		setParam(index++, dto.getBonusAllowance08  ());	// 賞与支給項目08
		setParam(index++, dto.getBonusAllowance09  ());	// 賞与支給項目09
		setParam(index++, dto.getBonusAllowance10  ());	// 賞与支給項目10
		setParam(index++, dto.getBonusAllowance11  ());	// 賞与支給項目11
		setParam(index++, dto.getBonusAllowance12  ());	// 賞与支給項目12
		setParam(index++, dto.getBonusAllowance13  ());	// 賞与支給項目13
		setParam(index++, dto.getBonusAllowance14  ());	// 賞与支給項目14
		setParam(index++, dto.getBonusAllowance15  ());	// 賞与支給項目15
		setParam(index++, dto.getBonusAllowance16  ());	// 賞与支給項目16
		setParam(index++, dto.getBonusAllowance17  ());	// 賞与支給項目17
		setParam(index++, dto.getBonusAllowance18  ());	// 賞与支給項目18
		setParam(index++, dto.getBonusAllowance19  ());	// 賞与支給項目19
		setParam(index++, dto.getBonusAllowance20  ());	// 賞与支給項目20
		setParam(index++, dto.getHealthInsurance   ());	// 健康保険料
		setParam(index++, dto.getPensionInsurance  ());	// 厚生年金保険
		setParam(index++, dto.getEmployeeInsurance ());	// 雇用保険料
		setParam(index++, dto.getIncomeTax         ());	// 所得税
		setParam(index++, dto.getNursingInsurance  ());	// 介護保険料
		setParam(index++, dto.getBonusDeduction06  ());	// 賞与控除項目06
		setParam(index++, dto.getBonusDeduction07  ());	// 賞与控除項目07
		setParam(index++, dto.getBonusDeduction08  ());	// 賞与控除項目08
		setParam(index++, dto.getBonusDeduction09  ());	// 賞与控除項目09
		setParam(index++, dto.getBonusDeduction10  ());	// 賞与控除項目10
		setParam(index++, dto.getBonusDeduction11  ());	// 賞与控除項目11
		setParam(index++, dto.getBonusDeduction12  ());	// 賞与控除項目12
		setParam(index++, dto.getBonusDeduction13  ());	// 賞与控除項目13
		setParam(index++, dto.getBonusDeduction14  ());	// 賞与控除項目14
		setParam(index++, dto.getBonusDeduction15  ());	// 賞与控除項目15
		setParam(index++, dto.getBonusDeduction16  ());	// 賞与控除項目16
		setParam(index++, dto.getBonusDeduction17  ());	// 賞与控除項目17
		setParam(index++, dto.getBonusDeduction18  ());	// 賞与控除項目18
		setParam(index++, dto.getBonusDeduction19  ());	// 賞与控除項目19
		setParam(index++, dto.getBonusDeduction20  ());	// 賞与控除項目20
		setParam(index++, dto.getAllowanceTotal    ());	// 総支給金額
		setParam(index++, dto.getDeductionTotal    ());	// 総控除金額
		setParam(index++, dto.getPaymentTotal      ());	// 差引支給額
		setParam(index++, dto.getBank1PayAmount    ());	// 銀行1振込額
		setParam(index++, dto.getBank2PayAmount    ());	// 銀行2振込額
		setParam(index++, dto.getCashPayAmount     ());	// 現金支給額
		setParam(index++, dto.getDependentCount    ());	// 扶養等の数
		setParam(index++, dto.getLastMonthTaxation ());	// 前月給与の課税対象額
		setParam(index++, dto.getTotalYearBonus    ());	// 年度累計賞与額
		setParam(index++, dto.getIncomeRate        ());	// 所得税率
		setParam(index++, dto.getEmpInsBasic       ());	// 雇保対象基準額
		setCommonParams(isInsert);
	}

	/**
	 * カラム名取得
	 * @param idx
	 * @return カラム名
	 */
	public String getColumn(
			int idx
		) {
		switch (idx) {
		case 0  : return COL_K_CODE; 	            //	社員コード
		case 1  : return COL_BONUS_ALLOWANCE_01; 	//	賞与支給項目01
		case 2  : return COL_BONUS_ALLOWANCE_02; 	//	賞与支給項目02
		case 3  : return COL_BONUS_ALLOWANCE_03; 	//	賞与支給項目03
		case 4  : return COL_BONUS_ALLOWANCE_04; 	//	賞与支給項目04
		case 5  : return COL_BONUS_ALLOWANCE_05; 	//	賞与支給項目05
		case 6  : return COL_BONUS_ALLOWANCE_06; 	//	賞与支給項目06
		case 7  : return COL_BONUS_ALLOWANCE_07; 	//	賞与支給項目07
		case 8  : return COL_BONUS_ALLOWANCE_08; 	//	賞与支給項目08
		case 9  : return COL_BONUS_ALLOWANCE_09; 	//	賞与支給項目09
		case 10 : return COL_BONUS_ALLOWANCE_10; 	//	賞与支給項目10
		case 11 : return COL_BONUS_ALLOWANCE_11; 	//	賞与支給項目11
		case 12 : return COL_BONUS_ALLOWANCE_12; 	//	賞与支給項目12
		case 13 : return COL_BONUS_ALLOWANCE_13; 	//	賞与支給項目13
		case 14 : return COL_BONUS_ALLOWANCE_14; 	//	賞与支給項目14
		case 15 : return COL_BONUS_ALLOWANCE_15; 	//	賞与支給項目15
		case 16 : return COL_BONUS_ALLOWANCE_16; 	//	賞与支給項目16
		case 17 : return COL_BONUS_ALLOWANCE_17; 	//	賞与支給項目17
		case 18 : return COL_BONUS_ALLOWANCE_18; 	//	賞与支給項目18
		case 19 : return COL_BONUS_ALLOWANCE_19; 	//	賞与支給項目19
		case 20 : return COL_BONUS_ALLOWANCE_20; 	//	賞与支給項目20
		case 21 : return COL_BONUS_DEDUCTION_06; 	//	賞与控除項目06
		case 22 : return COL_BONUS_DEDUCTION_07; 	//	賞与控除項目07
		case 23 : return COL_BONUS_DEDUCTION_08; 	//	賞与控除項目08
		case 24 : return COL_BONUS_DEDUCTION_09; 	//	賞与控除項目09
		case 25 : return COL_BONUS_DEDUCTION_10; 	//	賞与控除項目10
		case 26 : return COL_BONUS_DEDUCTION_11; 	//	賞与控除項目11
		case 27 : return COL_BONUS_DEDUCTION_12; 	//	賞与控除項目12
		case 28 : return COL_BONUS_DEDUCTION_13; 	//	賞与控除項目13
		case 29 : return COL_BONUS_DEDUCTION_14; 	//	賞与控除項目14
		case 30 : return COL_BONUS_DEDUCTION_15; 	//	賞与控除項目15
		case 31 : return COL_BONUS_DEDUCTION_16; 	//	賞与控除項目16
		case 32 : return COL_BONUS_DEDUCTION_17; 	//	賞与控除項目17
		case 33 : return COL_BONUS_DEDUCTION_18; 	//	賞与控除項目18
		case 34 : return COL_BONUS_DEDUCTION_19; 	//	賞与控除項目19
		case 35 : return COL_BONUS_DEDUCTION_20; 	//	賞与控除項目10
		default:
			return "";
		}
	}
}
