package com.steering.pss.qcm;

import java.sql.SQLException;
import java.util.ArrayList;

 
import CoreFS.SA06.CoreReturnObject;
import CoreFS.SA08.CoreXmlSqlParsersFactory;

import com.steering.comm.db.DBCommon;

/**
 * 基础信息管理类
 * @author wq 2014/10/13
 * @version v1.0
 * @modify
 */
public class CoreMenuzConfigure extends DBCommon {

    /**
     * 获取当前父节点下，最大编号
     * @param parm
     * @return
     */
    public CoreReturnObject GetMaxBaseCode(String sortcode) {
        String sql = CoreXmlSqlParsersFactory.getSql("CoreMenuzConfigure.GetMaxBaseCode");

        if("".equals(sortcode)){
            sql += " and SORT_CODE is null or SORT_CODE='' ";
        }else{
        	sql += " and SORT_CODE ='" + sortcode + "'";
        }
        return this.getData(sql);
    }

    /**
     * 基础信息新增
     * @param parm
     * @return
     */
    public CoreReturnObject doAddMemu(ArrayList<Object> parm) {
        CoreReturnObject cro = new CoreReturnObject();
        String strSql = CoreXmlSqlParsersFactory.getSql("CoreMenuzConfigure.doAddMemu");
        try {
            cro = this.getDao("TgDao").ExcuteNonQuery(strSql, parm.toArray());
        }
        catch (SQLException e) {
            cro = cro.SetErrInfo(e.getMessage());
        }
        return cro;
    }

    /**
     * 基础信息修改
     * @param parm
     * @return CoreReturnObject 必须返回CoreReturnObject
     */
    public CoreReturnObject doUpdateMemu(ArrayList<Object> parm) {
        CoreReturnObject cro = new CoreReturnObject();
        String strSql = CoreXmlSqlParsersFactory
                .getSql("CoreMenuzConfigure.doUpdateMemu");
        try {
            cro = this.getDao("TgDao").ExcuteNonQuery(strSql, parm.toArray());
        }
        catch (SQLException e) {
            cro = cro.SetErrInfo(e.getMessage());
        }
        return cro;
    }
    
    /**
     * 页面信息修改
     * @param parm
     * @return CoreReturnObject 必须返回CoreReturnObject
     */
    public CoreReturnObject doUpdatePage(ArrayList<Object> parm) {
        CoreReturnObject cro = new CoreReturnObject();
        String strSql = CoreXmlSqlParsersFactory
                .getSql("CoreMenuzConfigure.doUpdatePage");
        try {
            cro = this.getDao("TgDao").ExcuteNonQuery(strSql, parm.toArray());
        }
        catch (SQLException e) {
            cro = cro.SetErrInfo(e.getMessage());
        }
        return cro;
    }

    /**
     * 基础信息删除或恢复
     * @param plineCodes
     * @param operator 操作人
     * @param isDelete true删除 false恢复
     * @return CoreReturnObject 必须返回CoreReturnObject
     */
    public CoreReturnObject doDelete(ArrayList<Object> parm) {
    	CoreReturnObject cro = new CoreReturnObject();
        String strSql = CoreXmlSqlParsersFactory
                .getSql("CoreMenuzConfigure.doDelete");
        try {
            cro = this.getDao("TgDao").ExcuteNonQuery(strSql, parm.toArray());
        }
        catch (SQLException e) {
            cro = cro.SetErrInfo(e.getMessage());
        }
        return cro;
    }

    /**
     * 基础APP信息查询
     * @param includeDeleted 是否包含已删除数据
     * @param productionLineName 产线名称
     * @param departmentDesc 管理部门描述
     * @return CoreReturnObject 必须返回CoreReturnObject
     */
    public CoreReturnObject getTreeData() {

        return this
                .getDataBySqlID("CoreMenuzConfigure.TreeData");
    }
    
    /**
     * 基础APP页面信息查询
     */
    public CoreReturnObject getPageData(String validflag,String sortCode) {
    	Object[] obj = new Object[] { validflag, sortCode,"P"};
        return this.getDataBySqlID("CoreMenuzConfigure.getPageData", obj);
    }

}
