Accounting Software
Small Business Software Estimating Software
Construction Estimating SoftwareBookkeeping SoftwareInventory SoftwareInventory Control SoftwareInventory Tracking SoftwareInventory Management SoftwareBusiness Management Software

Draw Schedule Viewer (Source Code)

Link to: header | record viewer directory

Copyright Turtle Creek Software 1996-2006. All Rights Reserved.

Comments

CDrawScheduleViewer

This class manages draw schedule viewers for the Goldenseal accounting software,
small business management software, construction project management software and
construction estimating software.

viewer for project draw schedules. Setup for Goldenseal project management software.

SUPERCLASS = DB_RecordViewer

Source Code

/*********************************************************************************

FinishUpdatingFields TCS 9/5/00

Finish prep work after updating fields from an object, but before displaying them

*********************************************************************************/
void CDrawScheduleViewer::FinishUpdatingFields(const UInt8 creationMethod,
DB_PersistentObject *viewerObject)
{
// the superclass handles basic field updating
THE_SUPERCLASS::FinishUpdatingFields(creationMethod, viewerObject);

UInt8 calcMethod = GetPopupValue(tag_calcmethod);

FormatDrawTable(calcMethod);
FormatAmountField(calcMethod);
}
/******************************************************************************

ListenToMessage

Responds to a message v1.28, 01-30-96, 12-30-96

*******************************************************************************/
void CDrawScheduleViewer::ListenToMessage(MessageT inMessage, void *ioParam)
{
switch (inMessage)
{
case msg_TableEditCellChanged:
case msg_TableCVCellChanged:
{ // find the draw schedule table
CMemberTable *table =
TCS_SAFE_CAST(FindPaneByID(tag_drawtable), CMemberTable);
TCS_FailNILMsg(table, TCS_GetErrString(errID_BadTable));

// was a percentage changed?
TableIndexT col = table->SelectedColumn();
CMoney total;

if (col == CDrawSchedule::col_drawamount)
{
UInt8 calcMethod = GetPopupValue(tag_calcmethod);

// if so, get the sum of tax rates in the table
if (calcMethod == calc_percent)
{
total = table->GetColumnMoneyTotal(CDrawSchedule::col_drawamount);
SetFieldCString(tag_amount, total.GetPercentString());
}
else // TCS 9/17/01
{
RecalcAmountField();
}
}
}
break;

default:
break;
}
// Always call inherited method
THE_SUPERCLASS::ListenToMessage(inMessage, ioParam);
}
/*********************************************************************************

IsReadyToUpdateObject

before updating, let's make sure the table adds up

*********************************************************************************/
UInt8 CDrawScheduleViewer::IsReadyToUpdateObject(const UInt8 saveSource)
{
UInt8 results = DB_RecordViewer::IsReadyToUpdateObject(saveSource);
if (results != save_success)
return results;

UInt8 calcMethod = GetPopupValue(tag_calcmethod);
if (calcMethod == calc_dollars) // we don't need to fuss with dollar totals TCS 9/17/01
return save_success;

// find the draw schedule table
CMemberTable *table =
TCS_SAFE_CAST(FindPaneByID(tag_drawtable), CMemberTable);
TCS_FailNILMsg(table, TCS_GetErrString(errID_BadTable));

// get total column
SInt32 totalCol = CDrawSchedule::col_drawamount;

// make sure it adds up to 100%
if (table->AdjustPercentTotal(totalCol))
{
return save_success; // the total was ok, so we can just leave
}
else
{ // totals were not ok. User may have fixed it,
// so let's update the total field rev TCS 5/4/01
CMoney total = table->GetColumnMoneyTotal(CDrawSchedule::col_drawamount);
SetFieldCString(tag_amount, total.GetPercentString());
return save_notready;
}
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************

HandlePopupChanged

a popup menu has been clicked, act accordingly

*********************************************************************************/
void CDrawScheduleViewer::HandlePopupChanged(CTCS_StdPopupMenu *popupMenu)
{
TCS_FailNILMsg(popupMenu, TCS_GetErrString(errID_BadPopup));

UInt8 value = popupMenu->GetValue();

switch (popupMenu->GetPaneID())
{
case tag_calcmethod:
FormatDrawTable(value);
FormatAmountField(value);
break;

default:
break;
}

THE_SUPERCLASS::HandlePopupChanged(popupMenu);
}
/*********************************************************************************

HandleEditChanged TCS 9/17/01

an edit field has been changed, act accordingly

*********************************************************************************/
void CDrawScheduleViewer::HandleEditChanged(CTCS_EditField *editField)
{
TCS_FailNILMsg(editField, TCS_GetErrString(errID_BadField));
switch (editField->GetPaneID())
{
case tag_deposit:
case tag_finalpayment:
{
UInt8 calcMethod = GetPopupValue(tag_calcmethod);
if (calcMethod == calc_dollars)
RecalcAmountField();
}
break;

default:
break;
}
// be sure to pass it along to the superclass
THE_SUPERCLASS::HandleEditChanged(editField);
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************

FormatDrawTable

format the draw table to money or percent depending on calculation method

*********************************************************************************/
void CDrawScheduleViewer::FormatDrawTable(const SInt32 calcMethod)
{
CMemberTable *table =
TCS_SAFE_CAST(FindPaneByID(tag_drawtable), CMemberTable);
TCS_FailNILMsg(table, TCS_GetErrString(errID_BadTable));

if (calcMethod == calc_dollars)
{ // dollars
table->SetFieldType(CDrawSchedule::col_drawamount, fieldtype_money, true);
table->ResetColValues(CDrawSchedule::col_drawamount, fieldtype_money);
}
else
{ // percentages
table->SetFieldType(CDrawSchedule::col_drawamount, fieldtype_percent, true);
table->ResetColValues(CDrawSchedule::col_drawamount, fieldtype_percent);
}
}
/*********************************************************************************

FormatAmountField TCS 9/17/01

format the amount field to money or percent depending on calculation method

*********************************************************************************/
void CDrawScheduleViewer::FormatAmountField(const SInt32 calcMethod)
{
CMoney currentAmount = GetFieldMoneyValue(tag_amount);

if (calcMethod == calc_dollars)
{
SetFieldType(tag_amount, fieldtype_money);
SetFieldCString(tag_amount, currentAmount.GetCurrencyString());

}
else
{
SetFieldType(tag_amount, fieldtype_percent);
SetFieldCString(tag_amount, currentAmount.GetPercentString());
}
}
/*********************************************************************************

RecalcAmountField TCS 9/17/01

recalculate the total amount. This should be used only when the calculation
method is dollars, not percents.

*********************************************************************************/
void CDrawScheduleViewer::RecalcAmountField()
{
CMemberTable *table = TCS_SAFE_CAST(FindPaneByID(tag_drawtable), CMemberTable);
TCS_FailNILMsg(table, TCS_GetErrString(errID_BadTable));

CMoney total = table->GetColumnMoneyTotal(CDrawSchedule::col_drawamount);
total += GetFieldMoneyValue(tag_deposit);
total += GetFieldMoneyValue(tag_finalpayment);
SetFieldCString(tag_amount, total.GetCurrencyString());
}