package com.seeyon.apps.src_financing.dao;


import com.seeyon.ctp.common.exceptions.BusinessException;
import com.seeyon.ctp.util.JDBCAgent;

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

public class FinancingContractDaoImpl implements IFinancingContractDao {

//	本地
//	private String daleteFZFinancing = "delete from formmain_0097 WHERE field0002 = ?";
//	private String daleteFZFinancingSub = "delete from formson_0098 WHERE FORMMAIN_ID in (SELECT ID FROM formmain_0097 WHERE field0002 = ? )";
//	测试
//	private String daleteFZFinancing = "delete from formmain_0019 WHERE field0002 = ?";
//	private String daleteFZFinancingSub = "delete from formson_0020 WHERE FORMMAIN_ID in (SELECT ID FROM formmain_0019 WHERE field0002 = ? )";
//	正式
	private String daleteFZFinancing = "delete from formmain_0760 WHERE field0002 = ?";
	private String daleteFZFinancingSub = "delete from formson_0761 WHERE FORMMAIN_ID in (SELECT ID FROM formmain_0760 WHERE field0002 = ? )";



	
	@Override
	public int daleteFZFinancing(String contractCode) throws BusinessException, SQLException {
		int i = 0 ;
		JDBCAgent agent = new JDBCAgent();
		try {
			StringBuilder sql = new StringBuilder(daleteFZFinancing);
			List<Object> p = new ArrayList<Object>();
			p.add(contractCode);
			i=agent.execute(sql.toString(), p);
		}finally {
			if (agent != null) {
				agent.close();
			}
		}
		return i;
	}


	@Override
	public int daleteFZFinancingSub(String contractCode) throws BusinessException, SQLException {
		int i = 0 ;
		JDBCAgent agent = new JDBCAgent();
		try {
			StringBuilder sql = new StringBuilder(daleteFZFinancingSub);
//			StringBuilder sql = new StringBuilder("delete from formmain_0536 where id=?");
			List<Object> p = new ArrayList<Object>();
			p.add(contractCode);
			i=agent.execute(sql.toString(), p);
		}finally {
			if (agent != null) {
				agent.close();
			}
		}
		return i;
	}


}