Accounting Software
Small Business Software Estimating Software
Time Tracking SoftwareTime Management SoftwareTime Billing SoftwareContact Management SoftwareCustomer Management SoftwareProject Management SoftwareBusiness Management Software

Breakdown Tables (Source Code)

Link to: header | source code | source 3 | source 4 | tables directory

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

Source Code

This class manages general breakdown tables for the Goldenseal accounting software,
small business management software, construction project management software and
construction estimating software.

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

SetMemberColString TCS 8/17/98

fill in the column with the given tag with the given text

*********************************************************************************/
Boolean CBreakdownTable::SetMemberColString(const TableIndexT row, const TagType tag,
const CTextString &inText)
{
TableIndexT col = GetMemberCol(tag);
if (col)
return SetCellText(row, col, inText);
else
return false;
}
/*********************************************************************************

SetMemberColValue TCS 10/24/98

fill in the column with the given tag with the given value

*********************************************************************************/
Boolean CBreakdownTable::SetMemberColValue(const TableIndexT row, const TagType tag,
const SInt32 inValue)
{
TableIndexT col = GetMemberCol(tag);
if (col)
return SetCellValue(row, col, inValue);
else
return false;
}
/*********************************************************************************

SetMemberColMoney TCS 4/11/02

fill in the column with the given tag with the given money value

*********************************************************************************/
Boolean CBreakdownTable::SetMemberColMoney(const TableIndexT row, const TagType tag,
const CMoney &inValue)
{
return SetMemberColString(row, tag, inValue.GetCurrencyString());
}
/*********************************************************************************

SetMemberColNumber TCS 4/11/02

fill in the column with the given tag with the given number value

*********************************************************************************/
Boolean CBreakdownTable::SetMemberColNumber(const TableIndexT row, const TagType tag,
const CMoney &inValue)
{
return SetMemberColString(row, tag, inValue.GetNumberString());
}
/*********************************************************************************

SetMemberColPercent TCS 4/11/02

fill in the column with the given tag with the given percent value

*********************************************************************************/
Boolean CBreakdownTable::SetMemberColPercent(const TableIndexT row, const TagType tag,
const CMoney &inValue)
{
return SetMemberColString(row, tag, inValue.GetPercentString());
}
/*********************************************************************************

SetMemberColDate TCS 4/11/02

fill in the column with the given tag with the given date value

*********************************************************************************/
Boolean CBreakdownTable::SetMemberColDate(const TableIndexT row, const TagType tag,
const CDate &inDate)
{
return SetMemberColString(row, tag, inDate.GetCString());
}
/*********************************************************************************

SetMemberColTime TCS 4/29/03

fill in the column with the given tag with the given time value

*********************************************************************************/
Boolean CBreakdownTable::SetMemberColTime(const TableIndexT row, const TagType tag,
const CDate &inDate)
{
return SetMemberColString(row, tag, inDate.GetTimeString());
}
/*********************************************************************************

SetMemberCV TCS 8/17/98

fill in the cv field in the col with the given tag with the given value

*********************************************************************************/
Boolean CBreakdownTable::SetMemberCV(const TableIndexT row, const TagType tag,
const DBid inValue, const DBid classID)
{
TableIndexT col = GetMemberCol(tag);
if (col)
return SetCVCellValue(row, col, inValue, classID);
else
return false;
}
/*********************************************************************************

SetColType

set the column type for the given cell

*********************************************************************************/
void CBreakdownTable::SetCellColType(const TableIndexT /*row*/, const TableIndexT /*col*/,
const SInt32 inType)
{
switch (inType)
{
case coltype_cv:
case coltype_lookup:
{
// if there is no cv field, let's create one
//DB_Clairvoyant *cvField = TCS_SAFE_CAST(cellField, DB_Clairvoyant);
}
break;

case coltype_edit:
{
// if there used to be a cv field, let's destroy it

}
break;

default:
TCS_DebugAlert("Oops, bad case in CBreakdownTable::SetColType!");
break;
}
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************

GetColTitle

return the title of the given column

*********************************************************************************/
CTextString CBreakdownTable::GetColTitle(const TableIndexT col) const
{
// if we have a user-entered title, use that TCS 7/2/99
SLETableColInfo colInfo;
if (GetColInfo(col, colInfo))
{
if (colInfo.colTitle[0])
{
CTextString colTitle(colInfo.colTitle);
return colTitle;
}
}
// otherwise use the stock title
return GetStockColTitle(col);
}
/*********************************************************************************

GetStockColTitle TCS 7/2/99

return the default title of the given column

*********************************************************************************/
CTextString CBreakdownTable::GetStockColTitle(const TableIndexT col) const
{
// get the member info from the column
SMemberInfo memberInfo;
TCS_ASSERTMsg(GetColMemberInfo(col, &memberInfo), TCS_GetErrString(errID_BadColumn));

// and return the member name
return CTextString(memberInfo.memberName);
}
/*********************************************************************************

GetColType

return the column type for the given column

*********************************************************************************/
SInt32 CBreakdownTable::GetColType(const TableIndexT col) const
{
// get the member info from the column
SMemberInfo memberInfo;
TCS_ASSERTMsg(GetColMemberInfo(col, &memberInfo), TCS_GetErrString(errID_BadColumn));
return GetColType(memberInfo);
}
/*********************************************************************************

GetColType

return the column type for the given member column. Note that subclasses
that use different col types for different rows in the same column must override
either this method, or the GetColType(const TableIndexT col) form.

*********************************************************************************/
SInt32 CBreakdownTable::GetColType(const SMemberInfo &memberInfo) const
{
switch (memberInfo.tag)
{
case tag_bill:
case tag_pay:
case tag_received:
case tag_deposit:
case tag_taxable: // TCS 7/23/01
case tag_salepricing: // TCS 11/1/01
case tag_skipupdating:
case tag_materialmodifier: // TCS 12/11/01
case tag_labormodifier:
case tag_fixedquantity: // TCS 12/23/01
return coltype_checkmark;
break;

case tag_location:
case tag_category:
case tag_subcategory:
case tag_catsystem:
case tag_costitem:
case tag_paymentmethod:
return coltype_cv;
break;

case tag_unitcost: // this may be coltype_edit
case tag_name: // this may be coltype_edit
case tag_menuname: // TCS 3/27/00
case tag_phase:
case tag_contractamount:
case tag_prevpaid:
case tag_prevcompleted:
case tag_pending:
case tag_current:
case tag_pastdue:
case tag_date:
case tag_amountdue:
case tag_invoicenum:
case tag_transactid: // this may be coltype_lookup, but generally it's used for id #
case tag_costamount:
case tag_vendor: // this may be coltype_lookup
case tag_wagerateamount:
case tag_timeused:
case tag_jobname:
case tag_billingdate:
case tag_basedon:
case tag_comments: // TCS 7/23/01
case tag_conditions:
return coltype_caption;
break;

case tag_unitsize: // sometimes this will be coltype_edit
//case tag_transactiontype:
return coltype_lookup;
break;

case tag_costarea: // this may be coltype_menucv
case tag_transactiontype: // TCS 1/26/00
return coltype_menulookup;
break;

default:
return coltype_edit;
break;
}
}
/*********************************************************************************

GetColData

return the column data for the given column(cv menu #, etc)

*********************************************************************************/
SInt16 CBreakdownTable::GetColData(TableIndexT col) const
{
// get the member info from the column
SMemberInfo memberInfo;
TCS_ASSERTMsg(GetColMemberInfo(col, &memberInfo), TCS_GetErrString(errID_BadColumn));
return GetColData(memberInfo);
}
/*********************************************************************************

GetColData

return the column data for the given member

*********************************************************************************/
SInt32 CBreakdownTable::GetColData(const SMemberInfo &memberInfo) const
{
return memberInfo.params;
}
/*********************************************************************************

GetFieldType TCS 3/9/98

return the field type for the given column. The default is to fetch params
from the member info. Subclasses may override this or the next method to
use a different method of fetching field type.

*********************************************************************************/
UInt8 CBreakdownTable::GetFieldType(const TableIndexT col) const
{
SMemberInfo memberInfo;
TCS_ASSERTMsg(GetColMemberInfo(col, &memberInfo), TCS_GetErrString(errID_BadColumn));
UInt8 fieldType = DB_ClassDescriptor::GetFieldTypeForDataType(memberInfo.type);
return fieldType;
}
/*********************************************************************************

GetFieldType TCS 3/9/98

return the field type for the given cell. For some reason it won't compile
without this here. Why it doesn't inherit from CTCS_Table is beyond me.

*********************************************************************************/
UInt8 CBreakdownTable::GetFieldType(const TableIndexT /*row*/ , const TableIndexT col) const
{
return GetFieldType(col);
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************

GetMenuCVClassID

return the class ID for cv field in the given column

*********************************************************************************/
DBid CBreakdownTable::GetMenuCVClassID(const TableCellT &inCell) const
{
// get the member info from the column
SMemberInfo memberInfo;
TCS_ASSERTMsg(GetColMemberInfo(COL(inCell), &memberInfo), TCS_GetErrString(errID_BadColumn));
return GetMemberMenuCVClassID(memberInfo);
}/*********************************************************************************

GetMemberMenuCVClassID

return the class ID for cv field, based on the given member info

*********************************************************************************/
DBid CBreakdownTable::GetMemberMenuCVClassID(const SMemberInfo &memberInfo) const
{
TCS_ASSERTMsg(memberInfo.type == type_enum ||
memberInfo.type == type_objclass, TCS_GetErrString(errID_BadID));

// the cv class id is in the params;
return memberInfo.params;
}/*********************************************************************************

GetCellCVClassID

return the class ID for cv field in the given column

*********************************************************************************/
DBid CBreakdownTable::GetCellCVClassID(const TableCellT &inCell) const
{
// get the member info from the column
SMemberInfo memberInfo;
TCS_ASSERTMsg(GetColMemberInfo(COL(inCell), &memberInfo), TCS_GetErrString(errID_BadColumn));
return GetMemberCVClassID(memberInfo);
}/*********************************************************************************

GetMemberCVClassID

return the class ID for cv field, based on the given member info

*********************************************************************************/
DBid CBreakdownTable::GetMemberCVClassID(const SMemberInfo &memberInfo) const
{
TCS_ASSERTMsg(memberInfo.type == type_objectid ||
memberInfo.type == type_objectidx ||
memberInfo.type == type_cstringcv, TCS_GetErrString(errID_BadMember));

// the cv class id is in the params; bugfix TCS 9/27/01
return memberInfo.params;
}
/*********************************************************************************

GetDetailTransactionID TCS 11/18/99

get the transaction object id for a row

*********************************************************************************/
DBid CBreakdownTable::GetDetailTransactionID(const TableIndexT row) const
{
TagType idTag = GetDetailIDTag();
if (idTag)
{
SInt32 idCol = GetMemberCol(idTag);
if (idCol)
{
return GetCellValue(row, idCol);
}
else
return 0;
}
else
return 0;
}
/*********************************************************************************

GetDetailTransactionClass TCS 11/18/99

get the transaction object class id for a row

*********************************************************************************/
UInt8 CBreakdownTable::GetDetailTransactionClass(const TableIndexT row) const
{
TagType classTag = GetDetailClassTag();
if (classTag)
{
SInt32 classCol = GetMemberCol(classTag);
if (classCol)
{
return GetCellValue(row, classCol);
}
else
return 0;
}
else
return 0;
}
/*********************************************************************************

GetMaxTextLength TCS 12/3/03

get the maximum number of characters that can be typed in any column

*********************************************************************************/
SInt32 CBreakdownTable::GetMaxTextLength(const TableIndexT &col) const
{
TagType colTag = GetColTag(col);

switch (colTag)
{
case tag_comments:
return cStandardTextLen;
break;

default:
return cMenuTextLen - 1;
break;
}
}