package idc.service.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.*;

public class IdcDaddDeleteHandleCmd implements IdcCmd{

	IdcDAO dao = new IdcDAO();
	
	public void execute(HttpServletRequest request, HttpServletResponse response){
		String deffence_case = request.getParameter("deffence_case");
		String dadd_num = request.getParameter("dadd_num");
		
		request.setAttribute("deffence_case", deffence_case);
		
		daddDelete(dadd_num);
	}
	
	//deffence1add에서 삭제
	public void daddDelete(String dadd_num){
		Connection conn = null;
		PreparedStatement pstmt = null;
		
		try {
			conn = dao.getConn();			
			String sql = "DELETE FROM deffence1add WHERE dadd_num=?";
			pstmt = conn.prepareStatement(sql);
			pstmt.setInt(1, Integer.parseInt(dadd_num));			
			pstmt.executeUpdate();
			
		} catch (Exception e) {
			e.printStackTrace();
		} finally{
			try {
				if(pstmt != null) pstmt.close();
				if(conn != null) conn.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
	}

}