/// <summary>
        /// Initializes a new instance of the <see cref="PhoenixImperator.Pages.OrderSelectorPage"/> class.
        /// </summary>
        /// <param name="position">Position.</param>
        public OrderSelectorPage(Position position)
            : base("New Order")
        {
            BackgroundColor = Color.Black;

            AddListViewWithSearchBar (typeof(TextCell), Orders, (sender, e) => {
                Phoenix.Application.OrderTypeManager.Get(((OrderType)e.Item).Id,(orderType) => {
                    Order order = new Order{
                        PositionId = position.Id,
                        OrderType = orderType,
                        OrderTypeId = orderType.Id
                    };
                    OrderEditPage editPage = new OrderEditPage(order);
                    Device.BeginInvokeOnMainThread(() => {
                        RootPage.Root.NextPageAfterModal(editPage);
                    });
                });
            });

            Button cancelButton = new Button {
                Text = "Cancel",
                TextColor = Color.White
            };

            cancelButton.Clicked += (sender, e) => {
                Device.BeginInvokeOnMainThread(() => {
                    RootPage.Root.DismissModal();
                });
            };

            PageLayout.Children.Add (cancelButton);

            Phoenix.Application.OrderTypeManager.GetOrderTypesForPosition ((Position.PositionFlag)position.PositionType, (results) => {
                UpdateOrders(results);
            });
        }
Beispiel #2
0
 /// <summary>
 /// Creates a copy of the order with the specified position identifier.
 /// </summary>
 /// <param name="positionId">Position identifier.</param>
 public Order Copy(int positionId)
 {
     Order newOrder = new Order {
         OrderTypeId  = this.OrderTypeId,
         OrderType = this.OrderType,
         PositionId = positionId
     };
     foreach (OrderParameter param in Parameters) {
         newOrder.Parameters.Add (new OrderParameter {
             Value = param.Value,
             DisplayValue = param.DisplayValue
         });
     }
     return newOrder;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="PhoenixImperator.Pages.OrderEditPage"/> class.
        /// </summary>
        /// <param name="order">Order.</param>
        public OrderEditPage(Order order)
            : base(order.OrderType.Name)
        {
            CurrentOrder = order;

            formTable = new TableView {
                Root = new TableRoot(),
                Intent = TableIntent.Form,
                BackgroundColor = Color.White,
                VerticalOptions = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Fill
            };

            formTable.Root.Add (new TableSection ());

            Button saveButton = new Button {
                Text = "Save",
                TextColor = Color.White,
                BackgroundColor = Color.Blue
            };
            Button deleteButton = new Button {
                Text = "Delete Order",
                TextColor = Color.White,
                BackgroundColor = Color.Red
            };

            saveButton.Clicked += (sender, e) => {
                deleteButton.IsEnabled = false;
                saveButton.IsEnabled = false;
                SaveOrder();
            };

            deleteButton.Clicked += async(sender, e) => {
                bool confirm = await DisplayAlert("Delete Order","Are you sure?","Yes","No");
                if(confirm){
                    deleteButton.IsEnabled = false;
                    saveButton.IsEnabled = false;
                    DeleteOrder();
                }

            };

            ShowParameters ();

            AddSection ("Description");
            LastSection.Add (new ViewCell () {
                View = new StackLayout {
                    Children = {
                        new Label {
                            FontSize = Device.GetNamedSize (NamedSize.Small, typeof(Label)),
                            VerticalOptions = LayoutOptions.Fill,
                            HorizontalOptions = LayoutOptions.FillAndExpand,
                            Text = CurrentOrder.OrderType.Description,
                            BackgroundColor = Color.White,
                            TextColor = Color.Black
                        }
                    }
                }
            });

            PageLayout.Children.Add (deleteButton);
            PageLayout.Children.Add (new ScrollView { Content = formTable });
            PageLayout.Children.Add (saveButton);
        }