private void btnChangeStatus_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(SelectedOrderID)) { Constants.DeliveryStatus newDeliveryStatus = new Constants.DeliveryStatus(); Constants.DeliveryStatus oldDeliveryStatus = EnumHelper.Parse <Constants.DeliveryStatus>(_selectedOrder.order_status); if (oldDeliveryStatus != Constants.DeliveryStatus.Delivered) { switch (oldDeliveryStatus) { case Constants.DeliveryStatus.Waiting: newDeliveryStatus = Constants.DeliveryStatus.Delivering; break; case Constants.DeliveryStatus.Delivering: newDeliveryStatus = Constants.DeliveryStatus.Arrived; break; case Constants.DeliveryStatus.Arrived: newDeliveryStatus = Constants.DeliveryStatus.Delivered; if (_selectedOrder.payment_status.Equals(Constants.PaymentStatus.Unpaid.ToString())) { if ((new IrregularOrderPaymentView(_selectedOrder, ucItemsList.OrderItems)).ShowDialog() == DialogResult.OK) { _selectedOrder.payment_status = Constants.PaymentStatus.Paid.ToString(); } else { return; } } break; default: break; } _selectedOrder.order_status = newDeliveryStatus.ToString(); string result = _business.Update(_selectedOrder); if (string.IsNullOrEmpty(result)) { MessageBox.Show("Đơn hàng đã cập nhật thành công."); DataBind(); } else { MessageBox.Show(result, Constants.Messages.ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void btnChangeStatus_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(SelectedOrderID)) { Constants.DeliveryStatus newDeliveryStatus = new Constants.DeliveryStatus(); Constants.DeliveryStatus oldDeliveryStatus = EnumHelper.Parse <Constants.DeliveryStatus>(_selectedOrder.order_status); if (oldDeliveryStatus != Constants.DeliveryStatus.Delivered) { switch (oldDeliveryStatus) { case Constants.DeliveryStatus.Waiting: newDeliveryStatus = Constants.DeliveryStatus.Delivering; break; case Constants.DeliveryStatus.Delivering: newDeliveryStatus = Constants.DeliveryStatus.Arrived; break; case Constants.DeliveryStatus.Arrived: newDeliveryStatus = Constants.DeliveryStatus.Delivered; break; default: break; } _selectedOrder.order_status = newDeliveryStatus.ToString(); string result = _business.Update(_selectedOrder); if (string.IsNullOrEmpty(result)) { MessageBox.Show("Đơn hàng đã cập nhật thành công."); DataBind(); } else { MessageBox.Show(result, Constants.Messages.ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void PopulateOrderDetails(RegularOrder order) { if (order != null) { Sender = _customerBusiness.Get(order.sender_id); Recipient = _customerBusiness.Get(order.recipient_id); if (Sender == null) { MessageBox.Show("Không tìm thấy thông tin người gửi.", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (Recipient == null) { MessageBox.Show("Không tìm thấy thông tin người nhận.", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Warning); } cboDestination.SelectedValue = order.tour_id; Constants.DeliveryStatus deliveryStatus; bool parseResult = Enum.TryParse <Constants.DeliveryStatus>(order.order_status, out deliveryStatus); if (parseResult) { CurrentDeliveryStatus = deliveryStatus; } Constants.PaymentStatus paymentStatus; parseResult = Enum.TryParse <Constants.PaymentStatus>(order.payment_status, out paymentStatus); if (parseResult) { lblPaymentStatusText.Text = paymentStatus.GetDescription(); } Collection <OrderItem> items = (new OrderItemBusiness()).GetByOrderId(order.id); tbItemsQuantity.Text = items.Sum(item => item.quantity).ToString(); decimal totalCost = items.Sum(item => item.cost); tbTotalCost.Text = totalCost.ToString("N0"); this.ucItemsList.OrderID = order.id; this.ucItemsList.OrderItems = items; } }