protected override void CloseCanceledCallbackCore()
		{
			base.CloseCanceledCallbackCore();

			var current = this.Content;
			var cancel = new CancellationViewModel(current);
			cancel.CancelCancellationAction = () => this.Content = cancel.Fallback;
			cancel.PerformCancellationAction = () => this._installer.Cancel();

			this.Content = cancel;
		}
示例#2
0
        public List <ListItemModel> FindCancellationWarehouseListItemModel(CompanyModel company,
                                                                           CancellationViewModel data)
        {
            List <ListItemModel> model = new List <ListItemModel>();

            foreach (var warehouse in db.FindCancellationWarehouseList(company.Id,
                                                                       data.Step1.DeliveryWindowClosed,
                                                                       getEOLProductFlags(data.Step1)))
            {
                model.Add(new ListItemModel {
                    Id   = warehouse.LocationId.ToString(),
                    Text = warehouse.LocationName
                });
            }
            return(model);
        }
示例#3
0
        public List <ListItemModel> FindCancellationOrdersListItemModel(CompanyModel company,
                                                                        CancellationViewModel data)
        {
            List <ListItemModel> model = new List <ListItemModel>();

            foreach (var order in db.FindCancellationOrderList(company.Id,
                                                               data.Step1.BrandCategoryId,
                                                               data.Step2.CustomerList.ToIntString(),
                                                               data.Step1.DeliveryWindowClosed,
                                                               getEOLProductFlags(data.Step1)))
            {
                model.Add(new ListItemModel {
                    Id   = order.Id.ToString(),
                    Text = order.OrderNumber + (order.OrderDate == null ? "" : " " + order.OrderDate.Value.ToString(company.DateFormat))
                });
            }
            return(model);
        }
示例#4
0
        public List <ListItemModel> FindCancellationAccountManagerListItemModel(CompanyModel company,
                                                                                CancellationViewModel data)
        {
            List <ListItemModel> model = new List <ListItemModel>();

            foreach (var acctMgr in db.FindCancellationAccountManagerList(company.Id,
                                                                          data.Step2.CustomerList.ToIntString(),
                                                                          data.Step3.OrderList.ToIntString(),
                                                                          data.Step1.DeliveryWindowClosed,
                                                                          getEOLProductFlags(data.Step1)))
            {
                model.Add(new ListItemModel {
                    Id   = acctMgr.Id.ToString(),
                    Text = acctMgr.FullName
                });
            }
            return(model);
        }
示例#5
0
        public List <ListItemModel> FindCancellationProductListItemModel(CompanyModel company,
                                                                         CancellationViewModel data)
        {
            List <ListItemModel> model = new List <ListItemModel>();

            foreach (var product in db.FindCancellationProductList(company.Id,
                                                                   data.Step1.BrandCategoryId,
                                                                   data.Step2.CustomerList.ToIntString(),
                                                                   data.Step3.OrderList.ToIntString(),
                                                                   data.Step1.DeliveryWindowClosed,
                                                                   getEOLProductFlags(data.Step1)))
            {
                model.Add(new ListItemModel {
                    Id   = product.Id.ToString(),
                    Text = product.ItemNumber + " " + product.ItemName
                });
            }
            return(model);
        }
示例#6
0
        public Error DoCancellations(CompanyModel company,
                                     CancellationViewModel data)
        {
            var error    = new Error();
            int numItems = 0;

            foreach (var item in db.FindCancellationSummaryList(company.Id,
                                                                data.Step2.CustomerList.ToIntString(),
                                                                data.Step3.OrderList.ToIntString(),
                                                                data.Step4.ProductList.ToIntString(),
                                                                data.Step5.WarehouseList.ToIntString(),
                                                                data.Step6.AccountManagerList.ToIntString(),
                                                                data.Step1.DeliveryWindowClosed,
                                                                getEOLProductFlags(data.Step1),
                                                                data.Step1.CancelAll)
                     .ToList())
            {
                // Drop a line's alloactions
                db.DeleteAllocationsForSaleLine(company.Id, item.SodId);

                // Cancel the line
                var line = db.FindSalesOrderDetail(item.SodId);
                line.LineStatusId = db.FindSalesOrderHeaderSubStatus(SalesOrderHeaderSubStatus.PartiallyCompletePartiallyCancelled).Id;
                line.AllocQty     = 0;
                line.DateModified = DateTimeOffset.Now;
                db.InsertOrUpdateSalesOrderDetail(line);

                numItems++;
            }

            if (numItems == 0)
            {
                error.SetError("No items were selected for Cancellation!");
            }
            else
            {
                error.Message = numItems.ToString() + " Item(s) successfully cancelled.";
            }

            return(error);
        }
示例#7
0
        public CancellationSummaryListModel FindCancellationSummaryListModel(CompanyModel company,
                                                                             CancellationViewModel data,
                                                                             int index)
        {
            var model = new CancellationSummaryListModel();

            model.GridIndex = index;
            foreach (var item in db.FindCancellationSummaryList(company.Id,
                                                                data.Step2.CustomerList.ToIntString(),
                                                                data.Step3.OrderList.ToIntString(),
                                                                data.Step4.ProductList.ToIntString(),
                                                                data.Step5.WarehouseList.ToIntString(),
                                                                data.Step6.AccountManagerList.ToIntString(),
                                                                data.Step1.DeliveryWindowClosed,
                                                                getEOLProductFlags(data.Step1),
                                                                data.Step1.CancelAll))
            {
                model.Items.Add(Mapper.Map <FindCancellationSummaryList_Result, CancellationSummaryModel>(item));
            }
            return(model);
        }
示例#8
0
        // TODO Ajax this when we have some spare time and pass a message back
        public ActionResult CancelFlight(string flightNumber)
        {
            // TODO Setup some sort of DI and inject this, to remove EF reference and east testing
            MonarchContext context = new MonarchContext();
            BookingService service = new BookingService(context);

            var    vm     = new CancellationViewModel();
            Flight flight = service.GetFlight(flightNumber);

            // Display error if the flight Can#t be found
            if (flight == null)
            {
                vm.Message = "Flight not found";
            }

            // Check if the flight is already Cancelled
            else if (flight.FlightStatus == FlightStatus.Cancelled)
            {
                //TODO Add Logger and log exception
                vm.Message = string.Format("Flight {0} is already cancelled", flight.FlightNumber);
            }
            else
            {
                var cancelled = service.UpdateStatus(flightNumber, FlightStatus.Cancelled);
                if (cancelled)
                {
                    vm.Success = true;
                    vm.Message = string.Format("Flight Number {0} has been cancelled", flight.FlightNumber);
                }
                else
                {
                    //TODO Add Logger and log exception
                    vm.Message = string.Format("Error cancelling Flight Number {0}", flight.FlightNumber);
                }
            }

            return(View(vm));
        }
示例#9
0
        public List <ListItemModel> FindCancellationCustomersListItemModel(CompanyModel company, CancellationViewModel data)
        {
            List <ListItemModel> model = new List <ListItemModel>();

            foreach (var cust in db.FindCancellationCustomersList(company.Id,
                                                                  data.Step1.BrandCategoryId,
                                                                  data.Step1.DeliveryWindowClosed,
                                                                  getEOLProductFlags(data.Step1)))
            {
                model.Add(new ListItemModel {
                    Id   = cust.Id.ToString(),
                    Text = cust.Name
                });
            }

            return(model);
        }
        private CancellationViewModel loadViewModel(int stepNo)
        {
            CancellationViewModel model = null;
            string title = "";

            if (stepNo == 0)
            {
                model = new CancellationViewModel();
            }
            else
            {
                try {
                    model = (CancellationViewModel)Session["CVM"];
                } catch {
                    model = new CancellationViewModel();
                }
            }

            switch (stepNo)
            {
            case 0:
            case 1:
                title  = EvolutionResources.bnrSelectCriteria;
                stepNo = 1;
                model.Step1.ProductStatusList = LookupService.FindLOVItemsModel(null, LOVName.ProductStatus)
                                                .Where(lovi => lovi.ItemValue1 != "0")
                                                .Select(lovi => new ListItemModel {
                    Id = lovi.ItemValue1, Text = lovi.ItemText
                })
                                                .ToList();
                while (model.Step1.ProductStatus.Count() < model.Step1.ProductStatusList.Count())
                {
                    model.Step1.ProductStatus.Add(new ProductStatusValue());
                }
                model.Step1.BrandCategoryList = ProductService.FindBrandCategoryListItemModel(CurrentCompany);
                break;

            case 2:
                title = EvolutionResources.bnrSelectCustomers;
                model.Step2.CustomerList.AvailableItemsLabel = EvolutionResources.lblAvailableCustomers;
                model.Step2.CustomerList.SelectedItemsLabel  = EvolutionResources.lblSelectedCustomers;
                break;

            case 3:
                title = EvolutionResources.bnrSelectOrders;
                model.Step3.OrderList.AvailableItemsLabel = EvolutionResources.lblAvailableOrders;
                model.Step3.OrderList.SelectedItemsLabel  = EvolutionResources.lblSelectedOrders;
                break;

            case 4:
                title = EvolutionResources.bnrSelectProducts;
                model.Step4.ProductList.AvailableItemsLabel = EvolutionResources.lblAvailableProducts;
                model.Step4.ProductList.SelectedItemsLabel  = EvolutionResources.lblSelectedProducts;
                break;

            case 5:
                title = EvolutionResources.bnrSelectWarehouse;
                model.Step5.WarehouseList.AvailableItemsLabel = EvolutionResources.lblAvailableWarehouses;
                model.Step5.WarehouseList.SelectedItemsLabel  = EvolutionResources.lblSelectedWarehouses;
                break;

            case 6:
                title = EvolutionResources.bnrSelectAccountManagers;
                model.Step6.AccountManagerList.AvailableItemsLabel = EvolutionResources.lblAvailableAccountManagers;
                model.Step6.AccountManagerList.SelectedItemsLabel  = EvolutionResources.lblSelectedAccountManagers;
                break;

            case 7:
                title = EvolutionResources.bnrSummaryConfirmation;
                break;
            }

            model.Menu.Menu1.Options.Clear();
            model.Menu.Menu2.Options.Clear();

            PrepareViewModel(model, EvolutionResources.bnrCancellations +
                             (string.IsNullOrEmpty(title) ? "" : " - " + title) +
                             " - Step " + stepNo.ToString() + " of 7",
                             0,
                             MenuOptionFlag.RequiresNoSale);
            return(model);
        }
 private void saveViewModel(CancellationViewModel model)
 {
     Session["CVM"] = model;
 }
        public ActionResult SaveStep(CancellationViewModel model, string command)
        {
            int stepNo = 0;

            string[]             selectedIds = null;
            List <ListItemModel> availItems;
            Error viewError = null;

            var temp = loadViewModel(1);

            switch (command.ToLower())
            {
            case "nextstep2":
                // Move from step 1 (Parameters) to step 2 (Customer Selection)
                temp.Step1 = model.Step1;
                stepNo     = 2;

                temp.Step2.CustomerList.SetAvailableItems(SalesService.FindCancellationCustomersListItemModel(CurrentCompany, temp));
                temp.Step2.CustomerList.ControlPrefix = "Step2_CustomerList_";
                break;

            case "nextstep3":
                // Move from step 2 (Customer selection) to step 3 (Order selection)
                selectedIds = null;
                try {
                    selectedIds = Request.Form["Step2.CustomerList.SelectedIds"].Split(',');
                } catch { }
                if (selectedIds != null)
                {
                    availItems = SalesService.FindCancellationCustomersListItemModel(CurrentCompany, temp);
                    temp.Step2.CustomerList.SelectedItems = new List <ListItemModel>();
                    foreach (var id in selectedIds)
                    {
                        var item = availItems.Where(ai => ai.Id == id.ToString())
                                   .FirstOrDefault();
                        if (item != null)
                        {
                            temp.Step2.CustomerList.SelectedItems.Add(item);
                        }
                    }
                }
                stepNo = 3;
                temp.Step3.OrderList.SetAvailableItems(SalesService.FindCancellationOrdersListItemModel(CurrentCompany, temp));
                temp.Step3.OrderList.ControlPrefix = "Step3_OrderList_";
                break;

            case "nextstep4":
                // Move from step 3 (Order selection) to step 4 (Product selection)
                selectedIds = null;
                try {
                    selectedIds = Request.Form["Step3.OrderList.SelectedIds"].Split(',');
                } catch { }
                if (selectedIds != null)
                {
                    availItems = SalesService.FindCancellationOrdersListItemModel(CurrentCompany, temp);
                    temp.Step3.OrderList.SelectedItems = new List <ListItemModel>();
                    foreach (var id in selectedIds)
                    {
                        var item = availItems.Where(ai => ai.Id == id.ToString())
                                   .FirstOrDefault();
                        if (item != null)
                        {
                            temp.Step3.OrderList.SelectedItems.Add(item);
                        }
                    }
                }
                stepNo = 4;
                temp.Step4.ProductList.SetAvailableItems(SalesService.FindCancellationProductListItemModel(CurrentCompany, temp));
                temp.Step4.ProductList.ControlPrefix = "Step4_ProductList_";
                break;

            case "nextstep5":
                // Move from step 4 (Product selection) to step 5 (Warehouse selection)
                selectedIds = null;
                try {
                    selectedIds = Request.Form["Step4.ProductList.SelectedIds"].Split(',');
                } catch { }
                if (selectedIds != null)
                {
                    availItems = SalesService.FindCancellationProductListItemModel(CurrentCompany, temp);
                    temp.Step4.ProductList.SelectedItems = new List <ListItemModel>();
                    foreach (var id in selectedIds)
                    {
                        var item = availItems.Where(ai => ai.Id == id.ToString())
                                   .FirstOrDefault();
                        if (item != null)
                        {
                            temp.Step4.ProductList.SelectedItems.Add(item);
                        }
                    }
                }
                stepNo = 5;
                temp.Step5.WarehouseList.SetAvailableItems(SalesService.FindCancellationWarehouseListItemModel(CurrentCompany, temp));
                temp.Step5.WarehouseList.ControlPrefix = "Step5_WarehouseList_";
                break;

            case "nextstep6":
                // Move from step 5 (Warehouse selection) to step 6 (Account Manager selection)
                selectedIds = null;
                try {
                    selectedIds = Request.Form["Step5.WarehouseList.SelectedIds"].Split(',');
                } catch { }
                if (selectedIds != null)
                {
                    availItems = SalesService.FindCancellationWarehouseListItemModel(CurrentCompany, temp);
                    temp.Step5.WarehouseList.SelectedItems = new List <ListItemModel>();
                    foreach (var id in selectedIds)
                    {
                        var item = availItems.Where(ai => ai.Id == id.ToString())
                                   .FirstOrDefault();
                        if (item != null)
                        {
                            temp.Step5.WarehouseList.SelectedItems.Add(item);
                        }
                    }
                }
                stepNo = 6;
                temp.Step6.AccountManagerList.SetAvailableItems(SalesService.FindCancellationAccountManagerListItemModel(CurrentCompany, temp));
                temp.Step6.AccountManagerList.ControlPrefix = "Step6_AccountManagerList_";
                break;

            case "nextstep7":
                // Move from step 6 (Account Manager selection) to step 7 (Cancellation confirmation)
                selectedIds = null;
                try {
                    selectedIds = Request.Form["Step6.AccountManagerList.SelectedIds"].Split(',');
                } catch { }
                if (selectedIds != null)
                {
                    availItems = SalesService.FindCancellationAccountManagerListItemModel(CurrentCompany, temp);
                    temp.Step6.AccountManagerList.SelectedItems = new List <ListItemModel>();
                    foreach (var id in selectedIds)
                    {
                        var item = availItems.Where(ai => ai.Id == id.ToString())
                                   .FirstOrDefault();
                        if (item != null)
                        {
                            temp.Step6.AccountManagerList.SelectedItems.Add(item);
                        }
                    }
                }
                stepNo = 7;
                break;

            case "nextstep8":
                // Do the cancellations
                viewError = new Error();
                var error = SalesService.DoCancellations(CurrentCompany, temp);
                if (error.IsError)
                {
                    // Stay on step 7
                    viewError.SetError(error.Message);
                    stepNo = 7;
                }
                else
                {
                    viewError.SetInfo(error.Message);

                    temp.Step2.CustomerList.SelectedItemList.Clear();
                    temp.Step2.CustomerList.SelectedItems.Clear();
                    stepNo = 1;
                }
                break;

            case "prevstep1":
                // Move from step 2 (Customer Selection) to step 1 (Parameters)
                temp.Step2.CustomerList.SelectedItemList.Clear();
                temp.Step2.CustomerList.SelectedItems.Clear();
                stepNo = 1;
                break;

            case "prevstep2":
                // Move from step 3 (Order Selection) to step 2 (Customer selection)
                temp.Step3.OrderList.SelectedItemList.Clear();
                temp.Step3.OrderList.SelectedItems.Clear();
                stepNo = 2;
                temp.Step2.CustomerList.SetAvailableItems(SalesService.FindCancellationCustomersListItemModel(CurrentCompany, temp));
                temp.Step2.CustomerList.SetSelectedItems(temp.Step2.CustomerList.SelectedItems.ToList());
                temp.Step2.CustomerList.ControlPrefix = "Step2_CustomerList_";
                break;

            case "prevstep3":
                // Move from step 4 (Product selection) to step 3 (Order Selection)
                temp.Step4.ProductList.SelectedItemList.Clear();
                temp.Step4.ProductList.SelectedItems.Clear();
                stepNo = 3;
                temp.Step3.OrderList.SetAvailableItems(SalesService.FindCancellationOrdersListItemModel(CurrentCompany, temp));
                temp.Step3.OrderList.SetSelectedItems(temp.Step3.OrderList.SelectedItems.ToList());
                temp.Step3.OrderList.ControlPrefix = "Step3_OrderList_";
                break;

            case "prevstep4":
                // Move from step 5 (Warehouse selection) to step 4 (Product selection)
                temp.Step5.WarehouseList.SelectedItemList.Clear();
                temp.Step5.WarehouseList.SelectedItems.Clear();
                stepNo = 4;
                temp.Step4.ProductList.SetAvailableItems(SalesService.FindCancellationProductListItemModel(CurrentCompany, temp));
                temp.Step4.ProductList.SetSelectedItems(temp.Step4.ProductList.SelectedItems.ToList());
                temp.Step4.ProductList.ControlPrefix = "Step4_ProductList_";
                break;

            case "prevstep5":
                // Move from step 6 (Account Manager selection) to step 5 (Warehouse selection)
                temp.Step6.AccountManagerList.SelectedItemList.Clear();
                temp.Step6.AccountManagerList.SelectedItems.Clear();
                stepNo = 5;
                temp.Step5.WarehouseList.SetAvailableItems(SalesService.FindCancellationWarehouseListItemModel(CurrentCompany, temp));
                temp.Step5.WarehouseList.SetSelectedItems(temp.Step5.WarehouseList.SelectedItems.ToList());
                temp.Step5.WarehouseList.ControlPrefix = "Step5_WarehouseList_";
                break;

            case "prevstep6":
                // Move from step 7 (Cancellation Confirmation) to step 6 (Account Manager selection)
                stepNo = 6;
                temp.Step6.AccountManagerList.SetAvailableItems(SalesService.FindCancellationAccountManagerListItemModel(CurrentCompany, temp));
                temp.Step6.AccountManagerList.SetSelectedItems(temp.Step6.AccountManagerList.SelectedItems.ToList());
                temp.Step6.AccountManagerList.ControlPrefix = "Step6_AccountManagerList_";
                temp.Error = new Error();   // Clear any errors
                break;
            }
            saveViewModel(temp);
            temp = loadViewModel(stepNo);

            if (viewError != null)
            {
                temp.Error = viewError;
            }

            return(View("Cancellation" + stepNo.ToString(), temp));
        }