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

Linh fix update order note and switch apter update #173

Merged
merged 2 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading