package idc.deposit.command;

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

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import idc.model.IdcCmd;
import idc.model.IdcDAO;

public class IdcWeeklyNonpaymentModifyCmd implements IdcCmd
{

	IdcDAO dao = new IdcDAO();	
	
	//주간미납리스트 
	public void execute(HttpServletRequest request, HttpServletResponse response)
	{
		String service_code = request.getParameter("service_code");
		String service_note = request.getParameter("service_note");
		
		updateServiceNote(service_code, service_note);		
	}
	
	public void updateServiceNote(String service_code, String service_note){
		Connection conn = null;
		PreparedStatement pstmt = null;		
		String sql;
		
		try {
			conn = dao.getConn();									
			sql = "UPDATE serviceDB SET service_note=? ";
			sql +="WHERE service_code=?";
			pstmt = conn.prepareStatement(sql);						
			pstmt.setString(1, service_note);
			pstmt.setString(2, service_code);			
			pstmt.executeUpdate();			
			
		} catch (Exception e) {
			e.printStackTrace();
		} finally{
			try {				
				if(pstmt != null) pstmt.close();
				if(conn != null) conn.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
	}

}
