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

Vacation Item Viewer (Source Code)

Link to: header | record viewer directory

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

Comments

CVacationItemViewer

This class manages vacation items for the Goldenseal accounting software,
payroll software and small business management software.

It's a viewer for vacations and holidays. Part of the setup for the
Goldenseal payroll software.

SUPERCLASS = DB_RecordViewer

Source Code

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

GetReadyToUpdateFields TCS 2/25/99 split TCS 4/17/00

Do prep work before updating fields

*********************************************************************************/
void CVacationItemViewer::GetReadyToUpdateFields(const UInt8 creationMethod,
DB_PersistentObject *viewerObject)
{
TCS_FailNILMsg(viewerObject, TCS_GetErrString(errID_BadViewer));


// the superclass handles basic field updating
THE_SUPERCLASS::GetReadyToUpdateFields(creationMethod, viewerObject);
}
/*********************************************************************************

FinishUpdatingFields moved TCS 4/13/00

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

*********************************************************************************/
void CVacationItemViewer::FinishUpdatingFields(const UInt8 creationMethod,
DB_PersistentObject *viewerObject)
{
UInt8 vacationType = GetPopupValue(tag_vacationtype);
UInt8 holidayType = GetPopupValue(tag_holidaytype);

FormatHolidayFields(vacationType, holidayType);

THE_SUPERCLASS::FinishUpdatingFields(creationMethod, viewerObject);
}
/*********************************************************************************

HandleEditChanged TCS 5/26/99

an edit field has changed, act accordingly

*********************************************************************************/
void CVacationItemViewer::HandleEditChanged(CTCS_EditField *editField)
{
TCS_FailNILMsg(editField, TCS_GetErrString(errID_BadField));

SInt32 fieldID = editField->GetPaneID();

switch (fieldID)
{
case tag_holidaydate:
UpdateHolidayDate();
break;

default:
break;
}
// pass it along
THE_SUPERCLASS::HandleEditChanged(editField);
}
/*********************************************************************************

HandlePopupChanged

a popup menu has been clicked, act accordingly

*********************************************************************************/
void CVacationItemViewer::HandlePopupChanged(CTCS_StdPopupMenu *popupMenu)
{
UInt8 value = popupMenu->GetValue();

TCS_FailNILMsg(popupMenu, TCS_GetErrString(errID_BadPopup));
switch (popupMenu->GetPaneID())
{
case tag_vacationtype:
FormatHolidayFields(value, GetPopupValue(tag_holidaytype));
UpdateHolidayDate();
break;

case tag_holidaytype:
FormatFloatingFields(value);
UpdateHolidayDate();
break;

case tag_floatday:
case tag_floatweek:
case tag_floatmonth:
UpdateHolidayDate();
break;

case tag_paidtoclass: // TCS added 2/25/99
SetCVClassID(tag_paidto, value, cEraseValue);
break;

default:
break;
}

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

HandleCheckboxClicked TCS 5/24/02

handle a checkbox click

*********************************************************************************/
void CVacationItemViewer::HandleCheckboxClicked(CTCS_StdCheckbox *checkbox)
{
TCS_FailNILMsg(checkbox, TCS_GetErrString(errID_BadCheckbox));;

switch (checkbox->GetPaneID())
{
case tag_everyyear:
UpdateHolidayDate();
break;

default:
break;
}
// be sure to pass it along
THE_SUPERCLASS::HandleCheckboxClicked(checkbox);
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************

FormatHolidayFields

format the enablement of holiday fields, based on basic type

*********************************************************************************/
void CVacationItemViewer::FormatHolidayFields(const UInt8 vacationType,
const UInt8 holidayType)
{
Boolean isHoliday = (vacationType == condition_AddHoliday);

// holiday fields are shown for holidays
SetFieldEnabled(tag_holidaytype, isHoliday);
SetFieldEnabled(tag_everyyear, isHoliday);
SetFieldEnabled(tag_holidayamount, isHoliday); // rev TCS 7/31/02

TCS_FailNILMsg(mCurrViewerObject, TCS_GetErrString(errID_BadViewer));

if (isHoliday)
{
FormatFloatingFields(holidayType);
}
else
{ // not holiday, so turn off all the floating items
SetFieldEnabled(tag_floatday, false);
SetFieldEnabled(tag_floatmonth, false);
SetFieldEnabled(tag_floatweek, false);
SetFieldEnabled(tag_holidaydate, false);
}

// vacation fields are turned off for holidays
SetFieldEnabled(tag_vacationamount, !isHoliday);
SetFieldEnabled(tag_vacationunit, !isHoliday);
SetFieldEnabled(tag_vacationbase, !isHoliday);
SetFieldEnabled(tag_whencredited, !isHoliday); // rev TCS 7/31/02
SetFieldEnabled(tag_reducetime, !isHoliday);
SetFieldEnabled(tag_reduceto, !isHoliday);
SetFieldEnabled(tag_reduceunit, !isHoliday);
}
/*********************************************************************************

FormatFloatingFields

format the enablement of floating holiday fields, based on basic type

*********************************************************************************/
void CVacationItemViewer::FormatFloatingFields(const UInt8 holidayType)
{
Boolean isFloating = (holidayType == time_floating);

SetFieldEnabled(tag_floatday, isFloating);
SetFieldEnabled(tag_floatmonth, isFloating);
SetFieldEnabled(tag_floatweek, isFloating);

// date field is turned off for floating
SetFieldEnabled(tag_holidaydate, !isFloating);
}
/*********************************************************************************

UpdateHolidayDate TCS 5/24/02

reset the date of a holiday in the given year

*********************************************************************************/
void CVacationItemViewer::UpdateHolidayDate()
{
CDate holidayDate = GetFieldDateValue(tag_holidaydate);
UInt8 holidayType = GetFieldValue(tag_holidaytype);

CDate newDate = holidayDate;
newDate.SetYear(CDate::ThisYear());

if (GetFieldValue(tag_vacationtype) != condition_AddHoliday ||
!GetCheckboxValue(tag_everyyear) && holidayDate.GetYear() != CDate::ThisYear())
{
newDate.SetToNever();
SetFieldCString(tag_date, newDate.GetCString());
return;
}
else if (holidayType == time_firm)
{
// we're all set
}
else if (holidayType == time_floating)
{
UInt8 floatDay = GetPopupValue(tag_floatday);
UInt8 floatWeek = GetPopupValue(tag_floatweek);
UInt8 floatMonth = GetPopupValue(tag_floatmonth);
newDate = newDate.GetFloatingHolidayDate(floatDay, floatWeek, floatMonth);
}
else
{
newDate = newDate.GetHolidayDate(holidayType);
}

SetFieldCString(tag_date, newDate.GetCString());
}