public void CreateAddPositionScreen()
        {
            Section section = new Section();

            EntryElement nameEntry   = new EntryElement("Name", "", "");
            EntryElement priceEntry  = new EntryElement("Price", "price per unit", "");
            EntryElement amountEntry = new EntryElement("Amount", "", "");

            StringElement doneButton = new StringElement("DONE");

            doneButton.Tapped += () =>
            {
                var newPosition = new OrderPosition(0, nameEntry.Value,
                                                    Convert.ToInt32(priceEntry.Value),
                                                    Convert.ToInt32(amountEntry.Value));

                newPosition.OrderId = OrderId;

                Database.Insert(newPosition);

                Positions.Add(newPosition);

                ShowPositions();
            };

            section.Add(nameEntry);
            section.Add(priceEntry);
            section.Add(amountEntry);
            section.Add(doneButton);

            Root.Add(section);
        }
Exemplo n.º 2
0
        public OrderPositionDetailViewController(OrderPosition position, SQLiteConnection database) : base(new RootElement("Details"), true)
        {
            Section section = new Section();

            EntryElement name = new EntryElement("Name: ", "", position.Name);

            EntryElement price = new EntryElement("Price: ", "", position.Price.ToString());

            EntryElement amount = new EntryElement("Amount: ", "", position.Amount.ToString());

            StringElement deleteElement = new StringElement("Delete");

            deleteElement.Tapped += () =>
            {
                database.Delete(position);

                NavigationController.PopViewController(true);
            };

            section.Add(name);

            section.Add(price);

            section.Add(amount);

            section.Add(deleteElement);

            Root.Add(section);

            NavigationItem.SetRightBarButtonItem(
                new UIBarButtonItem(UIBarButtonSystemItem.Save, (sender, args) =>
            {
                position.Name   = name.Value;
                position.Price  = Convert.ToInt32(price.Value);
                position.Amount = Convert.ToInt32(amount.Value);
                database.Update(position);
            }), true);
        }
Exemplo n.º 3
0
 public void AddPostion(OrderPosition position)
 {
     Positions.Add(position);
     TotalSum += position.Price * position.Amount;
 }