public override void DataBind() { OrderGroup paymentPlanById; if (base.Request.QueryString["_v"].Equals("PaymentPlan-ObjectView")) { paymentPlanById = OrderHelper.GetPaymentPlanById(PrincipalInfo.CurrentPrincipal.GetContactId(), this.OrderGroupId); } else { paymentPlanById = OrderHelper.GetPurchaseOrderById(this.OrderGroupId); } OrderGroup orderGroup = paymentPlanById; Shipment dataItem = null; ObjectRepeaterDataItem objectRepeaterDataItem = this.DataItem as ObjectRepeaterDataItem; if (objectRepeaterDataItem != null && objectRepeaterDataItem.DataItem != null) { dataItem = (Shipment)objectRepeaterDataItem.DataItem; this._shipmentId = dataItem.Id; this.btnShipmentStatus.ContainerId = dataItem.Id.ToString(); this.btnShipmentStatus.DataBind(); this.ReturnExchangeButtonsHolder.ContainerId = dataItem.Id.ToString(); this.ReturnExchangeButtonsHolder.DataBind(); this.CompletePickupButton.ContainerId = dataItem.Id.ToString(); this.CompletePickupButton.DataBind(); } if (dataItem != null) { OrderShipmentStatus orderShipmentStatus = OrderStatusManager.GetOrderShipmentStatus(dataItem); this.lblShipStatus.Text = (string)base.GetGlobalResourceObject("OrderStrings", string.Concat(typeof(OrderShipmentStatus).Name, "_", orderShipmentStatus.ToString())); Currency currency = new Currency(orderGroup.BillingCurrency); decimal num = ((IEnumerable <ILineItem>)dataItem.LineItems.ToArray <ILineItem>()).Sum <ILineItem>((ILineItem x) => x.TryGetDiscountValue((ILineItemDiscountAmount y) => y.OrderAmount)); Label str = this.lblItemsSubTotal; Money money = new Money(dataItem.SubTotal + num, currency); //str.Text = money.ToString(); Label label = this.lblOrderLevelDiscount; money = new Money(num, currency); //label.Text = money.ToString(); Label str1 = this.lblOrderSubTotal; money = new Money(dataItem.SubTotal, currency); //str1.Text = money.ToString(); Label label1 = this.lblShippingCost; money = new Money(dataItem.ShippingSubTotal, currency); label1.Text = money.ToString(); Label str2 = this.lblShippingDiscount; money = new Money(dataItem.ShippingDiscountAmount, currency); str2.Text = money.ToString(); Label label2 = this.lblShippingTax; money = new Money(dataItem.ShippingTax, currency); label2.Text = money.ToString(); Label str3 = this.lblShipTotal; money = new Money(((dataItem.SubTotal + dataItem.ShippingSubTotal) + dataItem.ShippingTax) - dataItem.ShippingDiscountAmount, currency); str3.Text = money.ToString(); } }
/// <summary> /// Called by the workflow runtime to execute an activity. /// </summary> /// <param name="executionContext">The <see cref="T:Mediachase.Commerce.WorkflowCompatibility.ActivityExecutionContext"/> to associate with this <see cref="T:Mediachase.Commerce.WorkflowCompatibility.Activity"/> and execution.</param> /// <returns> /// The <see cref="T:Mediachase.Commerce.WorkflowCompatibility.ActivityExecutionStatus"/> of the run task, which determines whether the activity remains in the executing state, or transitions to the closed state. /// </returns> protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext) { // Check for multiple warehouses. In the default, we simply reject processing an order if the application has // multiple warehouses. Any corresponding fulfillment process is the responsibility of the client. CheckMultiWarehouse(); // Validate the properties at runtime ValidateRuntime(); // Return close status if order group is Payment Plan if (OrderGroup is PaymentPlan) { return(ActivityExecutionStatus.Closed); } var orderGroupStatus = OrderStatusManager.GetOrderGroupStatus(OrderGroup); var orderForms = OrderGroup.OrderForms.Where(o => !OrderForm.IsReturnOrderForm(o)); var inventoryRequests = new List <InventoryRequestItem>(); foreach (OrderForm orderForm in orderForms) { foreach (Shipment shipment in orderForm.Shipments) { if (!ValidateShipment(orderForm, shipment)) { continue; } var shipmentStatus = OrderStatusManager.GetOrderShipmentStatus(shipment); bool completingOrder = orderGroupStatus == OrderStatus.Completed || shipmentStatus == OrderShipmentStatus.Shipped; bool cancellingOrder = orderGroupStatus == OrderStatus.Cancelled || shipmentStatus == OrderShipmentStatus.Cancelled; _logger.Debug(string.Format("Adjusting inventory, got orderGroupStatus as {0} and shipmentStatus as {1}. completingOrder as {2} and cancellingOrder as {3}.", orderGroupStatus, shipmentStatus, completingOrder, cancellingOrder)); // When completing/cancelling an order or a shipment if (completingOrder || cancellingOrder) { var requestType = completingOrder ? InventoryRequestType.Complete : InventoryRequestType.Cancel; inventoryRequests.AddRange(GetRequestInventory(shipment, inventoryRequests.Count, requestType)); // When processed request, need to clear all operation keys from the shipment shipment.ClearOperationKeys(); } // When release a shipment, check if shipment contain a BackOrder then need to complete that BackOrder. else if (shipmentStatus == OrderShipmentStatus.Released) { foreach (LineItem lineItem in Shipment.GetShipmentLineItems(shipment)) { var lineItemIndex = orderForm.LineItems.IndexOf(lineItem); var completeBackOrderRequest = new List <InventoryRequestItem>(); var lineItemRequest = GetLineItemRequestInventory(shipment, lineItemIndex, 0, InventoryRequestType.Complete); // Only need to process complete BackOrder request type foreach (var request in lineItemRequest) { InventoryRequestType requestType; InventoryChange change; _operationKeySerializer.Service.TryDeserialize(request.OperationKey, out requestType, out change); if (requestType == InventoryRequestType.Backorder) { // Add BackOrder request to request list completeBackOrderRequest.Add(request); // Then remove BackOrder request operation key from shipment's operation key map shipment.RemoveOperationKey(lineItemIndex, request.OperationKey); } } // Storage the response operation keys from complete BackOrder mapping with line item index if (completeBackOrderRequest.Count > 0) { InventoryResponse response = _inventoryService.Service.Request(new InventoryRequest(DateTime.UtcNow, completeBackOrderRequest, null)); if (response != null && response.IsSuccess) { shipment.InsertOperationKeys(lineItemIndex, response.Items.Select(c => c.OperationKey)); } } } } else if (orderGroupStatus == OrderStatus.InProgress || orderGroupStatus == OrderStatus.AwaitingExchange) { // When placing an order or creating an exchange order bool placingOrder = shipmentStatus == OrderShipmentStatus.AwaitingInventory || shipmentStatus == OrderShipmentStatus.InventoryAssigned; if (placingOrder) { var lineItems = Shipment.GetShipmentLineItems(shipment); CancelOperationKeys(shipment); foreach (LineItem lineItem in lineItems) { RequestInventory(orderForm, shipment, lineItem); } } } } } if (inventoryRequests.Any()) { _inventoryService.Service.Request(new InventoryRequest(DateTime.UtcNow, inventoryRequests, null)); } // Retun the closed status indicating that this activity is complete. return(ActivityExecutionStatus.Closed); }