Retrieving Task's Budget Work and Cost Values

In Microsoft Project 2007 and later, tasks can have budget work and budget cost fields. With Aspose.Tasks for .NET, these values are available directly through the Tsk.BudgetWork and Tsk.BudgetCost fields.

Understanding Budget Work and Cost

Before Aspose.Tasks 5.0.0, developers had to calculate these values manually by summing the resource assignments. Now, they can be accessed directly from the task’s properties.

Example: Reading Budget Work and Cost

The following code example demonstrates how to retrieve a task’s BudgetWork and BudgetCost:

 1Project project = new Project("New Project.mpp");
 2
 3// Display budget work and budget cost for project summary task
 4Task projSummary = project.RootTask;
 5Console.WriteLine("projSummary.BudgetWork = " + projSummary.Get(Tsk.BudgetWork).ToString());
 6Console.WriteLine("projSummary.BudgetCost = " + projSummary.Get(Tsk.BudgetCost).ToString());
 7
 8// Display resource budget work
 9Resource resource = project.Resources.GetByUid(6);
10Console.WriteLine("Resource BudgetWork = " + resource.Get(Rsc.BudgetWork).ToString());
11
12// Display resource budget cost
13resource = project.Resources.GetByUid(7);
14Console.WriteLine("Resource BudgetCost = " + resource.Get(Rsc.BudgetCost).ToString());
15
16// Display assignment budget work and budget cost
17foreach (ResourceAssignment assignment in projSummary.Assignments)
18{
19    if (assignment.Get(Asn.Resource).Get(Rsc.Type) == ResourceType.Work)
20        Console.WriteLine("Assignment BudgetWork = " + assignment.Get(Asn.BudgetWork).ToString());
21    else
22        Console.WriteLine("Assignment BudgetCost = " + assignment.Get(Asn.BudgetCost).ToString());
23}

Key Notes

FAQ

Q: Can I set Budget Work and Budget Cost values programmatically?

Q: Do budget values depend on resource assignments?

Q: Are budget fields supported in all Microsoft Project file formats?

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.