package com.steering.pss.qcm;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import CoreFS.SA01.CoreIComponent;
import CoreFS.SA06.CorePageObject;
import CoreFS.SA06.CoreReturnObject;
import CoreFS.SA06.CoreSqlType.CoreOracleType;
import CoreFS.SA07.*;
import CoreFS.SA08.CoreXmlSqlParsersFactory;


/**
 * 平台的使用类都必须继承自平台的CoreIComponent类
 * 
 * @author 2014/09/24
 * @version v1.0
 * @modify
 */
public class CoreWellProductivity extends CoreIComponent {  
	/**
	 * 服务端的查询方法
	 * @param parm 姓名
	 * @return CoreReturnObject 必须返回CoreReturnObject
	 */
    public CoreReturnObject doQuery(ArrayList parm) {
    	CoreReturnObject cro = new CoreReturnObject();
        String sql = CoreXmlSqlParsersFactory.getSql("CoreWellProductivity.QUERY");
        
        if(parm != null && parm.size() == 1){
            cro = this.getDao("KgDao").ExcuteQuery(sql, parm.toArray());
        }
        
        return cro;
    }
    
    
    public CoreReturnObject bindValid() {
    	CoreReturnObject cro = new CoreReturnObject();
        String sql = CoreXmlSqlParsersFactory.getSql("CoreWellProductivity.bindValid");
        
        cro = this.getDao("KgDao").ExcuteQuery(sql);
        
        return cro;
    }
    
    public CoreReturnObject doAdd(ArrayList<ArrayList<Object>> parms) {
		CoreReturnObject cro = new CoreReturnObject();
		
		String sql = CoreXmlSqlParsersFactory.getSql("CoreWellProductivity.ADD");
		
		ArrayList<Object> sqllist=new ArrayList<Object>();
		ArrayList<Object[]> parmlist=new ArrayList<Object[]>();
		
		for(int i=0;i<parms.size();i++)
		{
			sqllist.add(sql);
			parmlist.add(parms.get(i).toArray());
		}
		
		try {
			cro = this.getDao("KgDao").ExcuteTransction(sqllist, parmlist);
		} catch (Exception e) {
			cro = cro.SetErrInfo(e.getMessage());
		}

		return cro;
	}
    

    public CoreReturnObject doDelete(ArrayList<Object> parms) {
    	CoreReturnObject cro = new CoreReturnObject();
		
		String sql = CoreXmlSqlParsersFactory.getSql("CoreWellProductivity.DELETE");
		
		try {
			cro = this.getDao("KgDao").ExcuteNonQuery(sql, parms.toArray());
		} catch (SQLException e) {
			cro = cro.SetErrInfo(e.getMessage());
		}

		return cro;
	}

	

	public CoreReturnObject doModify(ArrayList<ArrayList> parms) {

		CoreReturnObject cro = new CoreReturnObject();
		
		String sql = CoreXmlSqlParsersFactory.getSql("CoreWellProductivity.MODIFY");
		
		ArrayList<Object> sqllist=new ArrayList<Object>();
		ArrayList<Object[]> parmlist=new ArrayList<Object[]>();
		
		for(int i=0;i<parms.size();i++)
		{
			sqllist.add(sql);
			parmlist.add(parms.get(i).toArray());
		}
		
		try {
			cro = this.getDao("KgDao").ExcuteTransction(sqllist, parmlist);
		} catch (Exception e) {
			cro = cro.SetErrInfo(e.getMessage());
		}

		return cro;
		
	}

	

}
