home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / VSCPPv8.zip / VACPP / IBMCPP / samples / IOC / LANCELOT / LDBASE.CPP < prev    next >
C/C++ Source or Header  |  1995-05-01  |  75KB  |  2,418 lines

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