package core.stlmes.server.sale.dao;

import java.sql.SQLException;
import java.util.List;

import core.stlmes.server.sale.po.SlmOrderDeliveryTransitTgBean;
import core.stlmes.server.sale.po.SlmOrderLineDeliveryTgBean;
import core.stlmes.server.sale.po.SlmOrderLineTgBean;

import CoreFS.SA06.CoreReturnObject;

public class SlmOrderLineDeliveryTgDao extends BaseService
{
	private List<SlmOrderLineDeliveryTgBean> query(String sqlCondition)
			throws SQLException
	{
		List<SlmOrderLineDeliveryTgBean> list = null;
		String sqlStr = " select * from SLM_ORDER_LINE_DELIVERY where 1 = 1"
				+ " and VALIDFLAG = '1' ";
		sqlStr = sqlStr + sqlCondition;
		list = SlmOrderLineDeliveryTgBean.convertResultSetToBeanList(super
				.executeForResult(sqlStr));
		return list;
	}

	public SlmOrderLineDeliveryTgBean getSlmOrderDeliveryTransitTgByOrdPkAndOrdlnPkAndDlyPk(
			String ordPk, String ordLnPk, String ordDlyPk) throws SQLException
	{
		List<SlmOrderLineDeliveryTgBean> list = null;
		String sqlCondition = super.GetSqlConditionByStringValue("ORD_PK",
				ordPk);
		sqlCondition += super
				.GetSqlConditionByStringValue("ORD_LN_PK", ordLnPk);
		sqlCondition += super.GetSqlConditionByStringValue("ORD_LN_DLY_PK",
				ordDlyPk);
		list = query(sqlCondition);
		if (list == null || list.size() == 0) return null;
		return list.get(0);

	}

	public List<SlmOrderLineDeliveryTgBean> getSlmOrderLineDeliveryByOrdPkAndOrdlnPk(
			String ordPk, String ordLnPk) throws SQLException
	{
		List<SlmOrderLineDeliveryTgBean> list = null;
		String sqlCondition = super.GetSqlConditionByStringValue("ORD_PK",
				ordPk);
		sqlCondition += super
				.GetSqlConditionByStringValue("ORD_LN_PK", ordLnPk);

		list = query(sqlCondition);
		return list;

	}

	public List<SlmOrderLineDeliveryTgBean> getSlmOrderLineDeliveryByOrdPk(
			String ordPk) throws SQLException
	{
		List<SlmOrderLineDeliveryTgBean> list = null;
		String sqlCondition = super.GetSqlConditionByStringValue("ORD_PK",
				ordPk);

		list = query(sqlCondition);
		return list;

	}

}
