示例#1
0
        private async void Submit_Click(object sender, RoutedEventArgs e)
        {
            ContentDialog dialog = new ContentDialog
            {
                Title             = "Confirmation",
                Content           = "Are you ensure to endorse an order?",
                PrimaryButtonText = "Endorse Order",
                CloseButtonText   = "Cancel"
            };

            // alert user
            ContentDialogResult result = await dialog.EnqueueAndShowIfAsync();

            if (result == ContentDialogResult.Primary)
            {
                order = await order.ModifyAsync(x => x.Status = OrderStatusEnum.Endorsed);

                ContentDialog message = new ContentDialog
                {
                    Title           = "Success",
                    Content         = "Successfully endorsed order.",
                    CloseButtonText = "OK",
                    Width           = 400
                };

                if (order.DealerId != SignInManager.CurrentUser.Id)
                {
                    NotificationManager.CreateNotification(order.DealerId, "An Order Has Been Endorsed", $"{SignInManager.CurrentUser.FirstName} {SignInManager.CurrentUser.LastName} has endorsed one of your order pending requests.", NotificationTypeEnum.Order, order.Id);
                }

                await message.EnqueueAndShowIfAsync();

                Frame.Navigate(typeof(DeliverOrder), order, new DrillInNavigationTransitionInfo());
            }
        }
        private async void StackPanel_Tapped(object sender, TappedRoutedEventArgs e)
        {
            // abstract a common factor
            string str = (searchStatus == null ? "View" : "Select");

            // create a dialog
            ContentDialog dialog = new ContentDialog
            {
                Title             = "Confirmation",
                Content           = $"Are you ensure to {str.ToLower()} tapped order?",
                PrimaryButtonText = $"{str} Order",
                CloseButtonText   = "Cancel"
            };

            // display the dialog to user
            ContentDialogResult result = await dialog.EnqueueAndShowIfAsync();

            // if user selected "{str} account" button
            if (result == ContentDialogResult.Primary)
            {
                // if the user enter searching user UI by clicking nav bar, it would direct user to view account UI
                // else if the user was instructed to select an account, it would return a user previous UI
                Frame.Navigate(searchStatus ?? typeof(ViewOrder), ResultListViewControl.SelectedItem, new DrillInNavigationTransitionInfo());
            }
        }
        private async void Theme_Toggled(object sender, RoutedEventArgs e)
        {
            ContentDialog dialog = new ContentDialog
            {
                Title             = "Confirmation",
                Content           = "Are you sure to change the theme?",
                PrimaryButtonText = "Yes",
                CloseButtonText   = "Cancel"
            };

            if (await dialog.EnqueueAndShowIfAsync() == ContentDialogResult.Primary)
            {
                if (sender is ToggleSwitch toggle)
                {
                    applicationDataContainer["theme"] = toggle.IsOn;
                    RequestedTheme = toggle.IsOn ? ElementTheme.Light : ElementTheme.Dark;

                    await new ContentDialog
                    {
                        Title           = "Alert",
                        Content         = "Please restart the system after applying the changed theme.",
                        CloseButtonText = "OK"
                    }.EnqueueAndShowIfAsync();

                    CoreApplication.Exit();
                }
            }
            else if (sender is ToggleSwitch toggle)
            {
                Theme.Toggled -= Theme_Toggled;
                toggle.IsOn    = !toggle.IsOn;
                Theme.Toggled += Theme_Toggled;
            }
        }
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (e.Parameter is User user)
            {
                FillInformation(this.user = user);
            }
            else if (!PermissionManager.GetPermission(SignInManager.CurrentUser.Role).Contains(typeof(SearchAccounts)))
            {
                FillInformation(this.user = SignInManager.CurrentUser);
            }
            else
            {
                ContentDialog dialog = new ContentDialog
                {
                    Title             = "Alert",
                    Content           = "Which account would you want to modify?",
                    PrimaryButtonText = "Modify Other People Account",
                    CloseButtonText   = "Modify Your Account"
                };

                ContentDialogResult result = await dialog.EnqueueAndShowIfAsync();

                if (result == ContentDialogResult.Primary)
                {
                    Frame.Navigate(typeof(SearchAccounts), this.GetType(), new DrillInNavigationTransitionInfo());
                }
                else
                {
                    FillInformation(this.user = SignInManager.CurrentUser);
                }
            }
        }
示例#5
0
        private async void SelectDic_Click(object sender, RoutedEventArgs e)
        {
            DicDialog dialog = new DicDialog(x => x.Status == DicStatusEnum.Dispatching.ToString());

            ContentDialogResult button;

            bool isCompleted   = false;
            bool isDispatching = false;

            using (var context = new Context())
            {
                do
                {
                    // if dialog displays more than 1 times
                    if (dialog.Dic != null)
                    {
                        // if the order is not endorsed
                        if (!isCompleted)
                        {
                            ContentDialog error = new ContentDialog
                            {
                                Title           = "Alert",
                                Content         = "The DIC has not been completed, please wait till storemen completely assemble it.",
                                CloseButtonText = "OK",
                                Width           = 400
                            };

                            await error.EnqueueAndShowIfAsync();
                        }
                        else if (!isDispatching)
                        {
                            ContentDialog error = new ContentDialog
                            {
                                Title           = "Alert",
                                Content         = "You are not permitted to complete a non-dispatching DIC delivery.",
                                CloseButtonText = "OK",
                                Width           = 400
                            };

                            await error.EnqueueAndShowIfAsync();
                        }
                    }

                    button = await dialog.EnqueueAndShowIfAsync();
                } while (button == ContentDialogResult.Primary &&
                         !((isDispatching = dialog.Dic.Status == DicStatusEnum.Dispatching.ToString()) &&
                           (isCompleted = context.DidSpare.Count(x => dialog.Dic.Did.Any(y => y.Id == x.DidId)) == dialog.Dic.Did.Sum(x => x.Quantity))));
            }

            if (button == ContentDialogResult.Primary)
            {
                DicGUID.Text           = (dic = dialog.Dic).Id.ToString();
                SelectedDic.Text       = $"Selected DIC: {dic.Id}";
                SelectedDic.Visibility = Visibility.Visible;
                Submit.IsEnabled       = true;
            }
        }
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (e.Parameter is Order order)
            {
                if (order.Status == OrderStatusEnum.Pending)
                {
                    // pre define
                    var dealer = await UserManager.FindUserAsync(x => x.Id == order.DealerId);

                    var modifier = await UserManager.FindUserAsync(x => x.Id == order.ModifierId);

                    // non order product information required attribute
                    Guid.Text         = order.Id.ToString();
                    DealerGUID.Text   = order.DealerId.ToString();
                    SelectedUser.Text = $"{dealer.FirstName} {dealer.LastName}";
                    Address.Document.SetText(Windows.UI.Text.TextSetOptions.None, order.DeliveryAddress);

                    this.order = order;

                    // required attribute
                    using (var context = new Context())
                    {
                        // cast the ordered items into the binding list
                        items.UpdateObservableCollection(context.OrderProduct.Include(x => x.Product).ThenInclude(x => x.PriceHistory).Where(x => x.OrderId == order.Id).Select(x => new OrderProductViewModel(x)));
                    }
                }
                else
                {
                    ContentDialog error = new ContentDialog
                    {
                        Title           = "Error",
                        Content         = $"It is not permitted to modify a non-pending status order.",
                        CloseButtonText = "OK",
                        Width           = 400
                    };

                    await error.EnqueueAndShowIfAsync();

                    Frame.Navigate(typeof(SearchOrders), this.GetType(), new DrillInNavigationTransitionInfo());
                }
            }
            else
            {
                ContentDialog dialog = new ContentDialog
                {
                    Title           = "Alert",
                    Content         = "You have to choose a pending order before modifying it.",
                    CloseButtonText = "OK"
                };

                ContentDialogResult result = await dialog.EnqueueAndShowIfAsync();

                Frame.Navigate(typeof(SearchOrders), this.GetType(), new DrillInNavigationTransitionInfo());
            }
        }
示例#7
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (e.Parameter is Order order)
            {
                if (order.Status != OrderStatusEnum.Cancelled)
                {
                    if (order.Type == OrderTypeEnum.Reserve)
                    {
                        this.order    = order;
                        Submit.Click += Submit_Click;
                    }
                    else
                    {
                        ContentDialog error = new ContentDialog
                        {
                            Title           = "ERROR",
                            Content         = $"It is not permitted to unreserve a purchase type order.",
                            CloseButtonText = "OK",
                            Width           = 400
                        };

                        await error.EnqueueAndShowIfAsync();

                        Frame.Navigate(typeof(SearchOrders), this.GetType(), new DrillInNavigationTransitionInfo());
                    }
                }
                else
                {
                    ContentDialog error = new ContentDialog
                    {
                        Title           = "ERROR",
                        Content         = $"It is not permitted to unreserve an order with cancelled status.",
                        CloseButtonText = "OK",
                        Width           = 400
                    };

                    await error.EnqueueAndShowIfAsync();

                    Frame.Navigate(typeof(SearchOrders), this.GetType(), new DrillInNavigationTransitionInfo());
                }
            }
            else
            {
                ContentDialog dialog = new ContentDialog
                {
                    Title           = "ALERT",
                    Content         = "You have to choose a order before unreserving it.",
                    CloseButtonText = "OK"
                };

                ContentDialogResult result = await dialog.EnqueueAndShowIfAsync();

                Frame.Navigate(typeof(SearchOrders), this.GetType(), new DrillInNavigationTransitionInfo());
            }
        }
        private async void SelectOrder_Click(object sender, RoutedEventArgs e)
        {
            OrderDialog dialog = new OrderDialog(x => x.Status == OrderStatusEnum.Endorsed && x.Type == OrderTypeEnum.Purchase);

            ContentDialogResult button;

            using (var context = new Context())
            {
                bool isEndorsed = false, isIncomplete = false;

                do
                {
                    // if dialog displays more than 1 times
                    if (dialog.Order != null)
                    {
                        if (!isEndorsed)
                        {
                            ContentDialog error = new ContentDialog
                            {
                                Title           = "Alert",
                                Content         = "The order has not been endorsed, please wait till area manager endorses it.",
                                CloseButtonText = "OK",
                                Width           = 400
                            };

                            await error.EnqueueAndShowIfAsync();
                        }
                        else if (!isIncomplete)
                        {
                            ContentDialog error = new ContentDialog
                            {
                                Title           = "Alert",
                                Content         = "The selected order has been completed already. Please select another order.",
                                CloseButtonText = "OK",
                                Width           = 400
                            };

                            await error.EnqueueAndShowIfAsync();
                        }
                    }

                    button = await dialog.EnqueueAndShowIfAsync();
                } while (button == ContentDialogResult.Primary &&
                         !((isEndorsed = dialog.Order.Status == OrderStatusEnum.Endorsed) &&
                           (isIncomplete = dialog.Order.OrderProduct.Sum(x => x.Quantity) > context.Did.Include(x => x.Dic).Where(x => x.Dic.OrderId == dialog.Order.Id).Sum(x => x.Quantity))));
            }

            if (button == ContentDialogResult.Primary)
            {
                OrderGUID.Text           = (order = dialog.Order).Id.ToString();
                SelectedOrder.Text       = $"Selected Order: {order.Dealer.FirstName}'s Order";
                SelectedOrder.Visibility = Visibility.Visible;
                Submit.IsEnabled         = true;
            }
        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            ContentDialog dialog = new ContentDialog
            {
                Title             = "Confirmation",
                Content           = "Are you sure to sign out from the system?",
                PrimaryButtonText = "Yes",
                CloseButtonText   = "Cancel"
            };

            if (await dialog.EnqueueAndShowIfAsync() == ContentDialogResult.Primary)
            {
                SignInManager.SignOut();
                this.Frame.Navigate(typeof(LoginPage), null, new DrillInNavigationTransitionInfo());
            }
        }
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (e.Parameter is Order order)
            {
                SetOrderInformation(order);

                ModifyOrder.Click    += (sender, args) => Frame.Navigate(typeof(ModifyOrder), order, new DrillInNavigationTransitionInfo());
                EndorseOrder.Click   += (sender, args) => Frame.Navigate(typeof(EndorseOrder), order, new DrillInNavigationTransitionInfo());
                UnreserveOrder.Click += (sender, args) => Frame.Navigate(typeof(UnreserveOrder), order, new DrillInNavigationTransitionInfo());
                CancelOrder.Click    += (sender, args) => Frame.Navigate(typeof(CancelOrder), order, new DrillInNavigationTransitionInfo());
            }
            else if (e.Parameter is Guid id)
            {
                Order tmp;

                using (var context = new Context())
                {
                    tmp = context.Order.FirstOrDefault(x => x.Id == id);
                }

                SetOrderInformation(tmp);

                ModifyOrder.Click    += (sender, args) => Frame.Navigate(typeof(ModifyOrder), tmp, new DrillInNavigationTransitionInfo());
                EndorseOrder.Click   += (sender, args) => Frame.Navigate(typeof(EndorseOrder), tmp, new DrillInNavigationTransitionInfo());
                UnreserveOrder.Click += (sender, args) => Frame.Navigate(typeof(UnreserveOrder), tmp, new DrillInNavigationTransitionInfo());
                CancelOrder.Click    += (sender, args) => Frame.Navigate(typeof(CancelOrder), tmp, new DrillInNavigationTransitionInfo());
            }
            else
            {
                ContentDialog dialog = new ContentDialog
                {
                    Title           = "Alert",
                    Content         = "You have to choose a order before viewing it.",
                    CloseButtonText = "OK"
                };

                ContentDialogResult result = await dialog.EnqueueAndShowIfAsync();

                Frame.Navigate(typeof(SearchOrders), typeof(ViewOrder), new DrillInNavigationTransitionInfo());
            }
        }
示例#11
0
        private async void SelectDic_Click(object sender, RoutedEventArgs e)
        {
            OrderDialog dialog = new OrderDialog(x => x.Status == OrderStatusEnum.Endorsed);

            ContentDialogResult button;

            bool isEndorsed = false;

            using (var context = new Context())
            {
                do
                {
                    // if dialog displays more than 1 times
                    if (dialog.Order != null)
                    {
                        // if the order is not endorsed
                        if (!isEndorsed)
                        {
                            ContentDialog error = new ContentDialog
                            {
                                Title           = "Alert",
                                Content         = "The order has not been endorsed, please wait till area manager endorses it.",
                                CloseButtonText = "OK",
                                Width           = 400
                            };

                            await error.EnqueueAndShowIfAsync();
                        }
                    }

                    button = await dialog.EnqueueAndShowIfAsync();
                } while (button == ContentDialogResult.Primary && !(isEndorsed = dialog.Order.Status == OrderStatusEnum.Endorsed));
            }

            if (button == ContentDialogResult.Primary)
            {
                DicGUID.Text           = (order = dialog.Order).Id.ToString();
                SelectedDic.Text       = $"Selected DIC: {order.Id}";
                SelectedDic.Visibility = Visibility.Visible;
                Submit.IsEnabled       = true;
            }
        }
        private async void SelectDic_Click(object sender, RoutedEventArgs e)
        {
            DicDialog dialog = new DicDialog(x => x.Status == DicStatusEnum.Dispatched.ToString());

            ContentDialogResult button;

            bool isCompleted = false;

            using (var context = new Context())
            {
                do
                {
                    // if dialog displays more than 1 times
                    if (dialog.Dic != null)
                    {
                        // if the order is not endorsed
                        if (!isCompleted)
                        {
                            ContentDialog error = new ContentDialog
                            {
                                Title           = "Alert",
                                Content         = "You are not permitted to accept a non-dispatched despatch instruction cover delivery.",
                                CloseButtonText = "OK",
                                Width           = 400
                            };

                            await error.EnqueueAndShowIfAsync();
                        }
                    }

                    button = await dialog.EnqueueAndShowIfAsync();
                } while (button == ContentDialogResult.Primary && !(isCompleted = dialog.Dic.Status == DicStatusEnum.Dispatched.ToString()));
            }

            if (button == ContentDialogResult.Primary)
            {
                DicGUID.Text           = (dic = dialog.Dic).Id.ToString();
                SelectedDic.Text       = $"Selected DIC: {dic.Id}";
                SelectedDic.Visibility = Visibility.Visible;
                Submit.IsEnabled       = true;
            }
        }
示例#13
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (e.Parameter is Order order)
            {
                if (order.Status == OrderStatusEnum.Pending)
                {
                    this.order    = order;
                    Submit.Click += Submit_Click;
                }
                else
                {
                    ContentDialog error = new ContentDialog
                    {
                        Title           = "Error",
                        Content         = $"It is not permitted to endorse a non-pending status order.",
                        CloseButtonText = "OK",
                        Width           = 400
                    };

                    await error.EnqueueAndShowIfAsync();

                    Frame.Navigate(typeof(SearchOrders), this.GetType(), new DrillInNavigationTransitionInfo());
                }
            }
            else
            {
                ContentDialog dialog = new ContentDialog
                {
                    Title           = "Alert",
                    Content         = "You have to choose a order before endorsing it.",
                    CloseButtonText = "OK"
                };

                ContentDialogResult result = await dialog.EnqueueAndShowIfAsync();

                Frame.Navigate(typeof(SearchOrders), this.GetType(), new DrillInNavigationTransitionInfo());
            }
        }
示例#14
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (e.Parameter is Promotion promotion)
            {
                FillInformation(this.promotion = promotion);
            }
            else
            {
                ContentDialog dialog = new ContentDialog
                {
                    Title           = "Alert",
                    Content         = "You have to choose a promotion before modifying it.",
                    CloseButtonText = "OK"
                };

                ContentDialogResult result = await dialog.EnqueueAndShowIfAsync();

                Frame.Navigate(typeof(ViewPromotions), this.GetType(), new DrillInNavigationTransitionInfo());
            }
        }
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            // if the parameter is type "Type"
            if (e.Parameter is Type type)
            {
                // store it to instance variable
                searchStatus = type;

                // instantiate a dialog to remind user becauses of their initiative intention was not searching account
                ContentDialog Reminder = new ContentDialog
                {
                    Title           = "Reminder",
                    Content         = "Tap on the order which you want to modify on.",
                    CloseButtonText = "Got it"
                };

                // show the dialog
                await Reminder.EnqueueAndShowIfAsync();
            }
        }
示例#16
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (e.Parameter is Product product)
            {
                SetProductInformation(product);

                // add event listener
                ModifyProduct.Click += (sender, args) => Frame.Navigate(typeof(ModifyProduct), product, new DrillInNavigationTransitionInfo());
            }
            else if (e.Parameter is Guid id)
            {
                using (var context = new Context())
                {
                    var tmp = context.Product.FirstOrDefault(x => x.Id == id);
                    SetProductInformation(tmp);

                    // add event listener
                    ModifyProduct.Click += (sender, args) => Frame.Navigate(typeof(ModifyProduct), tmp, new DrillInNavigationTransitionInfo());
                }
            }
            else
            {
                ContentDialog dialog = new ContentDialog
                {
                    Title           = "Alert",
                    Content         = "You have to choose a product before viewing it.",
                    CloseButtonText = "OK"
                };

                ContentDialogResult result = await dialog.EnqueueAndShowIfAsync();

                Frame.Navigate(typeof(SearchProducts), typeof(ViewProduct), new DrillInNavigationTransitionInfo());
            }
        }