Пример #1
0
        private void ChangeStatus_Click(object sender, RoutedEventArgs e)
        {
            StackPanel sp           = new StackPanel();
            ListPicker ShippingDrop = new ListPicker();
            ListPicker PaymentDrop  = new ListPicker();

            PaymentDrop.SetValue(Microsoft.Phone.Controls.ListPicker.ItemCountThresholdProperty, 6);
            ListPicker OrderDrop     = new ListPicker();
            var        OrderIndex    = Array.IndexOf(OrderStatusValues, Order.OrderStatus.ToString());
            var        ShippingIndex = 0;

            switch (Order.ShippingStatus)
            {
            case ShippingStatus.NotYetShipped:
                ShippingIndex = 1;
                break;

            case ShippingStatus.PartiallyShipped:
                ShippingIndex = 2;
                break;

            case ShippingStatus.ShippingNotRequired:
                ShippingIndex = 4;
                break;

            default:
                ShippingIndex = Array.IndexOf(ShippingStatusValues, Order.ShippingStatus.ToString());
                break;
            }
            var PaymentIndex = 0;

            switch (Order.PayStatus)
            {
            case PaymentStatus.PartiallyRefunded:
                PaymentIndex = 2;
                break;

            default:
                PaymentIndex = Array.IndexOf(PayStatusValues, Order.PayStatus.ToString());
                break;
            }



            ShippingDrop.ItemsSource = ShippingStatusValues;
            PaymentDrop.ItemsSource  = PayStatusValues;
            OrderDrop.ItemsSource    = this.OrderStatusValues;

            ShippingDrop.SelectedIndex = ShippingIndex;
            OrderDrop.SelectedIndex    = OrderIndex;
            PaymentDrop.SelectedIndex  = PaymentIndex;

            ShippingDrop.SelectionChanged += (se, ev) => {
                ShippingIndex = ShippingDrop.SelectedIndex;
            };
            OrderDrop.SelectionChanged += (se, ev) => {
                OrderIndex = OrderDrop.SelectedIndex;
            };
            PaymentDrop.SelectionChanged += (se, ev) => {
                PaymentIndex = PaymentDrop.SelectedIndex;
            };

            sp.Children.Add(ShippingDrop);
            sp.Children.Add(PaymentDrop);
            sp.Children.Add(OrderDrop);

            CustomMessageBox messageBox = new CustomMessageBox()
            {
                Caption            = "Change Order Status",
                Message            = "Change the status accordingly",
                Content            = sp,
                LeftButtonContent  = "Submit",
                RightButtonContent = "Cancel"
            };

            messageBox.Dismissed += async(s1, e1) => {
                switch (e1.Result)
                {
                case CustomMessageBoxResult.LeftButton:
                    await api.ChangeOrderStatus(Order.OrderID, OrderStatusValues[OrderIndex]);

                    var PayS = new PaymentStatus[] { PaymentStatus.Paid, PaymentStatus.Authorized, PaymentStatus.PartiallyRefunded, PaymentStatus.Pending, PaymentStatus.Refunded, PaymentStatus.Voided };
                    await api.ChangePaymentStatus(Order.OrderID, PayS[PaymentIndex]);

                    var ShipS = new ShippingStatus[] { ShippingStatus.Delivered, ShippingStatus.NotYetShipped, ShippingStatus.PartiallyShipped, ShippingStatus.Shipped, ShippingStatus.ShippingNotRequired };
                    await api.ChangeShippingStatus(Order.OrderID, ShipS[ShippingIndex]);

                    MessageBox.Show("Status changed sucessfuly");
                    InitializeOrder();
                    break;
                }
            };

            messageBox.Show();
        }