コード例 #1
0
        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;
            }
        }
コード例 #2
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;
            }
        }