コード例 #1
0
        private void PrepareAccounts()
        {
            Configuration accountConfig = SilverCoinsManager.GetConfigurationRecordByKey("ACCINIT");

            if (accountConfig == null || accountConfig.BooleanValue == false)
            {
                Account[] accounts =
                {
                    new Account()
                    {
                        Name        = "Checking account",
                        Currency    = "EUR",
                        CreatedDate = DateTime.Today,
                        Icon        = Resource.Drawable.euro
                    },
                    new Account()
                    {
                        Name        = "Savings account",
                        Currency    = "EUR",
                        CreatedDate = DateTime.Today,
                        Icon        = Resource.Drawable.deposits
                    },
                    new Account()
                    {
                        Name        = "Cash",
                        Currency    = "EUR",
                        CreatedDate = DateTime.Today,
                        Icon        = Resource.Drawable.cash
                    },
                };

                foreach (var account in accounts)
                {
                    SilverCoinsManager.SaveAccount(account);
                }

                SilverCoinsManager.SaveConfiguration(new Configuration()
                {
                    Name         = "Accounts initalized",
                    Key          = "ACCINIT",
                    BooleanValue = true
                });
            }
        }
コード例 #2
0
        private void PrepareCategories()
        {
            Configuration categoryConfig = SilverCoinsManager.GetConfigurationRecordByKey("CATINIT");

            if (categoryConfig == null || categoryConfig.BooleanValue == false)
            {
                Category[] categories =
                {
                    new Category {
                        Name        = "Salary",
                        Description = "",
                        Type        = Category.CategoryTypes.Income,
                        CreatedDate = DateTime.Today,
                        Visible     = 1,
                        Icon        = Resource.Drawable.salary,
                    },
                    new Category {
                        Name        = "Groceries",
                        Description = "",
                        Type        = Category.CategoryTypes.Expense,
                        CreatedDate = DateTime.Today,
                        Visible     = 1,
                        Icon        = Resource.Drawable.groceries,
                    },
                    new Category {
                        Name        = "Eating out",
                        Description = "",
                        Type        = Category.CategoryTypes.Expense,
                        CreatedDate = DateTime.Today,
                        Visible     = 1,
                        Icon        = Resource.Drawable.eating_out,
                    },
                    new Category {
                        Name        = "Holidays",
                        Description = "",
                        Type        = Category.CategoryTypes.Expense,
                        CreatedDate = DateTime.Today,
                        Visible     = 1,
                        Icon        = Resource.Drawable.vacation,
                    },
                    new Category {
                        Name        = "Sport",
                        Description = "",
                        Type        = Category.CategoryTypes.Expense,
                        CreatedDate = DateTime.Today,
                        Visible     = 1,
                        Icon        = Resource.Drawable.sports,
                    },
                    new Category {
                        Name        = "Car",
                        Description = "",
                        Type        = Category.CategoryTypes.Expense,
                        CreatedDate = DateTime.Today,
                        Visible     = 1,
                        Icon        = Resource.Drawable.car,
                    },
                    new Category {
                        Name        = "Shopping",
                        Description = "",
                        Type        = Category.CategoryTypes.Expense,
                        CreatedDate = DateTime.Today,
                        Visible     = 1,
                        Icon        = Resource.Drawable.shopping,
                    },
                    new Category {
                        Name        = "Entertainment",
                        Description = "",
                        Type        = Category.CategoryTypes.Expense,
                        CreatedDate = DateTime.Today,
                        Visible     = 1,
                        Icon        = Resource.Drawable.entertainment,
                    },
                    new Category {
                        Name        = "Pets",
                        Description = "",
                        Type        = Category.CategoryTypes.Expense,
                        CreatedDate = DateTime.Today,
                        Visible     = 1,
                        Icon        = Resource.Drawable.pets,
                    },
                    new Category {
                        Name        = "Kids",
                        Description = "",
                        Type        = Category.CategoryTypes.Expense,
                        CreatedDate = DateTime.Today,
                        Visible     = 1,
                        Icon        = Resource.Drawable.kids,
                    },
                    new Category {
                        Name        = "Electronics",
                        Description = "",
                        Type        = Category.CategoryTypes.Expense,
                        CreatedDate = DateTime.Today,
                        Visible     = 1,
                        Icon        = Resource.Drawable.electronics,
                    },
                    new Category {
                        Name        = "Transfer",
                        Description = "",
                        Type        = Category.CategoryTypes.MoneyTransfer,
                        CreatedDate = DateTime.Today,
                        Visible     = 0,
                        Icon        = Resource.Drawable.transfer
                    },
                };

                foreach (var category in categories)
                {
                    SilverCoinsManager.SaveCategory(category);
                }

                SilverCoinsManager.SaveConfiguration(new Configuration()
                {
                    Name         = "Categories initalized",
                    Key          = "CATINIT",
                    BooleanValue = true
                });
            }
        }