/**
 * @(#)file    OwnListSaveBiz.java
 * @(#)author  gyeongmo an
 * @(#)date    2014.7.2
 * Copyright (c) www.udapsoft.co.kr, Inc.
 */
package kr.co.udapsoft.ebid.buyer.sycs.own.biz;

import kr.co.hsnc.common.base.WAFLogger;
import kr.co.hsnc.common.sql.persistent.Persistent;
import kr.co.hsnc.common.sql.persistent.PersistentImpl;
import kr.co.hsnc.common.util.ValueObject;

import com.udapsoft.waf.system.Biz;
import com.udapsoft.waf.system.HandlerStorage;

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

	public void doBiz() throws Exception {
        boolean success = false;
        params.set("login_user", storage.getUser().get("ACCT_ID"));
        success = saveOwnList(params);
        storage.setSuccess(success);
	}
	
	public boolean saveOwnList(ValueObject params) {
        Persistent persistent_u = null;
        StringBuffer sqlstr_u   = new StringBuffer();
        
		sqlstr_u.append("	UPDATE HEAD_OFFICE_INFO SET	\n");
		sqlstr_u.append("		CORP_REG_NO = ?          	\n");
		sqlstr_u.append("		, CORP_KOR = ?           	\n");
		sqlstr_u.append("		, CORP_ENG = ?           	\n");
		sqlstr_u.append("		, POST_NO = ?            	\n");
		sqlstr_u.append("		, ADDRESS = ?            	\n");
		sqlstr_u.append("		, CORP_STS = ?           	\n");
		sqlstr_u.append("		, BIZ_FORM = ?           	\n");
		sqlstr_u.append("		, REP_NAME = ?           	\n");
		sqlstr_u.append("		, CORP_TEL = ?           	\n");
		sqlstr_u.append("		, UPD_BY = ?             	\n");
		sqlstr_u.append("		, UPD_DATE = SYSDATE     	\n");
		sqlstr_u.append("		, COPR_NO = ?     	\n");
		sqlstr_u.append("		WHERE CORP_REG_NO = ?     	\n");
		
		try {
            conn.begin();
            persistent_u = new PersistentImpl(super.conn.getConnection());
            persistent_u.setStatement(sqlstr_u.toString());
            
            persistent_u.addParameter(params.get("corp_reg_no"));
            persistent_u.addParameter(params.get("corp_kor"));
            persistent_u.addParameter(params.get("corp_eng"));
            persistent_u.addParameter(params.get("post_no1") + params.get("post_no2"));
            persistent_u.addParameter(params.get("address"));
            persistent_u.addParameter(params.get("corp_sts"));
            persistent_u.addParameter(params.get("biz_form"));
            persistent_u.addParameter(params.get("rep_name"));
            persistent_u.addParameter(params.get("corp_tel"));
            persistent_u.addParameter(params.get("login_user"));
            persistent_u.addParameter(params.get("copr_no"));
            persistent_u.addParameter(params.get("corp_reg_no"));
            
            WAFLogger.debug(sqlstr_u.toString());
            persistent_u.execute();
            persistent_u.clearParameters();
              
            return true;
		}
        catch(Exception e) {
            super.doException(e);
            super.storage.setMessage(e.getMessage());
            super.storage.setDetailMessage(e);
            super.conn.setRollback();
            return false;
        }
        finally {
            super.conn.end();
        }
    }
		
	
	

}
