示例#1
0
        private void addButton_click(object sender, DependencyPropertyChangedEventArgs e)
        {
            string title    = itemNameBox.Text;
            int    quantity = int.Parse(quantityBox.Text);
            string type     = typeBox.Text;
            double price    = double.Parse(priceBox.Text);

            Item item = new Item(new Random().Next(), title, quantity, type, price);

            calculator.AddItem(item);
            double total = calculator.getTotal();

            totalLabel.Content = string.Format("Rp {0}", total);

            listBox.Items.Refresh();
        }
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            string title    = ItemNameBox.Text;
            int    quantity = int.Parse(QuantityBox.Text);
            string type     = TypeBox.Text;
            double price    = double.Parse(PriceBox.Text);

            Item item = new Item(new Random().Next(), title, quantity, type, price);

            calculator.AddItem(item);
            double total = calculator.getTotal();

            TotalLabel.Content = String.Format("Rp. {0}", total);
            ListBox.Items.Refresh();
        }
示例#3
0
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string title    = itemNameBox.Text;
                int    quantity = int.Parse(quantityBox.Text);
                string type     = typeBox.Text;
                double price    = double.Parse(priceBox.Text);

                Item item = new Item(new Random().Next(), title, quantity, type, price);
                calculator.addItem(item);
                double total = calculator.getTotal();
                totalLabel.Content = string.Format("Rp. {0}", total);
            }

            catch (Exception Error)
            {
                MessageBox.Show("Invalid");
            }
            listBox.Items.Refresh();
        }