๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
ํ”„๋กœ์ ํŠธ ๊ธฐ๋ก

์˜ˆ์•ฝ ์„ ํƒ ์ทจ์†Œ ๊ธฐ๋Šฅ ์ถ”๊ฐ€

by ์ฝ”๋”ฉํ•˜๋Š” ๋ถ•์–ด 2021. 2. 15.
๋ฐ˜์‘ํ˜•

ํ•œ ๋ช…์˜ ํšŒ์›์ด ์—ฌ๋Ÿฌ๋ฒˆ ์˜ˆ์•ฝ์„ ํ–ˆ์„ ๋•Œ

์˜ˆ์•ฝ์„ ์„ ํƒํ•ด์„œ ์ทจ์†Œํ•  ์ˆ˜ ์žˆ๊ฒŒ ๊ตฌํ˜„ํ•˜์˜€๋‹ค

โ€‹

โ€‹

โ€‹โ€‹

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 ๋ฐฐ์—ด ๊ฐ’์œผ๋กœ ๋ฐ›๋Š” ๊ฒƒ์ด์—ˆ๋‹ค

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€