package com.steering.pss.sale.order;
import java.sql.SQLException;
import java.util.ArrayList;

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

import com.steering.comm.db.DBCommon;
import com.steering.comm.tools.StringTool;

public class frmOrderReviewDelivery extends DBCommon {
    /**
     *合同交货期评审界面数据查询.
     *@param doQuery
     * @param appdate 签约时间
     * @param order 合同号
     * @param appstatus 审批状态
     * @return CoreReturnObject
     */
    public CoreReturnObject CoreOrderDelvryQuery(String appdate, String order, String appstatus) {
        String sql = CoreXmlSqlParsersFactory
                .getSql("frmOrderReviewDelivery.CoreOrderDelvryQuery");
        //Object[] params = new Object[] { appdate, order, appstatus };
        if (!StringTool.isNullOrEmpty(appdate)) {
            sql += appdate;
        }
        if (!StringTool.isNullOrEmpty(order)) {
            sql += " and B3.ORDER_NO = '" + order + "'";
        }
        if (!StringTool.isNullOrEmpty(appstatus)) {
           if(appstatus.equals("0"))
           {
               sql += " and B3.DELVRY_EDATE_MET <> '1'";
           }
           else
           {
               sql += " and B3.DELVRY_EDATE_MET = '" + appstatus + "'";
           }
        }
        sql += " order by ORDER_NO";
        return this.getData(sql);
    }
    /**
     * 根据合同号查询合同行信息
     * @param ordermodel 合同范本
     * @return CoreReturnObject
     */
    public CoreReturnObject CoreOrderSqeDelvryQuery(String ordermodel){
        Object[] obj = new Object[] { ordermodel };
        return this.getDataBySqlID("frmOrderReviewDelivery.CoreOrderSqeDelvryQuery",
                obj);
    }
    /**
     * 根据合同号查询交货信息
     * @param ordermodel 合同范本
     * @return CoreReturnObject
     */
    public CoreReturnObject CoreOrderDelvryTableQuery(String ordermodel){
        Object[] obj = new Object[] { ordermodel };
        return this.getDataBySqlID("frmOrderReviewDelivery.CoreOrderDelvryTableQuery",
                obj);
    }
    /**
     * 合同法务交货期审批业务保存.
     * @param parm 参数
     * @return CoreReturnObject 必须返回CoreReturnObject
     */
    public CoreReturnObject ReviewDeliverySave(ArrayList<Object> parm) {
        CoreReturnObject cro = new CoreReturnObject();
        String strSql = CoreXmlSqlParsersFactory
                .getSql("frmOrderReviewDelivery.ReviewDeliverySave");
        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 ReviewDeliveryDelete(ArrayList<Object> parm) {
        CoreReturnObject cro = new CoreReturnObject();
        String strSql = CoreXmlSqlParsersFactory
                .getSql("frmOrderReviewDelivery.ReviewDeliveryDelete");
        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 reviewDeliverySure(ArrayList<Object> parm) {
        CoreReturnObject cro = new CoreReturnObject();
        String strSql = CoreXmlSqlParsersFactory
                .getSql("frmOrderReviewDelivery.reviewDeliverySure");
        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 reviewDeliverySure2(ArrayList<Object> parm) {
        CoreReturnObject cro = new CoreReturnObject();
        String strSql = CoreXmlSqlParsersFactory
                .getSql("frmOrderReviewDelivery.reviewDeliverySure2");
        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 reviewDeliverySure3(ArrayList<Object> parm) {
        CoreReturnObject cro = new CoreReturnObject();
        String strSql = CoreXmlSqlParsersFactory
                .getSql("frmOrderReviewDelivery.reviewDeliverySure3");
        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 reviewDeliverySure4(ArrayList<Object> parm) {
        CoreReturnObject cro = new CoreReturnObject();
        String strSql = CoreXmlSqlParsersFactory
                .getSql("frmOrderReviewDelivery.reviewDeliverySure4");
        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 reviewDeliverySure5(ArrayList<Object> parm) {
        CoreReturnObject cro = new CoreReturnObject();
        String strSql = CoreXmlSqlParsersFactory
                .getSql("frmOrderReviewDelivery.reviewDeliverySure5");
        try {
            cro = this.getDao("TgDao").ExcuteNonQuery(strSql, parm.toArray());
        }
        catch (SQLException e) {
            cro = cro.SetErrInfo(e.getMessage());
        }
        return cro;
    }
}
