package utility;

import idc.model.IdcDAO;

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

public class IdcPaymentListUpdate
{
	public static void SetPaymentList(String name, String code, String _case, String payment)
	{
		IdcDAO dao = new IdcDAO();
		
		Connection conn=null;
		PreparedStatement pstmt=null;
		try	
		{
			conn=dao.getConn();
			String sql = "INSERT INTO paymentList (client_name, service_code, _case, payment_date, payment) ";
			sql += "values(?, ?, ?, curdate(), ?)";
			pstmt =conn.prepareStatement(sql);
			
			pstmt.setString(1, name);
			pstmt.setString(2, code);
			pstmt.setString(3, _case);
			pstmt.setString(4, payment);
			
			pstmt.executeUpdate();
		}
		catch (Exception e) 
		{
			System.out.println("IdcPaymentListUpdate - SetPaymentList 에서의 exception");
			e.printStackTrace();
		}
		finally
		{
			try 
			{
				if(conn!=null) conn.close();
				if(pstmt!=null)pstmt.close();
			}
			catch (SQLException e) 
			{
				System.out.println("IdcPaymentListUpdate - SetPaymentList 에서의 sqlexception");
				e.printStackTrace();
			}
		}
	}
}
