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); } } } }
public string UpdateOrderInfo(TOrder torder, List <TOrderItem> orderItems, string userId) { try { //Check Order string errorMessage = CheckOrder(torder, true); //check OrderItem errorMessage += orderItems.Count == 0 ? "Không có thông tin hàng hóa" : ""; if (string.IsNullOrEmpty(errorMessage) == false) { return(errorMessage); } if (torder.Type == Constants.VALUE_ORDER_TYPE_REGULAR) { using (RegularOrderBusiness business = new RegularOrderBusiness()) { business.Update(ThriftUtil.ConvertToEntityObject(torder) as RegularOrder); } } else { using (IrregularOrderBusiness business = new IrregularOrderBusiness()) { business.Update(ThriftUtil.ConvertToEntityObject(torder) as IrregularOrder); } } using (OrderItemBusiness business = new OrderItemBusiness()) { business.DeleteByOrderId(torder.OrderId); business.Insert(ThriftUtil.ConvertToOrderItemList(orderItems).Cast <OrderItem>()); } //notify to the others client station //BroadcastToClient(ClientAction.UpdateOrder,order,orderItems); return(""); } catch (Exception exc) { ServerLogger.logError("[UpdateOrderInfo]", exc); return(exc.Message); } }
public string UpdateSingleOrderInfo(TOrder torder, string userId) { try { //Check Order string errorMessage = CheckOrder(torder, true); if (string.IsNullOrEmpty(errorMessage) == false) { return(errorMessage); } if (torder.Type == Constants.VALUE_ORDER_TYPE_REGULAR) { using (RegularOrderBusiness business = new RegularOrderBusiness()) { business.Update(ThriftUtil.ConvertToEntityObject(torder) as RegularOrder); } } else { using (IrregularOrderBusiness business = new IrregularOrderBusiness()) { business.Update(ThriftUtil.ConvertToEntityObject(torder) as IrregularOrder); } } //notify to the others client station //BroadcastToClient(ClientAction.UpdateOrder,order,orderItems); return(""); } catch (Exception exc) { ServerLogger.logError("[UpdateSingleOrderInfo]", exc); return(exc.Message); } }
private void btnOK_Click(object sender, EventArgs e) { try { if (ValidateInput() && MessageBox.Show("Quyết toán những hóa đơn đã chọn?", Constants.Messages.CONFIRMATION_CAPTION) == DialogResult.OK) { // TO DO: add order info to Revenue var selectedOrders = new Collection <RegularOrder>(); decimal totalPayment = 0; Revenue revenue = new Revenue(); revenue.id = IDGenerator.RevenueId(); revenue.type = Constants.RevenueType.RegularOrder.ToString(); revenue.name = Constants.RevenueType.RegularOrder.GetDescription(); revenue.description = string.Empty; revenue.created_date = DateTime.Now; revenue.created_by = SystemParam.CurrentUser.id; List <RevenueDetail> revenueDetails = new List <RevenueDetail>(); foreach (DataGridViewRow row in _checkedRows) { string id = row.Cells["IDColumn"].Value.ToString(); var order = _orders.FirstOrDefault(o => o.id.Equals(id)); if (order != null) { order.order_status = Constants.DeliveryStatus.Closed.ToString(); selectedOrders.Add(order); RevenueDetail detail = new RevenueDetail(); detail.id = IDGenerator.RevenueDetailId(); detail.revenue_id = revenue.id; detail.object_id = order.id; detail.title = Constants.RevenueType.RegularOrder.GetDescription(); detail.type = Constants.RevenueType.RegularOrder.ToString(); detail.amount = order.total_cost; totalPayment += order.total_cost; detail.description = string.Empty; detail.created_date = DateTime.Now; detail.created_by = SystemParam.CurrentUser.id; revenueDetails.Add(detail); } } if (selectedOrders.Count > 0) { string result = _business.Update(selectedOrders); if (string.IsNullOrEmpty(result)) { result = _revenueBusiness.Insert(revenue, revenueDetails); if (string.IsNullOrEmpty(result)) { MessageBox.Show("Đã quyết toán thành công."); this.DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show(result, Constants.Messages.ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show(result, Constants.Messages.ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } catch (Exception ex) { AppLogger.logError(this.ToString(), ex); } }