/**
 * @(#)file    PuSupplierBiz.java
 * @(#)author  이성민
 * @(#)version 1.0
 * @(#)date    2014.06.25
 *
 * Copyright (c) www.udapsoft.co.kr, Inc.
 * All rights reserved.
 * This software is the proprietary information of udapsoft Inc.
 */
package kr.co.udapsoft.ebid.buyer.supplier.purchase.biz;



import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

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.base.WAFMessages;
import kr.co.hsnc.common.logger.Logger;
import kr.co.hsnc.common.sql.Row;
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 kr.co.udapsoft.common.sender.MessageSend;
import kr.co.udapsoft.common.sender.SmtpAuth;
import kr.co.udapsoft.ebid.buyer.common.file.FileManager;

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 PuSupplierSaveBiz extends Biz {

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

	/* (non-Javadoc)
	 * @see kr.co.hwenc.system.Biz#doBiz()
	 */
	public void doBiz() throws Exception {
		WAFLogger.debug("P : PuSupplierSaveBiz");
		WAFLogger.debug("EVENT : "+storage.getEvent());
		
		if(storage.compareEvent("SAVE_DATA"))
        {
			saveData();
        }
        else if(storage.compareEvent("UPDATE_DATA2"))
        {
        	updateData2();
        }
		else if(storage.compareEvent("SAVE_DATA2"))
		{
			saveData2();
		}
		else if(storage.compareEvent("SAVE_DELIRESUT"))
        {
			saveDeliresut();
			
        }
		else if(storage.compareEvent("SAVE_CERT"))
        {
			saveCert();
        }
		else if(storage.compareEvent("SAVE_PRIZE"))
        {
			savePrize();
        }
		else if(storage.compareEvent("SAVE_PATENT"))
        {
			savePatent();
        }
		else if(storage.compareEvent("SAVE_CERT2"))
        {
			saveCert2();
        }		
		else if(storage.compareEvent("UPDATE_APPRV"))
		{
			updateApprv();
		}
		else if(storage.compareEvent("DELETE_DATA"))
        {
			deleteData();
        }
		else if(storage.compareEvent("SAVE_CHARGE"))
        {
			updateCharge();
        }
		else if(storage.compareEvent("FACTOR_CONFIRM"))
		{
			boolean success = updateFactorConfirm();
			super.storage.setSuccess(success);
		}
		else if(storage.compareEvent("SAVE_DELIRESUT_ADMIT"))
        {
			saveDeliresutAdmit();
        }
		else if(storage.compareEvent("SAVE_DELIRESUT_REJECT"))
        {
			saveDeliresutAdmit();	
        }
		else if(storage.compareEvent("SAVE_CERT_ADMIT"))
        {
			saveCertAdmit();
        }
		else if(storage.compareEvent("SAVE_CERT_REJECT"))
        {
			saveCertAdmit();
        }
	}
	
	private void saveData(){

	    boolean success = false;
	    boolean success2 = false;
	    conn.begin();
        try 
        {
        	Connection con = conn.getConnection();
        	
        	success = updateInfo(con, params);
        	success2 = update_apprv_charge(con, params);
    	    
    	    if(params.get("finance_gbn").equals(""))
    	    {
    	    	success = saveFinance(con, params);
    	    }
    	    else
    	    {
    	    	success = updateFinance(con, params);
    	    }
    	    
	        String[] status = super.gets("sheet2.STATUS");
	        
	        for (int i = 0; i < status.length; i++) 
            {
                ValueObject vo = IBSheet7Utils.getIBSheet7SqlParams("SHEET2", params, i);
	        	if (IBSheet7Utils.equalStatusInsert(status[i])) 
                {
                    success = saveItemData(con, vo);
                }
                
                if (IBSheet7Utils.equalStatusUpdate(status[i])) 
                {
                    success = updateItemData(con, vo);
                }
                
                if (IBSheet7Utils.equalStatusDelete(status[i])) 
                {
                    success = deleteItemData(con, vo);
                }
                updateMainItemData(con, vo);
            }
    	    
    	    if(success == true)
    	    {
    	        con.commit();
    	        super.storage.setSuccess(success);
                storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
                WAFLogger.debug("past_status : " + params.get("past_status"));
                if("00".equals(params.get("past_status"))){
	    	        if(params.get("p_status").equals("02") || params.get("p_status").equals("03"))
	    	        {
	    	        	//sendSMS_EMAIL();
	    	        }
                }
    	    }
        } catch (Exception e) {
			super.doException(e);
			super.storage.setDetailMessage(e);
			super.storage.setMessage(e.getMessage());
			super.storage.setSuccess(false);
			super.conn.setRollback();
		} finally {
			conn.end();
		} 
	    
	    
	}
	
	private void updateData2(){

		WAFLogger.debug("======================UPDATE_DATA2===========================");
        boolean success = false;
	    conn.begin();
        try 
        {
        	Connection con = conn.getConnection();
       
        	
        	
        	success = updateInfo(con, params);
        	WAFLogger.debug("==========1:" + success);
        	success = update_charge(con, params);
        	WAFLogger.debug("==========2:" + success);
             
             String[] status = super.gets("sheet2.STATUS");
             
             for (int i = 0; i < status.length; i++) 
             {
                 if (IBSheet7Utils.equalStatusInsert(status[i])) 
                 {
                	 WAFLogger.debug("==========3:" + success);
                	 success = saveItemData(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET2", params, i));
                	 
                 }
                 
                 if (IBSheet7Utils.equalStatusUpdate(status[i])) 
                 {
                	 WAFLogger.debug("==========4:" + success);
                	 success = updateItemData(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET2", params, i));
                 }
                 
                 if (IBSheet7Utils.equalStatusDelete(status[i])) 
                 {
                	 WAFLogger.debug("==========5:" + success);
                	 success = deleteItemData(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET2", params, i));
                 }
             }
             
             
             
             if(success == true)
             {
            	 con.commit();
            	 WAFLogger.debug("==========="+ params.get("p_status"));
            	 if("00".equals(params.get("past_status"))){
	                 if(params.get("p_status").equals("02") || params.get("p_status").equals("03"))
	                 {
	                	 //sendSMS_EMAIL();
	                 }
            	 }
             }
             
             WAFLogger.debug("==========6:" + success);

             super.storage.setSuccess(success);
             storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
        } catch (Exception e) {
			super.doException(e);
			super.storage.setDetailMessage(e);
			super.storage.setMessage(e.getMessage());
			super.storage.setSuccess(false);
			super.conn.setRollback();
		} finally {
			conn.end();
		} 
        	
       
	}
	private void saveData2(){

        boolean success = false;
        boolean success2 = false;
        
        String yyyymmdd = (new java.text.SimpleDateFormat ("yyyyMMdd")).format (new java.util.Date());
        params.set("user_id", yyyymmdd);
        
        
	    conn.begin();
        try 
        {
        	Connection con = conn.getConnection();
       
        	
        	
        	 success = save_info(con, params);
             success2 = save_charge(con, params);
             
             
             
             String[] status = super.gets("sheet2.STATUS");
             
             for (int i = 0; i < status.length; i++) 
             {
                 if (IBSheet7Utils.equalStatusInsert(status[i])) 
                 {
                     success2 = saveItemData(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET2", params, i));
                 }
                 
                 if (IBSheet7Utils.equalStatusUpdate(status[i])) 
                 {
                     success2 = updateItemData(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET2", params, i));
                 }
                 
                 if (IBSheet7Utils.equalStatusDelete(status[i])) 
                 {
                     success2 = deleteItemData(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET2", params, i));
                 }
             }
             
             
             if(success == true)
             {
            	 con.commit();
            	 if("00".equals(params.get("past_status"))){
	                 if(params.get("p_status").equals("02") || params.get("p_status").equals("03"))
	                 {
	                	 //sendSMS_EMAIL();
	                 }
            	 }
             }
             
             

             super.storage.setSuccess(success);
             storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
        } catch (Exception e) {
			super.doException(e);
			super.storage.setDetailMessage(e);
			super.storage.setMessage(e.getMessage());
			super.storage.setSuccess(false);
			super.conn.setRollback();
		} finally {
			conn.end();
		} 
        
       
	}
	
	private void saveDeliresut(){
		
        boolean success = false;
        
        String[] status = super.gets("sheet5.STATUS");
        
	    conn.begin();
        try 
        {
        	Connection con = conn.getConnection();
        
        	for (int i = 0; i < status.length; i++) 
            {
                if (IBSheet7Utils.equalStatusInsert(status[i])) 
                {
                    success = saveDeliresultData(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET5", params, i));
                }
                
                if (IBSheet7Utils.equalStatusUpdate(status[i])) 
                {
                    success = updateDeliresultData(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET5", params, i));
                }
                
                if (IBSheet7Utils.equalStatusDelete(status[i])) 
                {
                    success = deleteDeliresultData(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET5", params, i));
                }
            }

            super.storage.setSuccess(success);
            storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
        } catch (Exception e) {
			super.doException(e);
			super.storage.setDetailMessage(e);
			super.storage.setMessage(e.getMessage());
			super.storage.setSuccess(false);
			super.conn.setRollback();
		} finally {
			conn.end();
		} 
        
	}
	private void saveCert(){
		
		boolean success = false;
		
		String[] status = super.gets("sheet6.STATUS");
		
		conn.begin();
		try 
		{
			Connection con = conn.getConnection();
			

            for (int i = 0; i < status.length; i++) 
            {
                if (IBSheet7Utils.equalStatusInsert(status[i])) 
                {
                    success = saveCertData(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET6", params, i));
                }
                
                if (IBSheet7Utils.equalStatusUpdate(status[i])) 
                {
                    success = updateCertData(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET6", params, i));
                }
                
                if (IBSheet7Utils.equalStatusDelete(status[i])) 
                {
                    success = deleteCertData(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET6", params, i));
                }
            }

            super.storage.setSuccess(success);
            storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
		} catch (Exception e) {
			super.doException(e);
			super.storage.setDetailMessage(e);
			super.storage.setMessage(e.getMessage());
			super.storage.setSuccess(false);
			super.conn.setRollback();
		} finally {
			conn.end();
		} 
		
	}
	private void savePrize(){
		
		boolean success = false;
		
		String[] status = super.gets("sheet7.STATUS");
		
		conn.begin();
		try 
		{
			Connection con = conn.getConnection();
			
			
            for (int i = 0; i < status.length; i++) 
            {
                if (IBSheet7Utils.equalStatusInsert(status[i])) 
                {
                    success = savePrizeData(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET7", params, i));
                }
                
                if (IBSheet7Utils.equalStatusUpdate(status[i])) 
                {
                    success = updatePrizeData(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET7", params, i));
                }
                
                if (IBSheet7Utils.equalStatusDelete(status[i])) 
                {
                    success = deletePrizeData(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET7", params, i));
                }
            }

            super.storage.setSuccess(success);
            storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
		} catch (Exception e) {
			super.doException(e);
			super.storage.setDetailMessage(e);
			super.storage.setMessage(e.getMessage());
			super.storage.setSuccess(false);
			super.conn.setRollback();
		} finally {
			conn.end();
		} 
		
	}
	private void savePatent(){
		
		boolean success = false;
		
		String[] status = super.gets("sheet8.STATUS");
		
		conn.begin();
		try 
		{
			Connection con = conn.getConnection();
			
            for (int i = 0; i < status.length; i++) 
            {
                if (IBSheet7Utils.equalStatusInsert(status[i])) 
                {
                    success = savePatentData(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET8", params, i));
                }
                
                if (IBSheet7Utils.equalStatusUpdate(status[i])) 
                {
                    success = updatePatentData(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET8", params, i));
                }
                
                if (IBSheet7Utils.equalStatusDelete(status[i])) 
                {
                    success = deletePatentData(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET8", params, i));
                }
            }

            super.storage.setSuccess(success);
            storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
			
		} catch (Exception e) {
			super.doException(e);
			super.storage.setDetailMessage(e);
			super.storage.setMessage(e.getMessage());
			super.storage.setSuccess(false);
			super.conn.setRollback();
		} finally {
			conn.end();
		} 
		
	}
	
private void saveCert2(){
		
		boolean success = false;
		
		String[] status = super.gets("sheet9.STATUS");
		
		conn.begin();
		try 
		{
			Connection con = conn.getConnection();
			
			System.out.println("status.length : "+status.length);
            for (int i = 0; i < status.length; i++) 
            {
            	System.out.println("status["+i+"] : "+status[i]);
                if (IBSheet7Utils.equalStatusInsert(status[i])) 
                {
                    success = saveCert2Data(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET9", params, i));
                }
                
                if (IBSheet7Utils.equalStatusUpdate(status[i])) 
                {
                    success = updateCert2Data(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET9", params, i));
                }
                
                if (IBSheet7Utils.equalStatusDelete(status[i])) 
                {
                    success = deleteCert2Data(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET9", params, i));
                }
            }

            super.storage.setSuccess(success);
            storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
		} catch (Exception e) {
			super.doException(e);
			super.storage.setDetailMessage(e);
			super.storage.setMessage(e.getMessage());
			super.storage.setSuccess(false);
			super.conn.setRollback();
		} finally {
			conn.end();
		} 
		
	}
	
	private void updateApprv(){
		
		
		conn.begin();
		try 
		{
			Connection con = conn.getConnection();
			
		    
		    update_apprv_info(con, params);
		    update_apprv_charge(con, params);
		    
		} catch (Exception e) {
			super.doException(e);
			super.storage.setDetailMessage(e);
			super.storage.setMessage(e.getMessage());
			super.storage.setSuccess(false);
			super.conn.setRollback();
		} finally {
			conn.end();
		} 
		
	}
	
	private void deleteData(){
		
		
		conn.begin();
		try 
		{
			Connection con = conn.getConnection();
			
            delete_supp_item(con, params);
            
            delete_charge(con, params);
                
            delete_info(con, params);
			
		} catch (Exception e) {
			super.doException(e);
			super.storage.setDetailMessage(e);
			super.storage.setMessage(e.getMessage());
			super.storage.setSuccess(false);
			super.conn.setRollback();
		} finally {
			conn.end();
		} 
		
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	private boolean update_apprv_info(Connection con, ValueObject params) throws Exception
    {
        
        Persistent persistent = null;
        StringBuffer sqlstr = new StringBuffer();
        
        
        try{
            
            persistent = new PersistentImpl(con);
            
            
            sqlstr.append("     UPDATE SUPP_INFO SET              \n")
                   .append("          STATUS = ?                            \n")
                   .append("         ,UPD_BY = ?                                \n")
                   .append("         ,UPD_DATE = TO_CHAR(SYSDATE, 'YYYY-MM-DD')                            \n")
                   .append("     WHERE CORP_ID = ?               \n");
            
            
            persistent.setStatement(sqlstr.toString());
            persistent.addParameter(params.get("p_status").trim());
            persistent.addParameter(storage.getUser().get("acct_id").trim());
            persistent.addParameter(params.get("p_corp_id").trim());
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
            
            
        } catch(Exception e) {
        	throw e;
        }
    }
	
	private boolean update_apprv_charge(Connection con, ValueObject params) throws Exception
    {
        
        Persistent persistent = null;
        StringBuffer sqlstr = new StringBuffer();
        
        
        try{
            
            persistent = new PersistentImpl(con);
            
            
            sqlstr.append("     UPDATE SUPP_CHARGE SET              \n")
                   .append("          RIGHT_ID = ?                            \n")
                   .append("         ,UPD_BY = ?                                \n")
                   .append("         ,UPD_DATE = TO_CHAR(SYSDATE, 'YYYY-MM-DD')                            \n")
                   .append("     WHERE CORP_ID = ?               \n");
            
            persistent.setStatement(sqlstr.toString());
            persistent.addParameter(params.get("p_right_id").trim());
            persistent.addParameter(storage.getUser().get("acct_id").trim());
            persistent.addParameter(params.get("p_corp_id").trim());
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
            
            
        } catch(Exception e) {
        	throw e;
        }
    }
	
	
	private boolean update_charge(Connection con, ValueObject params) throws Exception
    {
        
        Persistent persistent = null;
        StringBuffer sqlstr = new StringBuffer();
        
        
        try{
            
            persistent = new PersistentImpl(con);
            
            
            sqlstr.append("     UPDATE SUPP_CHARGE SET              \n")
                    .append("          USER_NAME = ?                            \n")
                    .append("         ,DIVISION = ?                            \n")
                    .append("         ,POSITION = ?                            \n")
                    .append("         ,EMAIL = ?                            \n")
                    .append("         ,TEL_NUM = ?                            \n")
                    .append("         ,FAX_NUM = ?                            \n")
                    .append("         ,NOTE = ?                            \n")
                    .append("         ,RIGHT_ID = ?                            \n")
                    .append("         ,UPD_BY = ?                                \n")
                    .append("         ,UPD_DATE = TO_CHAR(SYSDATE, 'YYYY-MM-DD')                            \n")
                    .append("     WHERE CORP_ID = ?               \n");
            
            persistent.setStatement(sqlstr.toString());
            persistent.addParameter(params.get("user_name"));
            persistent.addParameter(params.get("division"));
            persistent.addParameter(params.get("position"));
            persistent.addParameter(params.get("email"));
            persistent.addParameter(params.get("tel_num"));
            persistent.addParameter(params.get("fax_num"));
            persistent.addParameter(params.get("NOTE"));
            persistent.addParameter(params.get("p_right_id").trim());
            persistent.addParameter(storage.getUser().get("acct_id").trim());
            persistent.addParameter(params.get("p_corp_id").trim());
            
            WAFLogger.debug(persistent.getParameters());
            WAFLogger.debug(sqlstr.toString());
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
            
            
        } catch(Exception e) {
        	throw e;
        }
    }
	
	private boolean saveChargeData(Connection con, ValueObject params) throws Exception {
        
        Persistent persistent = null;
        StringBuffer sqlstr = new StringBuffer();
        
        
        try{
            
            persistent = new PersistentImpl(con);
            
            
            sqlstr.append("                                                        \n")
                   .append("         INSERT INTO SUPP_CHARGE          \n")
                   .append("         (                                              \n")
                   .append("             CHARGE_SEQ                          \n")
                   .append("            ,CORP_ID                                \n")
                   .append("            ,USER_ID                                \n")
                   .append("            ,DEFAULT_YN -- Y                    \n")
                   .append("            ,USER_NAME                            \n")
                   .append("            ,DIVISION                                 \n")
                   .append("            ,POSITION                                 \n")
                   .append("            ,EMAIL                                      \n")
                   .append("            ,TEL_NUM                                 \n")
                   .append("            ,FAX_NUM                                 \n")
                   .append("            ,NOTE                                 \n")
                   .append("            ,HP1                                 \n")
                   .append("            ,HP2                                 \n")
                   .append("            ,HP3                                 \n")
                   .append("            ,USE_YN                                  \n")
                   .append("            ,CRE_BY                                  \n")
                   .append("            ,CRE_DATE                              \n")
                   .append("         )VALUES(                                   \n")
                   .append("            (SELECT DECODE(MAX(CHARGE_SEQ), '', 1, MAX(CHARGE_SEQ)+1)  SEQ FROM SUPP_CHARGE WHERE CORP_ID = ?  )          \n")
                   .append("            ,?                                          \n")
                   .append("            ,?                                          \n")
                   .append("            ,?                                          \n")
                   .append("            ,?                                          \n")
                   .append("            ,?                                          \n")
                   .append("            ,?                                          \n")
                   .append("            ,?                                          \n")
                   .append("            ,?                                          \n")
                   .append("            ,?                                          \n")
                   .append("            ,?                                          \n")
                   .append("            ,?                                          \n")
                   .append("            ,?                                          \n")
                   .append("            ,?                                          \n")
                   .append("            ,?                                          \n")
                   .append("            ,?                                          \n")
                   .append("            ,TO_CHAR(SYSDATE, 'YYYY-MM-DD')                                          \n")
                   .append("         )                                              \n");

            
            
            persistent.setStatement(sqlstr.toString());
            persistent.addParameter(params.get("CORP_ID"));
            persistent.addParameter(params.get("CORP_ID"));
            persistent.addParameter(params.get("USER_ID"));
            persistent.addParameter("N");
            persistent.addParameter(params.get("USER_NAME"));
            persistent.addParameter(params.get("DIVISION"));
            persistent.addParameter(params.get("POSITION"));
            persistent.addParameter(params.get("EMAIL"));
            persistent.addParameter(params.get("TEL_NUM"));
            persistent.addParameter(params.get("FAX_NUM"));  
            persistent.addParameter(params.get("NOTE"));   
            persistent.addParameter(params.get("HP1"));
            persistent.addParameter(params.get("HP2"));
            persistent.addParameter(params.get("HP3"));
            persistent.addParameter("Y");
            persistent.addParameter(storage.getUser().get("acct_id"));
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
        } catch(Exception e) {
            throw e;
        }
    }
	
    
	private boolean updateChargeData(Connection con, ValueObject params) throws Exception
    {
        
        Persistent persistent = null;
        StringBuffer sqlstr = new StringBuffer();
        
        
        try{
            
            persistent = new PersistentImpl(con);
            
            
            sqlstr.append("     UPDATE SUPP_CHARGE SET              \n")
                    .append("            USER_NAME = ?                           \n")
            		.append("            ,DIVISION  = ?                               \n")
            		.append("            ,POSITION  = ?                               \n")
                    .append("         ,EMAIL = ?                		            \n")
                    .append("         ,TEL_NUM = ?                            \n")
                    .append("         ,FAX_NUM = ?                            \n")
                    .append("         ,NOTE = ?                            \n")
                    .append("         ,HP1 = ?                            \n")
                    .append("         ,HP2 = ?                            \n")
                    .append("         ,HP3 = ?                            \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_NAME"));
            persistent.addParameter(params.get("DIVISION"));
            persistent.addParameter(params.get("POSITION"));
            persistent.addParameter(params.get("email"));
            persistent.addParameter(params.get("tel_num"));
            persistent.addParameter(params.get("fax_num"));
            persistent.addParameter(params.get("NOTE"));
            persistent.addParameter(params.get("HP1"));
            persistent.addParameter(params.get("HP2"));
            persistent.addParameter(params.get("HP3"));
            persistent.addParameter(storage.getUser().get("acct_id").trim());
            persistent.addParameter(params.get("CORP_ID"));
            persistent.addParameter(params.get("CHARGE_SEQ"));
            
            
            WAFLogger.debug(persistent.getParameters());
            WAFLogger.debug(sqlstr.toString());
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
            
            
        } catch(Exception e) {
        	throw e;
        }
    }
	
	private boolean deleteChargeData(Connection con, ValueObject params) throws Exception
    {
        
        Persistent persistent = null;
        StringBuffer sqlstr = new StringBuffer();
        
        
        try{
            
            persistent = new PersistentImpl(con);
            
            
            sqlstr.append("     DELETE FROM  SUPP_CHARGE               \n")
                    .append("     WHERE CORP_ID = ?               \n")
            		.append("     AND CHARGE_SEQ = ?               \n");
            
            persistent.setStatement(sqlstr.toString());
            persistent.addParameter(params.get("CORP_ID").trim());
            persistent.addParameter(params.get("CHARGE_SEQ").trim());
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
            
            
        } catch(Exception e) {
        	throw e;
        }
    }
	
	
	
	private boolean saveItemData(Connection con, ValueObject sqlParams) throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        
        try {
            
            persistent = new PersistentImpl(con);
            
            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("p_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) {
            throw e;
        }
    }
	
	private boolean updateItemData(Connection con, ValueObject sqlParams) throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        
        try {
            
            persistent = new PersistentImpl(con);
            
            sql.append("    UPDATE SUPP_PUR_ITEM SET          \n ");
            sql.append("          KIND_SMALL = ?                            \n ");
            sql.append("        , REPRE_YN = ?                            \n ");
            sql.append("        , UPD_BY       = ?            \n ");
            sql.append("        , UPD_DATE   = SYSDATE                \n ");
            sql.append("        WHERE CORP_ID = ?  AND KIND_SMALL = ?                        \n ");
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(sqlParams.get("ITEM_CODE"));
            persistent.addParameter(sqlParams.get("MAIN_ITEM").equals("1") ? "Y" : "N");
            persistent.addParameter(storage.getUser().get("acct_id"));
            persistent.addParameter(params.get("p_corp_id"));
            persistent.addParameter(sqlParams.get("ITEM_CODE"));
            
            
            
            
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
        } catch(Exception e) {
            throw e;
        }
    }	
	
	private void updateMainItemData(Connection con, ValueObject sqlParams) throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        if("1".equals(sqlParams.get("MAIN_ITEM"))){
	        
	        try {
	            
	            persistent = new PersistentImpl(con);
	            
	            sql.append("    UPDATE SUPP_PUR_ITEM SET          \n ");
	            sql.append("        REPRE_YN = ?                            \n ");
	            sql.append("        , UPD_BY       = ?            \n ");
	            sql.append("        , UPD_DATE   = SYSDATE                \n ");
	            sql.append("        WHERE CORP_ID = ?  AND KIND_SMALL <> ?                        \n ");
	            
	            persistent.setStatement(sql.toString());
	            persistent.addParameter("N");
	            persistent.addParameter(storage.getUser().get("acct_id"));
	            persistent.addParameter(params.get("p_corp_id"));
	            persistent.addParameter(sqlParams.get("ITEM_CODE"));
	            
	            persistent.execute();
	            persistent.clearParameters();
	        } catch(Exception e) {
	            throw e;
	        }
        }
    }   
	
	
	private boolean deleteItemData(Connection con, ValueObject sqlParams) throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        
        try {
            
            persistent = new PersistentImpl(con);
            
            sql.append("    DELETE FROM  SUPP_PUR_ITEM          \n ");
            sql.append("        WHERE CORP_ID = ?                          \n ");
            sql.append("        AND KIND_SMALL = ?                          \n ");
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(params.get("p_corp_id"));
            persistent.addParameter(sqlParams.get("ITEM_CODE"));
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
        } catch(Exception e) {
            throw e;
        }
    }   
	
	


	private boolean saveDeliresultData(Connection con, ValueObject sqlParams) throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        
        try {
            
            persistent = new PersistentImpl(con);
            
            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("        , DELI_FILE_ID                      \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("         ,DELIRESULT_FILE_ID_S.nextval           \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("p_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(params.get("corp_reg_no"));
            persistent.addParameter(params.get("corp_reg_no"));
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
        } catch(Exception e) {
            throw e;
        }
    }
	
	private boolean updateDeliresultData(Connection con, ValueObject sqlParams) throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        
        try {
            
            persistent = new PersistentImpl(con);
            
            sql.append("    UPDATE SUPP_PUR_DELIRESULT SET          \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("        , UPD_BY       = ?            \n ");
            sql.append("        , UPD_DATE   = SYSDATE                \n ");
            sql.append("        WHERE CORP_ID = ?  AND SEQ = ?                        \n ");
            
            persistent.setStatement(sql.toString());
            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(storage.getUser().get("acct_id"));
            persistent.addParameter(params.get("p_corp_id"));
            persistent.addParameter(sqlParams.get("SEQ"));
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
        } catch(Exception e) {
            throw e;
        }
    }   
	
	
	private boolean deleteDeliresultData(Connection con, ValueObject sqlParams) throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        
        try {
            
            persistent = new PersistentImpl(con);
            
            sql.append("    DELETE FROM  SUPP_PUR_DELIRESULT          \n ");
            sql.append("        WHERE CORP_ID = ?                          \n ");
            sql.append("        AND SEQ = ?                          \n ");
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(params.get("p_corp_id"));
            persistent.addParameter(sqlParams.get("SEQ"));
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
        } catch(Exception e) {
            throw e;
        }
    }   
    
    
    
    
	
	
	
	private boolean saveCertData(Connection con, ValueObject sqlParams) throws Exception {
	    Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        
        try {
            
            persistent = new PersistentImpl(con);
            
            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("        , CERT_GOV                      \n ");
            sql.append("        , EXP_STA_DY                      \n ");
            sql.append("        , EXP_END_DY                      \n ");
            sql.append("        , CREDIT_YN                      \n ");
            sql.append("        , CERT_FILE_ID                      \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("         ,CERT_FILE_ID_S.nextval                 \n ");
            sql.append("         ,?                                      \n ");
            sql.append("         ,SYSDATE                          \n ");
            sql.append("        )                                       \n ");
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(params.get("p_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("CERT_GOV"));
            persistent.addParameter(sqlParams.get("EXP_STA_DY"));
            persistent.addParameter(sqlParams.get("EXP_END_DY"));
            persistent.addParameter(params.get("credit_yn"));
            
            
            persistent.addParameter(params.get("corp_reg_no"));
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
        } catch(Exception e) {
            throw e;
        }
    }
    
    private boolean updateCertData(Connection con, ValueObject sqlParams) throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        
        try {
            
            persistent = new PersistentImpl(con);
            
            sql.append("    UPDATE SUPP_CERT SET          \n ");
            sql.append("          CERT_DIV_CD = ?                            \n ");
            sql.append("        , CERT_NO = ?                            \n ");
            sql.append("        , CERT_CTNT = ?                            \n ");
            sql.append("        , CERT_SCOPE = ?                            \n ");
            sql.append("        , CERT_GOV = ?                            \n ");
            sql.append("        , EXP_STA_DY = ?                            \n ");
            sql.append("        , EXP_END_DY = ?                            \n ");
            sql.append("        , UPD_BY       = ?            \n ");
            sql.append("        , UPD_DATE   = SYSDATE                \n ");
            sql.append("        WHERE CORP_ID = ?  AND CERT_SEQ = ?                        \n ");
            
            persistent.setStatement(sql.toString());
            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("CERT_GOV"));
            persistent.addParameter(sqlParams.get("EXP_STA_DY"));
            persistent.addParameter(sqlParams.get("EXP_END_DY"));
            
            persistent.addParameter(storage.getUser().get("acct_id"));
            persistent.addParameter(params.get("p_corp_id"));
            persistent.addParameter(sqlParams.get("CERT_SEQ"));
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
        } catch(Exception e) {
            throw e;
        }
    }   
    
    
    private boolean deleteCertData(Connection con, ValueObject sqlParams) throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        
        try {
            
            persistent = new PersistentImpl(con);
            
            sql.append("    DELETE FROM  SUPP_CERT          \n ");
            sql.append("        WHERE CORP_ID = ?                          \n ");
            sql.append("        AND CERT_SEQ = ?                          \n ");
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(params.get("p_corp_id"));
            persistent.addParameter(sqlParams.get("CERT_SEQ"));
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
        } catch(Exception e) {
            throw e;
        }
    }   
    
    
    
	
    private boolean savePrizeData(Connection con, ValueObject sqlParams) throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        
        try {
            
            persistent = new PersistentImpl(con);
            
            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("p_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(params.get("corp_reg_no"));
            
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
        } catch(Exception e) {
            throw e;
        }
    }
    
    private boolean updatePrizeData(Connection con, ValueObject sqlParams) throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        
        try {
            
            persistent = new PersistentImpl(con);
            
            sql.append("    UPDATE SUPP_PRIZE SET          \n ");
            sql.append("          PRZ_DY = ?                            \n ");
            sql.append("        , PRZ_NM = ?                            \n ");
            sql.append("        , PRZ_GIVER = ?                            \n ");
            sql.append("        , PRZ_INFO = ?                            \n ");
            sql.append("        , UPD_BY       = ?            \n ");
            sql.append("        , UPD_DATE   = SYSDATE                \n ");
            sql.append("        WHERE CORP_ID = ?  AND PRZ_SEQ = ?                        \n ");
            
            persistent.setStatement(sql.toString());
            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(storage.getUser().get("acct_id"));
            persistent.addParameter(params.get("p_corp_id"));
            persistent.addParameter(sqlParams.get("PRZ_SEQ"));
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
        } catch(Exception e) {
            throw e;
        }
    }   
    
    
    private boolean deletePrizeData(Connection con, ValueObject sqlParams) throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        
        try {
            
            persistent = new PersistentImpl(super.conn.getConnection());
            
            sql.append("    DELETE FROM  SUPP_PRIZE          \n ");
            sql.append("        WHERE CORP_ID = ?                          \n ");
            sql.append("        AND PRZ_SEQ = ?                          \n ");
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(params.get("p_corp_id"));
            persistent.addParameter(sqlParams.get("PRZ_SEQ"));
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
        } catch(Exception e) {
            throw e;
        }
    }   
    
    
    
    private boolean savePatentData(Connection con, ValueObject sqlParams) throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        
        try {
            
            persistent = new PersistentImpl(con);
            
            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("p_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(params.get("corp_reg_no"));
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
        } catch(Exception e) {
            throw e;
        }
    }
    
    private boolean updatePatentData(Connection con, ValueObject sqlParams) throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        
        try {
            
            persistent = new PersistentImpl(con);
            
            sql.append("    UPDATE SUPP_PATENT SET          \n ");
            sql.append("          PAT_CD = ?                            \n ");
            sql.append("        , PAT_DY = ?                            \n ");
            sql.append("        , PAT_INFO = ?                            \n ");
            sql.append("        , UPD_BY       = ?            \n ");
            sql.append("        , UPD_DATE   = SYSDATE                \n ");
            sql.append("        WHERE CORP_ID = ?  AND PAT_SEQ = ?                        \n ");
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(sqlParams.get("PAT_CD"));
            persistent.addParameter(sqlParams.get("PAT_DY"));
            persistent.addParameter(sqlParams.get("PAT_INFO"));
            
            persistent.addParameter(storage.getUser().get("acct_id"));
            persistent.addParameter(params.get("p_corp_id"));
            persistent.addParameter(sqlParams.get("PAT_SEQ"));
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
        } catch(Exception e) {
            throw e;
        }
    }   
    
    
    private boolean deletePatentData(Connection con, ValueObject sqlParams) throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        
        try {
            
            persistent = new PersistentImpl(con);
            
            sql.append("    DELETE FROM  SUPP_PATENT          \n ");
            sql.append("        WHERE CORP_ID = ?                          \n ");
            sql.append("        AND PAT_SEQ = ?                          \n ");
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(params.get("p_corp_id"));
            persistent.addParameter(sqlParams.get("PAT_SEQ"));
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
        } catch(Exception e) {
            throw e;
        }
    }   
    
    private boolean saveCert2Data(Connection con, ValueObject sqlParams) throws Exception {
	    Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        
        try {        	
        	persistent = new PersistentImpl(con);
            
            sql.append("    INSERT INTO SUPP_ABILLTY          \n ");
            sql.append("    (                                           \n ");
            sql.append("          CORP_ID                                   \n ");
            sql.append("        , CON_SEQ                             \n ");
            sql.append("        , BASE_YEAR                   \n ");
            sql.append("        , LIC_CD                   \n ");
            sql.append("        , LIC_NM                   \n ");
            sql.append("        , LIC_NO                      \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("         ,SYSDATE                          \n ");
            sql.append("        )                                       \n ");
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(params.get("p_corp_id"));
            persistent.addParameter(sqlParams.get("BASE_YEAR"));
            persistent.addParameter(sqlParams.get("LIC_CD"));
            persistent.addParameter(sqlParams.get("LIC_NM"));
            persistent.addParameter(sqlParams.get("LIC_NO"));
            persistent.addParameter(params.get("corp_reg_no"));
            persistent.addParameter(sqlParams.get("CONREYR"));
            
            System.out.println(persistent.getParameters());
            System.out.println(sql.toString());
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
        } catch(Exception e) {
            throw e;
        }
    }
    
    private boolean updateCert2Data(Connection con, ValueObject sqlParams) throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        
        try {
            
            persistent = new PersistentImpl(con);
            
            sql.append("    UPDATE SUPP_ABILLTY SET          \n ");
            sql.append("          BASE_YEAR = ?                            \n ");
            sql.append("        , LIC_CD = ?                            \n ");
            sql.append("        , LIC_NM = ?                            \n ");
            sql.append("        , LIC_NO = ?                            \n ");
            sql.append("        , CONREYR = ?                            \n ");                        
            sql.append("        , UPD_BY       = ?            \n ");
            sql.append("        , UPD_DATE   = SYSDATE                \n ");
            sql.append("        WHERE CORP_ID = ?  AND CON_SEQ = ?                        \n ");
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(sqlParams.get("BASE_YEAR"));
            persistent.addParameter(sqlParams.get("LIC_CD"));
            persistent.addParameter(sqlParams.get("LIC_NM"));
            persistent.addParameter(sqlParams.get("LIC_NO"));
            persistent.addParameter(sqlParams.get("CONREYR"));
            persistent.addParameter(storage.getUser().get("acct_id"));
            
            persistent.addParameter(params.get("p_corp_id"));
            persistent.addParameter(sqlParams.get("CON_SEQ"));
            
            System.out.println(persistent.getParameters());
            System.out.println(sql.toString());
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
        } catch(Exception e) {
            throw e;
        }
    }   
    
    
    private boolean deleteCert2Data(Connection con, ValueObject sqlParams) throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        
        try {
            
            persistent = new PersistentImpl(con);
            
            sql.append("    DELETE FROM  SUPP_ABILLTY                 \n ");
            sql.append("     WHERE CORP_ID = ?                        \n ");
            sql.append("       AND CON_SEQ = ?                        \n ");
            
            persistent.setStatement(sql.toString());
            persistent.addParameter(params.get("p_corp_id"));
            persistent.addParameter(sqlParams.get("CON_SEQ"));
            
            System.out.println(persistent.getParameters());
            System.out.println(sql.toString());
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
        } catch(Exception e) {
            throw e;
        }
    } 
    
		
	
      /**
       * 회사정보 저장
       * @param params
       * @return
       * @throws Exception
       */
      private boolean updateInfo(Connection con, ValueObject params) throws Exception
      {
          
          Persistent persistent = null;
          StringBuffer sqlstr = new StringBuffer();
          
          WAFLogger.debug(params); 
          
          try{
              
              persistent = new PersistentImpl(con);
              
              
              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("   ,FACTOR_CD = ?      \n")
                    .append("   ,FACTOR_CONFIRM = ? \n")
                    .append("   ,MFTR_DIV_CD = ?    \n")
                    .append("   ,UPD_BY = ?         \n")
                    .append("   ,UPD_DATE = SYSDATE	\n")
                    .append("   ,USE_END_DY = ?     \n")
                    .append("   ,REG_REQ_DT = ?     \n")
                    .append("   ,REG_DT = ?         \n")
                    .append("   ,APPR_DT = ?        \n")
                    .append("   ,CAN_DT = ?           \n")
                    .append("   ,STATUS = ?           \n")
                    .append("   ,\"COMMENT\" = ?           \n")
                    .append("   ,MANAGE_NO = ?           \n")
                    .append("   ,NATION_CD = ?           \n")
                    .append("   ,BANK_CD = ?           \n")
                    .append("   ,BANK_NM = ?           \n")
                    .append("   ,BANK_ACCT = ?           \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("factor_cd"));
              persistent.addParameter(params.get("factor_confirm"));	//2023.10.05
              persistent.addParameter(params.get("mftr_div_cd"));
              persistent.addParameter(storage.getUser().get("acct_id"));
              persistent.addParameter("20991231");//2016.8.9 params.get("use_end_dy").trim().replace("-", "")
              persistent.addParameter(params.get("reg_req_dt").trim().replace("-", ""));
              persistent.addParameter(params.get("reg_dt").trim().replace("-", ""));
              persistent.addParameter(params.get("appr_dt").trim().replace("-", ""));
              persistent.addParameter(params.get("can_dt").trim().replace("-", ""));
              persistent.addParameter(params.get("p_status").trim());
              persistent.addParameter(params.get("comment").trim());
              persistent.addParameter(params.get("manage_no").trim());
              persistent.addParameter(params.get("nation_cd").trim());
              persistent.addParameter(params.get("bank_cd").trim());
              persistent.addParameter(params.get("bank_nm").trim());
              persistent.addParameter(params.get("bank_acct").trim());
              
              persistent.addParameter(params.get("p_corp_id"));
              WAFLogger.debug(persistent.getParameters());
              WAFLogger.debug(sqlstr.toString());
              
              
              persistent.execute();
              persistent.clearParameters();
              
              return true;
              
              
          } catch(Exception e) {
              throw e;
          }
      }
      
      
      
      private boolean saveFinance(Connection con, ValueObject sqlParams) throws Exception {
          Persistent persistent = null;
          StringBuffer sql = new StringBuffer();
          
          
          try {
              
              persistent = new PersistentImpl(con);
              
              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("p_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"));
              
              persistent.execute();
              persistent.clearParameters();
              
              return true;
          } catch(Exception e) {
              throw e;
          }
      }
      
      
      
      private boolean updateFinance(Connection con, ValueObject sqlParams) throws Exception {
          Persistent persistent = null;
          StringBuffer sql = new StringBuffer();
          
          
          try {
              
              persistent = new PersistentImpl(con);
              
              sql.append("    UPDATE SUPP_FINANCE SET          \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("        , UPD_BY  = ?                     \n ");
              sql.append("        , UPD_DATE = SYSDATE                      \n ");
              sql.append("     WHERE CORP_ID = ?                                       \n ");
              
              persistent.setStatement(sql.toString());
              
              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"));
              
              persistent.addParameter(params.get("p_corp_id"));
              
              persistent.execute();
              persistent.clearParameters();
              
              return true;
          } catch(Exception e) {
              throw e;
          }
      }
      
      
      private boolean save_info(Connection con, ValueObject params) throws Exception
      {
          
          Persistent persistent = null;
          StringBuffer sqlstr = new StringBuffer();
          
          
          try{
              
              persistent = new PersistentImpl(con);
              
              
              sqlstr.append("     INSERT INTO SUPP_INFO              \n")
                     .append("     (                                              \n")
                     .append("          CORP_ID                               \n")
                     .append("         ,JOB_DIV --P:구매. O:외주           \n")
                     .append("         ,IN_OUT_DIV --I:국내, O:국외     \n")
                     .append("         ,MANAGE_NO                         \n")
                     .append("         ,NATION_CD                          \n")
                     .append("         ,CORP_KOR                            \n")
                     .append("         ,REP_NAME                            \n")
                     .append("         ,CORP_TEL                            \n")
                     .append("         ,CORP_FAX                            \n")
                     .append("         ,POST_NO                            \n")
                     .append("         ,ADDRESS                            \n")
                     .append("         ,STATUS                               \n")
                     .append("         ,USE_END_DY                         \n")
                     .append("         ,CAN_DT                               \n")
                     .append("         ,\"COMMENT\"                        \n")
                     .append("         ,CRE_BY                                \n")
                     .append("         ,CRE_DATE                            \n")
                     .append("     )VALUES(                                  \n")
                     .append("          ?                                        \n")
                     .append("         ,?                                        \n")
                     .append("         ,?                                        \n")
                     .append("         ,?                                        \n")
                     .append("         ,?                                        \n")
                     .append("         ,?                                        \n")
                     .append("         ,?                                        \n")
                     .append("         ,?                                        \n")
                     .append("         ,?                                        \n")
                     .append("         ,?                                        \n")
                     .append("         ,?                                        \n")
                     .append("         ,?                                        \n")
                     .append("         ,?                                        \n")
                     .append("         ,?                                        \n")
                     .append("         ,?                                        \n")
                     .append("         ,?                                        \n")
                     .append("         ,SYSDATE                             \n")
                     .append("     )                                             \n");
              
              
              persistent.setStatement(sqlstr.toString());
              persistent.addParameter(params.get("p_corp_id").trim());
              persistent.addParameter(params.get("job_div").trim());
              persistent.addParameter("O");
              persistent.addParameter(params.get("manage_no").trim());
              persistent.addParameter(params.get("nation_cd").trim());
              persistent.addParameter(params.get("corp_kor").trim());
              persistent.addParameter(params.get("rep_name").trim());
              persistent.addParameter(params.get("corp_tel").trim());
              persistent.addParameter(params.get("corp_fax").trim());
              persistent.addParameter(params.get("post_no_1").trim() + "" + params.get("post_no_2").trim());
              persistent.addParameter(params.get("address").trim());
              persistent.addParameter(params.get("p_status").trim());
              persistent.addParameter("20991231"); //2016.8.9params.get("use_end_dy").trim().replace("-", "").trim()
              persistent.addParameter(params.get("can_dt").trim().replace("-", "").trim());
              persistent.addParameter(params.get("comment").trim());
              persistent.addParameter(storage.getUser().get("acct_id"));
              
              persistent.execute();
              persistent.clearParameters();
              
              return true;
              
              
          } catch(Exception e) {
        	  throw e;
          }
      }
      
      /**
       * 협력업체 담당자정보 저장
       * @param params
       * @return
       * @throws Exception
       */
      private boolean save_charge(Connection con, ValueObject params) throws Exception
      {
          
          Persistent persistent = null;
          StringBuffer sqlstr = new StringBuffer();
          
          
          try{
              
              persistent = new PersistentImpl(con);
              
              
              sqlstr.append("                                                        \n")
                     .append("         INSERT INTO SUPP_CHARGE          \n")
                     .append("         (                                              \n")
                     .append("             CHARGE_SEQ                          \n")
                     .append("            ,CORP_ID                                \n")
                     .append("            ,USER_ID                                \n")
                     .append("            ,DEFAULT_YN -- Y                    \n")
                     .append("            ,USER_NAME                            \n")
                     .append("            ,DIVISION                                 \n")
                     .append("            ,POSITION                                 \n")
                     .append("            ,EMAIL                                      \n")
                     .append("            ,TEL_NUM                                 \n")
                     .append("            ,FAX_NUM                                 \n")
                     .append("            ,HP1                                 \n")
                     .append("            ,HP2                                 \n")
                     .append("            ,HP3                                 \n")
                     .append("            ,USE_YN                                  \n")
                     .append("            ,RIGHT_ID                                \n")
                     .append("            ,CRE_BY                                  \n")
                     .append("            ,CRE_DATE                              \n")
                     .append("         )VALUES(                                   \n")
                     .append("            (SELECT DECODE(MAX(CHARGE_SEQ), '', 1, MAX(CHARGE_SEQ)+1)  SEQ FROM SUPP_CHARGE WHERE CORP_ID = ?  )          \n")
                     .append("            ,?                                          \n")
                     .append("            ,?                                          \n")
                     .append("            ,?                                          \n")
                     .append("            ,?                                          \n")
                     .append("            ,?                                          \n")
                     .append("            ,?                                          \n")
                     .append("            ,?                                          \n")
                     .append("            ,?                                          \n")
                     .append("            ,?                                          \n")
                     .append("            ,?                                          \n")
                     .append("            ,?                                          \n")
                     .append("            ,?                                          \n")
                     .append("            ,?                                          \n")
                     .append("            ,?                                          \n")
                     .append("            ,?                                          \n")
                     .append("            ,TO_CHAR(SYSDATE, 'YYYY-MM-DD')                                          \n")
                     .append("         )                                              \n");

              
              
              persistent.setStatement(sqlstr.toString());
              persistent.addParameter(params.get("p_corp_id"));
              persistent.addParameter(params.get("p_corp_id"));
              persistent.addParameter(params.get("user_id") + "_" +  params.get("p_corp_id"));
              persistent.addParameter("Y");
              persistent.addParameter(params.get("user_name"));
              persistent.addParameter(params.get("division"));
              persistent.addParameter(params.get("position"));
              persistent.addParameter(params.get("email"));
              persistent.addParameter(params.get("tel_num"));
              persistent.addParameter(params.get("fax_num"));
              persistent.addParameter(params.get("h_phon_1"));
              persistent.addParameter(params.get("h_phon_2"));
              persistent.addParameter(params.get("h_phon_3"));
              persistent.addParameter("Y");
              persistent.addParameter(params.get("p_right_id"));
              persistent.addParameter(storage.getUser().get("acct_id"));
              
              persistent.execute();
              persistent.clearParameters();
              
              return true;
              
              
          } catch(Exception e) {
        	  throw e;
          }
      }
  
      
      
      private boolean delete_info(Connection con, ValueObject params) throws Exception
      {
          
          Persistent persistent = null;
          StringBuffer sqlstr = new StringBuffer();
          
          
          try{
              
              persistent = new PersistentImpl(con);
              
              
              sqlstr.append("     DELETE FROM  SUPP_INFO               \n")
                     .append("     WHERE CORP_ID = ?               \n");
              
              
              persistent.setStatement(sqlstr.toString());
              persistent.addParameter(params.get("p_corp_id").trim());
              
              persistent.execute();
              persistent.clearParameters();
              
              return true;
              
              
          } catch(Exception e) {
        	  throw e;
          }
      }
      
      private boolean delete_charge(Connection con, ValueObject params) throws Exception
      {
          
          Persistent persistent = null;
          StringBuffer sqlstr = new StringBuffer();
          
          
          try{
              
              persistent = new PersistentImpl(con);
              
              
              sqlstr.append("     DELETE FROM  SUPP_CHARGE               \n")
                      .append("     WHERE CORP_ID = ?               \n");
              
              persistent.setStatement(sqlstr.toString());
              persistent.addParameter(params.get("p_corp_id").trim());
              
              persistent.execute();
              persistent.clearParameters();
              
              return true;
              
              
          } catch(Exception e) {
        	  throw e;
          }
      }
      
      private boolean delete_supp_item(Connection con, ValueObject params) throws Exception
      {
          
          Persistent persistent = null;
          StringBuffer sqlstr = new StringBuffer();
          
          
          try{
              
              persistent = new PersistentImpl(con);
              
              
              sqlstr.append("     DELETE FROM  SUPP_PUR_ITEM               \n")
                     .append("     WHERE CORP_ID = ?               \n");
              
              
              persistent.setStatement(sqlstr.toString());
              persistent.addParameter(params.get("p_corp_id").trim());
              
              persistent.execute();
              persistent.clearParameters();
              
              return true;
              
              
          } catch(Exception e) {
        	  throw e;
          }
      }
      
      
      public RowSet getUserInfo(String corp_id) throws Exception{
          
          Search search = new SearchImpl();
          RowSet rowSet = new RowSetImpl();
          
          StringBuffer sqlstr = new StringBuffer();       
          
          try {
              sqlstr.append(" SELECT USER_NAME, HP1, HP2, HP3, A.REP_NAME, B.EMAIL, A.CORP_KOR       \n");
              sqlstr.append(" FROM SUPP_INFO A, SUPP_CHARGE B            \n");
              sqlstr.append(" WHERE A.CORP_ID = B.CORP_ID            \n");
              sqlstr.append(" AND B.DEFAULT_YN = 'Y'            \n");
              sqlstr.append(" AND A.CORP_ID = "+corp_id+" \n");
              
              WAFLogger.debug(sqlstr.toString());
              
              search.setStatement(sqlstr.toString());
              rowSet = search.execute();            
          }
          catch(WAFSQLException se) {
        	  WAFLogger.error("SQL : \n" + sqlstr.toString());
              se.printStackTrace();
              throw se;
          }
          finally {
              if( rowSet == null ) rowSet = new RowSetImpl();
              return rowSet;
          }
      }
      
      private void updateCharge(){
  		
  		boolean success = false;
  		conn.begin();
  		try 
  		{
  			Connection con = conn.getConnection();
  			
	        String[] status = super.gets("sheet4.STATUS");
	        
	        for (int i = 0; i < status.length; i++) 
            {
	        	if (IBSheet7Utils.equalStatusInsert(status[i])) 
                {
                    success = saveChargeData(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET4", params, i));
                }
	        	
                if (IBSheet7Utils.equalStatusUpdate(status[i])) 
                {
                    success = updateChargeData(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET4", params, i));
                }
                
                if (IBSheet7Utils.equalStatusDelete(status[i])) 
                {
                    success = deleteChargeData(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET4", params, i));
                }
            }
	        
	        super.storage.setSuccess(success);
            storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
  		} catch (Exception e) {
  			super.doException(e);
  			super.storage.setDetailMessage(e);
  			super.storage.setMessage(e.getMessage());
  			super.storage.setSuccess(false);
  			super.conn.setRollback();
  		} finally {
  			conn.end();
  		} 
  		
  	}
      
      
      private void sendSMS_EMAIL(){
    	  try{
    		  if( params.get("taget") == null ){
    			  MessageSend messageSend = new MessageSend(storage);

    			  /**************SMS, EMAIL*********************/
    			  //사용자 정보 가져오기
    			  RowSet userInfo = getUserInfo(params.get("p_corp_id")); 

    			  //SMS
    			  String smsContent = WAFMessages.getMessage("Complete.approved.Supplier");

    			  String phon_no = userInfo.getRow(0).get("HP1") + userInfo.getRow(0).get("HP2") + userInfo.getRow(0).get("HP3");
    			  String re_phon_no = storage.getUser().get("USER_PHONE"); //SGC이앤씨 번호024899000

    			  messageSend.sendSMS(phon_no, re_phon_no, params.get("p_corp_id"), smsContent); //2015.9.21 협력업체 등록 re_phon_no
    			  

    			  //EMAIL
    			  String subject = WAFMessages.getMessage("Complete.approved.Supplier.Mail.Title");
    			  String subject_in = WAFMessages.getMessage("Complete.approved.Supplier.Mail.Title.in");

    			  String email = userInfo.getRow(0).get("EMAIL");

    			  StringBuffer mailContent = new StringBuffer();
    			  mailContent.append( WAFMessages.getMessage("Complete.approved.Supplier.Mail.Content") );

    			  messageSend.sendEmail(email, "test", subject, subject_in, mailContent);
    		  }
    	  }catch(Exception e){
    		  WAFLogger.debug(e.getMessage());
    	  }
      }
      
    private boolean updateFactorConfirm() throws Exception {
    	     Persistent persistent = null;
    	     StringBuffer sqlstr = new StringBuffer();
    	        
    	     try{
    	     	Connection con = conn.getConnection();
    	         persistent = new PersistentImpl(con);
    	         
    	         
    	         sqlstr.append("     UPDATE SUPP_INFO                                      \n")
    	                .append("       SET factor_cd = '1'                                \n")
    	                .append("         , factor_confirm = 'Y'                           \n")
    	                .append("     WHERE CORP_ID = "+params.get("p_corp_id").trim()+"   \n");
    	         
    	         persistent.setStatement(sqlstr.toString());    	            
    	         persistent.execute();
    	         persistent.clearParameters();
    	         
    	         return true;
    	     } catch(Exception e) {
    	     	throw e;
    	     }
    	 }
    
	private void saveDeliresutAdmit(){
		
        boolean success = false;
        
        String[] status = super.gets("sheet5.STATUS");
        
	    conn.begin();
        try 
        {
        	Connection con = conn.getConnection();
        
        	for (int i = 0; i < status.length; i++) 
            {                
        		if (IBSheet7Utils.equalStatusDelete(status[i])) 
                {
                    success = updateDeliresultAdmitData(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET5", params, i));
                }
            }

            super.storage.setSuccess(success);
            storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
        } catch (Exception e) {
			super.doException(e);
			super.storage.setDetailMessage(e);
			super.storage.setMessage(e.getMessage());
			super.storage.setSuccess(false);
			super.conn.setRollback();
		} finally {
			conn.end();
		} 
        
	}
	
	private boolean updateDeliresultAdmitData(Connection con, ValueObject sqlParams) throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        
        try {
            
            persistent = new PersistentImpl(con);
            
            sql.append("    UPDATE SUPP_PUR_DELIRESULT SET          \n ");
            sql.append("          DELIRESULT_CONFIRM = ?                            \n ");
            sql.append("        , UPD_BY       = ?            \n ");
            sql.append("        , UPD_DATE   = SYSDATE                \n ");
            sql.append("        WHERE CORP_ID = ?  AND SEQ = ?                        \n ");
            
            persistent.setStatement(sql.toString());
            if(storage.compareEvent("SAVE_DELIRESUT_ADMIT"))  persistent.addParameter("Y");
            else persistent.addParameter("N");
            
            persistent.addParameter(storage.getUser().get("acct_id"));
            persistent.addParameter(params.get("p_corp_id"));
            persistent.addParameter(sqlParams.get("SEQ"));
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
        } catch(Exception e) {
            throw e;
        }
    }
	
	private void saveCertAdmit(){
		
        boolean success = false;
        
        String[] status = super.gets("sheet6.STATUS");
        
	    conn.begin();
        try 
        {
        	Connection con = conn.getConnection();
        
        	for (int i = 0; i < status.length; i++) 
            {                
        		if (IBSheet7Utils.equalStatusDelete(status[i])) 
                {
                    success = updateCertAdmitData(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET6", params, i));
                }
            }

            super.storage.setSuccess(success);
            storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
        } catch (Exception e) {
			super.doException(e);
			super.storage.setDetailMessage(e);
			super.storage.setMessage(e.getMessage());
			super.storage.setSuccess(false);
			super.conn.setRollback();
		} finally {
			conn.end();
		} 
        
	}
	
	private boolean updateCertAdmitData(Connection con, ValueObject sqlParams) throws Exception {
        Persistent persistent = null;
        StringBuffer sql = new StringBuffer();
        
        
        try {
            
            persistent = new PersistentImpl(con);
            
            sql.append("    UPDATE SUPP_CERT SET          \n ");
            sql.append("          CERT_CONFIRM = ?                            \n ");
            sql.append("        , UPD_BY       = ?            \n ");
            sql.append("        , UPD_DATE   = SYSDATE                \n ");
            sql.append("        WHERE CORP_ID = ?  AND CERT_SEQ = ?                        \n ");
            
            persistent.setStatement(sql.toString());
            if(storage.compareEvent("SAVE_CERT_ADMIT"))  persistent.addParameter("Y");
            else persistent.addParameter("N");
            
            persistent.addParameter(storage.getUser().get("acct_id"));
            persistent.addParameter(params.get("p_corp_id"));
            persistent.addParameter(sqlParams.get("CERT_SEQ"));
            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
        } catch(Exception e) {
            throw e;
        }
    }  
}