Example #1
0
        public static BudgetList GetBudgets()
        {
            // Retrieve the Budget records from the data store
            List<BudgetDetails> details = SiteProvider.Accounts.GetBudgets();
            BudgetList list = new BudgetList();

            // Copy from the Budget records to the Budget objects
            foreach (BudgetDetails bd in details)
            {
                if (bd != null)
                {
                    // Create the new Budget object from the Budget Details retrieved
                    // from the database.
                    Budget b = new Budget(bd);

                    // Retrieve the list of Budget Items for the specified Budget.
                    List<BudgetItemDetails> itemDetails = SiteProvider.Accounts.GetBudgetItems(bd.ID);
                    BudgetItemList items = new BudgetItemList();
                    foreach (BudgetItemDetails bid in itemDetails)
                    {
                        if (bid != null)
                        {
                            BudgetItem bi = new BudgetItem(bid);
                            bi.Budget = b;
                            if (bid.TagID != -1)
                                bi.Tag = KapitalManager.Instance.Tags.FindByID(bid.TagID);

                            // Add the Budget Item to the list of BudgetItems.
                            items.Add(bi);
                        }
                    }

                    // Attach the list of items to the current Budget
                    b.BudgetItems = items;
                    list.Add(b);
                }
            }

            return list;
        }
Example #2
0
        public BudgetItem Copy()
        {
            BudgetItem bi = new BudgetItem();

            bi.ID = ID;
            bi.Budget = Budget;	// This was commented out...not sure why!
            bi.Tag = Tag;
            bi.Name = Name;
            bi.Amount = Amount;
            bi.TimePeriod = TimePeriod;
            bi.TimePeriodCount = TimePeriodCount;
            bi.ScheduledDate = ScheduledDate;
            bi.DayCount = DayCount;
            bi.Recur = Recur;

            return bi;
        }
Example #3
0
        public static Budget GetBudgetByID(int id)
        {
            BudgetDetails bd = SiteProvider.Accounts.GetBudgetByID(id);
            if (bd == null)
                return null;

            Budget b = new Budget(bd);

            // Retrieve each Budget Item for this Budget
            List<BudgetItemDetails> details = SiteProvider.Accounts.GetBudgetItems(b.ID);
            b.BudgetItems = new BudgetItemList();
            foreach (BudgetItemDetails bid in details)
            {
                BudgetItem bi = new BudgetItem(bid);
                bi.Budget = b;
                if (bid.TagID > 0)
                    bi.Tag = KapitalManager.Instance.Tags.FindByID(bid.TagID);
                b.BudgetItems.Add(bi);
            }

            return b;
        }
Example #4
0
 /// <summary>
 /// Update the Budget Item in the database with the Budget Item parameter.
 /// </summary>
 /// <param name="bi"></param>
 /// <returns></returns>
 public static bool UpdateBudgetItem(BudgetItem bi)
 {
     BudgetItemDetails bid = new BudgetItemDetails(bi);
     bool result = SiteProvider.Accounts.UpdateBudgetItem(bid);
     return result;
 }
Example #5
0
 /// <summary>
 /// Insert a new Budget Item into the database.
 /// </summary>
 /// <param name="bi"></param>
 /// <returns></returns>
 public static int InsertBudgetItem(BudgetItem bi)
 {
     BudgetItemDetails bid = new BudgetItemDetails(bi);
     int id = SiteProvider.Accounts.InsertBudgetItem(bid);
     bi.ID = id;
     return id;
 }
Example #6
0
        public static BudgetItemList GetBudgetItems(int budgetID)
        {
            if (budgetID < 0)
                return null;

            List<BudgetItemDetails> details = SiteProvider.Accounts.GetBudgetItems(budgetID);
            if (details == null || details.Count == 0)
            {
                return null;
            }

            BudgetItemList budgetItems = new BudgetItemList();
            foreach (BudgetItemDetails bid in details)
            {
                if (bid == null)
                    continue;

                BudgetItem bi = new BudgetItem(bid);

                if (bid.TagID > 0)
                    bi.Tag = KapitalManager.Instance.Tags.FindByID(bid.TagID);

                bi.Budget = null;

                budgetItems.Add(bi);
            }

            return budgetItems;
        }
Example #7
0
 public static BudgetItem GetBudgetItemByID(int budgetItemID)
 {
     BudgetItemDetails bid = SiteProvider.Accounts.GetBudgetItemByID(budgetItemID);
     BudgetItem bi = new BudgetItem(bid);
     return bi;
 }
Example #8
0
 /// <summary>
 /// Delete the Budget Item from the database.
 /// </summary>
 /// <param name="bi"></param>
 /// <returns></returns>
 public static bool DeleteBudgetItem(BudgetItem bi)
 {
     return (SiteProvider.Accounts.DeleteBudgetItem(bi.ID));
 }