home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / samples / ioc / lancelot / ldbase.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  73.3 KB  |  2,415 lines

  1. /******************************************************************************
  2. * .FILE:         ldbase.cpp                                                   *
  3. *                                                                             *
  4. * .DESCRIPTION:  Lancelot Sample Program:              Class Implementation   *
  5. *                                                                             *
  6. * .CLASSES:      LStatusData                                                  *
  7. *                LBadgeData                                                   *
  8. *                LEmployeeData                                                *
  9. *                LSkillData                                                   *
  10. *                LProjectData                                                 *
  11. *                LTimeCardData                                                *
  12. *                LAcctData                                                    *
  13. *                LTaskData                                                    *
  14. *                LQueryData                                                   *
  15. *                LDeleteEmployee                                              *
  16. *                                                                             *
  17. * .COPYRIGHT:                                                                 *
  18. *                                                                             *
  19. * .DISCLAIMER:                                                                *
  20. *                                                                             *
  21. * .NOTE: WE RECOMMEND USING A FIXED SPACE FONT TO LOOK AT THE SOURCE          *
  22. *                                                                             *
  23. ******************************************************************************/
  24.  
  25. #ifndef _IBASE_                         //Make sure ibase.hpp is included
  26.   #include <ibase.hpp>                  //  since that is where IC_<environ>
  27. #endif                                  //  is defined.
  28. #include "lancelot.h"
  29. #include <iprofile.hpp>
  30. #include <icnrctl.hpp>
  31. #include "lpagectl.hpp"
  32. #include "ldbase.hpp"
  33. #include "ldbqry.hpp"
  34.  
  35. // --------------------------------------------------------------------------------------------
  36. // Class LEmployeeData :: LEmployeeData() - constructor
  37. // --------------------------------------------------------------------------------------------
  38.  
  39. LEmployeeData :: LEmployeeData()
  40.           :   theEmployeeNum()
  41.            , theLastName()
  42.            , theFirstName()
  43.            , theMiddleInitial()
  44.            , theInternalPhone()
  45.            , theExternalPhone()
  46.            , theInternalAddr()
  47.            , theExternalAddr()
  48.            , theRoom()
  49.            , theBuilding()
  50.            , theDeptName()
  51.            , theDivision()
  52.            , theEmployeeType(LEmployeeData::Unemployed)
  53.            , theBadgeNumber()
  54.            , theBadgeIssue()
  55.            , theBadgeExpire()
  56.            , theManagerNum()
  57.            , theManagerName()
  58.            , badgeData()
  59. {
  60. }
  61.  
  62.  
  63. // --------------------------------------------------------------------------------------------
  64. // Class LEmployeeData :: LEmployeeData() - constructor
  65. // --------------------------------------------------------------------------------------------
  66.  
  67. LEmployeeData :: LEmployeeData(const IString empNum)
  68.           :   theEmployeeNum()
  69.            , theLastName()
  70.            , theFirstName()
  71.            , theMiddleInitial()
  72.            , theInternalPhone()
  73.            , theExternalPhone()
  74.            , theInternalAddr()
  75.            , theExternalAddr()
  76.            , theRoom()
  77.            , theBuilding()
  78.            , theDeptName()
  79.            , theDivision()
  80.            , theEmployeeType(LEmployeeData::Unemployed)
  81.            , theBadgeNumber()
  82.            , theBadgeIssue()
  83.            , theBadgeExpire()
  84.            , theManagerNum()
  85.            , theManagerName()
  86.            , badgeData(empNum)
  87. {
  88.   load(empNum);
  89. }
  90.  
  91.  
  92. // --------------------------------------------------------------------------------------------
  93. // Class LEmployeeData :: LEmployeeData() - constructor query data
  94. // --------------------------------------------------------------------------------------------
  95.  
  96. LEmployeeData :: LEmployeeData(LQueryData& qd)
  97.            : theEmployeeNum()
  98.            , theLastName()
  99.            , theFirstName()
  100.            , theMiddleInitial()
  101.            , theInternalPhone()
  102.            , theExternalPhone()
  103.            , theInternalAddr()
  104.            , theExternalAddr()
  105.            , theRoom()
  106.            , theBuilding()
  107.            , theDeptName()
  108.            , theDivision()
  109.            , theEmployeeType(LEmployeeData::Unemployed)
  110.            , theBadgeNumber()
  111.            , theBadgeIssue()
  112.            , theBadgeExpire()
  113.            , theManagerNum()
  114.            , theManagerName()
  115.            , badgeData(NULL)
  116. {
  117.   loadQryData(qd);
  118. }
  119.  
  120.  
  121. // --------------------------------------------------------------------------------------------
  122. // Class LEmployeeData :: ~LEmployeeData() - destructor
  123. // --------------------------------------------------------------------------------------------
  124. LEmployeeData :: ~LEmployeeData()
  125. { }
  126.  
  127.  
  128. // --------------------------------------------------------------------------------------------
  129. // Class LEmployeeData :: loadQryData() - get query info
  130. // --------------------------------------------------------------------------------------------
  131. LEmployeeData& LEmployeeData :: loadQryData(LQueryData& qd)
  132. {
  133.  
  134.    unsigned long empType ;
  135.    IString key, value, mt;
  136.  
  137.    for ( qd.setFirstWithKey("GENERAL");
  138.          qd.isValid() ;
  139.          qd.getNextWithKey("GENERAL") ) {
  140.  
  141.          qd.getItem(key, value, mt);
  142.          if (key =="employeeNum"  )
  143.              theEmployeeNum   = value;
  144.          else
  145.          if (key =="lastName"     )
  146.             theLastName = value;
  147.          else
  148.          if (key =="firstName"    )
  149.             theFirstName = value;
  150.          else
  151.          if (key =="middleInitial")
  152.             theMiddleInitial = value;
  153.          else
  154.          if (key =="internalPhone")
  155.             theInternalPhone = value;
  156.          else
  157.          if (key =="externalPhone")
  158.             theExternalPhone = value;
  159.          else
  160.          if (key =="internalAddr" )
  161.             theInternalAddr = value;
  162.          else
  163.          if (key =="externalAddr" )
  164.             theExternalAddr = value;
  165.          else
  166.          if (key =="room"         )
  167.             theRoom = value;
  168.          else
  169.          if (key =="building"     )
  170.             theBuilding = value;
  171.          else
  172.          if (key =="deptName"     )
  173.             theDeptName = value;
  174.          else
  175.          if (key =="division"     )
  176.             theDivision = value;
  177.          else
  178.  
  179.          if (key =="managerNum"  )
  180.              theManagerNum    = value;
  181.          else
  182.          if (key =="managerName"  )
  183.              theManagerName   = value;
  184.          else
  185.          if (key == "employeeType") {
  186.              empType          = value.asInt();
  187.              theEmployeeType  = (LEmployeeData::EmplType) empType;
  188.          } /* endif */
  189.  
  190.     }
  191.     return *this;
  192. }
  193.  
  194. // --------------------------------------------------------------------------------------------
  195. // Class LEmployeeData :: load() - get database (ini) data
  196. // --------------------------------------------------------------------------------------------
  197. LEmployeeData&  LEmployeeData :: load(const IString empNum)
  198. {
  199.    try
  200.    {
  201.      IProfile *p = new  IProfile("lempl.ini");
  202.      unsigned long empType ;
  203.      if (p->containsApplication(empNum)) {
  204.  
  205.        if (p->containsKeyName("employeeNum", empNum))
  206.           theEmployeeNum   = p->elementWithKey("employeeNum",empNum ) ;
  207.  
  208.        if (p->containsKeyName("lastName", empNum))
  209.           theLastName      = p->elementWithKey( "lastName", empNum) ;
  210.  
  211.        if (p->containsKeyName("firstName", empNum))
  212.           theFirstName     = p->elementWithKey( "firstName", empNum) ;
  213.  
  214.        if (p->containsKeyName("middleInitial", empNum))
  215.           theMiddleInitial = p->elementWithKey( "middleInitial", empNum) ;
  216.  
  217.        if (p->containsKeyName("internalPhone", empNum))
  218.           theInternalPhone = p->elementWithKey( "internalPhone", empNum) ;
  219.  
  220.        if (p->containsKeyName("externalPhone", empNum))
  221.           theExternalPhone = p->elementWithKey( "externalPhone", empNum) ;
  222.  
  223.        if (p->containsKeyName("internalAddr", empNum))
  224.           theInternalAddr  = p->elementWithKey( "internalAddr", empNum) ;
  225.  
  226.        if (p->containsKeyName("externalAddr", empNum))
  227.           theExternalAddr  = p->elementWithKey( "externalAddr", empNum) ;
  228.  
  229.        if (p->containsKeyName("room", empNum))
  230.           theRoom          = p->elementWithKey( "room", empNum) ;
  231.  
  232.        if (p->containsKeyName("building", empNum))
  233.           theBuilding      = p->elementWithKey( "building", empNum) ;
  234.  
  235.        if (p->containsKeyName("deptName", empNum))
  236.           theDeptName      = p->elementWithKey( "deptName", empNum) ;
  237.  
  238.        if (p->containsKeyName("divName", empNum))
  239.           theDivision     = p->elementWithKey( "divName", empNum) ;
  240.  
  241.        if (p->containsKeyName("employeeType", empNum)) {
  242.           empType          = p->integerWithKey( "employeeType", empNum) ;
  243.           theEmployeeType  = (LEmployeeData::EmplType) empType;
  244.        }
  245.  
  246.        if (p->containsKeyName("managerNum", empNum))
  247.           theManagerNum    = p->elementWithKey( "managerNum", empNum) ;
  248.  
  249.        if (p->containsKeyName("managerName", empNum))
  250.           theManagerName   = p->elementWithKey( "managerName", empNum) ;
  251.     }
  252.     delete p;
  253.   }
  254.   catch(...)
  255.   {}
  256.  
  257.   return *this;
  258. }
  259.  
  260.  
  261. // --------------------------------------------------------------------------------------------
  262. // Class LEmployeeData :: save() - save database (ini) data
  263. // --------------------------------------------------------------------------------------------
  264. LEmployeeData& LEmployeeData :: save( const IString empNum)
  265. {
  266.    try
  267.    {
  268.      IProfile *p = new IProfile("lempl.ini");
  269.  
  270.      p->deleteElementWithApplication( empNum );
  271.  
  272.      if (theEmployeeNum.length()!=0)
  273.        p->addOrReplaceElementWithKey("employeeNum",
  274.                                 theEmployeeNum,
  275.                                 empNum ) ;
  276.  
  277.      if (theLastName.length()!=0)
  278.        p->addOrReplaceElementWithKey("lastName",
  279.                                   theLastName,
  280.                                   empNum) ;
  281.  
  282.      if (theFirstName.length()!=0)
  283.        p->addOrReplaceElementWithKey("firstName" ,
  284.                                   theFirstName,
  285.                                   empNum ) ;
  286.  
  287.      if (theMiddleInitial.length()!=0)
  288.        p->addOrReplaceElementWithKey("middleInitial" ,
  289.                                   theMiddleInitial,
  290.                                   empNum ) ;
  291.  
  292.      if (theInternalPhone.length()!=0)
  293.        p->addOrReplaceElementWithKey("internalPhone" ,
  294.                                   theInternalPhone,
  295.                                   empNum ) ;
  296.  
  297.      if (theExternalPhone.length()!=0)
  298.        p->addOrReplaceElementWithKey("externalPhone" ,
  299.                                   theExternalPhone,
  300.                                   empNum ) ;
  301.  
  302.      if (theInternalAddr.length()!=0)
  303.         p->addOrReplaceElementWithKey("internalAddr" ,
  304.                                     theInternalAddr,
  305.                                     empNum ) ;
  306.  
  307.      if (theExternalAddr.length()!=0)
  308.        p->addOrReplaceElementWithKey("externalAddr" ,
  309.                                   theExternalAddr,
  310.                                   empNum ) ;
  311.  
  312.      if (theRoom.length()!=0)
  313.        p->addOrReplaceElementWithKey("room" ,
  314.                                   theRoom,
  315.                                   empNum ) ;
  316.  
  317.      if (theBuilding.length()!=0)
  318.        p->addOrReplaceElementWithKey("building" ,
  319.                                   theBuilding ,
  320.                                   empNum) ;
  321.  
  322.      if (theDeptName.length()!=0)
  323.        p->addOrReplaceElementWithKey("deptName",
  324.                                    theDeptName,
  325.                                    empNum) ;
  326.  
  327.      if (theDivision.length()!=0)
  328.        p->addOrReplaceElementWithKey("divName",
  329.                                    theDivision,
  330.                                    empNum) ;
  331.  
  332.        long et = (long) theEmployeeType;
  333.        p->addOrReplaceElementWithKey("employeeType" ,
  334.                                   (long) theEmployeeType,
  335.                                   empNum ) ;
  336.  
  337.      if (theBadgeNumber.length()!=0)
  338.        p->addOrReplaceElementWithKey("badgeNumber" ,
  339.                                   theBadgeNumber,
  340.                                   empNum ) ;
  341.  
  342.      if (theManagerNum.length()!=0)
  343.        p->addOrReplaceElementWithKey("managerNum" ,
  344.                                   theManagerNum,
  345.                                   empNum ) ;
  346.  
  347.      if (theManagerName.length()!=0)
  348.        p->addOrReplaceElementWithKey("managerName" ,
  349.                                   theManagerName,
  350.                                   empNum ) ;
  351.  
  352.     delete p;
  353.    }
  354.    catch(...)
  355.    {}
  356.  
  357.   return *this;
  358.  
  359. }
  360.  
  361.  
  362. // --------------------------------------------------------------------------------------------
  363. // Class LBadgeData :: LBadgeData() - constructor
  364. // --------------------------------------------------------------------------------------------
  365.  
  366. LBadgeData :: LBadgeData ()
  367.       : BadgeNumber()
  368.        ,BadgeIssue()
  369.        ,BadgeExpire()
  370.        ,TheIssueRange()
  371.        ,TheExpRange()
  372. {
  373.  
  374. }
  375.  
  376. LBadgeData :: LBadgeData (const IString  &eNum)
  377.       : BadgeNumber()
  378.        ,BadgeIssue()
  379.        ,BadgeExpire()
  380.        ,TheIssueRange()
  381.        ,TheExpRange()
  382. {
  383.    if (0 != eNum.length())
  384.       load(eNum);
  385.  
  386. }
  387.  
  388.  
  389. // --------------------------------------------------------------------------------------------
  390. // Class LBadgeData :: LBadgeData() - constructor - query info
  391. // --------------------------------------------------------------------------------------------
  392. LBadgeData :: LBadgeData (LQueryData& qd)
  393.       : BadgeNumber()
  394.        ,BadgeIssue()
  395.        ,BadgeExpire()
  396.        ,TheIssueRange("=")
  397.        ,TheExpRange("=")
  398. {
  399.       loadQueryData(qd);
  400.  
  401. }
  402.  
  403.  
  404. // --------------------------------------------------------------------------------------------
  405. // Class LBadgeData :: ~LBadgeData() - destructor
  406. // --------------------------------------------------------------------------------------------
  407. LBadgeData :: ~LBadgeData ()
  408. { }
  409.  
  410.  
  411. // --------------------------------------------------------------------------------------------
  412. // Class LBadgeData :: load() - database info
  413. // --------------------------------------------------------------------------------------------
  414. LBadgeData& LBadgeData :: load (const IString &empNum)
  415. {
  416.    try
  417.    {
  418.    IProfile
  419.     *p = new  IProfile("lbadge.ini");
  420.  
  421.    if (p->containsApplication(empNum)) {
  422.  
  423.     if (p->containsKeyName("badge", empNum))
  424.        BadgeNumber = p->elementWithKey("badge", empNum ) ;
  425.  
  426.     if (p->containsKeyName("issue", empNum))
  427.        BadgeIssue = p->elementWithKey("issue", empNum ) ;
  428.  
  429.     if (p->containsKeyName("expire", empNum))
  430.        BadgeExpire = p->elementWithKey("expire", empNum );
  431.  
  432.    }
  433.    delete p;
  434.    }
  435.    catch(...)
  436.    {}
  437.    return *this;
  438. }
  439.  
  440.  
  441. // --------------------------------------------------------------------------------------------
  442. // Class LBadgeData :: loadQueryData() - get query info
  443. // --------------------------------------------------------------------------------------------
  444. LBadgeData& LBadgeData :: loadQueryData(LQueryData& qd)
  445. {
  446.  
  447.    IString key, value, mt;
  448.    IString   badgeIssue
  449.             ,expire;
  450.  
  451.    for ( qd.setFirstWithKey("BADGE");
  452.          qd.isValid() ;
  453.          qd.getNextWithKey("BADGE") ) {
  454.  
  455.          qd.getItem(key, value, mt);
  456.  
  457.          if (key == "badgeNumber")
  458.             BadgeNumber = value ;
  459.  
  460.          if (key == "issueDate")
  461.             BadgeIssue = value ;
  462.  
  463.          if (key == "expireDate")
  464.             BadgeExpire = value;
  465.  
  466.          if (key == "issueDateRange")
  467.              TheIssueRange = value;
  468.  
  469.          if (key == "expireDateRange")
  470.             TheExpRange = value;
  471.  
  472.  
  473.     }
  474.     return *this;
  475. }
  476.  
  477.  
  478. // --------------------------------------------------------------------------------------------
  479. // Class LBadgeData :: save() - save database info
  480. // --------------------------------------------------------------------------------------------
  481. LBadgeData& LBadgeData :: save(const IString  empNum,
  482.                             const IString  badgeN,
  483.                             const IString  issueD,
  484.                             const IString  expD)
  485.  
  486. {
  487.    try
  488.    {
  489.    IProfile
  490.     *p = new  IProfile("lbadge.ini");
  491.  
  492.    p->deleteElementWithApplication( empNum );
  493.  
  494.    if ( badgeN.length() )
  495.      p->addOrReplaceElementWithKey(
  496.                           "badge",
  497.                            badgeN, empNum) ;
  498.  
  499.    if ( issueD.length() )
  500.      p->addOrReplaceElementWithKey(
  501.                           "issue",
  502.                            issueD, empNum) ;
  503.  
  504.    if ( expD.length() )
  505.      p->addOrReplaceElementWithKey(
  506.                                 "expire",
  507.                                  expD, empNum ) ;
  508.  
  509.    delete p;
  510.    }
  511.    catch(...)
  512.    {}
  513.    return *this;
  514. }
  515.  
  516.  
  517.  
  518. // --------------------------------------------------------------------------------------------
  519. // Class LStatusData :: LStatusData() constructor
  520. // --------------------------------------------------------------------------------------------
  521. LStatusData :: LStatusData (const IString empNum)
  522.       :  StatusActive("new")
  523.         ,StatusInactive("no")
  524.         ,StatusRate()
  525.         ,StatusStart()
  526.         ,StatusEnd()
  527.         ,TheRateRange()
  528.         ,TheStartRange()
  529.         ,TheEndRange()
  530.  
  531. {
  532.    load(empNum);
  533. }
  534.  
  535.  
  536. // --------------------------------------------------------------------------------------------
  537. // Class LStatusData :: LStatusData() constructor - query info
  538. // --------------------------------------------------------------------------------------------
  539. LStatusData :: LStatusData (LQueryData& qd)
  540.        : StatusActive("no")
  541.         ,StatusInactive("no")
  542.         ,StatusRate()
  543.         ,StatusStart()
  544.         ,StatusEnd()
  545.         ,TheRateRange("=")
  546.         ,TheStartRange("=")
  547.         ,TheEndRange("=")
  548. {
  549.    loadQueryData(qd);
  550.  
  551. };
  552.  
  553.  
  554. // --------------------------------------------------------------------------------------------
  555. // Class LStatusData :: ~LStatusData() destructor
  556. // --------------------------------------------------------------------------------------------
  557. LStatusData :: ~LStatusData ()
  558. { };
  559.  
  560.  
  561.  
  562. // --------------------------------------------------------------------------------------------
  563. // Class LStatusData :: load() get database info
  564. // --------------------------------------------------------------------------------------------
  565. LStatusData& LStatusData :: load (const IString empNum)
  566. {
  567.    try
  568.    {
  569.    IProfile
  570.     *p = new  IProfile("lstatus.ini");
  571.  
  572.    if (p->containsApplication(empNum)) {
  573.      unsigned long act = p->integerWithKey(
  574.                                   "statusActive", empNum ) ;
  575.      StatusActive = (act==1 ? "yes" : "no" );
  576.  
  577.      if (p->containsKeyName("statusRate", empNum))
  578.         StatusRate = p->elementWithKey("statusRate", empNum ) ;
  579.  
  580.      if (p->containsKeyName("statusStart", empNum))
  581.         StatusStart = p->elementWithKey("statusStart", empNum );
  582.  
  583.      if (p->containsKeyName("statusEnd", empNum))
  584.         StatusEnd = p->elementWithKey("statusEnd", empNum );
  585.    }
  586.    delete  p;
  587.    }
  588.    catch(...)
  589.    {}
  590.    return *this;
  591. }
  592.  
  593.  
  594.  
  595. // --------------------------------------------------------------------------------------------
  596. // Class LStatusData :: loadQueryData() get query info
  597. // --------------------------------------------------------------------------------------------
  598. LStatusData& LStatusData :: loadQueryData (LQueryData& qd)
  599. {
  600.  
  601.    IString key, value, mt;
  602.  
  603.  
  604.    for ( qd.setFirstWithKey("STATUS");
  605.          qd.isValid() ;
  606.          qd.getNextWithKey("STATUS") ) {
  607.  
  608.          qd.getItem(key, value, mt);
  609.  
  610.          if (key == "active")
  611.             StatusInactive = "yes";
  612.  
  613.          if (key == "inactive")
  614.             StatusActive = "no";
  615.  
  616.          if (key == "hourlyRate")
  617.             StatusRate = value;
  618.  
  619.          if (key == "startDate")
  620.             StatusStart = value;
  621.  
  622.          if (key == "endDate")
  623.             StatusEnd = value;
  624.  
  625.          if (key == "hourlyRateRange")
  626.              TheRateRange = value;
  627.  
  628.          if (key == "startDateRange")
  629.              TheStartRange = value;
  630.  
  631.          if (key == "endDateRange")
  632.              TheEndRange=value;
  633.     }
  634.   return *this;
  635.  
  636. }
  637.  
  638.  
  639. // --------------------------------------------------------------------------------------------
  640. // Class LStatusData :: save() save database info
  641. // --------------------------------------------------------------------------------------------
  642. LStatusData& LStatusData :: save(const IString empNum
  643.                              ,const IString sRate
  644.                              ,const IString sStart
  645.                              ,const IString sEnd
  646.                              ,IBase::Boolean        sAct)
  647. {
  648.    try
  649.    {
  650.    IProfile
  651.     *p = new  IProfile("lstatus.ini") ;
  652.  
  653.    p->deleteElementWithApplication( empNum );
  654.  
  655.     // p->addOrReplaceElementWithKey("statusActive",
  656.     //                              ((StatusActive == "yes")  ? 1 : 0), empNum);
  657.     p->addOrReplaceElementWithKey("statusActive",
  658.                                   sAct, empNum);
  659.  
  660.     if (sRate.length() != 0)
  661.         p->addOrReplaceElementWithKey("statusRate",
  662.                                       sRate, empNum) ;
  663.  
  664.     if (sStart.length() != 0)
  665.         p->addOrReplaceElementWithKey("statusStart",
  666.                                       sStart, empNum ) ;
  667.  
  668.     if (sEnd.length() != 0)
  669.        p->addOrReplaceElementWithKey("statusEnd",
  670.                                      sEnd , empNum) ;
  671.  
  672.     if (StatusActive != sEnd)
  673.        p->addOrReplaceElementWithKey("statusActive",
  674.                                      sAct , empNum) ;
  675.     delete p;
  676.    }
  677.    catch(...)
  678.    {}
  679.    return *this;
  680.  
  681. }
  682.  
  683.  
  684. // --------------------------------------------------------------------------------------------
  685. // Class LSkillData :: LSkillData() - contructor
  686. // --------------------------------------------------------------------------------------------
  687. LSkillData :: LSkillData (const IString empNum)
  688.            : itemsCur(items)
  689.              ,employeeNum(empNum)
  690.              ,TheRange()
  691. {
  692.    load(empNum); // fill bag
  693. }
  694.  
  695. // --------------------------------------------------------------------------------------------
  696. // Class LSkillData :: LSkillData() - contructor - query info
  697. // --------------------------------------------------------------------------------------------
  698. LSkillData :: LSkillData (LQueryData& qd)
  699.            : itemsCur(items)
  700.              ,employeeNum(qd.queryName())
  701.              ,TheRange("=")
  702. {
  703.    loadQueryData(qd); // fill bag
  704. }
  705.  
  706. // --------------------------------------------------------------------------------------------
  707. // Class LSkillData :: LSkillData() - destructor
  708. // --------------------------------------------------------------------------------------------
  709. LSkillData :: ~LSkillData ()
  710. {
  711.   emptyBag();
  712.  
  713. }
  714.  
  715.  
  716. // --------------------------------------------------------------------------------------------
  717. // Class LSkillData :: load() - get database info
  718. // --------------------------------------------------------------------------------------------
  719. LSkillData& LSkillData :: load (const IString empNum)
  720. {
  721.   if ( empNum != (IString)NULL )
  722.   {
  723.      IString  key=empNum;
  724.  
  725.      IString     skillName
  726.                 ,employeeNumber
  727.                 ,exp;
  728.      int i=0;
  729.      try
  730.      {
  731.      IProfile
  732.       *p = new IProfile("lskill.ini");
  733.  
  734.      // concat to make multiple entries unique
  735.      key  = empNum  + IString(i);
  736.  
  737.      items.removeAll();
  738.      itemsCur.invalidate();
  739.  
  740.      while (p->containsApplication(key)) {
  741.  
  742.         if (p->containsKeyName("skillName", key))
  743.            skillName = p->elementWithKey( "skillName",key ) ;
  744.         else
  745.            skillName = "";
  746.  
  747.         if (p->containsKeyName("exp", key))
  748.            exp  = p->elementWithKey( "exp", key ) ;
  749.         else
  750.            exp = "";
  751.  
  752.         // add it to the bag
  753.         items.add(Item(Item::file, skillName, exp, key ));
  754.  
  755.         // this is how multiple items are handled for a given user/employee
  756.         key = empNum + IString(++i);
  757.  
  758.      } /* endwhile */
  759.      delete p;
  760.      }
  761.      catch(...)
  762.      {}
  763.   }
  764.   return *this;
  765. }  // get
  766.  
  767.  
  768. // --------------------------------------------------------------------------------------------
  769. // Class LSkillData :: loadQueryData() - get query info
  770. // --------------------------------------------------------------------------------------------
  771. LSkillData& LSkillData :: loadQueryData(LQueryData& qd)
  772. {
  773.  
  774.    IString key, value;
  775.    IString   skill, years, range ;
  776.  
  777.  
  778.    for ( qd.setFirstWithKey("SKILL");
  779.          qd.isValid() ;
  780.          qd.getNextWithKey("SKILL") ) {
  781.  
  782.          qd.getItem(skill, years, range);
  783.  
  784.          items.add(Item(skill, years, range));
  785.  
  786.     }
  787.     return *this;
  788. }
  789.  
  790. // --------------------------------------------------------------------------------------------
  791. // Class LSkillData :: save() - save database info
  792. // --------------------------------------------------------------------------------------------
  793. LSkillData&  LSkillData :: save(const IString empNum)
  794. {
  795.    try
  796.    {
  797.      IProfile
  798.       *p = new IProfile("lskill.ini");
  799.      // put data in IProfile
  800.      IString  appl=empNum;
  801.      IString  projName, projDes, respMgr, projState;
  802.      int i=0;
  803.  
  804.      Items::Cursor itemsCur1(items), itemsCur2(items);
  805.  
  806.      if (items.numberOfElements() == 0 )
  807.         return *this;
  808.  
  809.      // concat to make multiple entries unique
  810.      appl = empNum + IString(i);
  811.  
  812.      //IProfile delete them all and then put then back
  813.      while (p->containsApplication(appl)) {
  814.         p->deleteElementWithApplication( appl ) ;
  815.         appl = empNum + IString(++i);
  816.      } /* endwhile */
  817.  
  818.      // must now iterate thru bag and save
  819.  
  820.      i = 0;
  821.      appl = empNum + IString(i);
  822.      itemsCur1.setToFirst();
  823.      do {
  824.         Entry name = itemsCur1.element().item1();
  825.  
  826.         items.locateElementWithKey(name, itemsCur2);
  827.         do  {
  828.            Entry item1 = itemsCur2.element().item1();
  829.            Entry item2 = itemsCur2.element().item2();
  830.  
  831.            p->addOrReplaceElementWithKey("skillName", item1.text(), appl);
  832.            p->addOrReplaceElementWithKey("exp", item2.text(), appl);
  833.  
  834.            appl = empNum + IString(++i);
  835.  
  836.         } while (items.locateNextElementWithKey(name, itemsCur2));
  837.  
  838.      } while (items.setToNextWithDifferentKey(itemsCur1));
  839.  
  840.      delete p;
  841.    }
  842.    catch(...)
  843.    {}
  844.    return *this;
  845. }
  846.  
  847.  
  848. // --------------------------------------------------------------------------------------------
  849. // Class LSkillData :: getItem() - get skill info
  850. // --------------------------------------------------------------------------------------------
  851. IBase::Boolean LSkillData :: getItem( IString& item1
  852.                                     ,IString& item2
  853.                                     ,Rule& rule
  854.                                     , Boolean useKey)
  855. {
  856.  
  857.    if (false == itemsCur.isValid())
  858.       return false;  // none left
  859.  
  860.    Entry i1 = itemsCur.element().item1();
  861.  
  862.    Entry i2 = itemsCur.element().item2();
  863.  
  864.    item1 =  i1.text();
  865.    item2 =  i2.text();
  866.    rule  =  (LSkillData::Rule  )itemsCur.element().rule();
  867.  
  868.    return true;
  869.  
  870. }
  871.  
  872. // --------------------------------------------------------------------------------------------
  873. // Class LSkillData :: getItem() - get skill info - query info
  874. // --------------------------------------------------------------------------------------------
  875. IBase::Boolean LSkillData ::getItem( IString& item1
  876.                                    ,IString& item2
  877.                                    ,Boolean useKey)
  878. {
  879.    if (false == itemsCur.isValid())
  880.       return false;  // none left
  881.  
  882.    if (useKey) {
  883.       Entry name = itemsCur.element().item1();
  884.       items.locateElementWithKey(name, itemsCur);
  885.    }
  886.    Entry i1 = itemsCur.element().item1();
  887.    Entry i2 = itemsCur.element().item2();
  888.    item1 =  i1.text();
  889.    item2 =  i2.text();
  890.  
  891.    return true;
  892.  
  893. }
  894.  
  895.  
  896. // --------------------------------------------------------------------------------------------
  897. // Class LSkillData :: putItem() - put skill info - query info
  898. // --------------------------------------------------------------------------------------------
  899. IBase::Boolean LSkillData :: putItem( const IString& item1
  900.                                     ,const IString& item2
  901.                                     ,const Rule& rule)
  902. {
  903.  
  904.      Boolean done = false;
  905.      Item::Rule iRule = (Item::Rule) rule;
  906.      Items::Cursor  itemsC(items);
  907.  
  908.  
  909.      itemsC.setToFirst();
  910.  
  911.      if (false == itemsC.isValid())
  912.         items.add(Item(iRule, item1, item2));
  913.      else {
  914.        // search bag for a duplicate
  915.  
  916.        // Entry name = itemsCur.element().item1();
  917.        // the key is the id concatenated with a number
  918.  
  919.        // loop thru the bag and see if there is a match
  920.        do {
  921.          Entry i1 = itemsC.element().item1();
  922.          if (i1.text() == item1) {
  923.              Entry i2 = itemsC.element().item2();
  924.              if (i2.text() != item2) {
  925.                 // a duplicate entry was found, with something different
  926.  
  927.                 // new entry, reflected in container
  928.  
  929.                 items.add(Item(Item::replace, item1, i2.text()));
  930.  
  931.                 done = true;
  932.              }
  933.              else {  // entry matches
  934.                 // if doing an ADD, CHANGE do nothing
  935.                 // if a REMOVE
  936.                 if (iRule == Item::replace) {
  937.                     // udated entry
  938.                     items.add(Item(iRule, item1, item2));
  939.                     // delete old entry
  940.                     items.removeAt(itemsC);
  941.                 }
  942.  
  943.              }
  944.          }
  945.  
  946.        } while (done == false &&
  947.                 items.setToNextWithDifferentKey(itemsC)); /* enddo */
  948.  
  949.        if (done == false ) {
  950.           // a unique one
  951.           items.add(Item( iRule, item1, item2));
  952.        } /* endif */
  953.  
  954.      }
  955.  
  956.    return  true;
  957.  
  958. }
  959.  
  960.  
  961. // --------------------------------------------------------------------------------------------
  962. // Class LSkillData :: emptyBag() - empty the skill bag
  963. // --------------------------------------------------------------------------------------------
  964. LSkillData&  LSkillData :: emptyBag()  {
  965.  // attach to employee number
  966.  
  967.  items.removeAll();
  968.  itemsCur.invalidate();
  969.  return *this;
  970. }
  971.  
  972.  
  973. // --------------------------------------------------------------------------------------------
  974. // Class LSkillData :: deleteCurrentItem() - delete current skill
  975. // --------------------------------------------------------------------------------------------
  976. LSkillData& LSkillData ::  deleteCurrentItem()
  977. {
  978.     if (itemsCur.isValid()) {
  979.        items.removeAt(itemsCur);
  980.     } /* endif */
  981.     return *this;
  982. }
  983.  
  984. // --------------------------------------------------------------------------------------------
  985. // Class LSkillData :: operator=    - copy LSkillData contents to another
  986. // --------------------------------------------------------------------------------------------
  987. LSkillData& LSkillData::operator=( const LSkillData& from )
  988. {
  989.   items = from.getItems();
  990.   itemsCur = from.getItemsCursor();
  991.   employeeNum = from.employeeNumber();
  992.   TheRange = from.theRange();
  993.   return *this;
  994. }
  995.  
  996.  
  997. // --------------------------------------------------------------------------------------------
  998. // Class LAcctData :: LAcctData() - contructor
  999. // --------------------------------------------------------------------------------------------
  1000. LAcctData :: LAcctData (const IString empNum)
  1001.            : itemsCur(items)
  1002.              ,employeeNum(empNum)
  1003. {
  1004.    load(empNum);
  1005. }
  1006.  
  1007. // --------------------------------------------------------------------------------------------
  1008. // Class LAcctData :: LAcctData() - contructor - query
  1009. // --------------------------------------------------------------------------------------------
  1010. LAcctData :: LAcctData (LQueryData& qd)
  1011.            : itemsCur(items)
  1012.              ,employeeNum(NULL)
  1013. {
  1014.    loadQueryData(qd);
  1015. }
  1016.  
  1017. // --------------------------------------------------------------------------------------------
  1018. // Class LAcctData :: LAcctData() - destructor
  1019. // --------------------------------------------------------------------------------------------
  1020. LAcctData :: ~LAcctData ()
  1021. {
  1022.    emptyBag();
  1023. }
  1024.  
  1025.  
  1026. // --------------------------------------------------------------------------------------------
  1027. // Class LAcctData :: load() - get database data
  1028. // --------------------------------------------------------------------------------------------
  1029. LAcctData& LAcctData :: load (const IString empNum)
  1030. {
  1031.   if ( empNum != (IString)NULL )
  1032.   {
  1033.      try
  1034.      {
  1035.      IProfile
  1036.       *p = new IProfile("lacct.ini");
  1037.  
  1038.      IString
  1039.        userName,
  1040.        node,
  1041.        key=empNum;
  1042.  
  1043.      int i=0;
  1044.  
  1045.      // concat to make multiple entries unique
  1046.      key  = empNum  + IString(i);
  1047.  
  1048.      emptyBag();
  1049.  
  1050.      while (p->containsApplication(key)) {
  1051.  
  1052.         if (p->containsKeyName("userName", key))
  1053.            userName = p->elementWithKey( "userName",key ) ;
  1054.         else
  1055.            userName = "";
  1056.  
  1057.  
  1058.         if (p->containsKeyName("node", key))
  1059.            node = p->elementWithKey( "node", key ) ;
  1060.         else
  1061.            node = "";
  1062.  
  1063.         // add it to the bag
  1064.         items.add(Item(Item::file, userName, node, key ));
  1065.  
  1066.         // this is how multiple items are handled for a given user/employee
  1067.         key = empNum + IString(++i);
  1068.  
  1069.      } /* endwhile */
  1070.     delete p;
  1071.     }
  1072.     catch(...)
  1073.     {}
  1074.   }
  1075.   return *this;
  1076. }
  1077.  
  1078.  
  1079. // --------------------------------------------------------------------------------------------
  1080. // Class LAcctData :: loadQueryData() - get query data
  1081. // --------------------------------------------------------------------------------------------
  1082. LAcctData& LAcctData :: loadQueryData(LQueryData& qd)
  1083. {
  1084.  
  1085.    IString key, value;
  1086.    IString   userName, mt
  1087.             ,node;
  1088.  
  1089.    for ( qd.setFirstWithKey("ACCOUNT");
  1090.          qd.isValid() ;
  1091.          qd.getNextWithKey("ACCOUNT") ) {
  1092.  
  1093.          qd.getItem(userName, node, key);
  1094.  
  1095.          // add it to the bag
  1096.          if ((userName.length() >0) && (node.length() > 0) )
  1097.             items.add(Item(userName, node));
  1098.     }
  1099.     return *this;
  1100. }
  1101.  
  1102.  
  1103.  
  1104. // --------------------------------------------------------------------------------------------
  1105. // Class LAcctData :: save() - save db data
  1106. // --------------------------------------------------------------------------------------------
  1107. LAcctData& LAcctData :: save(const IString empNum)
  1108. {
  1109.    try
  1110.    {
  1111.      IProfile
  1112.       *p = new IProfile("lacct.ini");
  1113.  
  1114.      // put data in IProfile
  1115.      IString
  1116.        appl=empNum;
  1117.      int
  1118.        i=0;
  1119.      Items::Cursor itemsCur1(items), itemsCur2(items);
  1120.  
  1121.      if (items.numberOfElements()== 0) return *this;
  1122.  
  1123.      // concat to make multiple entries unique
  1124.      appl = empNum + IString(i);
  1125.  
  1126.      //IProfile delete them all and then put then back
  1127.      while (p->containsApplication(appl)) {
  1128.         p->deleteElementWithApplication( appl ) ;
  1129.         appl = empNum + IString(++i);
  1130.      } /* endwhile */
  1131.  
  1132.      // must now iterate thru bag and save
  1133.  
  1134.  
  1135.    i = 0;
  1136.    appl = empNum + IString(i);
  1137.    itemsCur1.setToFirst();
  1138.    do {
  1139.       Entry name = itemsCur1.element().item1();
  1140.  
  1141.       items.locateElementWithKey(name, itemsCur2);
  1142.       do  {
  1143.          Entry item1 = itemsCur2.element().item1();
  1144.          Entry item2 = itemsCur2.element().item2();
  1145.  
  1146.          p->addOrReplaceElementWithKey("userName", item1.text(), appl);
  1147.          p->addOrReplaceElementWithKey("node", item2.text(), appl);
  1148.          appl = empNum + IString(++i);
  1149.  
  1150.       } while (items.locateNextElementWithKey(name, itemsCur2));
  1151.  
  1152.    } while (items.setToNextWithDifferentKey(itemsCur1));
  1153.  
  1154.    delete p;
  1155.    }
  1156.    catch(...)
  1157.    {}
  1158.    return *this;
  1159. }
  1160.  
  1161.  
  1162. // --------------------------------------------------------------------------------------------
  1163. // Class LAcctData :: getItem() - get a db item
  1164. // --------------------------------------------------------------------------------------------
  1165. IBase::Boolean LAcctData :: getItem( IString& item1
  1166.                                    ,IString& item2
  1167.                                    , Rule& rule
  1168.                                    , Boolean useKey)
  1169. {
  1170.  
  1171.  
  1172.    if (false == itemsCur.isValid())
  1173.       return false;  // none left
  1174.  
  1175.    Entry i1 = itemsCur.element().item1();
  1176.  
  1177.    Entry i2 = itemsCur.element().item2();
  1178.  
  1179.    item1 =  i1.text();
  1180.    item2 =  i2.text();
  1181.    rule  =  (LAcctData::Rule  )itemsCur.element().rule();
  1182.  
  1183.    return  true;
  1184.  
  1185. }
  1186.  
  1187. // --------------------------------------------------------------------------------------------
  1188. // Class LAcctData :: getItem() - get a query item
  1189. // --------------------------------------------------------------------------------------------
  1190. IBase::Boolean LAcctData :: getItem( IString& item1
  1191.                                    ,IString& item2
  1192.                                    ,Boolean useKey)
  1193. {
  1194.    if (false == itemsCur.isValid())
  1195.       return false;  // none left
  1196.  
  1197.    if (useKey) {
  1198.       Entry name = itemsCur.element().item1();
  1199.       items.locateElementWithKey(name, itemsCur);
  1200.    }
  1201.    item1  = itemsCur.element().item1().text();
  1202.    item2  = itemsCur.element().item2().text();
  1203.  
  1204.    //item1 =  i1.text();
  1205.  
  1206.    return true;
  1207.  
  1208. }
  1209.  
  1210.  
  1211.  
  1212. // --------------------------------------------------------------------------------------------
  1213. // Class LAcctData :: putItem() - add an item to the bag
  1214. // --------------------------------------------------------------------------------------------
  1215. LAcctData& LAcctData :: putItem( const IString& item1
  1216.                               ,const IString& item2
  1217.                               ,const Rule& rule )
  1218. {
  1219.  
  1220.      Item::Rule iRule = (Item::Rule) rule;
  1221.      // duplicates allowed
  1222.      items.add(Item(iRule, item1, item2));
  1223.  
  1224.      return *this;
  1225.  
  1226. }
  1227.  
  1228.  
  1229. // --------------------------------------------------------------------------------------------
  1230. // Class LAcctData :: emptyBag() - empty the bag
  1231. // --------------------------------------------------------------------------------------------
  1232. LAcctData&  LAcctData :: emptyBag()  {
  1233.  // attach to employee number
  1234.  
  1235.  items.removeAll();
  1236.  itemsCur.invalidate();
  1237.  return  *this;
  1238. }
  1239.  
  1240.  
  1241. // --------------------------------------------------------------------------------------------
  1242. // Class LAcctData :: deleteCurrentItem() -
  1243. // --------------------------------------------------------------------------------------------
  1244. LAcctData& LAcctData ::  deleteCurrentItem()
  1245. {
  1246.     if (itemsCur.isValid()) {
  1247.        items.removeAt(itemsCur);
  1248.     } /* endif */
  1249.     return *this;
  1250. }
  1251.  
  1252. // --------------------------------------------------------------------------------------------
  1253. // Class LAcctData :: operator=    - copy LAcctData contents to another
  1254. // --------------------------------------------------------------------------------------------
  1255. LAcctData& LAcctData::operator=( const LAcctData& from )
  1256. {
  1257.   items = from.getItems();
  1258.   itemsCur = from.getItemsCursor();
  1259.   employeeNum = from.employeeNumber();
  1260.   return *this;
  1261. }
  1262.  
  1263.  
  1264. // --------------------------------------------------------------------------------------------
  1265. // Class LTaskData :: LTaskData() - contructor
  1266. // --------------------------------------------------------------------------------------------
  1267. LTaskData :: LTaskData (const IString empNum)
  1268.            : itemsCur(items)
  1269.              ,employeeNum(empNum)
  1270. {
  1271.    load(empNum);
  1272. }
  1273.  
  1274. // --------------------------------------------------------------------------------------------
  1275. // Class LTaskData :: LTaskData() - destructor
  1276. // --------------------------------------------------------------------------------------------
  1277. LTaskData :: ~LTaskData ()
  1278. {
  1279.    emptyBag();
  1280. }
  1281.  
  1282.  
  1283. // --------------------------------------------------------------------------------------------
  1284. // Class LTaskData :: load()
  1285. // --------------------------------------------------------------------------------------------
  1286. LTaskData& LTaskData :: load (const IString empNum)
  1287. {
  1288.   if ( empNum != (IString)NULL )
  1289.   {
  1290.      IString
  1291.        key=empNum,
  1292.        theTask,
  1293.        theDesc,
  1294.        theBill,
  1295.        employeeNumber;
  1296.  
  1297.      int
  1298.        i=0;
  1299.  
  1300.    try
  1301.    {
  1302.      IProfile
  1303.       *p = new IProfile("ltask.ini");
  1304.  
  1305.      // concat to make multiple entries unique
  1306.      key  = empNum  + IString(i);
  1307.  
  1308.      emptyBag();
  1309.  
  1310.      while (p->containsApplication(key)) {
  1311.         if (p->containsKeyName("Task", key))
  1312.            theTask = p->elementWithKey( "Task",key ) ;
  1313.         else
  1314.            theTask = "";
  1315.         if (p->containsKeyName("Desc", key))
  1316.            theDesc = p->elementWithKey( "Desc",key ) ;
  1317.         else
  1318.            theDesc = "";
  1319.  
  1320.         if (p->containsKeyName("Billable", key))
  1321.            theBill = p->elementWithKey( "Billable",key ) ;
  1322.         else
  1323.            theBill = "";
  1324.  
  1325.         // add it to the bag
  1326.         items.add(Item(Item::file, theTask, theDesc, theBill, key ));
  1327.  
  1328.         // this is how multiple items are handled for a given user/employee
  1329.         key = empNum + IString(++i);
  1330.  
  1331.      } /* endwhile */
  1332.      delete p;
  1333.    }
  1334.    catch(...)
  1335.    {}
  1336.   }
  1337.   return *this;
  1338. }
  1339.  
  1340.  
  1341.  
  1342. // --------------------------------------------------------------------------------------------
  1343. // Class LTaskData :: save () - save database info
  1344. // --------------------------------------------------------------------------------------------
  1345. LTaskData& LTaskData :: save(const IString empNum)
  1346. {
  1347.      // put data in IProfile
  1348.      IString
  1349.        appl=empNum,
  1350.        theTask,
  1351.        theDesc,
  1352.        theBill,
  1353.        employeeNumber;
  1354.  
  1355.      int
  1356.        i=0;
  1357.  
  1358.      Items::Cursor
  1359.        itemsCur1(items),
  1360.        itemsCur2(items);
  1361.  
  1362.      if (items.numberOfElements() == 0 )
  1363.         return *this;
  1364.  
  1365.    try
  1366.    {
  1367.      IProfile
  1368.       *p = new IProfile("ltask.ini");
  1369.  
  1370.      // concat to make multiple entries unique
  1371.      appl = empNum + IString(i);
  1372.  
  1373.      //IProfile delete them all and then put then back
  1374.      while (p->containsApplication(appl)) {
  1375.         p->deleteElementWithApplication( appl ) ;
  1376.         appl = empNum + IString(++i);
  1377.      } /* endwhile */
  1378.  
  1379.      // must now iterate thru bag and save
  1380.  
  1381.    i = 0;
  1382.    appl = empNum + IString(i);
  1383.    itemsCur1.setToFirst();
  1384.    do {
  1385.       Entry name = itemsCur1.element().item1();
  1386.  
  1387.  
  1388.       items.locateElementWithKey(name, itemsCur2);
  1389.       do  {
  1390.          Entry item1 = itemsCur2.element().item1();
  1391.          Entry item2 = itemsCur2.element().item2();
  1392.          Entry item3 = itemsCur2.element().item3();
  1393.  
  1394.          if ( item1.text().length() )
  1395.          {
  1396.            p->addOrReplaceElementWithKey("Task", item1.text(), appl);
  1397.            p->addOrReplaceElementWithKey("Billable", item3.text(), appl);
  1398.  
  1399.            if ( item2.text().length() )
  1400.              p->addOrReplaceElementWithKey("Desc", item2.text(), appl);
  1401.  
  1402.            appl = empNum + IString(++i);
  1403.          }
  1404.  
  1405.       } while (items.locateNextElementWithKey(name, itemsCur2));
  1406.  
  1407.    } while (items.setToNextWithDifferentKey(itemsCur1));
  1408.  
  1409.    delete p;
  1410.    }
  1411.    catch(...)
  1412.    {}
  1413.    return *this;
  1414. }
  1415.  
  1416.  
  1417. // --------------------------------------------------------------------------------------------
  1418. // Class LTaskData :: getItem() - get database info
  1419. // --------------------------------------------------------------------------------------------
  1420. IBase:: Boolean LTaskData :: getItem( IString& item1
  1421.                                     ,IString& item2
  1422.                                     ,IString& item3
  1423.                                     ,Rule& rule)
  1424. {
  1425.    if (false == itemsCur.isValid())
  1426.       return false;  // none left
  1427.  
  1428.    Entry name = itemsCur.element().item1();
  1429.  
  1430.    items.locateElementWithKey(name, itemsCur);
  1431.  
  1432.    item1 = itemsCur.element().item1().text();
  1433.    item2 = itemsCur.element().item2().text();
  1434.    item3 = itemsCur.element().item3().text();
  1435.  
  1436.    rule  =  (LTaskData::Rule  )itemsCur.element().rule();
  1437.  
  1438.    return true;
  1439. }
  1440.  
  1441.  
  1442.  
  1443. // --------------------------------------------------------------------------------------------
  1444. // Class LTaskData :: putItem() - save database info
  1445. // --------------------------------------------------------------------------------------------
  1446. IBase::Boolean LTaskData :: putItem( const IString& item1,
  1447.                                     const IString& item2,
  1448.                                     const IString& item3,
  1449.                                     const Rule& rule )
  1450. {
  1451.      Boolean done = false;
  1452.      Item::Rule iRule = (Item::Rule) rule;
  1453.      Items::Cursor  itemsC(items);
  1454.  
  1455.      itemsC.setToFirst();
  1456.  
  1457.      if (false == itemsC.isValid())
  1458.         items.add(Item(iRule, item1, item2, item3));
  1459.      else {
  1460.        // search bag for a duplicate
  1461.  
  1462.        // Entry name = itemsCur.element().item1();
  1463.        // the key is the id concatenated with a number
  1464.  
  1465.        // loop thru the bag and see if there is a match
  1466.        do {
  1467.          Entry i1 = itemsC.element().item1();
  1468.          if (i1.text() == item1) {
  1469.              Entry i2 = itemsC.element().item2();
  1470.              Entry i3 = itemsC.element().item3();
  1471.              if ((i2.text() != item2) | (i3.text() != item3)) {
  1472.                 // a duplicate entry was found, with something different
  1473.  
  1474.                 // new entry, reflected in container
  1475.  
  1476.                 items.add(Item(Item::replace,
  1477.                                item1,
  1478.                                item2,
  1479.                                item3 ));
  1480.                 done = true;
  1481.              }
  1482.              else {  // entry matches
  1483.                 // if doing an ADD, CHANGE do nothing
  1484.                 // if a REMOVE
  1485.                 if (iRule == Item::replace) {
  1486.                     // udated entry
  1487.                     items.add(Item(iRule, item1, item2, item3));
  1488.                     // delete old entry
  1489.                     items.removeAt(itemsC);
  1490.                 }
  1491.  
  1492.              }
  1493.          }
  1494.  
  1495.        } while (done == false &&
  1496.                 items.setToNextWithDifferentKey(itemsC)); /* enddo */
  1497.  
  1498.        if (done == false ) {
  1499.           // a unique one
  1500.           items.add(Item( iRule, item1, item2, item3));
  1501.        } /* endif */
  1502.  
  1503.      }
  1504.  
  1505.    return true;
  1506. }
  1507.  
  1508.  
  1509. // --------------------------------------------------------------------------------------------
  1510. // Class LTaskData :: emptyBag() - empty bag
  1511. // --------------------------------------------------------------------------------------------
  1512. LTaskData&  LTaskData :: emptyBag()  {
  1513.  
  1514.  items.removeAll();
  1515.  itemsCur.invalidate();
  1516.  return *this;
  1517. }
  1518.  
  1519.  
  1520. // --------------------------------------------------------------------------------------------
  1521. // Class LTaskData :: deletCurrentItem()
  1522. // --------------------------------------------------------------------------------------------
  1523. LTaskData& LTaskData ::  deleteCurrentItem()
  1524. {
  1525.     if (itemsCur.isValid()) {
  1526.        items.removeAt(itemsCur);
  1527.     } /* endif */
  1528.     return *this;
  1529. }
  1530.  
  1531.  
  1532. // --------------------------------------------------------------------------------------------
  1533. // Class LTaskData :: isInAndBillable() - see if its in
  1534. // --------------------------------------------------------------------------------------------
  1535. IBase :: Boolean  LTaskData :: isInAndBillable( const IString& empNum,
  1536.                                                const IString& theTask )
  1537. {
  1538.   try
  1539.   {
  1540.   IProfile
  1541.    *p = new IProfile("ltask.ini");
  1542.  
  1543.   int i=0;
  1544.   IString idTask, appl, idBillable;
  1545.  
  1546.   // concat to make multiple entries unique
  1547.   appl = empNum  + IString(i);
  1548.  
  1549.   while (p->containsApplication(appl)) {
  1550.     if (p->containsKeyName("Task", appl)) {
  1551.         idTask = p->elementWithKey( "Task",appl) ;
  1552.         if (idTask == theTask) {
  1553.  
  1554.            if (p->containsKeyName("Billable", appl))
  1555.               idBillable = p->elementWithKey( "Billable",appl) ;
  1556.               if (idBillable == "yes")
  1557.                   return true;
  1558.               else
  1559.                   return false;
  1560.         }
  1561.     }
  1562.  
  1563.     // this is how multiple items are handled for a given user/employee
  1564.     appl = empNum + IString(++i);
  1565.  
  1566.   } /* endwhile */
  1567.   delete p;
  1568.   }
  1569.   catch(...)
  1570.   {}
  1571.   return false;
  1572. }
  1573.  
  1574. // --------------------------------------------------------------------------------------------
  1575. // Class LTaskData :: operator=    - copy LTaskData contents to another
  1576. // --------------------------------------------------------------------------------------------
  1577. LTaskData& LTaskData::operator=( const LTaskData& from )
  1578. {
  1579.   items = from.getItems();
  1580.   itemsCur = from.getItemsCursor();
  1581.   employeeNum = from.employeeNumber();
  1582.   return *this;
  1583. }
  1584.  
  1585.  
  1586. // --------------------------------------------------------------------------------------------
  1587. // Class LProjectData :: LProjectData() -
  1588. // --------------------------------------------------------------------------------------------
  1589. LProjectData :: LProjectData (const IString empNum)
  1590.            : itemsCur(items)
  1591.              ,employeeNum(empNum)
  1592. {
  1593.    load(empNum);
  1594. }
  1595.  
  1596. // --------------------------------------------------------------------------------------------
  1597. // Class LProjectData :: ~LProjectData() -
  1598. // --------------------------------------------------------------------------------------------
  1599. LProjectData :: ~LProjectData ()
  1600. {
  1601.   emptyBag();
  1602. }
  1603.  
  1604.  
  1605. // --------------------------------------------------------------------------------------------
  1606. // Class LProjectData :: load() - load database info
  1607. // --------------------------------------------------------------------------------------------
  1608. LProjectData& LProjectData :: load (const IString empNum)
  1609. {
  1610.   if ( empNum != (IString)NULL )
  1611.   {
  1612.      IString  key=empNum;
  1613.  
  1614.      IString     theProject
  1615.                 ,cbActive
  1616.                 ,theDesc
  1617.                 ,theMgr
  1618.                 ,employeeNumber ;
  1619.      int i=0;
  1620.  
  1621.    try
  1622.    {
  1623.      IProfile
  1624.       *p = new IProfile("lproject.ini");
  1625.  
  1626.      // concat to make multiple entries unique
  1627.      key  = empNum  + IString(i);
  1628.  
  1629.      emptyBag();
  1630.  
  1631.      while (p->containsApplication(key)) {
  1632.  
  1633.         if (p->containsKeyName("Project", key))
  1634.            theProject = p->elementWithKey( "Project",key ) ;
  1635.         else
  1636.            theProject = "";
  1637.         if (p->containsKeyName("Active", key))
  1638.            cbActive   = p->elementWithKey( "Active", key ) ;
  1639.         else
  1640.            cbActive = "";
  1641.  
  1642.         if (p->containsKeyName("Desc", key))
  1643.            theDesc    = p->elementWithKey( "Desc",key ) ;
  1644.         else
  1645.            theDesc = "";
  1646.  
  1647.         if (p->containsKeyName("Mgr", key))
  1648.            theMgr     = p->elementWithKey( "Mgr",key ) ;
  1649.         else
  1650.            theMgr = "";
  1651.  
  1652.         // add it to the bag
  1653.         items.add(Item(Item::file
  1654.                        ,theProject
  1655.                        ,theDesc
  1656.                        ,theMgr
  1657.                        ,cbActive
  1658.                        , key ));
  1659.  
  1660.         // this is how multiple items are handled for a given user/employee
  1661.         key = empNum + IString(++i);
  1662.  
  1663.      } /* endwhile */
  1664.      delete p;
  1665.    }
  1666.    catch(...)
  1667.    {}
  1668.   }
  1669.   return *this;
  1670. }
  1671.  
  1672.  
  1673.  
  1674. // --------------------------------------------------------------------------------------------
  1675. // Class LProjectData :: save() - save database info
  1676. // --------------------------------------------------------------------------------------------
  1677. LProjectData&  LProjectData :: save(const IString empNum)
  1678. {
  1679.    try
  1680.    {
  1681.      IProfile
  1682.       *p = new IProfile("lproject.ini") ;
  1683.      // put data in IProfile
  1684.      IString  appl=empNum;
  1685.  
  1686.      IString     theProject
  1687.                 ,cbActive
  1688.                 ,theDesc
  1689.                 ,theMgr ;
  1690.      int i=0;
  1691.      Items::Cursor itemsCur1(items), itemsCur2(items);
  1692.      if (items.numberOfElements() == 0 )
  1693.         return *this;
  1694.  
  1695.  
  1696.      // concat to make multiple entries unique
  1697.      appl = empNum + IString(i);
  1698.  
  1699.      //IProfile delete them all and then put then back
  1700.      while (p->containsApplication(appl)) {
  1701.         p->deleteElementWithApplication( appl ) ;
  1702.         appl = empNum + IString(++i);
  1703.      } /* endwhile */
  1704.  
  1705.      // must now iterate thru bag and save
  1706.  
  1707.    i = 0;
  1708.    appl = empNum + IString(i);
  1709.    itemsCur1.setToFirst();
  1710.    do {
  1711.       Entry name = itemsCur1.element().item1();
  1712.  
  1713.       items.locateElementWithKey(name, itemsCur2);
  1714.       do  {
  1715.          Entry item1 = itemsCur2.element().item1();
  1716.  
  1717.          Entry item2 = itemsCur2.element().item2();
  1718.  
  1719.          Entry item3 = itemsCur2.element().item3();
  1720.  
  1721.          Entry item4 = itemsCur2.element().item4();
  1722.  
  1723.          if ( item1.text().length() )
  1724.          {
  1725.            p->addOrReplaceElementWithKey("Project"     , item1.text(), appl);
  1726.  
  1727.            p->addOrReplaceElementWithKey("Active"      , item4.text(), appl);
  1728.  
  1729.            if ( item2.text().length() )
  1730.              p->addOrReplaceElementWithKey("Desc"        , item2.text(), appl);
  1731.  
  1732.            if ( item3.text().length() )
  1733.              p->addOrReplaceElementWithKey("Mgr"         , item3.text(), appl);
  1734.  
  1735.            appl = empNum + IString(++i);
  1736.          }
  1737.  
  1738.       } while (items.locateNextElementWithKey(name, itemsCur2));
  1739.  
  1740.    } while (items.setToNextWithDifferentKey(itemsCur1));
  1741.  
  1742.    delete p;
  1743.    }
  1744.    catch(...)
  1745.    {}
  1746.    return *this;
  1747. }
  1748.  
  1749.  
  1750. // --------------------------------------------------------------------------------------------
  1751. // Class LProjectData :: getItem() - get info
  1752. // --------------------------------------------------------------------------------------------
  1753. IBase::Boolean  LProjectData :: getItem( IString& item1,
  1754.                                         IString& item2,
  1755.                                         IString& item3,
  1756.                                         IString& item4,
  1757.                                         Rule rule)
  1758. {
  1759.  
  1760.    if (false == itemsCur.isValid())
  1761.       return false;  // none left
  1762.  
  1763.    Entry name = itemsCur.element().item1();
  1764.  
  1765.    items.locateElementWithKey(name, itemsCur);
  1766.  
  1767.    item1 = itemsCur.element().item1().text();
  1768.    item2 = itemsCur.element().item2().text();
  1769.    item3 = itemsCur.element().item3().text();
  1770.    item4 = itemsCur.element().item4().text();
  1771.  
  1772.    rule  =  (LProjectData::Rule  )itemsCur.element().rule();
  1773.  
  1774.    return true;
  1775.  
  1776. }
  1777.  
  1778.  
  1779.  
  1780. // --------------------------------------------------------------------------------------------
  1781. // Class LProjectData :: putItem() - save info
  1782. // --------------------------------------------------------------------------------------------
  1783. LProjectData&  LProjectData :: putItem( const IString& item1,
  1784.                                       const IString& item2,
  1785.                                       const IString& item3,
  1786.                                       const IString& item4,
  1787.                                       const Rule& rule )
  1788. {
  1789.      Boolean done = false;
  1790.      Item::Rule iRule = (Item::Rule) rule;
  1791.      Items::Cursor  itemsC(items);
  1792.  
  1793.  
  1794.      itemsC.setToFirst();
  1795.  
  1796.      if (false == itemsC.isValid())
  1797.         items.add(Item(iRule, item1, item2, item3, item4 ));
  1798.      else {
  1799.        // search bag for a duplicate
  1800.  
  1801.        // Entry name = itemsCur.element().item1();
  1802.        // the key is the id concatenated with a number
  1803.  
  1804.        // loop thru the bag and see if there is a match
  1805.        do {
  1806.          Entry i1 = itemsC.element().item1();
  1807.          if (i1.text() == item1) {
  1808.              Entry i2 = itemsC.element().item2();
  1809.              Entry i3 = itemsC.element().item2();
  1810.              Entry i4 = itemsC.element().item2();
  1811.              if ((i2.text() != item2) &&
  1812.                  (i3.text() != item3) &&
  1813.                  (i4.text() != item4) )
  1814.               {
  1815.  
  1816.                 // a duplicate entry was found, with something different
  1817.  
  1818.                 // new entry, reflected in container
  1819.  
  1820.                 items.add(Item(Item::replace
  1821.                           , item1
  1822.                           , i2.text()
  1823.                           , i3.text()
  1824.                           , i4.text() ));
  1825.  
  1826.                 done = true;
  1827.              }
  1828.              else {  // entry matches
  1829.                 // if doing an ADD, CHANGE do nothing
  1830.                 // if a REMOVE
  1831.                 if (iRule == Item::replace) {
  1832.                     // udated entry
  1833.                     items.add(Item(iRule, item1, item2, item3, item4 ));
  1834.                     // delete old entry
  1835.                     items.removeAt(itemsC);
  1836.                 }
  1837.              }
  1838.          }
  1839.  
  1840.        } while (done == false &&
  1841.                 items.setToNextWithDifferentKey(itemsC)); /* enddo */
  1842.  
  1843.        if (done == false ) {
  1844.           // a unique one
  1845.           items.add(Item( iRule, item1, item2, item3, item4));
  1846.        } /* endif */
  1847.  
  1848.      }
  1849.  
  1850.    return *this;
  1851. }
  1852.  
  1853. // --------------------------------------------------------------------------------------------
  1854. // Class LProjectData :: emptyBag() - empty the bag
  1855. // --------------------------------------------------------------------------------------------
  1856. LProjectData&  LProjectData :: emptyBag()  {
  1857.  
  1858.  items.removeAll();
  1859.  itemsCur.invalidate();
  1860.  return *this;
  1861. }
  1862.  
  1863.  
  1864. // --------------------------------------------------------------------------------------------
  1865. // Class LProjectData :: deleteCurrentItem() - delete an item
  1866. // --------------------------------------------------------------------------------------------
  1867. LProjectData&  LProjectData ::  deleteCurrentItem()
  1868. {
  1869.     if (itemsCur.isValid()) {
  1870.        items.removeAt(itemsCur);
  1871.     } /* endif */
  1872.     return *this;
  1873. }
  1874.  
  1875. // --------------------------------------------------------------------------------------------
  1876. // Class LProjectData :: operator=    - copy LProjectData contents to another
  1877. // --------------------------------------------------------------------------------------------
  1878. LProjectData& LProjectData::operator=( const LProjectData& from )
  1879. {
  1880.   items = from.getItems();
  1881.   itemsCur = from.getItemsCursor();
  1882.   employeeNum = from.employeeNumber();
  1883.   return *this;
  1884. }
  1885.  
  1886.  
  1887. // --------------------------------------------------------------------------------------------
  1888. // Class TCard :: TCard contructor
  1889. // --------------------------------------------------------------------------------------------
  1890. TCard :: TCard()
  1891. {
  1892.   Date        = IString();
  1893.   ProjectName = IString();
  1894.   TaskName    = IString();
  1895.   Hours       = IString();
  1896.  
  1897. }
  1898.  
  1899. // --------------------------------------------------------------------------------------------
  1900. // Class TCard :: TCard destructor
  1901. // --------------------------------------------------------------------------------------------
  1902. TCard :: ~TCard()
  1903. {
  1904.  
  1905. }
  1906.  
  1907.  
  1908. // --------------------------------------------------------------------------------------------
  1909. // Class TimeCard :: TCardData
  1910. // --------------------------------------------------------------------------------------------
  1911. LTimeCardData :: LTimeCardData(const char* empNum,
  1912.                                   const IDate &theDate)
  1913.                    : theWeek(theDate)
  1914.                     ,tcard()
  1915.                     ,employeeNum(empNum)
  1916. {
  1917.    IString k = empNum + theWeek.asString();
  1918.    load(k);
  1919. }
  1920.  
  1921. // --------------------------------------------------------------------------------------------
  1922. // Class TimeCard :: TCard destructor
  1923. // --------------------------------------------------------------------------------------------
  1924. LTimeCardData :: ~LTimeCardData()
  1925. {
  1926.  
  1927. }
  1928.  
  1929.  
  1930. // --------------------------------------------------------------------------------------------
  1931. // Class TimeCard :: load() - get dataabse info
  1932. // --------------------------------------------------------------------------------------------
  1933. LTimeCardData& LTimeCardData :: load (const IString IDandDate)
  1934. {
  1935.    try
  1936.    {
  1937.      IProfile
  1938.       *p = new IProfile("ltime.ini");
  1939.  
  1940.      IString
  1941.        key=IDandDate;
  1942.  
  1943.      IString
  1944.        theDate,
  1945.        theProj,
  1946.        theTask,
  1947.        theHours;
  1948.  
  1949.      int
  1950.        i=0;
  1951.  
  1952.      // concat to make multiple entries unique
  1953.      key  += IString(i);
  1954.  
  1955.      while (p->containsApplication(key)) {
  1956.  
  1957.         if (p->containsKeyName("Date", key))
  1958.             theDate = p->elementWithKey( "Date",key ) ;
  1959.         else
  1960.             theDate = "";
  1961.  
  1962.         if (p->containsKeyName("Project", key))
  1963.             theProj    = p->elementWithKey( "Project", key ) ;
  1964.         else
  1965.             theProj = "";
  1966.  
  1967.         if (p->containsKeyName("Task", key))
  1968.             theTask    = p->elementWithKey( "Task", key ) ;
  1969.         else
  1970.             theTask = "";
  1971.  
  1972.         if (p->containsKeyName("Hours", key))
  1973.             theHours   = p->elementWithKey( "Hours", key ) ;
  1974.         else
  1975.             theHours = "";
  1976.  
  1977.         tcard[i].setDate(theDate);
  1978.         tcard[i].setProjectName(theProj);
  1979.         tcard[i].setTaskName(theTask);
  1980.         tcard[i].setHours(theHours);
  1981.  
  1982.         // this is how multiple items are handled for a given user/employee
  1983.         key = IDandDate+ IString(++i);
  1984.  
  1985.      } /* endwhile */
  1986.  
  1987.     delete p;
  1988.    }
  1989.    catch(...)
  1990.    {}
  1991.     return *this;
  1992. }  // get
  1993.  
  1994.  
  1995.  
  1996. // --------------------------------------------------------------------------------------------
  1997. // Class TimeCard :: save() - get dataabse info
  1998. // --------------------------------------------------------------------------------------------
  1999. LTimeCardData&  LTimeCardData  :: save(const IString IDandDate)
  2000. {
  2001.    try
  2002.    {
  2003.      IProfile
  2004.       *p = new IProfile("ltime.ini");
  2005.      // put data in IProfile
  2006.      IString    appl
  2007.               , theProj
  2008.               , theDate
  2009.               , theTask
  2010.               , theHours;
  2011.      int i=0;
  2012.  
  2013.      // concat to make multiple entries unique
  2014.      appl = IDandDate + IString(i);
  2015.  
  2016.      //IProfile delete them all and then put then back
  2017.      while (p->containsApplication(appl)) {
  2018.         p->deleteElementWithApplication( appl ) ;
  2019.         appl = IDandDate + IString(++i);
  2020.      }
  2021.  
  2022.      i = 0;
  2023.      appl = IDandDate + IString(i);
  2024.      for (i = 0 ;i < tcEntries; i++) {
  2025.  
  2026.          theDate  = tcard[i].date();
  2027.          theProj  = tcard[i].projectName();
  2028.          theTask  = tcard[i].taskName();
  2029.          theHours = tcard[i].hours();
  2030.  
  2031.          appl = IDandDate + IString(i);
  2032.  
  2033.          if ( theDate.length() )
  2034.             p->addOrReplaceElementWithKey("Date",       theDate , appl);
  2035.  
  2036.          if ( theProj.length() )
  2037.             p->addOrReplaceElementWithKey("Project",    theProj , appl);
  2038.  
  2039.          if ( theTask.length() )
  2040.             p->addOrReplaceElementWithKey("Task",       theTask , appl);
  2041.  
  2042.          if ( theHours.asInt() )
  2043.             p->addOrReplaceElementWithKey("Hours",      theHours, appl);
  2044.      }
  2045.  
  2046.      delete p;
  2047.    }
  2048.    catch(...)
  2049.    {}
  2050.      return *this;
  2051. }
  2052.  
  2053.  
  2054. // --------------------------------------------------------------------------------------------
  2055. // Class LQueryData :: LQueryData() - constructor
  2056. // --------------------------------------------------------------------------------------------
  2057. LQueryData :: LQueryData (const IString queryName)
  2058.              : itemsCur(items)
  2059.              ,QueryName(queryName)
  2060. {
  2061.    loadIni(queryName); // fill bag
  2062. }
  2063.  
  2064. // --------------------------------------------------------------------------------------------
  2065. // Class LQueryData :: LQueryData() - destructor
  2066. // --------------------------------------------------------------------------------------------
  2067. LQueryData :: ~LQueryData ()
  2068. {
  2069.   emptyBag();
  2070.  
  2071. }
  2072.  
  2073.  
  2074. // --------------------------------------------------------------------------------------------
  2075. // Class LQueryData :: loadIni() - read save query info
  2076. // --------------------------------------------------------------------------------------------
  2077. LQueryData& LQueryData :: loadIni (const IString queryName)
  2078. {
  2079.      // go thru the ini getting all the query data
  2080.    int
  2081.       nd,
  2082.       i;
  2083.  
  2084.    IString
  2085.       page,
  2086.       key,
  2087.       value,
  2088.       theWord,
  2089.       range,
  2090.       i1="",
  2091.       i2="",
  2092.       i3="";
  2093.  
  2094.    if (queryName.length() == 0)
  2095.       return *this;
  2096.  
  2097.    try
  2098.    {
  2099.       IProfile
  2100.          theProfile = IProfile("lsaveqry.ini");
  2101.  
  2102.       IProfile::Cursor
  2103.          iniQueryCur = IProfile::Cursor(theProfile, queryName);
  2104.  
  2105.      for (iniQueryCur.setToFirst();
  2106.           iniQueryCur.isValid();
  2107.           iniQueryCur.setToNext())
  2108.      {
  2109.           // get the KEY data
  2110.           theWord  = theProfile.applicationOrKeyAt(iniQueryCur);
  2111.           switch (theWord.numWords()) {
  2112.             case 2 :
  2113.  
  2114.               page = theWord.word(1);
  2115.               key  = theWord.word(2);
  2116.               value = theProfile.elementWithKey(theWord, queryName);
  2117.               if (key.isDigits()) {
  2118.                  // data is for a container
  2119.                 nd= value.numWords();
  2120.                 if (nd >= 3 ) {
  2121.                    // handle a space. assumes 3 keywords
  2122.                    for (i=1;i < nd-1 ;++i ) {
  2123.                       i1 += " " + value.word(i);
  2124.                    } /* endfor */
  2125.  
  2126.                    i2 = value.word(nd-1); // something
  2127.                    i3 = value.word(nd);   // range
  2128.                    items.add(Item(page, i1, i2, i3 ));
  2129.                    i1 = "";
  2130.                 } /* endif */
  2131.                 else
  2132.                 if (nd == 2 ) {
  2133.                    // this is an acct query
  2134.                    // handle a space. assumes 2 keywords
  2135.                    i1 = value.word(1);
  2136.                    i2 = value.word(2);
  2137.                    items.add(Item(page, i1, i2 ));
  2138.                    i1 = "";
  2139.                 } /* endif */
  2140.  
  2141.  
  2142.  
  2143.               }
  2144.               else
  2145.                 items.add(Item(page, key, value ));
  2146.  
  2147.               break;
  2148.             case 3:
  2149.               page   = theWord.word(1);
  2150.               key    = theWord.word(2);
  2151.               range  = theWord.word(3);
  2152.               value = theProfile.elementWithKey(theWord, queryName);
  2153.  
  2154.               items.add(Item(page, key, value, range ));
  2155.               break;
  2156.  
  2157.           }
  2158.      }
  2159.    }
  2160.    catch(...)
  2161.    {}
  2162.  
  2163.    return *this;
  2164. }  // get
  2165.  
  2166.  
  2167.  
  2168. // --------------------------------------------------------------------------------------------
  2169. // Class LQueryData :: saveIni() - save save query info
  2170. // --------------------------------------------------------------------------------------------
  2171. IBase::Boolean LQueryData :: saveIni(const IString queryName)
  2172. {
  2173.    Boolean
  2174.       rv = true;
  2175.    try
  2176.    {
  2177.      IProfile
  2178.        *p = new IProfile("lsaveqry.ini");
  2179.  
  2180.      //
  2181.      // pass in the title
  2182.      // put data in IProfile
  2183.  
  2184.      // IString  appl=fileName;
  2185.      // IString  projName, projDes, respMgr, projState;
  2186.      // int i=0;
  2187.  
  2188.      // go thru the bag and save in the ini
  2189.  
  2190.  
  2191.      // concat to make ultiple entries unique
  2192.  
  2193.  
  2194.      //IProfile delete them all and then put then back
  2195.      if ( p->containsApplication( queryName ) )
  2196.        rv = false;
  2197.      p->deleteElementWithApplication( queryName ) ;
  2198.  
  2199.      // must now iterate thru bag and save
  2200.  
  2201.      Items::Cursor itemsCur1(items);
  2202.  
  2203.      IString i1,i2 ;
  2204.  
  2205.      for ( itemsCur1.setToFirst() ;
  2206.            itemsCur1.isValid();
  2207.            itemsCur1.setToNext()) {
  2208.  
  2209.           Entry key  = itemsCur1.element().item1();
  2210.           i1  = key.text();
  2211.  
  2212.           Entry data = itemsCur1.element().item2();
  2213.  
  2214.           Entry d1   = itemsCur1.element().item3();
  2215.           Entry d2   = itemsCur1.element().item4();
  2216.           if (d1.text().length() > 0 ) {
  2217.              i2 = data.text() + " " + d1.text() + " " + d2.text();
  2218.  
  2219.           } else {
  2220.              i2  = data.text();
  2221.           } /* endif */
  2222.  
  2223.           p->addOrReplaceElementWithKey(i1, i2 , queryName);
  2224.       }
  2225.  
  2226.       delete p;
  2227.    }
  2228.    catch(...)
  2229.    {}
  2230.    return rv;
  2231. }
  2232.  
  2233.  
  2234. // --------------------------------------------------------------------------------------------
  2235. // Class LQueryData :: getItem() - get a query item
  2236. // --------------------------------------------------------------------------------------------
  2237. IBase :: Boolean LQueryData :: getItem( IString& item2
  2238.                                       ,IString& item3
  2239.                                       ,IString& item4)
  2240. {
  2241.    // get a query
  2242.    if (false == itemsCur.isValid())
  2243.       return false;  // none left
  2244.  
  2245.  
  2246.    // item 1 is a key
  2247.    // not used, delete later, its the PAGE
  2248.    Entry i2 = itemsCur.element().item2();
  2249.    Entry i3 = itemsCur.element().item3();
  2250.    Entry i4 = itemsCur.element().item4();
  2251.  
  2252.    item2 =  i2.text();
  2253.    item3 =  i3.text();
  2254.    item4 =  i4.text();
  2255.    return true;
  2256.  
  2257. }
  2258.  
  2259.  
  2260. // --------------------------------------------------------------------------------------------
  2261. // Class LQueryData :: emptyBag() - empty the bag
  2262. // --------------------------------------------------------------------------------------------
  2263. LQueryData&  LQueryData :: emptyBag()  {
  2264.  items.removeAll();
  2265.  itemsCur.invalidate();
  2266.  return *this;
  2267. }
  2268.  
  2269.  
  2270. // --------------------------------------------------------------------------------------------
  2271. // Class LQueryData :: deleteItem() - delete an item
  2272. // --------------------------------------------------------------------------------------------
  2273. LQueryData& LQueryData :: deleteItem(IString& queryName )
  2274. {
  2275.    if (queryName.length() != 0 ) {
  2276.       try
  2277.       {
  2278.          IProfile
  2279.             *p = new IProfile("lsaveqry.ini");
  2280.  
  2281.          p->deleteElementWithApplication(queryName);
  2282.          delete p;
  2283.       }
  2284.       catch(...)
  2285.       {}
  2286.    }
  2287.    return *this;
  2288. }
  2289.  
  2290. // --------------------------------------------------------------------------------------------
  2291. // Class LQueryData :: setFirstWithKey() - point to the first key
  2292. // --------------------------------------------------------------------------------------------
  2293. IBase :: Boolean LQueryData :: setFirstWithKey(char*  key)
  2294. {
  2295.   Entry aKey = Entry(key);
  2296.   items.locateElementWithKey(aKey, itemsCur);
  2297.   return itemsCur.isValid();
  2298. }
  2299.  
  2300. // --------------------------------------------------------------------------------------------
  2301. // Class LQueryData :: getNextWithKey() - get next first key
  2302. // --------------------------------------------------------------------------------------------
  2303. IBase :: Boolean LQueryData :: getNextWithKey(char*  key)
  2304. {
  2305.   Entry aKey = Entry(key);
  2306.   items.locateNextElementWithKey(aKey, itemsCur);
  2307.   return itemsCur.isValid();
  2308. }
  2309.  
  2310.  
  2311. // --------------------------------------------------------------------------------------------
  2312. // Class LQueryData :: putItem() - save item
  2313. // --------------------------------------------------------------------------------------------
  2314. LQueryData& LQueryData :: putItem( const IString& item1,
  2315.                                  const IString& item2,
  2316.                                  const IString& item3,
  2317.                                  const IString& item4)
  2318. {
  2319.      items.add(Item( item1, item2, item3, item4  ));
  2320.      return *this;
  2321. }
  2322.  
  2323.  
  2324. // --------------------------------------------------------------------------------------------
  2325. // Class LDeleteEmployee :: LDeleteEmployee() - constructor
  2326. // --------------------------------------------------------------------------------------------
  2327. LDeleteEmployee :: LDeleteEmployee()
  2328.                       : emplDB("lempl.ini"),
  2329.                         acctDB("lacct.ini"),
  2330.                         badgeDB("lbadge.ini"),
  2331.                         projectDB("lproj.ini"),
  2332.                         skillDB("lskill.ini"),
  2333.                         statusDB("lstatus.ini"),
  2334.                         taskDB("ltask.ini"),
  2335.                         timecDB("ltime.ini"),
  2336.                         workDB("lwork.ini")
  2337. {}
  2338.  
  2339. // --------------------------------------------------------------------------------------------
  2340. // Class LDeleteEmployee :: ~LDeleteEmployee() - destructor
  2341. // --------------------------------------------------------------------------------------------
  2342. LDeleteEmployee :: ~LDeleteEmployee()
  2343. {}
  2344.  
  2345.  
  2346. // --------------------------------------------------------------------------------------------
  2347. // Class LDeleteEmployee :: deleteFromDataBase() delete an employee from all db's (ini's)
  2348. // --------------------------------------------------------------------------------------------
  2349. LDeleteEmployee&  LDeleteEmployee :: deleteFromDataBase(const IString& empNum)
  2350. {
  2351.   // delete someone from the database
  2352.  
  2353.   // genl data base entry
  2354.   emplDB.deleteElementWithApplication(empNum);
  2355.  
  2356.   // badge database
  2357.   badgeDB.deleteElementWithApplication(empNum);
  2358.  
  2359.   // status database
  2360.   statusDB.deleteElementWithApplication(empNum);
  2361.  
  2362.   // These database ini's are container objects
  2363.   IString appl ;
  2364.   short i=0;
  2365.  
  2366.   // account database
  2367.   appl = empNum + IString(i);
  2368.   while (acctDB.containsApplication(appl)) {
  2369.         acctDB.deleteElementWithApplication( appl ) ;
  2370.         appl = empNum + IString(++i);
  2371.   } /* endwhile */
  2372.  
  2373.   i = 0;
  2374.   // skill   database
  2375.   appl = empNum + IString(i);
  2376.   while (skillDB.containsApplication(appl)) {
  2377.         skillDB.deleteElementWithApplication( appl ) ;
  2378.         appl = empNum + IString(++i);
  2379.   } /* endwhile */
  2380.  
  2381.   i = 0;
  2382.   // project database
  2383.   appl = empNum + IString(i);
  2384.   while (projectDB.containsApplication(appl)) {
  2385.         projectDB.deleteElementWithApplication( appl ) ;
  2386.         appl = empNum + IString(++i);
  2387.   } /* endwhile */
  2388.  
  2389.   i = 0;
  2390.   // task    database
  2391.   appl = empNum + IString(i);
  2392.   while (taskDB.containsApplication(appl)) {
  2393.         taskDB.deleteElementWithApplication( appl ) ;
  2394.         appl = empNum + IString(++i);
  2395.   } /* endwhile */
  2396.  
  2397.   i = 0;
  2398.   // time card database
  2399.   appl = empNum + IString(i);
  2400.   while (timecDB.containsApplication(appl)) {
  2401.         timecDB.deleteElementWithApplication( appl ) ;
  2402.         appl = empNum + IString(++i);
  2403.   } /* endwhile */
  2404.  
  2405.   i = 0;
  2406.   // work card database
  2407.   appl = empNum + IString(i);
  2408.   while (workDB.containsApplication(appl)) {
  2409.          workDB.deleteElementWithApplication( appl ) ;
  2410.          appl = empNum + IString(++i);
  2411.   } /* endwhile */
  2412.   return *this;
  2413.  
  2414. }
  2415.