package core.stlmes.server.sale.dao;

import java.text.SimpleDateFormat;
import java.util.Date;

import CoreFS.SA06.CoreReturnObject;

public class SlmBusinessOpeInfoDao extends BaseService
{
	public CoreReturnObject insert(
			core.stlmes.server.sale.po.SlmBusinessOpeInfoBean bean)
			throws java.sql.SQLException,java.lang.Exception
	{
		CoreReturnObject obj = new CoreReturnObject();
		java.lang.StringBuilder sb = new StringBuilder();
		sb.append(" INSERT INTO SLM_BUSINESS_OPEINFO( ");
		sb.append("SEQ, ");
		sb.append("BUSINESSTYPE, ");
		sb.append("ORDER_NO, ");
		sb.append("ORDER_SEQ, ");
		sb.append("DLIV_DIRNO, ");
		sb.append("INVOICENO, ");
		sb.append("BUYERCODE, ");
		sb.append("PERSON, ");
		sb.append("BUSINESS_DATE, ");
		sb.append("BUSINESS_VALUE  ");
		sb.append(" ) ");
		sb.append("  VALUES ");
		sb.append("  ( ");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ,");
		sb.append("? ");
		sb.append(" ) ");

		Object[] params = new Object[]
		{ java.util.UUID.randomUUID().toString(), bean.getBusinessType(),
				bean.getOrder_no(), bean.getOrder_seq(), bean.getDliv_dirno(),
				bean.getInvoiceNo(), "", bean.getPerson(), new Date(),
				bean.getBusinessValue() };
		String sql = sb.toString();
		sql = super.getPreparedSQL(sql, params);
		super.ExcuteNonQuery(sql);
		return obj;

	}

	public CoreReturnObject delete(int saveDays) throws java.sql.SQLException,
			java.lang.Exception
	{
		CoreReturnObject cro = new CoreReturnObject();
		String sqlStr = " delete from SLM_BUSINESS_OPEINFO a where 1 = 1 and business_date < sysdate - ? ";
		sqlStr = super.getPreparedSQL(sqlStr, new Object[]
		{ saveDays });
		super.ExcuteNonQuery(sqlStr);
		return cro;

	}

}
