package com.steering.pss.plnsaleord.order.baseMethod;

import java.sql.SQLException;
import java.util.ArrayList;
import CoreFS.SA06.CoreReturnObject;
import CoreFS.SA08.CoreXmlSqlParsersFactory;
import com.steering.comm.db.DBCommon;
public class FrmBaseModelLen extends DBCommon {
	/**
	 * 查询扣型加长
	 * @return
	 */
	public CoreReturnObject doQuery(String modelCode) {
		String sql = CoreXmlSqlParsersFactory.getSql("FrmBaseModelLen.doQuery");
		if (!modelCode.equals("")) {
			sql += " AND T.MODEL_CODE='" + modelCode + "'";
		}
		sql+=" ORDER BY T.CREATE_TIME ASC";
		return this.getData(sql);
	}
	
	/**
	 * 查询扣型加长
	 * @return
	 */
	public CoreReturnObject doQueryNew(String modelCode,String leraMin,String leraMax,
			String DiaMin,String DiaMax,String thickMin,String thickMax,String jgNum) {
		String sql = CoreXmlSqlParsersFactory.getSql("FrmBaseModelLen.doQuery");
		if (!modelCode.equals("")) {
			sql += " AND T.MODEL_CODE='" + modelCode + "'";
		}
		if (!leraMin.equals("")) {
			sql += " AND T.LEN_TOLERA_MIN='" + leraMin + "'";
		}
		if (!leraMax.equals("")) {
			sql += " AND T.LEN_TOLERA_MAX='" + leraMax + "'";
		}
		if (!DiaMin.equals("")) {
			sql += " AND T.DIAMETER_MIN='" + DiaMin + "'";
		}
		if (!DiaMax.equals("")) {
			sql += " AND T.DIAMETER_MAX='" + DiaMax + "'";
		}
		if (!thickMin.equals("")) {
			sql += " AND T.WALLTHICK_MIN='" + thickMin + "'";
		}
		if (!thickMax.equals("")) {
			sql += " AND T.WALLTHICK_MAX='" + thickMax + "'";
		}
		if (!jgNum.equals("")) {
			sql += " AND T.JG_NUM='" + jgNum + "'";
		}
		sql+=" ORDER BY T.CREATE_TIME ASC";
		return this.getData(sql);
	}
	/**
	 * 查询最大ID
	 * @return
	 */
	public CoreReturnObject doQueryMaxId() {
		return this.getDataBySqlID("FrmBaseModelLen.doQueryMaxId");
	}

	/**
	 * 查询扣型
	 * 
	 * @return
	 */
	public CoreReturnObject queryModel() {
		  return this.getDataBySqlID("FrmBaseModelLen.doQueryModel");
	}
	 /**
     *新增.
     * @param parm 参数
     * @return CoreReturnObject 必须返回CoreReturnObject
     */
    public CoreReturnObject doAdd(ArrayList<Object> parm) {
        CoreReturnObject cro = new CoreReturnObject();
        String strSql = CoreXmlSqlParsersFactory
                .getSql("FrmBaseModelLen.doAdd");
        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 doUpdate(ArrayList<Object> parm) {
        CoreReturnObject cro = new CoreReturnObject();
        String strSql = CoreXmlSqlParsersFactory
                .getSql("FrmBaseModelLen.doUpdate");
        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 doDelete(ArrayList<Object> parm) {
        CoreReturnObject cro = new CoreReturnObject();
        String strSql = CoreXmlSqlParsersFactory
                .getSql("FrmBaseModelLen.doDelete");
        try {
            cro = this.getDao("TgDao").ExcuteNonQuery(strSql, parm.toArray());
        }
        catch (SQLException e) {
            cro = cro.SetErrInfo(e.getMessage());
        }
        return cro;
    }
}