/**
 * @(#)file    TermsAgreeSaveBiz.java
 * @(#)author  이성민
 * @(#)version 1.0
 *
 */
package kr.co.udapsoft.ebid.supplier.portal.own.biz;



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

import javax.servlet.http.HttpServletRequest;

import org.jdom.Document;
import org.jdom.Element;
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;

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.persistent.Persistent;
import kr.co.hsnc.common.sql.persistent.PersistentImpl;
import kr.co.hsnc.common.sql.search.Search;
import kr.co.hsnc.common.sql.search.SearchImpl;
import kr.co.hsnc.common.sql.util.RowSetUtility;
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 SuppOwnSaveBiz extends Biz {

	public SuppOwnSaveBiz(HandlerStorage storage) 
	{
		super(storage);
	}

	/* (non-Javadoc)
	 * @see kr.co.hwenc.system.Biz#doBiz()
	 */
	public void doBiz() throws Exception 
	{
	    
		//System.out.println("event==============>" + storage.getEvent());
		
		if(storage.compareEvent("SAVE_LIST"))
        {
            boolean success = false;
            boolean success2 = false;
            boolean success3 = false;
            String[] status = super.gets("sheet2.STATUS");
            
            
            
            try {
                super.conn.begin();
                
                success = updateInfo(params);
                
                success2 = updateChage(params);
                
                
                
                
                if(params.get("job_div").equals("P"))
                {
                    deleteData();
                    
                    for (int i = 0; i < status.length; i++) {
                        
                      if (IBSheet7Utils.equalStatusInsert(status[i])) {
                        
                        //System.out.println(IBSheet7Utils.getIBSheet7SqlParams("SHEET2", params, i));
                          
                        success3 = saveData(IBSheet7Utils.getIBSheet7SqlParams("SHEET2", params, i));
                      }
                  }
                }
                else
                {
                    deleteData2();
                    for (int i = 0; i < status.length; i++) 
                    {
                        
                      if (IBSheet7Utils.equalStatusInsert(status[i])) {
                          
                          success3 = saveData2(IBSheet7Utils.getIBSheet7SqlParams("SHEET2", params, i));
                      }
                      
                      //주력분야
                      
                      deleteData3();
                      
                      String[] chk_val = params.get("out_main_check").split(",");
                      
                      for(int k=0; k < chk_val.length; k++)
                      {
                          params.set("out_main_code", chk_val[k]);
                          saveOutMain(params);
                      }
                      
                  }
                }
                
                
                super.storage.setSuccess(success);
                storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
            } catch (Exception e) {
                WAFLogger.error(e);
                super.conn.setRollback();
                super.storage.setSuccess(false);
                throw new Exception(e);
                
            } finally {
                super.conn.close();
            }
        }
		else if(storage.compareEvent("SAVE_DELIRESULT"))
        {
		    boolean success = false;
		    
		    String[] status = super.gets("sheet1.STATUS");
		    
		    try 
		    {
		        super.conn.begin();
		        
		        deleteDeliresult();
		        
		        for (int i = 0; i < status.length; i++) 
		        {
		            if (IBSheet7Utils.equalStatusInsert(status[i])) 
		            {
		                success = saveDeliresult(IBSheet7Utils.getIBSheet7SqlParams("SHEET1", params, i));
		            }
		        }
		        
		        super.storage.setSuccess(success);
                storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
		    } 
		    catch (Exception e) 
		    {
                //System.out.println("SAVE_DELIRESULT===>" + e);
                super.conn.setRollback();
                super.storage.setSuccess(false);
                throw new Exception(e);
                
            } finally {
                super.conn.close();
            }
        }
		else if(storage.compareEvent("SAVE_CRET"))
        {
            boolean success = false;
            
            String[] status = super.gets("sheet2.STATUS");
            
            try 
            {
                super.conn.begin();
                
                deleteCert();
                
                for (int i = 0; i < status.length; i++) 
                {
                    if (IBSheet7Utils.equalStatusInsert(status[i])) 
                    {
                        success = saveCert(IBSheet7Utils.getIBSheet7SqlParams("SHEET2", params, i));
                    }
                }
                
                super.storage.setSuccess(success);
                storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
            } 
            catch (Exception e) 
            {
                //System.out.println("SAVE_CRET===>" + e);
                super.conn.setRollback();
                super.storage.setSuccess(false);
                throw new Exception(e);
                
            } finally {
                super.conn.close();
            }
        }
		else if(storage.compareEvent("SAVE_PRIZE"))
        {
            boolean success = false;
            
            String[] status = super.gets("sheet3.STATUS");
            
            try 
            {
                super.conn.begin();
                
                deletePrize();
                
                for (int i = 0; i < status.length; i++) 
                {
                    if (IBSheet7Utils.equalStatusInsert(status[i])) 
                    {
                        success = savePrize(IBSheet7Utils.getIBSheet7SqlParams("SHEET3", params, i));
                    }
                }
                
                super.storage.setSuccess(success);
                storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
            } 
            catch (Exception e) 
            {
                //System.out.println("SAVE_PRIZE===>" + e);
                super.conn.setRollback();
                super.storage.setSuccess(false);
                throw new Exception(e);
                
            } finally {
                super.conn.close();
            }
        }
		else if(storage.compareEvent("SAVE_PATENT"))
        {
            boolean success = false;
            
            String[] status = super.gets("sheet4.STATUS");
            
            try 
            {
                super.conn.begin();
                
                deletePatent();
                
                
                for (int i = 0; i < status.length; i++) 
                {
                    if (IBSheet7Utils.equalStatusInsert(status[i])) 
                    {
                        success = savePatent(IBSheet7Utils.getIBSheet7SqlParams("SHEET4", params, i));
                    }
                }
                
                if(success == true)
                {
                    deleteFinance();
                    
                    success = saveFinance(params);
                }
                
                super.storage.setSuccess(success);
                storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
            } 
            catch (Exception e) 
            {
                //System.out.println("SAVE_PATENT===>" + e);
                super.conn.setRollback();
                super.storage.setSuccess(false);
                throw new Exception(e);
                
            } finally {
                super.conn.close();
            }
        }
		else if(storage.compareEvent("SAVE_CON_RESULT"))
        {
            boolean success = false;
            
            String[] status = super.gets("sheet1.STATUS");
            
            try 
            {
                super.conn.begin();
                
                deleteConResult();
                
                for (int i = 0; i < status.length; i++) 
                {
                    if (IBSheet7Utils.equalStatusInsert(status[i])) 
                    {
                        success = saveConResult(IBSheet7Utils.getIBSheet7SqlParams("SHEET1", params, i));
                    }
                }
                
                super.storage.setSuccess(success);
                storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
            } 
            catch (Exception e) 
            {
                //System.out.println("SAVE_PRIZE===>" + e);
                super.conn.setRollback();
                super.storage.setSuccess(false);
                throw new Exception(e);
                
            } finally {
                super.conn.close();
            }
        }
		else if(storage.compareEvent("SAVE_CON_ABILLTY"))
        {
            boolean success = false;
            
            String[] status = super.gets("sheet2.STATUS");
            
            try 
            {
                super.conn.begin();
                
                deleteConAbillty();
                
                for (int i = 0; i < status.length; i++) 
                {
                    if (IBSheet7Utils.equalStatusInsert(status[i])) 
                    {
                        success = saveConAbillty(IBSheet7Utils.getIBSheet7SqlParams("SHEET2", params, i));
                    }
                }
                
                super.storage.setSuccess(success);
                storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
            } 
            catch (Exception e) 
            {
                //System.out.println("SAVE_PRIZE===>" + e);
                super.conn.setRollback();
                super.storage.setSuccess(false);
                throw new Exception(e);
                
            } finally {
                super.conn.close();
            }
        }
		else if(storage.compareEvent("SAVE_TECH_MAN"))
        {
            boolean success = false;
            
            String[] status = super.gets("sheet3.STATUS");
            
            try 
            {
                super.conn.begin();
                
                deleteTechMan();
                
                for (int i = 0; i < status.length; i++) 
                {
                    if (IBSheet7Utils.equalStatusInsert(status[i])) 
                    {
                        success = saveTechMan(IBSheet7Utils.getIBSheet7SqlParams("SHEET3", params, i));
                    }
                }
                
                super.storage.setSuccess(success);
                storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
            } 
            catch (Exception e) 
            {
                //System.out.println("SAVE_TECH_MAN===>" + e);
                super.conn.setRollback();
                super.storage.setSuccess(false);
                throw new Exception(e);
                
            } finally {
                super.conn.close();
            }
        }
		else if(storage.compareEvent("SAVE_CRET_OUT"))
        {
            boolean success = false;
            
            String[] status = super.gets("sheet4.STATUS");
            
            try 
            {
                super.conn.begin();
                
                deleteCert();
                
                for (int i = 0; i < status.length; i++) 
                {
                    if (IBSheet7Utils.equalStatusInsert(status[i])) 
                    {
                        success = saveCert(IBSheet7Utils.getIBSheet7SqlParams("SHEET4", params, i));
                    }
                }
                
                
                if(success == true)
                {
                    deleteFinance();
                    success = saveFinance(params);
                }
                
                super.storage.setSuccess(success);
                storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
            } 
            catch (Exception e) 
            {
                //System.out.println("SAVE_CRET_OUT===>" + e);
                super.conn.setRollback();
                super.storage.setSuccess(false);
                throw new Exception(e);
                
            } finally {
                super.conn.close();
            }
        }
		
            
	}
	
	
	/**
	 * 회사정보 저장
	 * @param params
	 * @return
	 * @throws Exception
	 */
	private boolean updateInfo(ValueObject params) throws Exception
    {
        
        Persistent persistent = null;
        StringBuffer sqlstr = new StringBuffer();
        
        
        try{
            
            conn.begin();
            persistent = new PersistentImpl(super.conn.getConnection());
            
           
            sqlstr.append("     UPDATE SUPP_INFO SET            \n")
                   .append("           HEAD_CORP_REG_N = ?           \n")
                   .append("          ,COPR_NO = ?           \n")
                   .append("          ,SUB_PLACE_NO = ?           \n")
                   .append("          ,CORP_KOR = ?           \n")
                   .append("          ,REP_NAME = ?           \n")
                   .append("          ,CORP_STS = ?           \n")
                   .append("          ,BIZ_FORM = ?           \n")
                   .append("          ,CORP_DIV_CD = ?           \n")
                   .append("          ,ESTA_DATE = ?           \n")
                   .append("          ,CORP_TEL = ?           \n")
                   .append("          ,CORP_FAX = ?           \n")
                   .append("          ,CORP_SCALE = ?           \n")
                   .append("          ,POST_NO = ?                     \n")
                   .append("          ,ADDRESS = ?                  \n")
                   .append("          ,PLACE_POST_NO = ?           \n")
                   .append("          ,PLACE_ADDRESS = ?        \n")
                   .append("          ,TAX_ADDR_CD = ?              \n")
		           .append("          ,BANK_CD = ?           \n")
		           .append("          ,BANK_NM = ?           \n")
		           .append("          ,BANK_ACCT = ?           \n");
                   if(params.get("job_div").equals("P"))
                   {
                       sqlstr.append("          ,FACTOR_CD = ?              \n");
                       sqlstr.append("          ,MFTR_DIV_CD = ?              \n");
                   }
            
           sqlstr.append("          ,UPD_BY = ?                       \n")
                   .append("          ,UPD_DATE = sysdate           \n")
                   .append("      WHERE CORP_ID = ?                 \n");
            
            
            persistent.setStatement(sqlstr.toString());
            persistent.addParameter(params.get("head_corp_reg_n"));
            persistent.addParameter(params.get("copr_no"));
            persistent.addParameter(params.get("sub_place_no"));
            persistent.addParameter(params.get("corp_kor"));
            persistent.addParameter(params.get("rep_name"));
            persistent.addParameter(params.get("corp_sts"));
            persistent.addParameter(params.get("biz_form"));
            persistent.addParameter(params.get("corp_div_cd"));
            persistent.addParameter(params.get("esta_date"));
            persistent.addParameter(params.get("corp_tel"));
            persistent.addParameter(params.get("corp_fax"));
            persistent.addParameter(params.get("corp_scale"));
            persistent.addParameter(params.get("post_no_1") + "" + params.get("post_no_2"));
            persistent.addParameter(params.get("address"));
            persistent.addParameter(params.get("place_post_no_1") + "" + params.get("place_post_no_2"));
            persistent.addParameter(params.get("place_address"));
            persistent.addParameter(params.get("tax_addr_cd"));
            persistent.addParameter(params.get("bank_cd").trim());
            persistent.addParameter(params.get("bank_nm").trim());
            persistent.addParameter(params.get("bank_acct").trim());
            
            if(params.get("job_div").equals("P"))
            {
                persistent.addParameter(params.get("factor_cd"));
                persistent.addParameter(params.get("mftr_div_cd"));
            }
            
            persistent.addParameter(storage.getUser().get("acct_id"));
            persistent.addParameter(params.get("corp_id"));
            
            WAFLogger.debug(persistent.getParameters());
            persistent.execute();
            persistent.clearParameters();
            
            return true;
            
            
        } catch(Exception e) {
            //System.out.println("updateInfo====>" + e);
            e.printStackTrace();
            conn.setRollback();
            throw e;
            
        }
        
        finally {
            super.conn.end();
        }
    }
	
	/**
	 * 담당자 정보 업데이트
	 * @param params
	 * @return
	 * @throws Exception
	 */
	private boolean updateChage(ValueObject params) throws Exception
    {
        
        Persistent persistent = null;
        StringBuffer sqlstr = new StringBuffer();
        
        
        try{
            
            conn.begin();
            persistent = new PersistentImpl(super.conn.getConnection());
            
            
            sqlstr.append("     UPDATE SUPP_CHARGE SET          \n")
                   .append("             USER_ID = ?                    \n")
                   //.append("         , PASSWD = ?                    \n")2016.8.1 
                   .append("           , USER_NAME = ?                 \n")
                   .append("           , DIVISION = ?                   \n")
                   .append("           , POSITION = ?                   \n")
                   .append("           , TEL_NUM = ?                     \n")
                   .append("           , FAX_NUM = ?                    \n")
                   .append("           , HP1 = ?                        \n")
                   .append("           , HP2 = ?                         \n")
                   .append("           , HP3 = ?                        \n")
                   .append("           , EMAIL = ?                        \n")
                   .append("           , NOTE = ?                        \n")
                   .append("           , DEFAULT_YN = ?                        \n") //담당자구분
                   .append("           , UPD_BY = ?                      \n")
                   .append("           , UPD_DATE = SYSDATE        \n")
                   .append("         WHERE CORP_ID = ?               \n")
                   .append("             AND CHARGE_SEQ = ?         \n");
            
            
            persistent.setStatement(sqlstr.toString());
            persistent.addParameter(params.get("user_id"));
            //persistent.addParameter(params.get("passwd"));
            persistent.addParameter(params.get("user_name"));
            persistent.addParameter(params.get("division"));
            persistent.addParameter(params.get("position"));
            persistent.addParameter(params.get("tel_num"));
            persistent.addParameter(params.get("fax_num"));
            persistent.addParameter(params.get("NOTE"));
            persistent.addParameter(params.get("h_phon_1"));
            persistent.addParameter(params.get("h_phon_2"));
            persistent.addParameter(params.get("h_phon_3"));
            persistent.addParameter(params.get("email"));
            persistent.addParameter("Y"); //담당자 구분
            persistent.addParameter(storage.getUser().get("acct_id"));
            persistent.addParameter(params.get("corp_id"));
            persistent.addParameter(params.get("charge_seq"));
            
            WAFLogger.debug(sqlstr.toString());
            WAFLogger.debug(persistent.getParameters());
            persistent.execute();
            persistent.clearParameters();
            
            return true;
            
            
        } catch(Exception e) {
//          e.printStackTrace();
            WAFLogger.error(this.getClass().getName() + " --> saveData() : " + e.getMessage());
            WAFLogger.error("SQL : " + persistent.toString());
            WAFLogger.error(e);
            conn.setRollback();
            throw e;
            
        }
        
        finally {
            super.conn.end();
        }
    }
	
	
	private void deleteData() throws Exception {
	    
	    Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        try {
            
            conn.begin();
            persistent = new PersistentImpl(super.conn.getConnection());
            
            sql.append("   DELETE FROM SUPP_PUR_ITEM WHERE CORP_ID = ?      \n");
            
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(params.get("corp_id"));
            
            
            persistent.execute();
            persistent.clearParameters();
            
        } catch(Exception e) {
            //System.out.println("deleteData====>" + e);
            e.printStackTrace();
            conn.setRollback();
            throw e;
            
        }
        
        finally {
            super.conn.end();
        }
            
	}
	
	
	private void deleteData2() throws Exception {
        
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        try {
            
            conn.begin();
            persistent = new PersistentImpl(super.conn.getConnection());
            
            sql.append("   DELETE FROM SUPP_OUT_ITEM WHERE CORP_ID = ?      \n");
            
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(params.get("corp_id"));
            
            persistent.execute();
            persistent.clearParameters();
            
        } catch(Exception e) {
            //System.out.println("deleteData2====>" + e);
            e.printStackTrace();
            conn.setRollback();
            throw e;
            
        }
        
        finally {
            super.conn.end();
        }
            
    }
	
	private void deleteData3() throws Exception {
        
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        try {
            
            conn.begin();
            persistent = new PersistentImpl(super.conn.getConnection());
            
            sql.append("   DELETE FROM SUPP_OUT_MAIN WHERE CORP_ID = ?      \n");
            
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(params.get("corp_id"));
            
            persistent.execute();
            persistent.clearParameters();
            
        } catch(Exception e) {
            //System.out.println("deleteData2====>" + e);
            e.printStackTrace();
            conn.setRollback();
            throw e;
            
        }
        
        finally {
            super.conn.end();
        }
            
    }
	

	private boolean saveData(ValueObject sqlParams) throws Exception {
	    Persistent persistent = null;
	    StringBuffer sql = new StringBuffer();
        
        
        try {
            
            conn.begin();
            persistent = new PersistentImpl(super.conn.getConnection());
            
            sql.append("    INSERT INTO SUPP_PUR_ITEM          \n ");
            sql.append("    (                                           \n ");
            sql.append("          CORP_ID                                   \n ");
            sql.append("        , KIND_SMALL                             \n ");
            sql.append("        , REPRE_YN                   \n ");
            sql.append("        , CRE_BY                   \n ");
            sql.append("        , CRE_DATE                   \n ");
            sql.append("        ) VALUES (                          \n ");
            sql.append("          ?                                       \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("        ,SYSDATE                          \n ");
            sql.append("        )                                       \n ");
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(params.get("corp_id"));
            persistent.addParameter(sqlParams.get("ITEM_CODE"));
            persistent.addParameter(sqlParams.get("MAIN_ITEM").equals("1") ? "Y" : "N");
            persistent.addParameter(storage.getUser().get("acct_id"));
            
            WAFLogger.debug(persistent.getParameters());
            persistent.execute();
            persistent.clearParameters();
            
            return true;
        } catch(Exception e) {
//          e.printStackTrace();
            WAFLogger.error(this.getClass().getName() + " --> saveData() : " + e.getMessage());
            WAFLogger.error("SQL : " + persistent.toString());
            WAFLogger.error(e);
            conn.setRollback();
            throw e;
            
        }
        
        finally {
            super.conn.end();
        }
    }
	
	private boolean saveData2(ValueObject sqlParams) throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        
        try {
            
            conn.begin();
            persistent = new PersistentImpl(super.conn.getConnection());
            
            sql.append("    INSERT INTO SUPP_OUT_ITEM          \n ");
            sql.append("    (                                           \n ");
            sql.append("          CORP_ID                                   \n ");
            sql.append("        , OUT_ITEM_CD                             \n ");
            sql.append("        , REPRE_YN                   \n ");
            sql.append("        , CRE_BY                   \n ");
            sql.append("        , CRE_DATE                   \n ");
            sql.append("        ) VALUES (                          \n ");
            sql.append("          ?                                       \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("        ,SYSDATE                          \n ");
            sql.append("        )                                       \n ");
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(params.get("corp_id"));
            persistent.addParameter(sqlParams.get("ITEM_CODE"));
            persistent.addParameter(sqlParams.get("MAIN_ITEM").equals("1") ? "Y" : "N");
            persistent.addParameter(storage.getUser().get("acct_id"));
            
            WAFLogger.debug(persistent.getParameters());
            persistent.execute();
            persistent.clearParameters();
            
            return true;
        } catch(Exception e) {
//          e.printStackTrace();
            WAFLogger.error(this.getClass().getName() + " --> saveData() : " + e.getMessage());
            WAFLogger.error("SQL : " + persistent.toString());
            WAFLogger.error(e);
            conn.setRollback();
            throw e;
            
        }
        
        finally {
            super.conn.end();
        }
    }
	
	
	
	
	private void deleteDeliresult() throws Exception {
	    Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        try {
            
            conn.begin();
            persistent = new PersistentImpl(super.conn.getConnection());
            
            sql.append("   DELETE FROM SUPP_PUR_DELIRESULT WHERE CORP_ID = ?      \n");
            
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(params.get("corp_id"));
            
            
            persistent.execute();
            persistent.clearParameters();
            
        } catch(Exception e) {
            //System.out.println("deleteData====>" + e);
            e.printStackTrace();
            conn.setRollback();
            throw e;
            
        }
        
        finally {
            super.conn.end();
        }
	}
	
	
	private boolean saveDeliresult(ValueObject sqlParams) throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        
        try {
            
            conn.begin();
            persistent = new PersistentImpl(super.conn.getConnection());
            
            sql.append("    INSERT INTO SUPP_PUR_DELIRESULT          \n ");
            sql.append("    (                                           \n ");
            sql.append("          CORP_ID                                   \n ");
            sql.append("        , SEQ                             \n ");
            sql.append("        , DELI_CORP_NM                   \n ");
            sql.append("        , DELI_CORP_NO                   \n ");
            sql.append("        , ITEM_NM                      \n ");
            sql.append("        , CONT_AMT                      \n ");
            sql.append("        , QTY                      \n ");
            sql.append("        , STD                      \n ");
            sql.append("        , DELI_START_DY                      \n ");
            sql.append("        , DELI_END_DY                      \n ");
            sql.append("        , CREDIT_YN                      \n ");
            sql.append("        , CRE_BY                      \n ");
            sql.append("        , CRE_DATE                      \n ");
            sql.append("        , UPD_BY                      \n ");
            sql.append("        , UPD_DATE                      \n ");
            sql.append("        ) VALUES (                          \n ");
            sql.append("          ?                                       \n ");
            sql.append("         ,SUPP_PUR_DELIRESULT_S.nextval                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,SYSDATE                          \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,SYSDATE                          \n ");
            sql.append("        )                                       \n ");
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(params.get("corp_id"));
            persistent.addParameter(sqlParams.get("DELI_CORP_NM"));
            persistent.addParameter(sqlParams.get("DELI_CORP_NO"));
            persistent.addParameter(sqlParams.get("ITEM_NM"));
            persistent.addParameter(sqlParams.get("CONT_AMT"));
            persistent.addParameter(sqlParams.get("QTY"));
            persistent.addParameter(sqlParams.get("STD"));
            persistent.addParameter(sqlParams.get("DELI_START_DY"));
            persistent.addParameter(sqlParams.get("DELI_END_DY"));
            persistent.addParameter(params.get("credit_yn"));
            
            
            persistent.addParameter(storage.getUser().get("acct_id"));
            persistent.addParameter(storage.getUser().get("acct_id"));
            
            //System.out.println(persistent.getParameters());
            //System.out.println(sql.toString());
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
        } catch(Exception e) {
            e.printStackTrace();
            //System.out.println("savePrize===>" + e);
            conn.setRollback();
            throw e;
            
        }
        
        finally {
            super.conn.end();
        }
    }
	
	
	private boolean saveCert(ValueObject sqlParams) throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        
        try {
            
            conn.begin();
            persistent = new PersistentImpl(super.conn.getConnection());
            
            sql.append("    INSERT INTO SUPP_CERT          \n ");
            sql.append("    (                                           \n ");
            sql.append("          CORP_ID                                   \n ");
            sql.append("        , CERT_SEQ                             \n ");
            sql.append("        , CERT_DIV_CD                   \n ");
            sql.append("        , CERT_NO                   \n ");
            sql.append("        , CERT_CTNT                      \n ");
            sql.append("        , CERT_SCOPE                      \n ");
            sql.append("        , CRE_GOV                      \n ");
            sql.append("        , EXP_STA_DY                      \n ");
            sql.append("        , EXP_END_DY                      \n ");
            sql.append("        , CREDIT_YN                      \n ");
            sql.append("        , CRE_BY                      \n ");
            sql.append("        , CRE_DATE                      \n ");
            sql.append("        ) VALUES (                          \n ");
            sql.append("          ?                                       \n ");
            sql.append("         ,SUPP_CERT_S.nextval           \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,SYSDATE                          \n ");
            sql.append("        )                                       \n ");
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(params.get("corp_id"));
            persistent.addParameter(sqlParams.get("CERT_DIV_CD"));
            persistent.addParameter(sqlParams.get("CERT_NO"));
            persistent.addParameter(sqlParams.get("CERT_CTNT"));
            persistent.addParameter(sqlParams.get("CERT_SCOPE"));
            persistent.addParameter(sqlParams.get("CRE_GOV"));
            persistent.addParameter(sqlParams.get("EXP_STA_DY"));
            persistent.addParameter(sqlParams.get("EXP_END_DY"));
            persistent.addParameter(params.get("credit_yn"));
            
            
            persistent.addParameter(storage.getUser().get("acct_id"));
            
            //System.out.println(persistent.getParameters());
            //System.out.println(sql.toString());
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
        } catch(Exception e) {
            e.printStackTrace();
            //System.out.println("saveCert===>" + e);
            conn.setRollback();
            throw e;
            
        }
        
        finally {
            super.conn.end();
        }
    }
	
	
	private void deleteCert() throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        try {
            
            conn.begin();
            persistent = new PersistentImpl(super.conn.getConnection());
            
            sql.append("   DELETE FROM SUPP_CERT WHERE CORP_ID = ?      \n");
            
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(params.get("corp_id"));
            
            
            persistent.execute();
            persistent.clearParameters();
            
        } catch(Exception e) {
            //System.out.println("deleteCert====>" + e);
            e.printStackTrace();
            conn.setRollback();
            throw e;
            
        }
        
        finally {
            super.conn.end();
        }
    }
	
	
    private boolean savePrize(ValueObject sqlParams) throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        
        try {
            
            conn.begin();
            persistent = new PersistentImpl(super.conn.getConnection());
            
            sql.append("    INSERT INTO SUPP_PRIZE          \n ");
            sql.append("    (                                           \n ");
            sql.append("          CORP_ID                                   \n ");
            sql.append("        , PRZ_SEQ                             \n ");
            sql.append("        , PRZ_DY                   \n ");
            sql.append("        , PRZ_NM                   \n ");
            sql.append("        , PRZ_GIVER                      \n ");
            sql.append("        , PRZ_INFO                      \n ");
            sql.append("        , CREDIT_YN                      \n ");
            sql.append("        , CRE_BY                      \n ");
            sql.append("        , CRE_DATE                      \n ");
            sql.append("        ) VALUES (                          \n ");
            sql.append("          ?                                       \n ");
            sql.append("         ,SUPP_PRIZE_S.nextval          \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,SYSDATE                          \n ");
            sql.append("        )                                       \n ");
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(params.get("corp_id"));
            persistent.addParameter(sqlParams.get("PRZ_DY"));
            persistent.addParameter(sqlParams.get("PRZ_NM"));
            persistent.addParameter(sqlParams.get("PRZ_GIVER"));
            persistent.addParameter(sqlParams.get("PRZ_INFO"));
            persistent.addParameter(params.get("credit_yn"));
            persistent.addParameter(storage.getUser().get("acct_id"));
            
            //System.out.println(persistent.getParameters());
            //System.out.println(sql.toString());
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
        } catch(Exception e) {
            e.printStackTrace();
            //System.out.println("savePrize===>" + e);
            conn.setRollback();
            throw e;
            
        }
        
        finally {
            super.conn.end();
        }
    }
    
    
    
    private void deletePrize() throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        try {
            
            conn.begin();
            persistent = new PersistentImpl(super.conn.getConnection());
            
            sql.append("   DELETE FROM SUPP_PRIZE WHERE CORP_ID = ?      \n");
            
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(params.get("corp_id"));
            
            
            persistent.execute();
            persistent.clearParameters();
            
        } catch(Exception e) {
            //System.out.println("deletePrize====>" + e);
            e.printStackTrace();
            conn.setRollback();
            throw e;
            
        }
        
        finally {
            super.conn.end();
        }
    }
    
    
    
    
    
    private boolean savePatent(ValueObject sqlParams) throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        
        try {
            
            conn.begin();
            persistent = new PersistentImpl(super.conn.getConnection());
            
            sql.append("    INSERT INTO SUPP_PATENT          \n ");
            sql.append("    (                                           \n ");
            sql.append("          CORP_ID                                   \n ");
            sql.append("        , PAT_SEQ                             \n ");
            sql.append("        , PAT_CD                   \n ");
            sql.append("        , PAT_DY                   \n ");
            sql.append("        , PAT_INFO                      \n ");
            sql.append("        , CREDIT_YN                      \n ");
            sql.append("        , CRE_BY                      \n ");
            sql.append("        , CRE_DATE                      \n ");
            sql.append("        ) VALUES (                          \n ");
            sql.append("          ?                                       \n ");
            sql.append("         ,SUPP_PATENT_S.nextval          \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,SYSDATE                          \n ");
            sql.append("        )                                       \n ");
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(params.get("corp_id"));
            persistent.addParameter(sqlParams.get("PAT_CD"));
            persistent.addParameter(sqlParams.get("PAT_DY"));
            persistent.addParameter(sqlParams.get("PAT_INFO"));
            persistent.addParameter(params.get("credit_yn"));
            persistent.addParameter(storage.getUser().get("acct_id"));
            
            //System.out.println(persistent.getParameters());
            //System.out.println(sql.toString());
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
        } catch(Exception e) {
            e.printStackTrace();
            //System.out.println("savePatent===>" + e);
            conn.setRollback();
            throw e;
            
        }
        
        finally {
            super.conn.end();
        }
    }
    
    
    private void deletePatent() throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        try {
            
            conn.begin();
            persistent = new PersistentImpl(super.conn.getConnection());
            
            sql.append("   DELETE FROM SUPP_PATENT WHERE CORP_ID = ?      \n");
            
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(params.get("corp_id"));
            
            
            persistent.execute();
            persistent.clearParameters();
            
        } catch(Exception e) {
            //System.out.println("deltePatent====>" + e);
            e.printStackTrace();
            conn.setRollback();
            throw e;
            
        }
        
        finally {
            super.conn.end();
        }
    }
    
    
    
    
    
    private boolean saveConResult(ValueObject sqlParams) throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        
        //System.out.println(sqlParams.get("CONT_DY"));
        
        try {
            
            conn.begin();
            persistent = new PersistentImpl(super.conn.getConnection());
            
            sql.append("    INSERT INTO SUPP_CONT_RESULT          \n ");
            sql.append("    (                                           \n ");
            sql.append("          CORP_ID                                   \n ");
            sql.append("        , CONT_SEQ                             \n ");
            sql.append("        , CONT_NM                   \n ");
            sql.append("        , ORDR_ORG_NM                   \n ");
            sql.append("        , ORDR_NM                      \n ");
            sql.append("        , CONT_AMT                      \n ");
            sql.append("        , CONT_DY                      \n ");
            sql.append("        , CONT_STA_DY                      \n ");
            sql.append("        , CONT_END_DY                      \n ");
            sql.append("        , CREDIT_YN                      \n ");
            sql.append("        , CRE_BY                      \n ");
            sql.append("        , CRE_DATE                      \n ");
            sql.append("        , ETEC_YN                      \n ");
            sql.append("        ) VALUES (                          \n ");
            sql.append("          ?                                       \n ");
            sql.append("         ,SUPP_CONT_RESULT_S.nextval          \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,SYSDATE                          \n ");
            sql.append("         ,?                                      \n ");
            sql.append("        )                                       \n ");
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(params.get("corp_id"));
            persistent.addParameter(sqlParams.get("CONT_NM"));
            persistent.addParameter(sqlParams.get("ORDR_ORG_NM"));
            persistent.addParameter(sqlParams.get("ORDR_NM"));
            persistent.addParameter(sqlParams.get("CONT_AMT"));
            persistent.addParameter(sqlParams.get("CONT_DY").replace("-", ""));
            persistent.addParameter(sqlParams.get("CONT_STA_DY"));
            persistent.addParameter(sqlParams.get("CONT_END_DY"));
            persistent.addParameter(params.get("credit_yn"));
            persistent.addParameter(storage.getUser().get("acct_id"));
            persistent.addParameter(sqlParams.get("ETEC_YN"));
            //System.out.println(persistent.getParameters());
            //System.out.println(sql.toString());
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
        } catch(Exception e) {
            e.printStackTrace();
            //System.out.println("saveConResult===>" + e);
            conn.setRollback();
            throw e;
            
        }
        
        finally {
            super.conn.end();
        }
    }
    
    
    private void deleteConResult() throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        try {
            
            conn.begin();
            persistent = new PersistentImpl(super.conn.getConnection());
            
            sql.append("   DELETE FROM SUPP_CONT_RESULT WHERE CORP_ID = ?      \n");
            
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(params.get("corp_id"));
            
            
            persistent.execute();
            persistent.clearParameters();
            
        } catch(Exception e) {
            //System.out.println("deleteConResult====>" + e);
            e.printStackTrace();
            conn.setRollback();
            throw e;
            
        }
        
        finally {
            super.conn.end();
        }
    }
    
    
    
    private boolean saveConAbillty(ValueObject sqlParams) throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        
        try {
            
            conn.begin();
            persistent = new PersistentImpl(super.conn.getConnection());
            
            sql.append("    INSERT INTO SUPP_CON_ABILLTY          \n ");
            sql.append("    (                                           \n ");
            sql.append("          CORP_ID                                   \n ");
            sql.append("        , CON_SEQ                             \n ");
            sql.append("        , BASE_YEAR                   \n ");
            sql.append("        , LIC_NM                   \n ");
            sql.append("        , LIC_NO                      \n ");
            sql.append("        , CON_ABI_AMT                      \n ");
            sql.append("        , AREA_LANK                      \n ");
            sql.append("        , AREA_ALL_LANK                      \n ");
            sql.append("        , NATION_LANK                      \n ");
            sql.append("        , NATION_ALL_LANK                      \n ");
            sql.append("        , CREDIT_YN                      \n ");
            sql.append("        , CRE_BY                      \n ");
            sql.append("        , CONREYR                      \n ");
            sql.append("        , CRE_DATE                      \n ");
            sql.append("        ) VALUES (                          \n ");
            sql.append("          ?                                       \n ");
            sql.append("         ,SUPP_CON_ABILLTY_S.nextval          \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,SYSDATE                          \n ");
            sql.append("        )                                       \n ");
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(params.get("corp_id"));
            persistent.addParameter(sqlParams.get("BASE_YEAR"));
            persistent.addParameter(sqlParams.get("LIC_NM"));
            persistent.addParameter(sqlParams.get("LIC_NO"));
            persistent.addParameter(sqlParams.get("CON_ABI_AMT"));
            persistent.addParameter(sqlParams.get("AREA_LANK"));
            persistent.addParameter(sqlParams.get("AREA_ALL_LANK"));
            persistent.addParameter(sqlParams.get("NATION_LANK"));
            persistent.addParameter(sqlParams.get("NATION_ALL_LANK"));
            persistent.addParameter(params.get("credit_yn"));
            persistent.addParameter(storage.getUser().get("acct_id"));
            persistent.addParameter(sqlParams.get("CONREYR"));
            
            //System.out.println(persistent.getParameters());
            //System.out.println(sql.toString());
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
        } catch(Exception e) {
            e.printStackTrace();
            //System.out.println("saveConResult===>" + e);
            conn.setRollback();
            throw e;
            
        }
        
        finally {
            super.conn.end();
        }
    }
    
    
    private void deleteConAbillty() throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        try {
            
            conn.begin();
            persistent = new PersistentImpl(super.conn.getConnection());
            
            sql.append("   DELETE FROM SUPP_CON_ABILLTY WHERE CORP_ID = ?      \n");
            
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(params.get("corp_id"));
            
            
            persistent.execute();
            persistent.clearParameters();
            
        } catch(Exception e) {
            //System.out.println("deleteConAbillty====>" + e);
            e.printStackTrace();
            conn.setRollback();
            throw e;
            
        }
        
        finally {
            super.conn.end();
        }
    }
    
    
    private boolean saveTechMan(ValueObject sqlParams) throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        
        try {
            
            conn.begin();
            persistent = new PersistentImpl(super.conn.getConnection());
            
            sql.append("    INSERT INTO SUPP_TECH_MAN          \n ");
            sql.append("    (                                           \n ");
            sql.append("          CORP_ID                                   \n ");
            sql.append("        , SEQ                             \n ");
            sql.append("        , NM                   \n ");
            sql.append("        , BIRTHDAY                   \n ");
            sql.append("        , POSITION                      \n ");
            sql.append("        , QUAL_ITEM_CLASS                      \n ");
            sql.append("        , REG_NO                      \n ");
            sql.append("        , FIELD                      \n ");
            sql.append("        , TECH_CLASS                      \n ");
            sql.append("        , CREDIT_YN                      \n ");
            sql.append("        , CRE_BY                      \n ");
            sql.append("        , CRE_DATE                      \n ");
            sql.append("        ) VALUES (                          \n ");
            sql.append("          ?                                       \n ");
            sql.append("         ,SUPP_TECH_MAN_S.nextval          \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,SYSDATE                          \n ");
            sql.append("        )                                       \n ");
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(params.get("corp_id"));
            persistent.addParameter(sqlParams.get("NM"));
            persistent.addParameter(sqlParams.get("BIRTHDAY"));
            persistent.addParameter(sqlParams.get("POSITION"));
            persistent.addParameter(sqlParams.get("QUAL_ITEM_CLASS"));
            persistent.addParameter(sqlParams.get("REG_NO"));
            persistent.addParameter(sqlParams.get("FIELD"));
            persistent.addParameter(sqlParams.get("TECH_CLASS"));
            persistent.addParameter(params.get("credit_yn"));
            persistent.addParameter(storage.getUser().get("acct_id"));
            
            //System.out.println(persistent.getParameters());
            //System.out.println(sql.toString());
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
        } catch(Exception e) {
            e.printStackTrace();
            //System.out.println("saveTechMan===>" + e);
            conn.setRollback();
            throw e;
            
        }
        
        finally {
            super.conn.end();
        }
    }
    
    
    private void deleteTechMan() throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        try {
            
            conn.begin();
            persistent = new PersistentImpl(super.conn.getConnection());
            
            sql.append("   DELETE FROM SUPP_TECH_MAN WHERE CORP_ID = ?      \n");
            
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(params.get("corp_id"));
            
            
            persistent.execute();
            persistent.clearParameters();
            
        } catch(Exception e) {
            //System.out.println("deleteTechMan====>" + e);
            e.printStackTrace();
            conn.setRollback();
            throw e;
            
        }
        
        finally {
            super.conn.end();
        }
    }
    
    
    
    
    
    private boolean saveFinance(ValueObject sqlParams) throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        
        try {
            
            conn.begin();
            persistent = new PersistentImpl(super.conn.getConnection());
            
            sql.append("    INSERT INTO SUPP_FINANCE          \n ");
            sql.append("    (                                           \n ");
            sql.append("          CORP_ID                                   \n ");
            sql.append("        , BASE_YEAR                             \n ");
            sql.append("        , CAPITAL_AMT                   \n ");
            sql.append("        , FLOAT_ASSET                   \n ");
            sql.append("        , FLOAT_DEBT                      \n ");
            sql.append("        , OWN_CAP                      \n ");
            sql.append("        , TOT_CAP                      \n ");
            sql.append("        , CUR_PROFIT                      \n ");
            sql.append("        , GROSS_ASSET                      \n ");
            sql.append("        , SALES_AMT                      \n ");
            sql.append("        , CUR_SALES_AMT                      \n ");
            sql.append("        , PRI_SALES_AMT                      \n ");
            sql.append("        , CREDIT_YN                      \n ");
            sql.append("        , CRE_BY                      \n ");
            sql.append("        , CRE_DATE                      \n ");
            sql.append("        ) VALUES (                          \n ");
            sql.append("          ?                                       \n ");
            sql.append("         ,?                                   \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,SYSDATE                          \n ");
            sql.append("        )                                       \n ");
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(params.get("corp_id"));
            persistent.addParameter(params.get("base_year"));
            persistent.addParameter(params.get("capital_amt").replace(",", ""));
            persistent.addParameter(params.get("float_asset").replace(",", ""));
            persistent.addParameter(params.get("float_debt").replace(",", ""));
            persistent.addParameter(params.get("own_cap").replace(",", ""));
            persistent.addParameter(params.get("tot_cap").replace(",", ""));
            persistent.addParameter(params.get("cur_profit").replace(",", ""));
            persistent.addParameter(params.get("gross_asset").replace(",", ""));
            persistent.addParameter(params.get("sales_amt").replace(",", ""));
            persistent.addParameter(params.get("cur_sales_amt").replace(",", ""));
            persistent.addParameter(params.get("pri_sales_amt").replace(",", ""));
            persistent.addParameter(params.get("credit_yn"));
            persistent.addParameter(storage.getUser().get("acct_id"));
            
            //System.out.println(persistent.getParameters());
            //System.out.println(sql.toString());
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
        } catch(Exception e) {
            e.printStackTrace();
            //System.out.println("saveFinance===>" + e);
            conn.setRollback();
            throw e;
            
        }
        
        finally {
            super.conn.end();
        }
    }
    
    
    private void deleteFinance() throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        try {
            
            conn.begin();
            persistent = new PersistentImpl(super.conn.getConnection());
            
            sql.append("   DELETE FROM SUPP_FINANCE WHERE CORP_ID = ?      \n");
            
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(params.get("corp_id"));
            
            
            persistent.execute();
            persistent.clearParameters();
            
        } catch(Exception e) {
            //System.out.println("delteFinance====>" + e);
            e.printStackTrace();
            conn.setRollback();
            throw e;
            
        }
        
        finally {
            super.conn.end();
        }
    }
    
    
    private boolean saveOutMain(ValueObject sqlParams) throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        
        try {
            
            conn.begin();
            persistent = new PersistentImpl(super.conn.getConnection());
            
            sql.append("    INSERT INTO SUPP_OUT_MAIN          \n ");
            sql.append("    (                                           \n ");
            sql.append("          CORP_ID                                   \n ");
            sql.append("        , OUT_MAIN_CD                             \n ");
            sql.append("        , CRE_BY                   \n ");
            sql.append("        , CRE_DATE                   \n ");
            sql.append("        ) VALUES (                          \n ");
            sql.append("          ?                                       \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,?                                      \n ");
            sql.append("        ,SYSDATE                          \n ");
            sql.append("        )                                       \n ");
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(params.get("corp_id"));
            persistent.addParameter(params.get("out_main_code"));
            persistent.addParameter(storage.getUser().get("acct_id"));
            
            WAFLogger.debug(persistent.getParameters());
            persistent.execute();
            persistent.clearParameters();
            
            return true;
        } catch(Exception e) {
            e.printStackTrace();
            //System.out.println("saveOutMain====>" + e);
            conn.setRollback();
            throw e;
            
        }
        
        finally {
            super.conn.end();
        }
    }
    
	
	
}