home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
VSCPPv8.zip
/
VACPP
/
IBMCPP
/
samples
/
VISBUILD
/
OASEARCH
/
CONTRACT.CPV
< prev
next >
Wrap
Text File
|
1995-05-15
|
8KB
|
250 lines
//****************************************************************************
// OAContract Class - C++ Code File (contract.cpv) *
// *
// COPYRIGHT: Copyright (C) International Business Machines Corp., 1994,1995 *
// *
// DISCLAIMER OF WARRANTIES: *
// The following [enclosed] code is sample code created by IBM *
// Corporation. This sample code is not part of any standard IBM product *
// and is provided to you solely for the purpose of assisting you in the *
// development of your applications. The code is provided "AS IS", *
// without warranty of any kind. IBM shall not be liable for any damages *
// arising out of your use of the sample code, even if they have been *
// advised of the possibility of such damages. *
//****************************************************************************
//NOTE: WE RECOMMEND USING A FIXED-SPACE FONT TO LOOK AT THE SOURCE.
//
// Default Part Code Generation begins here...
INotificationId OAContract::accountNumId = "OAContract::accountNum";
INotificationId OAContract::companyNameId = "OAContract::companyName";
INotificationId OAContract::projectMgrId = "OAContract::projectMgr";
INotificationId OAContract::deptNameId = "OAContract::deptName";
INotificationId OAContract::positionTitleId = "OAContract::positionTitle";
INotificationId OAContract::startDateId = "OAContract::startDate";
INotificationId OAContract::endDateId = "OAContract::endDate";
INotificationId OAContract::currContractorId = "OAContract::currContractor";
IString OAContract::accountNum() const
{
return iAccountNum;
}
OAContract & OAContract::setAccountNum(const IString & aAccountNum)
{
if (iAccountNum != aAccountNum)
{
iAccountNum = aAccountNum;
notifyObservers(INotificationEvent(OAContract::accountNumId, *this));
} // endif
return *this;
}
IString OAContract::companyName() const
{
return iCompanyName;
}
OAContract & OAContract::setCompanyName(const IString & aCompanyName)
{
if (iCompanyName != aCompanyName)
{
iCompanyName = aCompanyName;
notifyObservers(INotificationEvent(OAContract::companyNameId, *this));
} // endif
return *this;
}
IString OAContract::projectMgr() const
{
return iProjectMgr;
}
OAContract & OAContract::setProjectMgr(const IString & aProjectMgr)
{
if (iProjectMgr != aProjectMgr)
{
iProjectMgr = aProjectMgr;
notifyObservers(INotificationEvent(OAContract::projectMgrId, *this));
} // endif
return *this;
}
IString OAContract::deptName() const
{
return iDeptName;
}
OAContract & OAContract::setDeptName(const IString & aDeptName)
{
if (iDeptName != aDeptName)
{
iDeptName = aDeptName;
notifyObservers(INotificationEvent(OAContract::deptNameId, *this));
} // endif
return *this;
}
IString OAContract::positionTitle() const
{
return iPositionTitle;
}
OAContract & OAContract::setPositionTitle(const IString & aPositionTitle)
{
if (iPositionTitle != aPositionTitle)
{
iPositionTitle = aPositionTitle;
notifyObservers(INotificationEvent(OAContract::positionTitleId, *this));
} // endif
return *this;
}
IString OAContract::startDate() const
{
return iStartDate;
}
OAContract & OAContract::setStartDate(const IString & aStartDate)
{
if (iStartDate != aStartDate)
{
iStartDate = aStartDate;
notifyObservers(INotificationEvent(OAContract::startDateId, *this));
} // endif
return *this;
}
IString OAContract::endDate() const
{
return iEndDate;
}
OAContract & OAContract::setEndDate(const IString & aEndDate)
{
if (iEndDate != aEndDate)
{
iEndDate = aEndDate;
notifyObservers(INotificationEvent(OAContract::endDateId, *this));
} // endif
return *this;
}
IString OAContract::currContractor() const
{
return iCurrContractor;
}
OAContract & OAContract::setCurrContractor(const IString & aCurrContractor)
{
if (iCurrContractor != aCurrContractor)
{
iCurrContractor = aCurrContractor;
notifyObservers(INotificationEvent(OAContract::currContractorId, *this));
} // endif
return *this;
}
// Default Part Code Generation ends here.
OAContract & OAContract::getContract(const IString & anAccountNum)
{
// Start data access code
IProfile *p = new IProfile("contract.ini");
// Check for this account number in the profile collection
if (!p->containsKeyName("accountNum", anAccountNum))
{
throw IException("A record was not found for this contract.");
delete p;
return *this;
}
// If other data exists for this contract,
// set the corresponding contract attributes
setAccountNum(anAccountNum);
if (p->containsKeyName("companyName", anAccountNum))
setCompanyName(p->elementWithKey("companyName", anAccountNum));
if (p->containsKeyName("projectMgr", anAccountNum))
setProjectMgr(p->elementWithKey("projectMgr", anAccountNum));
if (p->containsKeyName("deptName", anAccountNum))
setDeptName(p->elementWithKey("deptName", anAccountNum));
if (p->containsKeyName("positionTitle", anAccountNum))
setPositionTitle(p->elementWithKey("positionTitle", anAccountNum));
if (p->containsKeyName("startDate", anAccountNum))
setStartDate(p->elementWithKey("startDate", anAccountNum));
if (p->containsKeyName("endDate", anAccountNum))
setEndDate(p->elementWithKey("endDate", anAccountNum));
if (p->containsKeyName("currContractor", anAccountNum))
setCurrContractor(p->elementWithKey("currContractor", anAccountNum));
delete p;
// End data access code
return *this;
}
OAContract & OAContract::putContract(const IString & anAccountNum)
{
// Start data entry code
IProfile *p = new IProfile("contract.ini");
// Test for missing account number
// Necessary because of possible direct entry from OAMain EDIT menu
if (anAccountNum.isWhiteSpace() || anAccountNum.length()==0)
{
throw IException("You did not enter an account number. Please try again.");
delete p;
return *this;
}
p->addOrReplaceElementWithKey("accountNum", accountNum(), anAccountNum);
// If other data about this contract exists, update it in the database
if (companyName)
p->addOrReplaceElementWithKey("companyName", companyName(), anAccountNum);
if (projectMgr)
p->addOrReplaceElementWithKey("projectMgr", projectMgr(), anAccountNum);
if (deptName)
p->addOrReplaceElementWithKey("deptName", deptName(), anAccountNum);
if (positionTitle)
p->addOrReplaceElementWithKey("positionTitle", positionTitle(), anAccountNum);
if (startDate)
p->addOrReplaceElementWithKey("startDate", startDate(), anAccountNum);
if (endDate)
p->addOrReplaceElementWithKey("endDate", endDate(), anAccountNum);
if (currContractor)
p->addOrReplaceElementWithKey("currContractor", currContractor(), anAccountNum);
delete p;
// End data entry code
return *this;
}
// Copy constructor
OAContract::OAContract(const OAContract & aContract)
: IStandardNotifier(aContract),
iAccountNum(aContract.accountNum()),
iCompanyName(aContract.companyName()),
iProjectMgr(aContract.projectMgr()),
iDeptName(aContract.deptName()),
iPositionTitle(aContract.positionTitle()),
iStartDate(aContract.startDate()),
iEndDate(aContract.endDate()),
iCurrContractor(aContract.currContractor())
{
enableNotification();
}