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

Commit

Permalink
Merge pull request #173 from hardingadonis/linh-fix-update-order
Browse files Browse the repository at this point in the history
Linh fix update order note and switch apter update
  • Loading branch information
hardingadonis authored Mar 10, 2024
2 parents 47e3dd8 + 411b22b commit 8882979
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)

Integer id_customer = Integer.valueOf(id);
Customer customer = Singleton.customerDAO.getByID(id_customer).get();
if (!name.isEmpty()) {
customer.setName(name);
if (!name.trim().isEmpty()) {
customer.setName(name.trim());
}
if (!address.isEmpty()) {
customer.setAddress(address);
if (!address.trim().isEmpty()) {
customer.setAddress(address.trim());
}
Singleton.customerDAO.save(customer);
response.sendRedirect(request.getContextPath() + "/customer-detail?id="+id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

@WebServlet(name = "UpdateOrderServlet", urlPatterns = {"/update-order"})
public class UpdateOrderServlet extends HttpServlet {

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
Expand Down Expand Up @@ -43,26 +44,27 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
String ID = request.getParameter("id");
Order order = Singleton.orderDAO.getByID(Integer.valueOf(ID)).orElse(null);


String status = request.getParameter("status");


if (status != null && !status.equals(order.getStatus()) ) {

order.setStatus(Order.Status.valueOf(status));
Singleton.orderDAO.save(order);
String note = request.getParameter("note");

response.sendRedirect("./order");
return;
}
else {
response.sendRedirect("./order");
return;
if (status != null && !status.equals(order.getStatus())) {

order.setStatus(Order.Status.valueOf(status));

}
if(!note.trim().isEmpty()){
order.setNote(note.trim());
}
Singleton.orderDAO.save(order);

response.sendRedirect(request.getContextPath() + "/order-detail?id=" + ID);

// else {
// response.sendRedirect(request.getContextPath() + "/order-detail?id=" + ID);
// return;
// }

}





}
5 changes: 4 additions & 1 deletion src/main/webapp/view/jsp/management/order/update-order.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@
</div>
<div class="mb-3">
<div class="mb-3">
<label class="form-label" for="country"><strong>Ghi chú</strong></label><textarea class="form-control" readonly=""></textarea>
<label class="form-label" for="country">
<strong>Ghi chú</strong>
</label>
<textarea class="form-control" id="order-note" name="note" placeholder="${requestScope.ord.note}"></textarea>
</div>

<button class="btn btn-primary btn-sm" type="button">
Expand Down

0 comments on commit 8882979

Please sign in to comment.