Exemple #1
0
        private void btnAddExpense_Click(object sender, RoutedEventArgs e)
        {
            //Create random info
            string          type        = RandomString(5, true);
            RandomGenerator generator   = new RandomGenerator();
            int             rand        = generator.RandomNumber(0, 100);
            decimal         amount      = Convert.ToDecimal(rand);
            DateTime        claimedDate = DateTime.Now;

            //create object with info
            Expenses newExpenses = new Expenses()
            {
                Type = type, ClaimedDate = claimedDate, Amount = amount
            };

            //add to collection
            expenses.Add(newExpenses);
            txtblkTotalExpenses.Text = "Total Expenses €" + GetTotalExpenses().ToString();
        }
Exemple #2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Expenses e1 = new Expenses()
            {
                Type = "Office", Amount = 15.55m, ClaimedDate = new DateTime(2014, 02, 12)
            };
            Expenses e2 = new Expenses()
            {
                Type = "Entertainment", Amount = 82.63m, ClaimedDate = new DateTime(2014, 01, 25)
            };
            Expenses e3 = new Expenses()
            {
                Type = "Entertainment", Amount = 26.81m, ClaimedDate = new DateTime(2014, 02, 06)
            };

            expenses.Add(e1);
            expenses.Add(e2);
            expenses.Add(e3);
            lbxExpenses.ItemsSource  = expenses;
            txtblkTotalExpenses.Text = "Total Expenses €" + GetTotalExpenses().ToString();
        }