package wenrgise.hrms.businessdelegate;

import java.rmi.RemoteException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import javax.ejb.CreateException;
import wenrgise.common.bean.BaseHeaderBean;
import wenrgise.common.exception.EnrgiseApplicationException;
import wenrgise.common.exception.EnrgiseSystemException;
import wenrgise.common.utility.RecordMetaInfo;
import wenrgise.common.vo.BaseQueryVO;
import wenrgise.common.vo.ThisPageVO;
import wenrgise.ejb.common.utility.ServiceLocator;
import wenrgise.hrms.bean.HrmLvCreditHdrBean;
import wenrgise.hrms.ejb.facade.HrmFacade;
import wenrgise.hrms.ejb.facade.HrmFacadeHome;

public class HrmLvCreditBD extends HrmBaseBD {
  public String saveImpl(BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList oDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException {
    return null;
  }
  
  public boolean updateHeaderRecordImpl(BaseHeaderBean oBaseHeaderBean) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException {
    return true;
  }
  
  public RecordMetaInfo getTotalDetailRecordCountImpl(String sPrimaryKey, String sScreenName) throws EnrgiseApplicationException, EnrgiseSystemException {
    return null;
  }
  
  public ArrayList getDetailRecordImpl(String sPrimaryKey, String sScreenName, long lAbsoluteStart, long lAbsoluteEnd) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException {
    return null;
  }
  
  public ArrayList getHeaderRecordImpl(BaseQueryVO oQueryVO, long lStartPosition, long lLastPosition) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException {
    return null;
  }
  
  public RecordMetaInfo getHeaderMetaImpl(BaseQueryVO oQueryVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    return null;
  }
  
  public String submitImpl(String sButtonName, BaseHeaderBean oBaseHeaderBean, Timestamp oWhenPicked, String sScreenName, String sScreenMode, boolean bHeaderDataChanged, ArrayList oDetailBeanArray, boolean bDetailDataChanged, Timestamp oDetailPicked) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException {
    try {
      String sHeaderPrimaryKey = null;
      HrmFacadeHome oHome = (HrmFacadeHome)ServiceLocator.getLocator().getService("HrmFacade");
      HrmFacade oFacade = oHome.create();
      if (sButtonName.equalsIgnoreCase("butCreditLeaves"))
        sHeaderPrimaryKey = oFacade.creditLeaves((HrmLvCreditHdrBean)oBaseHeaderBean, oWhenPicked, oDetailBeanArray, oDetailPicked); 
      return sHeaderPrimaryKey;
    } catch (CreateException oCrt) {
      throw new EnrgiseSystemException(oCrt);
    } 
  }
  
  public String getInsertDataImpl(BaseQueryVO oBaseQueryVO) throws RemoteException, EnrgiseApplicationException, EnrgiseSystemException {
    return null;
  }
  
  public Map getDisabledFieldsImpl(ThisPageVO oThisPageVO) throws EnrgiseApplicationException, EnrgiseSystemException {
    HashMap oHashMap = new HashMap();
    ArrayList oDisableList = new ArrayList();
    ArrayList oEnableList = new ArrayList();
    oDisableList.add("butDelete");
    oDisableList.add("butExecute");
    oDisableList.add("butInsert");
    oDisableList.add("butSave");
    oDisableList.add("butRefresh");
    oDisableList.add("butPrint");
    oDisableList.add("buttxtRegion");
    oDisableList.add("butCreditLeaves");
    HrmLvCreditHdrBean oHrmLvCreditHdrBean = (HrmLvCreditHdrBean)oThisPageVO.getOHeaderBean();
    if (null != oHrmLvCreditHdrBean.getEmployeeNoId() && null != oHrmLvCreditHdrBean.getLeaveTypeId() && null != oHrmLvCreditHdrBean.getTxtNoOfDays()) {
      oEnableList.add("butCreditLeaves");
      oEnableList.add("butQuery");
    } else {
      oDisableList.add("butCreditLeaves");
      oDisableList.add("butQuery");
    } 
    oHashMap.put("D", oDisableList);
    oHashMap.put("E", oEnableList);
    return oHashMap;
  }
}
