コード例 #1
0
        private async void CreateNewTransactionItem()
        {
            transactionItems = await transactionsTable.ToCollectionAsync();

            if (isFormFilled())
            {
                var transactionItem = new transactionItem
                {
                    transactionUsername    = tbUsername.Text,
                    transactionDate        = dateSelection.Date.DateTime,
                    transactionType        = (string)comboType.SelectedItem,
                    transactionCategory    = (string)comboCategory.SelectedItem,
                    transactionAmount      = float.Parse(textAmount.Text),
                    transactionDescription = textDescription.Text
                };

                InsertTransaction(transactionItem);
                clearFormElements();
            }

            else
            {
                var dialog = new MessageDialog("Please fill required fields in form!");
                dialog.Commands.Add(new UICommand("OK"));
                await dialog.ShowAsync();
            }
        }
コード例 #2
0
        private void CreateDummyTransaction()
        {
            Random rand = new Random();

            DateTime start        = new DateTime(2012, 1, 1);
            var      range        = DateTime.Now - start;
            var      randTimeSpan = new TimeSpan((long)(rand.NextDouble() * range.Ticks));
            DateTime randomDate   = start + randTimeSpan;

            var types = new List <string> {
                "Income", "Expense"
            };
            int indType = rand.Next(types.Count);

            var categories = new List <string>();

            if (indType == 0)
            {
                categories.Add("Salary");
                categories.Add("Asset");
            }
            else
            {
                categories.Add("Entertainment");
                categories.Add("Bills");
                categories.Add("Groceries");
                categories.Add("Investment");
            }
            int indCat = rand.Next(categories.Count);



            var transactionItem = new transactionItem
            {
                transactionDate        = randomDate,
                transactionType        = types[indType],
                transactionCategory    = categories[indCat],
                transactionAmount      = rand.Next(100),
                transactionDescription = "Test data goes here.",
                transactionUsername    = tbUsername.Text
            };

            InsertTransaction(transactionItem);
        }
コード例 #3
0
 private async void DeleteTransaction(transactionItem transaction)
 {
     await transactionsTable.DeleteAsync(transaction);
 }
コード例 #4
0
        private async void InsertTransaction(transactionItem transaction)
        {
            await transactionsTable.InsertAsync(transaction);

            RefreshTransactions();
        }