示例#1
0
        public void readFromFile()
        {
            using (StreamReader reader = new StreamReader(myBudgetPath))
            {
                myHistoryBudgetList.Clear();
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    //split every line with the character '|'
                    string[] parts = line.Split('|');

                    int id = Convert.ToInt32(parts[0]);
                    Budget tempBudget = new Budget(id);
                    int eventID = Convert.ToInt32(parts[0]);
                    for (int i = 1; i < parts.Length; i++)
                    {
                        if (i % 3 == 1)
                        {
                            //add a budget item to the budget
                            string name = parts[i];
                            double amountSpent = Convert.ToDouble(parts[i + 1]);
                            double amountTotal = Convert.ToDouble(parts[i + 2]);
                            tempBudget.addBudgetItem(name, amountSpent, amountTotal);
                        }
                    }
                    //push one budget item to the list
                    myHistoryBudgetList.Add(tempBudget);
                }
            }
        }
示例#2
0
        //add a budget of an event
        public void createBudget()
        {
            int id;
            if (numBudgets != 0)
                id = budgetList[numBudgets - 1].getEventID() + 1;
            else
                id = 1;

            Budget tempBudget = new Budget(id);
            budgetList.Add(tempBudget);
            numBudgets++;
        }