Example #1
0
 public void GetFromCSV(string path)
 {
     //Чита податоци од csv фајл и запишува во овој објект.
     using (StreamReader file = new StreamReader(path))
     {
         string type = "";
         string line;
         line = file.ReadLine();
         if (line == null)
         {
             return;
         }
         string[] parts = line.Split(',');
         Income   = Convert.ToDecimal(parts[0]);
         Expenses = Convert.ToDecimal(parts[1]);
         Total    = Convert.ToDecimal(parts[2]);
         while ((line = file.ReadLine()) != null)
         {
             if (line.Equals("Categories:"))
             {
                 type = line;
                 continue;
             }
             else if (line.Equals("Accounts:"))
             {
                 type = line;
                 continue;
             }
             else if (line.Equals("Transactions:"))
             {
                 type = line;
                 continue;
             }
             if (type.Equals("Categories:"))
             {
                 if (line[0] == '1')
                 {
                     IncomeCategories.Add(line.Substring(2), new IncomeCategory(line.Substring(2)));
                 }
                 else
                 {
                     ExpensesCategories.Add(line.Substring(2), new ExpensesCategory(line.Substring(2)));
                 }
             }
             else if (type.Equals("Accounts:"))
             {
                 Account a = MakeAccount(line);
                 Accounts.Add(a.Name, a);
             }
             else if (type.Equals("Transactions:"))
             {
                 Transactions.Add(MakeTransaction(line));
             }
         }
         file.Close();
     }
 }
Example #2
0
 /// <summary>
 /// Adds a new Income SubCategory with the name in the NewIncomeName TextBox.
 /// </summary>
 public void AddIncomeCategory()
 {
     if (NewIncomeName == String.Empty)
     {
         IncomeCategories.Add(new Category("Default"));
     }
     else
     {
         IncomeCategories.Add(new Category(NewIncomeName));
         NewIncomeName = String.Empty;
     }
 }
Example #3
0
        /// <summary>
        /// Base Constructor, Subscribes to the SendEnter Event.
        /// </summary>
        public SubCategoryViewModel()
        {
            #region Test Data. Should get replaced on startup.
            IncomeCategories.Add(new Category("Temp Income Category 1"));
            IncomeCategories.Add(new Category("Temp Income Category 2"));
            IncomeCategories.Add(new Category("Temp Income Category 3"));
            IncomeCategories.Add(new Category("Should not be shown."));

            ExpenseCategories.Add(new Category("Temp Expense Category 1"));
            ExpenseCategories.Add(new Category("Temp Expense Category 2"));
            ExpenseCategories.Add(new Category("Temp Expense Category 3"));
            ExpenseCategories.Add(new Category("Should not be shown."));
            #endregion

            SubCategoryView.SendEnter += this.SubCategoryView_SendKeyPress;
        }