/**
 *
 * @(#)author  [OK]
 * @(#)version 1.0
 * @(#)date    2014-09-11
 * @(#)since   JDK 1.6.2
 *
 * Copyright (c) www.udapsoft.co.kr, Inc.
 * All rights reserved.
 */
package kr.co.udapsoft.ebid.buyer.payment.purchase.biz;


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

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

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

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

	public void doBiz() throws Exception {

		if(storage.compareEvent("")){
			RowSet rowSet = getCombo();

	        String selectText = HTMLMaker.getSelectTagText4Sheet(rowSet);
	        storage.addObject("selectText", selectText);
    		
    		String selectValue =  HTMLMaker.getSelectTagValue4Sheet( rowSet);
    		storage.addObject("selectValue", selectValue);
			
		}else if(storage.compareEvent("GET_LIST")){
			
			params.set("sheet1", getList(params));
			storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
			
		}else if(storage.compareEvent("GET_DETAIL")){
			
			params.set("sheet2", getDetail(params));
			storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
	        			
		}else if(storage.compareEvent("GET_LC")){
			RowSet rowSet = getComboLC(params);
			storage.addRowSet("ROWSET", rowSet);
	        storage.setSuccess(true);
			
		}else if(storage.compareEvent("SAVE_LC_LIST")){			
			boolean success = false;
			String[] status = super.gets("sheet1.STATUS");

			try {
				super.conn.begin();
				
				Connection con = super.conn.getConnection();
				
				//배치값 생성 
				for (int i = 0; i < status.length; i++) {
					if (IBSheet7Utils.equalStatusInsert(status[i]) || IBSheet7Utils.equalStatusUpdate(status[i]) ) {
						success = updateData(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET1", params, i) );
					}else if (IBSheet7Utils.equalStatusDelete(status[i])){
						success = deleteData(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET1", params, i) );
					}
				}
				
				super.storage.setSuccess(success);
				storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
				
			} catch (Exception e) {
				WAFLogger.error(e);
				super.conn.setRollback();
				throw new Exception(e);
				
			} finally {
				super.conn.close();
			}
		}else if(storage.compareEvent("SAVE_LC_DETAIL")){			
			boolean success = false;
			String[] status = super.gets("sheet2.STATUS");

			try {
				super.conn.begin();
				
				Connection con = super.conn.getConnection();
				
				//배치값 생성 
				for (int i = 0; i < status.length; i++) {
					if (IBSheet7Utils.equalStatusInsert(status[i]) || IBSheet7Utils.equalStatusUpdate(status[i]) ) {
						success = updateDataDetail(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET2", params, i) );
					}else if (IBSheet7Utils.equalStatusDelete(status[i])){
						success = deleteDataDetail(con, IBSheet7Utils.getIBSheet7SqlParams("SHEET2", params, i) );
					}
				}
				
				super.storage.setSuccess(success);
				storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
				
			} catch (Exception e) {
				WAFLogger.error(e);
				super.conn.setRollback();
				throw new Exception(e);
				
			} finally {
				super.conn.close();
			}
		}
	}
    
    public RowSet getList(ValueObject Params) {
        Search search = new SearchImpl();
        RowSet listRowSet = null;
        String sqlstr = "";
        
        try {
        	sqlstr	+=	"  SELECT 		 	                                \n"
        		    + 	" 	      A.PUR_CONT_ID		 	                    \n"
        		    + 	" 	     ,A.DEPT_CD		 	                        \n"
        		    + 	" 	     ,A.DEPT_NAME		 	                    \n"
        		    + 	" 	     ,A.CON_CHARGE_NAME		                    \n"
        		    + 	" 	     ,A.ORD_DOC_NO 		 	                    \n"
        		    + 	" 	     ,A.CST_DOC_NAME		                    \n"
        		    + 	" 	     ,B.CORP_KOR		 	                    \n"
        		    + 	" 	     ,F_GET_CODE_NAME('NATION_CD', B.NATION_CD) NATION \n"
        		    + 	" 	     ,A.CURRENCY_GB		 	                    \n"
        		    + 	" 	     ,A.ORD_AMT		 	                        \n"
        		    + 	" 	     ,A.ORD_SUPPLY_AMT		                    \n"
        		    + 	" 	     ,A.ORD_SURTAX_AMT		                    \n"
        		    + 	" 	     ,A.PREPAY_AMT		 	                    \n"
        		    + 	" 	     ,A.MID_AMT		 	                        \n"
        		    + 	" 	     ,A.RMDR_AMT		 	                    \n"
        		    + 	" 	     ,NVL(C.SEQ,0) SEQ                          \n"
        		    + 	" 	     ,C.LC_AMT		 	                        \n"
        		    + 	" 	     ,C.RATE		 	                        \n"
        		    + 	" 	     ,C.OPEN_DATE		 	                    \n"
        		    + 	" 	     ,C.EXPIRE_DATE		 	                    \n"
        		    + 	" 	     ,C.BANK_CD		 	                        \n"
        		    + 	" 	     ,C.BANK_NM		 	                        \n"
        		    + 	" 	     ,C.LC_NO 		 	                        \n"
        		    + 	" 	     ,C.LC_AMT - NVL(D.PAY_AMT,0)  LC_REMAIN    \n"
        		    + 	" 	     ,C.PAY_CONDI 		 	                    \n"
        		    + 	" 	 FROM PUR1000T A		 	                    \n"
        		    + 	" 	     ,SUPP_INFO B		 	                    \n"
        		    + 	" 	     ,CONT_PUR_LC C		 	                    \n"
        		    + 	" 	     ,(SELECT PUR_CONT_ID, LC_NO, NVL(SUM(PAY_AMT),0) PAY_AMT		\n"
        		    + 	" 	        FROM CONT_PUR_LCPAY  		 	                            \n"
        		    + 	" 	       GROUP BY PUR_CONT_ID, LC_NO ) D		 	                    \n"
          		    + 	" 	WHERE A.CORP_ID = B.CORP_ID	                    \n"
        		    + 	"  	  AND A.PUR_CONT_ID = C.PUR_CONT_ID(+)		 	\n"
        		    + 	"  	  AND C.PUR_CONT_ID = D.PUR_CONT_ID(+)		 	\n"
        		    + 	"  	  AND C.SEQ = D.LC_NO(+)             		 	\n"
        		    + 	" 	  AND A.CURRENCY_GB <> 'KRW'		 	        \n";
        	
        	if(!"".equals(params.get("p_cst_doc_name"))){	//계약명
        		sqlstr += " AND UPPER(A.CST_DOC_NAME) LIKE '%'||UPPER('"+Params.get("p_cst_doc_name")+"')||'%'																				\n";
    		} 
        	if(!"".equals(params.get("p_member_name"))){	//업체명
        		sqlstr += " AND UPPER(B.CORP_KOR) LIKE '%'||UPPER('"+Params.get("p_member_name")+"')||'%'																				\n";
    		} 
        	if(!"".equals(params.get("p_dept_cd"))){		//현장
        		sqlstr	+= " AND A.DEPT_CD = '"+Params.get("p_dept_cd")+"'	\n";
        	}
        	//계약일자 
        	sqlstr += " AND A.CON_IN_DATE BETWEEN '"+Params.get("p_from_dt")+"' AND '"+Params.get("p_to_dt")+"'		\n";
        	sqlstr += " ORDER BY A.ORD_DOC_NO, C.SEQ                                           		\n";
            search.setStatement(sqlstr);
            //WAFLogger.debug(sqlstr);
            listRowSet = search.execute();
           
        }
        catch(Exception e) {
            WAFLogger.error(this.getClass().getName() + " --> getList() : " + e.getMessage());
            WAFLogger.error("SQL : " + search.getStatement());
            WAFLogger.error(e);
            return null;
        }
        finally {
            if( listRowSet == null ) listRowSet = new RowSetImpl();
            return listRowSet;
        }
    }
    
    public RowSet getDetail(ValueObject Params) {
        Search search = new SearchImpl();
        RowSet listRowSet = null;
        String sqlstr = "";
        
        try {
        	sqlstr	+=	"SELECT NVL(C.SEQ, 0)  SEQ                                   \n"
        		+ 	" 	,A.PUR_CONT_ID                                               \n"
        		+ 	" 	,NVL(LC_AMT,0)  LC_AMT                                       \n"
        		+ 	" 	,C.PAY_AMT                                                   \n"
        		+ 	" 	,C.RATE                                                      \n"
        		+ 	" 	,C.NEGO_DATE                                                 \n"
        		+ 	" 	,C.PAY_DATE PAY_DATE                                         \n"
        		+ 	" 	,C.USANCE_INT                                                \n"
        		+ 	" 	,C.LC_NO                                                     \n"
        		+ 	" 	FROM PUR1000T A                                              \n"
        		+ 	" 	    ,CONT_PUR_LC B                                           \n"    
        		+ 	" 	    ,CONT_PUR_LCPAY C                                        \n"    
        		+ 	" 	WHERE A.PUR_CONT_ID = B.PUR_CONT_ID                          \n"
        		+ 	" 	AND A.PUR_CONT_ID = C.PUR_CONT_ID                            \n"
        		+ 	" 	AND C.LC_NO = B.SEQ                                          \n"
        		+ 	" 	AND A.PUR_CONT_ID = '"+Params.get("pur_cont_id")+"'          \n"
        		+ 	" 	ORDER BY  DECODE(NVL(C.PAY_DATE, ''), '', C.PAY_DATE)        \n";
        		/*+ 	" 	, (SELECT PUR_CONT_ID PUR_CONT_ID, '선급' GB                  \n"                
        		+ 	" 	         ,REQ_PREPAY_SUPPLY_AMT PAY_AMT, PREPAY_ID PAY_ID    \n"
        		+ 	" 	         ,PREPAY_DATE PAY_DATE                               \n"
        		+ 	" 	     FROM PUR1030T                                           \n"
        		+ 	" 	   UNION ALL                                                 \n"
        		+ 	" 	   SELECT PUR_CONT_ID, '대금', CUR_REQ_APPLYAMT, PAYREQ_ID    \n"  
        		+ 	" 	         ,REQ_DATE                                           \n"  
        		+ 	" 	     FROM PUR1100T ) B                                       \n"
        		+ 	" 	, CONT_PUR_LCPAY C                                           \n"    
        		+ 	" 	, CONT_PUR_LC D                                              \n"    
        		+ 	" 	WHERE A.PUR_CONT_ID = B.PUR_CONT_ID(+)                       \n"
        		+ 	" 	AND B.PUR_CONT_ID = C.PUR_CONT_ID(+)                         \n"
        		+ 	" 	AND B.PAY_ID = C.PAYREQ_ID(+)                                \n"
        		+ 	" 	AND C.PUR_CONT_ID = D.PUR_CONT_ID(+)                         \n"
        		+ 	" 	AND C.LC_NO = D.SEQ(+)                                       \n"
        		+ 	" 	AND A.PUR_CONT_ID = '"+Params.get("pur_cont_id")+"'          \n"
        		+ 	" 	ORDER BY  B.GB , DECODE(NVL(C.PAY_DATE, ''), '', B.PAY_DATE, C.PAY_DATE)        \n";    	*/	 
        	
            search.setStatement(sqlstr);
            WAFLogger.debug(sqlstr.toString());
            listRowSet = search.execute();
           
        }
        catch(Exception e) {
            WAFLogger.error(this.getClass().getName() + " --> getList() : " + e.getMessage());
            WAFLogger.error("SQL : " + search.getStatement());
            WAFLogger.error(e);
            return null;
        }
        finally {
            if( listRowSet == null ) listRowSet = new RowSetImpl();
            return listRowSet;
        }
    }
    
	private boolean updateData(Connection connection, ValueObject sqlParams) throws Exception {
		PreparedStatement pstmt = null;
		
		try {
			StringBuffer sql = new StringBuffer();
			sql.append("MERGE INTO CONT_PUR_LC A  		           			                \n");
			sql.append("USING DUAL  					                                    \n");
			sql.append("   ON (A.PUR_CONT_ID = ? 					                        \n");
			sql.append("  AND A.SEQ = ? )  					                            \n");
			sql.append(" WHEN MATCHED THEN  	 			                                \n");
			sql.append("      UPDATE           					                            \n");
			sql.append("      SET LC_NO       = ?   				                        \n");
			sql.append("         ,LC_AMT      = ?   				                        \n");
			sql.append("         ,RATE        = ? 					                        \n");
			sql.append("         ,OPEN_DATE   = ?  					                        \n");
			sql.append("         ,EXPIRE_DATE = ?  					                        \n");
			sql.append("         ,BANK_CD     = ?  					                        \n");
			sql.append("         ,BANK_NM     = ?  					                        \n");
			sql.append("         ,UP_BY       = ?  					                        \n");
			sql.append("         ,UP_DATE     =  SYSDATE		 	                        \n");
			sql.append("         ,PAY_CONDI   = ?   		 	                            \n");
			sql.append("  WHEN NOT MATCHED THEN  					                        \n");
			sql.append("       INSERT (PUR_CONT_ID, SEQ, LC_NO, LC_AMT, RATE,   			\n");
			sql.append("		       OPEN_DATE, EXPIRE_DATE, BANK_CD, BANK_NM, CRE_BY,   	\n");
			sql.append("		       CRE_DATE, UP_BY, UP_DATE, PAY_CONDI)                 \n");
			sql.append("        VALUES(? , CONT_PUR_LC_S.NEXTVAL, ?, ?, ?, 			     	\n");
			sql.append("               ? ,  ?, ?, ?, ?, 			 	                    \n");
			sql.append("               SYSDATE , ? , SYSDATE, ?)		 	                \n");
			
			pstmt = connection.prepareStatement(sql.toString());
			int paramIdx = 1;
			
			pstmt.setString(paramIdx++, sqlParams.get("PUR_CONT_ID"));
			pstmt.setString(paramIdx++, sqlParams.get("SEQ"));
 
			pstmt.setString(paramIdx++, sqlParams.get("LC_NO"));
			pstmt.setString(paramIdx++, sqlParams.get("LC_AMT"));
			pstmt.setString(paramIdx++, sqlParams.get("RATE"));
			pstmt.setString(paramIdx++, sqlParams.get("OPEN_DATE"));
			pstmt.setString(paramIdx++, sqlParams.get("EXPIRE_DATE"));
			pstmt.setString(paramIdx++, sqlParams.get("BANK_CD"));
			pstmt.setString(paramIdx++, sqlParams.get("BANK_NM"));
			pstmt.setString(paramIdx++, storage.getUser().get("ACCT_ID"));
			pstmt.setString(paramIdx++, sqlParams.get("PAY_CONDI"));
			
			
			pstmt.setString(paramIdx++, sqlParams.get("PUR_CONT_ID"));
			pstmt.setString(paramIdx++, sqlParams.get("LC_NO"));
			pstmt.setString(paramIdx++, sqlParams.get("LC_AMT"));
			pstmt.setString(paramIdx++, sqlParams.get("RATE"));
			pstmt.setString(paramIdx++, sqlParams.get("OPEN_DATE"));
			pstmt.setString(paramIdx++, sqlParams.get("EXPIRE_DATE"));
			pstmt.setString(paramIdx++, sqlParams.get("BANK_CD"));
			pstmt.setString(paramIdx++, sqlParams.get("BANK_NM"));
			pstmt.setString(paramIdx++, storage.getUser().get("ACCT_ID"));
			pstmt.setString(paramIdx++, storage.getUser().get("ACCT_ID"));
			pstmt.setString(paramIdx++, sqlParams.get("PAY_CONDI"));
			//System.out.println(sql.toString());
			pstmt.executeUpdate();
			return true;
			
		} catch (Exception e) {
			WAFLogger.error(e);
			System.out.println(e);
			throw new Exception(e);
		} finally {
			try {
				if(pstmt != null) pstmt.close();
			} catch(SQLException se) {
				WAFLogger.error(se);
			}
		}
	}	
	
	private boolean deleteData(Connection connection, ValueObject sqlParams) throws Exception {
		PreparedStatement pstmt = null;
		PreparedStatement pstmt1 = null;
		try {
			StringBuffer sql = new StringBuffer();
			StringBuffer sql1 = new StringBuffer();
			sql.append("DELETE   		           			                            \n");
			sql.append("  FROM CONT_PUR_LC 					                            \n");
			sql.append(" WHERE PUR_CONT_ID = ? 					                        \n");
			sql.append("   AND SEQ = ?   					                            \n");
			pstmt = connection.prepareStatement(sql.toString());
			int paramIdx = 1;
			pstmt.setString(paramIdx++, sqlParams.get("PUR_CONT_ID"));
			pstmt.setString(paramIdx++, sqlParams.get("SEQ"));
			pstmt.executeUpdate();
			
			sql1.append("DELETE   		           			                                \n");
			sql1.append("  FROM CONT_PUR_LCPAY 					                            \n");
			sql1.append(" WHERE PUR_CONT_ID = ? 					                        \n");
			sql1.append("   AND LC_NO = ?   					                            \n");
			pstmt1 = connection.prepareStatement(sql1.toString());
			int paramIdx1 = 1;
			pstmt1.setString(paramIdx1++, sqlParams.get("PUR_CONT_ID"));
			pstmt1.setString(paramIdx1++, sqlParams.get("SEQ"));
			pstmt1.executeUpdate();
			
			return true;
			
		} catch (Exception e) {
			WAFLogger.error(e);
			System.out.println(e);
			throw new Exception(e);
		} finally {
			try {
				if(pstmt != null) pstmt.close();
			} catch(SQLException se) {
				WAFLogger.error(se);
			}
		}
	}	
	
	private boolean updateDataDetail(Connection connection, ValueObject sqlParams) throws Exception {
		PreparedStatement pstmt = null;

		try {
			StringBuffer sql = new StringBuffer();
			sql.append("MERGE INTO CONT_PUR_LCPAY A  		           	                    \n");
			sql.append("USING DUAL  					                                    \n");
			sql.append("   ON (A.PUR_CONT_ID = ? 					                        \n");
			sql.append("  AND A.SEQ = ? )  		                                    \n");
			sql.append(" WHEN MATCHED THEN  	 			                                \n");
			sql.append("      UPDATE           					                            \n");
			sql.append("      SET PAY_GB      = ?   				                        \n");
			//sql.append("         ,PAYREQ_ID   = ?   				                        \n");
			//sql.append("         ,PAY_SEQ     = ?  					                    \n");
			sql.append("         ,UP_BY       = ?  					                        \n");
			sql.append("         ,UP_DATE     =  SYSDATE		 	                        \n");
			sql.append("         ,PAY_AMT     = ?  					                        \n");
			sql.append("         ,RATE        = ?  					                        \n");
			sql.append("         ,NEGO_DATE   = ?  					                        \n");
			sql.append("         ,PAY_DATE    = ?  					                        \n");
			sql.append("         ,USANCE_INT  = ?  					                        \n");
			sql.append("         ,LC_NO       = ?                                           \n");
			sql.append("  WHEN NOT MATCHED THEN  					                        \n");
			sql.append("       INSERT (PUR_CONT_ID, SEQ, PAY_GB, PAYREQ_ID,   		        \n");
			sql.append("		       CRE_BY, CRE_DATE, UP_BY, UP_DATE, PAY_AMT,   	    \n");
			sql.append("		       RATE, NEGO_DATE, PAY_DATE, USANCE_INT, LC_NO)  		\n");
			sql.append("       VALUES (  ? , (SELECT NVL(MAX(SEQ)+1,1) FROM CONT_PUR_LCPAY WHERE PUR_CONT_ID = ? ), ?, ?,    	\n");
			sql.append("               ? , SYSDATE, ?, SYSDATE, ?, 			 	            \n");
			sql.append("               ? , ? , ? , ?, ? )  			 	                    \n");
					   
			pstmt = connection.prepareStatement(sql.toString());
			int paramIdx = 1;
			
			pstmt.setString(paramIdx++, sqlParams.get("PUR_CONT_ID"));
			pstmt.setString(paramIdx++, sqlParams.get("SEQ"));
			
			pstmt.setString(paramIdx++, sqlParams.get("PAY_GB"));
			//pstmt.setString(paramIdx++, sqlParams.get("PAYREQ_ID"));
			//pstmt.setString(paramIdx++, sqlParams.get("PAY_SEQ"));
			pstmt.setString(paramIdx++, storage.getUser().get("ACCT_ID"));
			pstmt.setString(paramIdx++, sqlParams.get("PAY_AMT"));
			pstmt.setString(paramIdx++, sqlParams.get("RATE"));
			pstmt.setString(paramIdx++, sqlParams.get("NEGO_DATE"));
			pstmt.setString(paramIdx++, sqlParams.get("PAY_DATE"));
			pstmt.setString(paramIdx++, sqlParams.get("USANCE_INT"));
			pstmt.setString(paramIdx++, sqlParams.get("LC_NO"));
			
			pstmt.setString(paramIdx++, sqlParams.get("PUR_CONT_ID"));
			pstmt.setString(paramIdx++, sqlParams.get("PUR_CONT_ID"));
			pstmt.setString(paramIdx++, sqlParams.get("PAY_GB"));
			pstmt.setString(paramIdx++, sqlParams.get("PAYREQ_ID"));
			pstmt.setString(paramIdx++, storage.getUser().get("ACCT_ID"));
			pstmt.setString(paramIdx++, storage.getUser().get("ACCT_ID"));
			pstmt.setString(paramIdx++, sqlParams.get("PAY_AMT"));
			pstmt.setString(paramIdx++, sqlParams.get("RATE"));
			pstmt.setString(paramIdx++, sqlParams.get("NEGO_DATE"));
			pstmt.setString(paramIdx++, sqlParams.get("PAY_DATE"));
			pstmt.setString(paramIdx++, sqlParams.get("USANCE_INT"));
			pstmt.setString(paramIdx++, sqlParams.get("LC_NO"));
			
			pstmt.executeUpdate();
			return true;
			
		} catch (Exception e) {
			WAFLogger.error(e);
			System.out.println(e);
			throw new Exception(e);
		} finally {
			try {
				if(pstmt != null) pstmt.close();
			} catch(SQLException se) {
				WAFLogger.error(se);
			}
		}
	}	
	private boolean deleteDataDetail(Connection connection, ValueObject sqlParams) throws Exception {
		PreparedStatement pstmt = null;

		try {
			StringBuffer sql = new StringBuffer();
			sql.append("DELETE    		           	                    \n");
			sql.append("  FROM CONT_PUR_LCPAY   		           	    \n");
			sql.append(" WHERE PUR_CONT_ID = ? 					        \n");
			sql.append("   AND SEQ = ?   		                        \n");
								   
			pstmt = connection.prepareStatement(sql.toString());
			int paramIdx = 1;
			
			pstmt.setString(paramIdx++, sqlParams.get("PUR_CONT_ID"));
			pstmt.setString(paramIdx++, sqlParams.get("SEQ"));
			
			pstmt.executeUpdate();
			return true;
			
		} catch (Exception e) {
			WAFLogger.error(e);
			System.out.println(e);
			throw new Exception(e);
		} finally {
			try {
				if(pstmt != null) pstmt.close();
			} catch(SQLException se) {
				WAFLogger.error(se);
			}
		}
	}	
	
    public RowSet getCombo() {
        
        Search search = new SearchImpl();
        RowSet sysRowSet = null;
        String sqlstr = "";
        
        try {
        	sqlstr = " SELECT DETAILCD, DETAILNM \n"
                   + " FROM EBID_COM911T          \n"
                   + " WHERE BASECD = '550' ORDER BY DETAILCD                    \n";
            search.setStatement(sqlstr);
            sysRowSet = search.execute();
        }
        catch(Exception e) {

            WAFLogger.error(this.getClass().getName() + " --> getSystemRowSet() : " + e.getMessage());
            WAFLogger.error("SQL : " + search.getStatement());
            WAFLogger.error(e);
            return null;
        }
        finally {

            if( sysRowSet == null ) sysRowSet = new RowSetImpl();
            return sysRowSet;
        }
    }
    
public RowSet getComboLC(ValueObject Params) {
        
        Search search = new SearchImpl();
        RowSet sysRowSet = null;
        String sqlstr = "";
        
        try {
        	sqlstr = " SELECT SEQ, LC_NO                                           \n"
                   + " FROM CONT_PUR_LC                                            \n"
                   + " WHERE PUR_CONT_ID = '" + Params.get("pur_cont_id") + "'     \n";
            search.setStatement(sqlstr);
            System.out.println(sqlstr.toString());
            sysRowSet = search.execute();
        }
        catch(Exception e) {

            WAFLogger.error(this.getClass().getName() + " --> getSystemRowSet() : " + e.getMessage());
            WAFLogger.error("SQL : " + search.getStatement());
            WAFLogger.error(e);
            return null;
        }
        finally {

            if( sysRowSet == null ) sysRowSet = new RowSetImpl();
            return sysRowSet;
        }
    }

	
}
