/**
 * Copyright (c) 2003-2004 System Integrator Corporation.
 *                 All Rights Reserved.
 */
package jp.co.sint.beans.mallmgr;

import java.sql.Connection;

//import javax.servlet.http.HttpServletRequest;　//7.1.1 ST0236 削除

import jp.co.sint.basic.SIBasic;
import jp.co.sint.config.SIConfig;
import jp.co.sint.database.SIDBAccessException;
import jp.co.sint.database.SIDBUtil;
import jp.co.sint.tools.SIUtil;
import jp.co.sint.tools.SIURLParameter;//7.1.1 ST0236 追加

import org.apache.log4j.Category;

/**
 * @version $Id: UISelectCtgry.java,v 1.0 2003/09/26 Exp $
 * @author  Jinwang Chen
 * <br>Description:
 * <p>History</p>
 * <p>Author&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Date&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Reason</p>
 *  ============&nbsp;&nbsp;&nbsp;==========&nbsp;&nbsp;===========================<br>
 * Jinwang Chen    2003/09/26 10:25:47  Original
 */
public class UISelectCtgry extends SIBasic{
  //ログ用のインスタンスの生成
  private static Category log=Category.getInstance(SIConfig.SILOG4J_WEBSHOP_CATEGORY_NAME);

  //カテゴリコード
  private String ctgryCodeTxt=SIConfig.SICATEGORY_ROOT_CODE;

  //カテゴリ名
  private String ctgryNameTxt="";

  public UISelectCtgry(){
  }

  //setter of カテゴリコード
  public void setCtgryCodeTxt(String lCtgryCodeTxt){
    if (SIUtil.isNull(lCtgryCodeTxt)) lCtgryCodeTxt=SIConfig.SICATEGORY_ROOT_CODE;
    this.ctgryCodeTxt=SIUtil.changeTo(lCtgryCodeTxt.trim(),this.encode);
  }

  //setter of カテゴリ名
  public void setCtgryNameTxt(String lCtgryNameTxt){
    if (SIUtil.isNull(lCtgryNameTxt)) lCtgryNameTxt="";
    this.ctgryNameTxt=SIUtil.changeTo(lCtgryNameTxt.trim(),this.encode);
  }

  //getter of カテゴリコード
  public String getCtgryCodeTxt(){
    return this.ctgryCodeTxt;
  }

  //getter of カテゴリコード
  public String getCtgryNameTxt(){
    return this.ctgryNameTxt;
  }

  /**
   * <b>init</b>
   * 該当商品レコードに関わる各パラメータデータを取得して設定します。
   * @param lUrlParam
   * @param lConnection ＤＢへのコネンクション
   * @return なし
   * @throws なし
   */
  public void init(SIURLParameter lUrlParam,Connection lConnection){//7.1.1 ST0236 修正
    this.setEncode(SIConfig.SIENCODE_SHIFT_JIS);
    this.setCtgryCodeTxt((String)lUrlParam.getParam("ctgryCodeTxt"));//カテゴリコード	//7.1.1 ST0236 修正
    this.setCtgryNameTxt((String)lUrlParam.getParam("ctgryNameTxt"));//カテゴリコード	//7.1.1 ST0236 修正
    if (SIUtil.isNull(this.getCtgryNameTxt())){
      this.setEncode(SIConfig.SIENCODE_NONE);
      String lSql="SELECT CtgryName FROM CtgryMTbl WHERE CtgryCode="+SIDBUtil.SQL2Str(getCtgryCodeTxt());
      try {
        this.setCtgryNameTxt(SIDBUtil.getFirstData(lConnection,lSql));
      } catch (SIDBAccessException e) {
        e.printStackTrace();
      }
    }
  }
}
