예제 #1
0
        protected void Wizard1_PreviousButtonClick(object sender, WizardNavigationEventArgs e)
        {
            if (e.CurrentStepIndex == (int)StepsEnum.Refine_Shipments &&
                e.NextStepIndex == (int)StepsEnum.Define_Criteria)
            {
                ////get all shipments that have been lock for routing  during this wizard and change their status back to Mapped
                ////therefore unlocking them
                //List<TDCShipment> shipmentsToRemove = null;
                //try
                //{
                //   shipmentsToRemove = RoutingController.GetShipmentsByRoutingHistoryId(RoutingHistoryId.Value, false);
                //}
                //catch (Exception ex)
                //{
                //    Console.WriteLine(ex);
                //}

                if (!RoutingController.RemoveItemsFromRouting(null, User.Identity.Name,
                                                              RoutingHistoryId.Value))
                {
                    DisplayMessage("There was a problem un-locking the Shipments.");
                    e.Cancel = true;
                }
            }
            else if (e.CurrentStepIndex == (int)StepsEnum.Merge_Delivery_Points &&
                     e.NextStepIndex == (int)StepsEnum.Refine_Shipments)
            {
                siteCodesToMerge.Clear();
                GridViewShipmentsToRefine.DataBind();
            }
        }
예제 #2
0
        protected void Remove_Click(object sender, EventArgs e)
        {
            List <TDCShipment> shipmentsToRemoveFromRouting = new List <TDCShipment>();

            foreach (int shipmentId in ShipmentIdsToRemoveFromRouting)
            {
                TDCShipment tdcShipment = new TDCShipment();
                tdcShipment.Id     = shipmentId;
                tdcShipment.Status = Shipment.StatusEnum.Routing;
                shipmentsToRemoveFromRouting.Add(tdcShipment);
            }
            if (RemoveItemsFromRouting(shipmentsToRemoveFromRouting))
            {
                GridViewShipmentsToRefine.DataBind();
                GridViewShipmentsToRefine.PageIndex = 0;
            }
        }
예제 #3
0
        protected void Wizard1_NextButtonClick(object sender, WizardNavigationEventArgs e)
        {
            try
            {
                if (e.CurrentStepIndex == (int)StepsEnum.Define_Criteria &&
                    e.NextStepIndex == (int)StepsEnum.Refine_Shipments)
                {
                    if (ListBoxRegions.SelectedValue == "")
                    {
                        DisplayMessage("Please Select a Region.");
                        RoutingHistoryId = null;
                        e.Cancel         = true;
                        return;
                    }
                    else
                    {
                        try
                        {
                            RoutingHistoryId = RoutingController.SetOptrakLocks(User.Identity.Name, ListBoxRegions.SelectedValue, (RoutingController.PeriodEnum)RadioButtonListPeriod.SelectedIndex);

                            if (RoutingHistoryId == -2)
                            {
                                //there are no shipments matching the criteria to lock so display message to user
                                DisplayMessage("No shipments were found to Route.");
                                RoutingHistoryId = null;
                                e.Cancel         = true;
                                return;
                            }
                        }
                        catch (Exception ex)
                        {
                            ExceptionPolicy.HandleException(ex, "User Interface");
                        }


                        if (RoutingHistoryId == null)
                        {
                            DisplayMessage(
                                "There was a problem locking the Shipments which match the specified criteria for Routing.",
                                DiscoveryMessageType.Error);
                            e.Cancel = true;
                        }
                        else
                        {
                            GridViewShipmentsToRefine.Sort("ShipmentName,pafpostcode,estimateddeliverydate",
                                                           SortDirection.Ascending);
                        }
                    }
                }

                else if (e.CurrentStepIndex == (int)StepsEnum.Refine_Shipments &&
                         e.NextStepIndex == (int)StepsEnum.Merge_Delivery_Points)
                {
                    List <TDCShipment> shipmentsToRemoveFromRouting = new List <TDCShipment>();

                    foreach (int shipmentId in ShipmentIdsToRemoveFromRouting)
                    {
                        TDCShipment tdcShipment = new TDCShipment();
                        tdcShipment.Id     = shipmentId;
                        tdcShipment.Status = Shipment.StatusEnum.Routing;
                        shipmentsToRemoveFromRouting.Add(tdcShipment);
                    }
                    e.Cancel = !RemoveItemsFromRouting(shipmentsToRemoveFromRouting);
                    if (!e.Cancel)
                    {
                        //merge their delivery points using Customer Name and PAF postcode
                        bool mergeWorked = false;
                        try
                        {
                            mergeWorked = RoutingController.MergeDeliveryPointsAutomatically(RoutingHistoryId.Value);
                        }
                        catch (Exception ex)
                        {
                            ExceptionPolicy.HandleException(ex, "User Interface");
                        }
                        if (!mergeWorked)
                        {
                            DisplayMessage("Merging of Delivery points failed.");
                            e.Cancel = true;
                        }

                        MultiView1.ActiveViewIndex = 0;
                        GridViewMergedPoints.DataBind();
                    }
                }
            }
            catch (Exception ex)
            {
                if (ExceptionPolicy.HandleException(ex, "User Interface"))
                {
                    DisplayMessage(ex);
                }
            }
        }