Link to: header | record viewer
directory
Copyright Turtle Creek Software 1996-2006. All Rights Reserved.
Comments
COverheadAccountViewer
This class manages overhead accounts for the Goldenseal accounting software,
small business management software, construction
project management software and
construction estimating software.
a viewer for overhead accounts
SUPERCLASS = CAccountViewer
Constructor
/*********************************************************************************
constructor
*********************************************************************************/
COverheadAccountViewer::COverheadAccountViewer(const SPaneInfo &inPaneInfo,
const SViewInfo &inViewInfo)
: CAccountViewer(inPaneInfo, inViewInfo)
{
}
Source Code
/*********************************************************************************
FinishUpdatingFields split TCS 4/17/00
Finish prep work after updating fields from an object, but before displaying them
*********************************************************************************/
void COverheadAccountViewer::FinishUpdatingFields(const UInt8 creationMethod,
DB_PersistentObject *viewerObject)
{
TCS_FailNILMsg(viewerObject, TCS_GetErrString(errID_BadObject));
// the superclass handles basic field updating
THE_SUPERCLASS::FinishUpdatingFields(creationMethod, viewerObject);
Boolean allowDistribution = GetCheckboxValue(tag_allowdistribution);
// set up the estimate field
PrepareEstimateField(id_OverheadAccount, viewerObject->GetDBID()); // TCS 1/3/02
// fetch the rental unit member table and update it TCS 1/24/99
CMemberTable *table =
TCS_SAFE_CAST(FindPaneByID(tag_overheadtable), CMemberTable);
if (table)
{
if (allowDistribution)
{
table->SetTableCanBeChanged(true);
table->Refresh();
}
else
{
table->MakeEmptyTable();
table->SetTableCanBeChanged(false);
table->Refresh();
}
}
}
/*********************************************************************************
HandleCheckboxClicked TCS 3/30/99
handle a checkbox click
*********************************************************************************/
void COverheadAccountViewer::HandleCheckboxClicked(CTCS_StdCheckbox *checkbox)
{
TCS_FailNILMsg(checkbox, TCS_GetErrString(errID_BadCheckbox));
Boolean value = checkbox->GetValue();
switch (checkbox->GetPaneID())
{
case tag_allowdistribution:
{
CMemberTable *table =
TCS_SAFE_CAST(FindPaneByID(tag_overheadtable), CMemberTable);
if (value && table)
{
table->MakeSingleRowTable();
table->SetTableCanBeChanged(true);
}
else if (table)
{
table->SetTableCanBeChanged(false);
table->MakeEmptyTable();
}
}
break;
default:
break;
}
// be sure to pass it along
THE_SUPERCLASS::HandleCheckboxClicked(checkbox);
}
/*********************************************************************************
IsReadyToUpdateObject TCS 3/30/99
before updating, let's make sure the table adds up
*********************************************************************************/
UInt8 COverheadAccountViewer::IsReadyToUpdateObject(const UInt8 saveSource)
{
// first let the superclass have a try TCS 1/29/01
UInt8 saveSuccess = THE_SUPERCLASS::IsReadyToUpdateObject(saveSource);
if (saveSuccess != save_success)
return saveSuccess;
// if in find, we're always OK TCS 1/4/01
if (InFindMode())
return save_notneeded;
if (GetCheckboxValue(tag_allowdistribution))
{
// find the owner table
CMemberTable *table =
TCS_SAFE_CAST(FindPaneByID(tag_overheadtable), CMemberTable);
TCS_FailNILMsg(table, TCS_GetErrString(errID_BadObject));
// get total column
SInt32 accountCol = 1;
SInt32 totalCol = 2;
// make sure it adds up to 100% and has owners
if (table->AdjustRequiredValues(accountCol, id_OverheadAccount, totalCol))
{
if (table->AdjustPercentTotal(totalCol)) // reversed order TCS 3/6/00
return save_success;
else
return save_notready;
}
else
return save_notready;
}
else
return save_success;
}
|