Working with Task Costs
Contents
[
Hide
Show
]To estimate the cost of a project, tasks are associated with costs. Aspose.Tasks for C++ API supports this feature of Microsoft Project with a range of properties.
Working with Task Cost
The Tsk exposes a number of properties for working with task cost:
- Cost: a task’s projected or scheduled cost (double).
- BCWP: the budgeted cost of the work performed to date (double).
- BCWS: the budgeted cost of scheduled work (double).
- FixedCost: the fixed cost associated with a task (single).
- FixedCostAccrual: the fixed cost accrued for a task (CostAccrualType).
Viewing Task Costs in Microsoft Project
To view task costs in Microsoft Project:
- On the Task Entry form, go to the Insert menu and select Columns.
- Add the cost columns.
Getting Task Costs
The following code example demonstrates how to get a task’s cost.
1// Create new project
2System::SharedPtr<Project> project = System::MakeObject<Project>();
3
4// Add task and set cost
5System::SharedPtr<Task> task = project->get_RootTask()->get_Children()->Add(u"Task");
6task->Set<System::Decimal>(Tsk::Cost(), static_cast<System::Decimal>(800));
7
8// Display cost related properties of task
9System::Console::WriteLine(task->Get<System::Decimal>(Tsk::RemainingCost()));
10System::Console::WriteLine(task->Get<double>(Tsk::FixedCost()));
11System::Console::WriteLine(task->Get<double>(Tsk::CostVariance()));
12System::Console::WriteLine(project->get_RootTask()->Get<System::Decimal>(Tsk::Cost()));
13System::Console::WriteLine(project->get_RootTask()->Get<double>(Tsk::FixedCost()));
14System::Console::WriteLine(project->get_RootTask()->Get<System::Decimal>(Tsk::RemainingCost()));
15System::Console::WriteLine(project->get_RootTask()->Get<double>(Tsk::CostVariance()));