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

Delivery Method Viewer (Source Code)

Link to: header | record viewer directory

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

Comments

CDeliveryMethodViewer

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

It's a viewer for shipping methods and delivery methods. This class uses a 'step' table
to calculate shipping or delivery charges. It also sets the address which is
filled into sales transactions.

SUPERCLASS = DB_RecordViewer

Source Code

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

FinishUpdatingFields split TCS 4/17/00

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

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

TCS_FailNILMsg(viewerObject, TCS_GetErrString(errID_BadViewer));
SInt32 calcMethod;

// here we need to make sure that the rate table is formatted
// correctly
TCS_ASSERTMsg(viewerObject->GetMemberValue(tag_chargemethod,
type_long, &calcMethod), TCS_GetErrString(errID_BadValue));
FormatRateTable(calcMethod);

CToFromTable *table =
TCS_SAFE_CAST(FindPaneByID(tag_chargetable), CToFromTable);
TCS_FailNILMsg(table, TCS_GetErrString(errID_BadTable));
table->SetToColumn(CDeliveryMethod::col_to);
table->SetFromColumn(CDeliveryMethod::col_from);
table->FillToFromValues(calcMethod == CDeliveryMethod::charge_ByCostDollar ||
calcMethod == CDeliveryMethod::charge_ByCostPercent);
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************

HandlePopupChanged

a popup menu has been clicked, act accordingly

*********************************************************************************/
void CDeliveryMethodViewer::HandlePopupChanged(CTCS_StdPopupMenu *popupMenu)
{
TCS_FailNILMsg(popupMenu, TCS_GetErrString(errID_BadPopup));
switch (popupMenu->GetPaneID())
{
case tag_chargemethod:
FormatRateTable(popupMenu->GetValue());
break;

default:
break;
}

THE_SUPERCLASS::HandlePopupChanged(popupMenu);
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************

FormatRateTable

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

*********************************************************************************/
void CDeliveryMethodViewer::FormatRateTable(const SInt32 calcMethod)
{
CToFromTable *table =
TCS_SAFE_CAST(FindPaneByID(tag_chargetable), CToFromTable);
TCS_FailNILMsg(table, TCS_GetErrString(errID_BadTable));

if (calcMethod == CDeliveryMethod::charge_ByCostDollar ||
calcMethod == CDeliveryMethod::charge_ByWeightDollar)
{ // dollars
table->SetFieldType(CDeliveryMethod::col_cost, fieldtype_money, true);
}
else
{ // percentages
table->SetFieldType(CDeliveryMethod::col_cost, fieldtype_percent, true);
}

if (calcMethod == CDeliveryMethod::charge_ByCostDollar ||
calcMethod == CDeliveryMethod::charge_ByCostPercent)
{ // dollars
table->SetFieldType(CDeliveryMethod::col_to, fieldtype_money, true);
table->SetFieldType(CDeliveryMethod::col_from, fieldtype_money, true);
table->ResetColValues(CDeliveryMethod::col_from, fieldtype_money);
}
else
{ //weights
table->SetFieldType(CDeliveryMethod::col_to, fieldtype_number, true);
table->SetFieldType(CDeliveryMethod::col_from, fieldtype_number, true);
table->ResetColValues(CDeliveryMethod::col_from, fieldtype_number);
}
}
/******************************************************************************

ListenToMessage

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

*******************************************************************************/
void CDeliveryMethodViewer::ListenToMessage(MessageT inMessage, void *ioParam)
{
// fetch the calc method
SInt32 calcMethod = GetPopupValue(tag_chargemethod);

switch (inMessage)
{
case msg_TableEditCellChanged:
case msg_TableCVCellChanged:
{ // find the shipping charge table
CToFromTable *table =
TCS_SAFE_CAST(FindPaneByID(tag_chargetable), CToFromTable);
TCS_FailNILMsg(table, TCS_GetErrString(errID_BadObject));
// was a to value changed?
table->ValidateToFromValues(calcMethod == CDeliveryMethod::charge_ByCostDollar ||
calcMethod == CDeliveryMethod::charge_ByCostPercent);
}
break;

case msg_TableNewRow :
{ // find the shipping charge table
CToFromTable *table =
TCS_SAFE_CAST(FindPaneByID(tag_chargetable), CToFromTable);
TCS_FailNILMsg(table, TCS_GetErrString(errID_BadObject));
// fill in some values
table->FillToFromValues(calcMethod == CDeliveryMethod::charge_ByCostDollar ||
calcMethod == CDeliveryMethod::charge_ByCostPercent);
}
break;
}
// Always call inherited method
THE_SUPERCLASS::ListenToMessage(inMessage, ioParam);
}