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); } } } }