package com.steering.pss.sale.order.qualityDesign.Dao.idao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.steering.pss.sale.order.qualityDesign.Dao.imp.MpsDaoImp;

import CoreFS.SA08.CoreXmlSqlParsersFactory;

/**
 * MPS
 * 
 * @author Administrator
 * 
 */
public class IMpsDao implements MpsDaoImp {
	/**
	 * 查询工艺参数记录
	 * 
	 * @param con
	 *            连接字符串
	 * @param ordPk
	 *            合同头号
	 * @param ordLnPk
	 *            合同行号
	 * @return
	 * @throws SQLException
	 */
	public int getTechParameter(Connection con, String ordPk, String ordLnPk)
			throws SQLException {
		int count = 0;
		String sql = CoreXmlSqlParsersFactory
				.getSql("IMpsDao.getTechParameter");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(1, ordPk);
		ps.setObject(2, ordLnPk);
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = Integer.parseInt(rs.getString("COUNT"));
		}
		rs.close();
		ps.close();
		return count;
	}

	/**
	 * 查询工艺参数记录
	 * 
	 * @param con
	 *            连接字符串
	 * @param ordPk
	 *            合同头号
	 * @param ordLnPk
	 *            合同行号
	 * @return
	 * @throws SQLException
	 */
	public int getTechParameter(Connection con, String ordLnPk)
			throws SQLException {
		int count = 0;
		String sql = CoreXmlSqlParsersFactory
				.getSql("IMpsDao.getTechParameterN");
		PreparedStatement ps = con.prepareStatement(sql);
		ps.setObject(2, ordLnPk);
		ResultSet rs = ps.executeQuery();
		if (rs.next()) {
			count = Integer.parseInt(rs.getString("COUNT"));
		}
		rs.close();
		ps.close();
		return count;
	}
}
