Skip to content
This repository was archived by the owner on May 11, 2024. It is now read-only.

Commit 469f70f

Browse files
committed
admin
1 parent 0d2e876 commit 469f70f

File tree

8 files changed

+101
-98
lines changed

8 files changed

+101
-98
lines changed

flower_shop.sql

+73-74
Large diffs are not rendered by default.

src/main/java/com/bakaqc/flower/controller/UpdateOrderController.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ public class UpdateOrderController extends HttpServlet {
1414
@Override
1515
protected void doGet(HttpServletRequest request, HttpServletResponse response)
1616
throws ServletException, IOException {
17-
request.setCharacterEncoding("UTF-8");
1817
response.setContentType("text/html; charset=UTF-8");
1918

2019
}
@@ -24,17 +23,19 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
2423
throws ServletException, IOException {
2524
request.setCharacterEncoding("UTF-8");
2625
response.setContentType("text/html; charset=UTF-8");
27-
String url = request.getHeader("referer");
2826

2927
String id = request.getParameter("id");
3028
String status = request.getParameter("status");
29+
3130
Order order = new Order();
3231
order.setId(Integer.parseInt(id));
3332
order.setStatus(OrderStatus.create(status));
3433
OrderDAO.getInstance().update(order);
35-
3634
request.getRequestDispatcher("/view/OrderAdmin.jsp").forward(request, response);
3735

36+
String url = request.getHeader("referer");
3837
response.sendRedirect(url);
38+
3939
}
40+
4041
}

src/main/java/com/bakaqc/flower/dao/OrderDAO.java

+11-13
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ public List<Order> selectAll() {
4949

5050
return list;
5151
}
52-
53-
52+
5453
public List<Order> selectProcess() {
5554
List<Order> list = new ArrayList<>();
5655

@@ -81,7 +80,8 @@ public List<Order> selectProcess() {
8180

8281
return list;
8382
}
84-
public List<Order> selectShip() {
83+
84+
public List<Order> selectShip() {
8585
List<Order> list = new ArrayList<>();
8686

8787
try {
@@ -111,7 +111,8 @@ public List<Order> selectShip() {
111111

112112
return list;
113113
}
114-
public List<Order> selectDone() {
114+
115+
public List<Order> selectDone() {
115116
List<Order> list = new ArrayList<>();
116117

117118
try {
@@ -141,7 +142,8 @@ public List<Order> selectDone() {
141142

142143
return list;
143144
}
144-
public List<Order> selectCancel() {
145+
146+
public List<Order> selectCancel() {
145147
List<Order> list = new ArrayList<>();
146148

147149
try {
@@ -230,13 +232,9 @@ public void update(Order ob) {
230232
try {
231233
Connection conn = JDBC.getConnection();
232234

233-
PreparedStatement smt = conn.prepareStatement("UPDATE `order` SET user_id = ?, total_price = ?, payment = ?, status = ?, create_at = ? WHERE id = ?");
234-
smt.setInt(1, ob.getUserID());
235-
smt.setInt(2, ob.getTotalPrice());
236-
smt.setString(3, ob.getPayment().toString());
237-
smt.setString(4, ob.getStatus().toString());
238-
smt.setString(5, Convert.convert(LocalDateTime.now()));
239-
smt.setInt(6, ob.getId());
235+
PreparedStatement smt = conn.prepareStatement("UPDATE `order` SET status = ? WHERE id = ?");
236+
smt.setString(1, ob.getStatus().toString());
237+
smt.setInt(2, ob.getId());
240238

241239
smt.executeUpdate();
242240

@@ -262,7 +260,7 @@ public void delete(String id) {
262260
System.err.println(ex.getMessage());
263261
}
264262
}
265-
263+
266264
public static void main(String[] args) {
267265

268266
}

src/main/java/com/bakaqc/flower/model/option/OrderStatus.java

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ public enum OrderStatus {
66
DONE("done"),
77
CANCELED("canceled");
88

9+
public static boolean isValid(String status) {
10+
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
11+
}
12+
913
private final String label;
1014

1115
private OrderStatus(String label) {

src/main/java/com/bakaqc/flower/service/JDBC.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
public class JDBC {
66

7-
private static String DBURL = "jdbc:mysql://localhost:3333/flower_shop";
7+
private static String DBURL = "jdbc:mysql://localhost:3306/flower_shop";
88
private static String USERNAME = "root";
99
private static String PASSWORD = "";
1010

src/main/webapp/view/AccountAdmin.jsp

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@
5454
<thead>
5555
<tr>
5656
<th width="10"><input type="checkbox" id="all"></th>
57-
<th>ID Khách Hàng</th>
58-
<th width="150">Họ và tên</th>
57+
<th width="30">ID</th>
58+
<th>Họ và tên</th>
5959
<th width="300">Địa chỉ</th>
6060
<th>Năm sinh</th>
6161
<th>Giới tính</th>
6262
<th>Email</th>
6363
<th>Trạng Thái</th>
64-
<th width="100">Tính năng</th>
64+
<th width="80">Tính năng</th>
6565

6666
</tr>
6767
</thead>

src/main/webapp/view/OrderAdmin.jsp

+2-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@
8787
data-keyboard="false">
8888
<div class="modal-dialog modal-dialog-centered" role="document">
8989
<div class="modal-content">
90-
<form action="${pageContext.request.contextPath}/admin/updateOrder" method="post">
90+
91+
<form class="form" action="${pageContext.request.contextPath}/admin/updateOrder" method="post">
9192
<div class="modal-body">
9293
<div class="row">
9394
<div class="form-group col-md-12">

src/main/webapp/view/ProductAdmin.jsp

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@
4646
<thead>
4747
<tr>
4848
<th width="10"><input type="checkbox" id="all"></th>
49-
<th width="20">ID</th>
49+
<th width="30">ID</th>
5050
<th width="300">Tên Sản Phẩm</th>
51-
<th width="50">Ảnh</th>
51+
<th width="80">Ảnh</th>
5252
<th>Danh mục</th>
5353
<th>Giá</th>
54-
<th width="100">Tính năng</th>
54+
<th width="80">Tính năng</th>
5555
</tr>
5656
</thead>
5757
<tbody>

0 commit comments

Comments
 (0)