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

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

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 org.apache.log4j.Category;

/**
 * @version $Id: SIPayeeInfo.java,v 1.0 2003/11/28 Exp $
 * @author  Shionoya Yoshiaki
 * <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/11/28 12:00:00  Original
 */
public class SIPayeeInfo extends SIBasic {
  
  private static Category log = Category.getInstance(SIConfig.SILOG4J_WEBSHOP_CATEGORY_NAME);
  
  private String mallShopCode = "";
  
  private String payMethodCode = "";
  
  private String payMethodName = "";
  
  private String payeeCode = "";
  
  private String bankCode = "";
  
  private String bankName = "";
  
  private String bankNameKana = "";
  
  private String subBankCode = "";
  
  private String subBankName = "";
  
  private String subBankNameKana = "";
  
  private String accountType = "";
  
  private String accountNo = "";
  
  private String accountName = "";
  
  private String type = "";
  
  
  public SIPayeeInfo() {}
  
  public SIPayeeInfo(Connection lConnection,String payMethodCode) {
    if (SIUtil.isNull(payMethodCode)) return;
    else this.setPayMethodCode(payMethodCode);
    Statement lStatement = null;
    ResultSet lResultSet = null;
    
    try {
      lStatement = lConnection.createStatement();
      lResultSet = lStatement.executeQuery("SELECT * FROM payeeinfomtbl WHERE paymethodcode=" + SIDBUtil.SQL2Like(this.getPayMethodCode()));
      
      if (lResultSet.next()) {
        this.setMallShopCode(lResultSet.getString("mallshopcode"));
        this.setPayeeCode(lResultSet.getString("payeecode"));
        this.setBankCode(lResultSet.getString("bankcode"));
        this.setBankName(lResultSet.getString("bankname"));
        this.setBankNameKana(lResultSet.getString("banknamekana"));
        this.setSubBankCode(lResultSet.getString("subbankcode"));
        this.setSubBankName(lResultSet.getString("subbankname"));
        this.setSubBankNameKana(lResultSet.getString("subbanknamekana"));
        this.setAccountType(lResultSet.getString("accounttype"));
        this.setAccountNo(lResultSet.getString("accountno"));
        this.setAccountName(lResultSet.getString("accountname"));
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      SIDBUtil.close(lStatement, lResultSet);
    }
    
  }
  
  // setter of 口座名義
  public void setAccountName(String string) {
    if (string == null)
      string = "";
    string = SIUtil.changeTo(string.trim(), this.encode);
    
    accountName = string;
  }
  
  // setter of 口座番号
  public void setAccountNo(String string) {
    if (string == null)
      string = "";
    string = SIUtil.changeTo(string.trim(), this.encode);
    
    accountNo = string;
  }
  
  // setter of 口座種類
  public void setAccountType(String string) {
    if (string == null)
      string = "";
    string = SIUtil.changeTo(string.trim(), this.encode);
    
    accountType = string;
  }
  
  // setter of 金融機関コード
  public void setBankCode(String string) {
    if (string == null)
      string = "";
    string = SIUtil.changeTo(string.trim(), this.encode);
    bankCode = string;
  }
  
  // setter of 金融機関名
  public void setBankName(String string) {
    if (string == null)
      string = "";
    string = SIUtil.changeTo(string.trim(), this.encode);
    bankName = string;
  }
  
  // setter of 金融機関名カナ
  public void setBankNameKana(String string) {
    if (string == null)
      string = "";
    string = SIUtil.changeTo(string.trim(), this.encode);
    bankNameKana = string;
  }
  
  // setter of log
  public void setLog(Category category) {
    log = category;
  }
  
  // setter of 管理コード
  public void setMallShopCode(String string) {
    if (string == null)
      string = "";
    string = SIUtil.changeTo(string.trim(), this.encode);
    mallShopCode = string;
  }
  
  // setter of 支払先ID
  public void setPayeeCode(String string) {
    if (string == null)
      string = "";
    string = SIUtil.changeTo(string.trim(), this.encode);
    payeeCode = string;
  }
  
  // setter of 支払方法
  public void setPayMethodCode(String string) {
    if (string == null)
      string = "";
    string = SIUtil.changeTo(string.trim(), this.encode);
    payMethodCode = string;
  }
  
  // setter of 支払方法名称
  public void setPayMethodName(String string) {
    if (string == null)
      string = "";
    string = SIUtil.changeTo(string.trim(), this.encode);
    payMethodName = string;
  }
  
  // setter of 金融機関支店コード
  public void setSubBankCode(String string) {
    if (string == null)
      string = "";
    string = SIUtil.changeTo(string.trim(), this.encode);
    subBankCode = string;
  }
  
  // setter of 金融機関支店名
  public void setSubBankName(String string) {
    if (string == null)
      string = "";
    string = SIUtil.changeTo(string.trim(), this.encode);
    subBankName = string;
  }
  
  // setter of 金融機関支店名カナ
  public void setSubBankNameKana(String string) {
    if (string == null)
      string = "";
    string = SIUtil.changeTo(string.trim(), this.encode);
    subBankNameKana = string;
  }
  
  // setter of 表示モード
  public void setType(String string) {
    if (string == null)
      string = "";
    string = SIUtil.changeTo(string.trim(), this.encode);
    type = string;
  }
  
  /**
   * <b>getDisplayMode</b> 運用モード区分を取得します
   * 
   * @param mallShopCode
   * @return String 運用区分
   * @throws SIDBAccessException
   */
  public static String getDisplayMode(SILogin lLogin) throws SIDBAccessException {
    String[] aryDisplayMode = new String[4];
    aryDisplayMode[0] = "A"; // モール一括 ・モール管理者
    aryDisplayMode[1] = "B"; // モール一括 ・ショップ管理者
    aryDisplayMode[2] = "C"; // ショップ個別・モール管理者
    aryDisplayMode[3] = "D"; // ショップ個別・ショップ管理者
    
    if (SIUtil.match(SIConfig.SIADMIN_MM, lLogin.getAdminType()))
      return aryDisplayMode[0];
    else if (SIUtil.match(SIConfig.SIADMIN_MS, lLogin.getAdminType()))
      return aryDisplayMode[1];
    else if (SIUtil.match(SIConfig.SIADMIN_SM, lLogin.getAdminType()))
      return aryDisplayMode[2];
    else if (SIUtil.match(SIConfig.SIADMIN_SS, lLogin.getAdminType()))
      return aryDisplayMode[3];
    
    return "";
  }
  
  // getter of 口座名義
  public String getAccountName() {
    return accountName;
  }
  
  // getter of 口座番号
  public String getAccountNo() {
    return accountNo;
  }
  
  // getter of 口座種類
  public String getAccountType() {
    return accountType;
  }
  
  // getter of 金融機関コード
  public String getBankCode() {
    return bankCode;
  }
  
  // getter of 金融機関名
  public String getBankName() {
    return bankName;
  }
  
  // getter of 金融機関名カナ
  public String getBankNameKana() {
    return bankNameKana;
  }
  
  // getter of log
  public Category getLog() {
    return log;
  }
  
  // getter of 管理コード
  public String getMallShopCode() {
    return mallShopCode;
  }
  
  // getter of 支払先ID
  public String getPayeeCode() {
    return payeeCode;
  }
  
  // getter of 支払方法ID
  public String getPayMethodCode() {
    return payMethodCode;
  }
  
  // getter of 支払方法名称
  public String getPayMethodName() {
    return payMethodName;
  }
  
  // getter of 金融機関支店コード
  public String getSubBankCode() {
    return subBankCode;
  }
  
  // getter of 金融機関支店名
  public String getSubBankName() {
    return subBankName;
  }
  
  // getter of 金融機関支店名カナ
  public String getSubBankNameKana() {
    return subBankNameKana;
  }
  
  // getter of 表示モード
  public String getType() {
    return type;
  }
  
}