Exemplo n.º 1
0
        public SalesDocumentPage(SalesDocument document)
        {
            InitializeComponent();

            NavigationBar.ChangeMyOrdersTabColor();

            this.document = document;

            DisplayData();
        }
Exemplo n.º 2
0
        public static void UpdatePrice(SalesDocument document)
        {
            double price = 0;

            foreach (KeyValuePair <Product, int> product in document.Products)
            {
                price += product.Key.Price * product.Value;
            }
            document.TotalPrice = price - (price * 0.1);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds a generic example document to the corresponding StackLayout
        /// </summary>
        private void AddDocumentToStack(StackLayout stack, SalesDocument document)
        {
            var documentGrid = new Grid
            {
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(2, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(45, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(45, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(6, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(2, GridUnitType.Star)
                    },
                },

                RowDefinitions =
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                }
            };

            Button btnViewDocument = new Button
            {
                BackgroundColor = buttonColor,
                BorderColor     = (Color)App.Current.Resources["SPBlue"],
                BorderRadius    = 20,
            };

            btnViewDocument.ClassId  = document.Number.ToString();
            btnViewDocument.Clicked += Clicked_btnViewDocument;

            documentGrid.Children.Add(btnViewDocument, 0, 4, 0, 4);

            documentGrid.Children.Add(new Label
            {
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Start,
                Text             = document.Number,
                FontSize         = fontSize,
                InputTransparent = true,
            }, 1, 1);

            documentGrid.Children.Add(new Label
            {
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Start,
                Text             = document.Status,
                FontSize         = fontSize,
                InputTransparent = true,
            }, 1, 2);

            documentGrid.Children.Add(new Label
            {
                HorizontalOptions = LayoutOptions.End,
                Text             = "$" + document.TotalPrice.ToString("N2"),
                FontSize         = fontSize,
                InputTransparent = true,
            }, 2, 1);

            string productInfoText = document.Products.Values.First() + "x " + document.Products.Keys.First().Description;

            if (document.Products.Count > 1)
            {
                productInfoText += "\n(plus " + (document.Products.Keys.Count - 1) + " other product";
                if (document.Products.Count > 2)
                {
                    productInfoText += "s";
                }
                productInfoText += ")";
            }

            StackLayout stackProductInfo = new StackLayout //stack layout used to contain label to fix word wrap issues
            {
                Padding          = new Thickness(0, 0, 0, 4),
                InputTransparent = true
            };

            stackProductInfo.Children.Add(new Label
            {
                VerticalOptions   = LayoutOptions.StartAndExpand,
                HorizontalOptions = LayoutOptions.StartAndExpand,
                Text     = productInfoText,
                FontSize = 12,
            });

            documentGrid.Children.Add(stackProductInfo, 1, 3, 3, 4);

            documentGrid.Children.Add(new Image
            {
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center,
                Source            = buttonIndicator,
                InputTransparent  = true,
            }, 3, 4, 0, 5);

            documentGrid.Children.Add(new Label
            {
                FontSize          = fontSize,
                HorizontalOptions = LayoutOptions.End,
                Text             = document.Date.ToString("dd/MM/yyyy"),
                InputTransparent = true,
            }, 2, 2);

            StackLayout documentLayout = new StackLayout();

            documentLayout.Children.Add(documentGrid);

            stack.Children.Add(documentLayout);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Adds a generic example document to the corresponding StackLayout
        /// </summary>
        private void AddDocumentToStack(StackLayout stack, SalesDocument document)
        {
            var documentGrid = new Grid
            {
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(2, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(48, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(48, GridUnitType.Star)
                    },
                    //new ColumnDefinition { Width = new GridLength(6, GridUnitType.Star) },
                    new ColumnDefinition {
                        Width = new GridLength(2, GridUnitType.Star)
                    },
                },

                RowDefinitions =
                {
                    new RowDefinition {
                        Height = new GridLength(3, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(42, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(42, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(3, GridUnitType.Star)
                    },
                }
            };

            Button btnViewDocument = new Button
            {
                BackgroundColor = buttonColor,
                BorderColor     = (Color)App.Current.Resources["SPBlue"],
                BorderRadius    = 20
            };

            btnViewDocument.ClassId  = document.Number.ToString();
            btnViewDocument.Clicked += Clicked_btnViewDocument;

            documentGrid.Children.Add(btnViewDocument, 0, 4, 0, 4);

            documentGrid.Children.Add(new Label
            {
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Start,
                Text             = document.Number,
                FontSize         = fontSize,
                InputTransparent = true,
            }, 1, 1);

            documentGrid.Children.Add(new Label
            {
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Start,
                Text             = document.Status,
                FontSize         = fontSize,
                InputTransparent = true,
            }, 1, 2);

            documentGrid.Children.Add(new Label
            {
                HorizontalOptions = LayoutOptions.End,
                Text             = "$" + document.TotalPrice.ToString("N2"),
                FontSize         = fontSize,
                InputTransparent = true,
            }, 2, 1);

            /*documentGrid.Children.Add(new Image
             * {
             *  VerticalOptions = LayoutOptions.Center,
             *  HorizontalOptions = LayoutOptions.Center,
             *  Source = buttonIndicator,
             *  InputTransparent = true,
             * }, 3, 4, 0, 4);*/

            documentGrid.Children.Add(new Label
            {
                FontSize          = fontSize,
                HorizontalOptions = LayoutOptions.End,
                Text             = document.Date.ToString("MM/dd/yyyy HH:mm tt"),
                InputTransparent = true,
            }, 2, 2);

            StackLayout documentLayout = new StackLayout();

            documentLayout.Children.Add(documentGrid);

            stack.Children.Add(documentLayout);
        }