ν”„λ‘œμ νŠΈ 기둝

μ˜ˆμ•½ 선택 μ·¨μ†Œ κΈ°λŠ₯ μΆ”κ°€

μ½”λ”©ν•˜λŠ” λΆ•μ–΄ 2021. 2. 15. 02:46
λ°˜μ‘ν˜•

ν•œ λͺ…μ˜ νšŒμ›μ΄ μ—¬λŸ¬λ²ˆ μ˜ˆμ•½μ„ ν–ˆμ„ λ•Œ

μ˜ˆμ•½μ„ μ„ νƒν•΄μ„œ μ·¨μ†Œν•  수 있게 κ΅¬ν˜„ν•˜μ˜€λ‹€

​

​

​​

ReservationRemoveAction.java

package reservation.action;

import java.io.PrintWriter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import action.Action;
import reservation.svc.ReservationRemoveService;
import subject.svc.SubjectCartRemoveService;
import vo.ActionForward;

public class ReservationRemoveAction implements Action {

	@Override
	public ActionForward execute(HttpServletRequest request, HttpServletResponse response) throws Exception {

		String[] res_num = request.getParameterValues("res_num");

		ReservationRemoveService reservationRemoveService = new ReservationRemoveService();

		boolean result = reservationRemoveService.removeResService(res_num);
		ActionForward forward = null;

		if (result == true) {
			forward = new ActionForward("ReservationViewAction.res", false);

		} else {
			response.setContentType("text/html;charset=UTF-8");
			PrintWriter out = response.getWriter();
			out.println("<script>");
			out.println("alert('μ˜ˆμ•½ μ·¨μ†Œ μ‹€νŒ¨')");
			out.println("history.back()");
			out.println("</script>");
		}

		return forward;
	}

}

 

 

ReservationRemoveService.java

package reservation.svc;

import static db.JdbcUtil.close;
import static db.JdbcUtil.commit;
import static db.JdbcUtil.getConnection;
import static db.JdbcUtil.rollback;
import java.sql.Connection;
import dao.ReservationDAO;

public class ReservationRemoveService {
	public boolean removeResService(String res_num[]) {

		boolean deleteResult = false;
		Connection con = getConnection();
		ReservationDAO reservationDAO = ReservationDAO.getInstance();
		reservationDAO.setConnection(con);
		int deleteCount = reservationDAO.deleteReservation(res_num);

		if (deleteCount > 0) {
			commit(con);
			deleteResult = true;
		} else {
			rollback(con);
		}
		close(con);

		return deleteResult;
	}

}

 

 

appointment_cos.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="vo.Reservation"%>
<%@ page import="dao.ReservationDAO"%>
<%@ page import="vo.MemberBean"%>
<%@ page import="dao.MemberDAO"%>
<%@ page import="java.util.*"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<fmt:requestEncoding value="UTF-8" />

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>μ˜ˆμ•½ν™•μΈνŽ˜μ΄μ§€(νšŒμ›)</title>
</head>

<body>
	<div class="card shadow mb-4">
		<div class="mem_list">
			<br>
			<h2 class="h3 mb-2 text-gray-800">${memberLog.member_name}λ‹˜μ˜ μ˜ˆμ•½μ •λ³΄</h2>
			<br>
		</div>

		<form action="ReservationRemove.res" name="remove" method="post">
			<table class="table3 table-bordered" id="dataTable" cellspacing="0" align="center">

				<tr align="center">
					<td width=200px; height=50px;><b>선택</b></td>
					<td width=200px; height=50px;><b>λ°˜λ €λ™λ¬Ό 이름</b></td>
					<td width=200px;><b>μ’…λ₯˜</b></td>
					<td width=200px;><b>μ§„λ£Œλͺ…</b></td>
					<td width=200px;><b>μ˜ˆμ•½λ‚ μ§œ</b></td>
					<td width=200px;><b>νŠΉμ΄μ‚¬ν•­</b></td>
					<td width=200px;><b>μ—°λ½μ²˜</b></td>
				</tr>
				<c:forEach var="list" items="${reservationList }">
					<tr>
						<td><input type="checkbox" id="check" name="res_num" value="${list.num }" onclick="check(this.form)" /></td>
						<td height=50px;><a href="${pageContext.request.contextPath }/animalMemberViewAction2.am">${list.animal_name }</a></td>
						<!-- <td><input type="hidden" name="animal_name" value="${list.animal_name }"></td>  -->
						<td height=50px;>${list.kind }</td>
						<!-- <td><input type="hidden" name="subject" value="${list.subject }"></td>  -->
						<td height=50px;>${list.subject }</td>
						<!-- <td><input type="hidden" name="subject" value="${list.subject }"></td>  -->
						<td height=50px;>${list.dateS }</td>
						<!-- <td></td>  -->
						<td height=50px;>${list.etc }</td>
						<!-- <td><input type="hidden" name="etc" value="${list.etc }"></td>  -->
						<td height=50px;>${list.phone }</td>
						<!-- <td><input type="hidden" name="phone" value="${list.phone }"></td>  -->
					</tr>
				</c:forEach>
			</table>
			<br> <br>
			<table class="table1" align="center">
				<tr>
					<td><button type="button" class="btn btn-outline-info btn-lg">
							<a href="javascript:history.back()" style="color:skyblue">λŒμ•„κ°€κΈ°</a>
						</button></td>
					<td><button type="button" class="btn btn-outline-info btn-lg"
							onclick="document.remove.submit();">μ˜ˆμ•½μ·¨μ†Œ</button></td>
				</tr>
			</table>
			<br>
		</form>
	</div>

	<!--    <c:if test="${list == null }">
      		<section class="div_empty">
           		μ˜ˆμ•½ 정보가 μ—†μŠ΅λ‹ˆλ‹€.
      		</section>
  			 </c:if>   -->

	<!-- footer -->
	<jsp:include page="/footer_ad.jsp"></jsp:include>
	<!-- END footer -->

</body>
</html>

ν¬μΈνŠΈλŠ” μ²΄ν¬λ°•μŠ€λ₯Ό PK λ°°μ—΄ κ°’μœΌλ‘œ λ°›λŠ” κ²ƒμ΄μ—ˆλ‹€

λ°˜μ‘ν˜•