package core.stlmes.server.sale.dao.fund;

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

import CoreFS.SA06.CoreReturnObject;
import core.stlmes.server.sale.dbhelp.DbTrans;
import core.stlmes.server.sale.po.SlmBalanceInfoBean;
import core.stlmes.server.sale.po.fund.SelFundCustAccountBean;
import core.stlmes.server.sale.po.fund.SelFundCustFundInoutBean;
import core.stlmes.server.sale.po.fund.SelFundPactAccountBean;

public class FundPactAccountDao extends BaseDao
{
	private List<SelFundPactAccountBean> query(String sqlCondition)
			throws SQLException
	{
		List<SelFundPactAccountBean> list = null;
		String sqlStr = "select * from sel_fund_pact_account  where   1 = 1 ";
		sqlStr = sqlStr + sqlCondition;
		java.sql.ResultSet set = super.executeForResult(sqlStr);
		list = SelFundPactAccountBean.convertResultSetToBeanList(set);
		return list;
	}

	public List<SelFundPactAccountBean> GetSelFundPactAccountByBalAndBuyercodeAndSecAccount(
			String balancesubject, String buyerCode, String secAccount)
			throws SQLException
	{
		String sqlCondition = super.getSqlCondition(balancesubject, buyerCode,
				secAccount);
		return query(sqlCondition);
	}

	public List<SelFundPactAccountBean> GetSelFundPactAccountByBalanceAndBuyerCodeAndSecAndPactno(
			String balancesubject, String buyerCode, String secAccount,
			String pactno) throws SQLException
	{
		String sqlCondition = super.getSqlCondition(balancesubject, buyerCode,
				secAccount, pactno);
		return query(sqlCondition);
	}

	public CoreReturnObject insert(SelFundPactAccountBean bean)
			throws java.sql.SQLException,java.lang.Exception
	{
		CoreReturnObject cro = new CoreReturnObject();
		String sqlIn = " insert into  sel_fund_pact_account"
				+ " ( balancesubject,buyercode,secondaccount,"
				+ " pactno, totalmoney,leavemoney,"
				+ " pact_begindate,isinvoince,importor,"
				+ " importtime, updatetime ) " + "  values"
				+ "(?,?,?,?,?,?,?,?,?,sysdate, sysdate)";
		Object[] obj = new Object[]
		{ bean.getBalancesubject(), bean.getBuyercode(),
				bean.getSecondaccount(), bean.getPactno(),
				bean.getTotalmoney(), bean.getLeavemoney(),
				bean.getPact_begindate(), bean.getIsinvoince(),
				bean.getImportor() };
		String sql = super.getPreparedSQL(sqlIn, obj);
		return cro;

	}

}
