package com.etecenc.ebid.sycs.code.biz;


import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import kr.co.hsnc.common.base.WAFLogger;
import kr.co.hsnc.common.sql.RowSet;
import kr.co.hsnc.common.sql.RowSetImpl;
import kr.co.hsnc.common.sql.WAFSQLException;
import kr.co.hsnc.common.sql.search.Search;
import kr.co.hsnc.common.sql.search.SearchImpl;
import kr.co.hsnc.common.util.ValueObject;

import com.udapsoft.modular.web.ibsheet7.IBSheet7Factory;
import com.udapsoft.modular.web.ibsheet7.util.IBSheet7Utils;
import com.udapsoft.waf.system.Biz;
import com.udapsoft.waf.system.HandlerStorage;

public class CommCodeListBiz extends Biz {
	public CommCodeListBiz (HandlerStorage storage) {
		super(storage);
	}

	public void doBiz() throws Exception {
		
		if (storage.compareEvent("")) {
			
			IBSheet7Utils.setIBSheet7Combo("MASTERSHEET", "GENDER", storage);
		} else {
			//IBSheet7 시스템 코드 Combo 셋업
			params.set("masterSheet", getMasterData());
			storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
		}
			
	}
	
	private RowSet getMasterData() {
		Search search = new SearchImpl();
        RowSet rowSet = new RowSetImpl();
        try {
        	search.setStatement("select pid, first_name, last_name, birth, gender, salary from master_tbl");
            rowSet = search.execute();
            
        } catch (WAFSQLException se) {
            super.doException(se);
            this.storage.setSuccess(false);
            this.storage.setMessage(se.getMessage());
            storage.setDetailMessage(se);
            
        } finally {    
            if(rowSet == null) rowSet = new RowSetImpl();
        }
        return rowSet;
	}
	
}