Link to: header | record viewer
directory
Copyright Turtle Creek Software 1996-2006. All Rights Reserved.
Comments
This class manages summation calculation viewers for the Goldenseal accounting software,
small business management software, construction
project management software and
construction estimating software.
CCalcSummationsViewer
a viewer for the summations calculations list. We use these to add up
totals in the Balance Sheet, Income Statement and other accounting software reports
SUPERCLASS = DB_RecordViewer
Constructor
/*********************************************************************************
constructor
*********************************************************************************/
CCalcSummationsViewer::CCalcSummationsViewer(const SPaneInfo &inPaneInfo,
const SViewInfo &inViewInfo)
: DB_RecordViewer(inPaneInfo, inViewInfo)
{
}
Source Code
/*********************************************************************************
FinishUpdatingFields split DK 4/17/00
Finish prep work after updating fields from an object, but before displaying them
*********************************************************************************/
void CCalcSummationsViewer::FinishUpdatingFields(const UInt8 creationMethod,
DB_PersistentObject *viewerObject)
{
// the superclass handles basic field updating
THE_SUPERCLASS::FinishUpdatingFields(creationMethod, viewerObject);
RecalcTableTotal();
}
#if CAN_USE_MARK
#pragma mark -
#endif/*********************************************************************************
ListenToMessage
listen to a message
*********************************************************************************/
void CCalcSummationsViewer::ListenToMessage(MessageT inMessage, void *ioParam)
{
switch (inMessage)
{
case msg_TableEditCellChanged:
// recalc the total
RecalcTableTotal();
break;
case msg_TableCVCellChanged:
{ // we have a different calculator listed.
// First check for circularity DK 9/7/99
CMemberTable *table =
TCS_SAFE_CAST(FindPaneByID(tag_summationstable), CMemberTable);
TCS_FailNILMsg(table, TCS_GetErrString(errID_BadTable));
TableIndexT row = table->SelectedRow();
CMoney zeroValue = 0;
if (table->SelectedColumn() == CCalcSummation::col_type)
{ // we've changed the calculator class, so erase stuff DK 9/16/99
table->SetCVCellValue(row, CCalcSummation:: col_item, 0); // bugfix DK 1/14/02
table->SetCellText(row, CCalcSummation:: col_subtotal, zeroValue.GetCurrencyString());
table->RefreshRow(row);
}
else
{ // we've changed the calculator
UInt8 calcClass = table->GetCellValue(row, CCalcSummation::col_type);
DBid calcID = table->GetCellValue(row,CCalcSummation:: col_item);
TCS_FailNILMsg(gDBFile, TCS_GetErrString(errID_BadFile));
TCS_FailNILMsg(mCurrViewerObject, TCS_GetErrString(errID_BadObject));
DB_PersistentObject *calc = gDBFile->GetOneObject(calcClass, calcID);
if (calc)
{
DB_ObjectWatcher watcher(calc);
if (calc->DependsOnCalc(mCurrViewerObject->GetDBClassID(),
mCurrViewerObject->GetDBID()))
{
// we don't give an alert, since the target switch causes problems
TCS_SysBeep(); // DK bugfix 10/18/00
table->SetCVCellValue(row, CCalcSummation:: col_item, 0);
}
else // it's a valid calc, so fill in calculated value DK 9/16/99
{
calc->SetCalcDirty(); // DK 8/29/02
CMoney value = calc->GetCalculatorMoney();
table->SetCellText(row, CCalcSummation:: col_subtotal, value.GetCurrencyString());
table->RefreshCell(row, CCalcSummation:: col_subtotal);
}
}
else // no calculator, so clear value DK 9/16/99
{
table->SetCellText(row, CCalcSummation:: col_subtotal, zeroValue.GetCurrencyString());
table->RefreshCell(row, CCalcSummation:: col_subtotal);
}
}
// recalc the total
RecalcTableTotal();
}
break;
default:
break;
}
THE_SUPERCLASS::ListenToMessage(inMessage, ioParam);
}/*********************************************************************************
RecalcTableTotal
get the total
*********************************************************************************/
void CCalcSummationsViewer::RecalcTableTotal()
{
// get the table
CMemberTable *table =
TCS_SAFE_CAST(FindPaneByID(tag_summationstable), CMemberTable);
TCS_FailNILMsg(table, TCS_GetErrString(errID_BadObject));
TCS_FailNILMsg(gDBFile, TCS_GetErrString(errID_BadFile));
// update the total field
CMoney totalRate =
table->GetColumnMoneyTotal(CCalcSummation::col_subtotal);
SetFieldMoneyValue(tag_currentvalue, totalRate);
}
|