<%@page import="bbs.Bbs"%>
<%@page import="bbs.BbsDAO"%>
<%@page import="java.io.PrintWriter"%>
<%@page import="pay.Pay"%>
<%@page import="user.User"%>
<%@page import="user.UserDAO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<% 
		int count = Integer.parseInt(request.getParameter("count"));
		int pnum = Integer.parseInt(request.getParameter("pro_num"));
		int price = Integer.parseInt(request.getParameter("pr"));
		String ID = null;
		if (session.getAttribute("ID") != null) {
			ID = (String) session.getAttribute("ID");
		}
		UserDAO u = new UserDAO();
		User user = new User();
		Pay p = new Pay();
		int x= u.yournum(ID);
		user = u.userInfo(ID);
		user.setUser_no(x);
		
		p.wo(x, user.getAddress(), "준비중", count * price);
		int y = p.onum();
		p.wd(y, pnum, count, user.getName(),Integer.parseInt(user.getPhone_number()));
		BbsDAO b = new BbsDAO();
		Bbs bbs = new Bbs();
		bbs = b.getBbs(pnum);
		b.buying(bbs.getRemaining(), count, pnum);
	%>
	<script>
		location.href = 'creditlist.jsp';
	</script>
</body>
</html>