home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / VSCPPv8.zip / VACPP / IBMCPP / samples / IOC / LANCELOT / LACCT.CPP < prev    next >
C/C++ Source or Header  |  1995-04-07  |  34KB  |  722 lines

  1. /******************************************************************************
  2. * FILE NAME: lacct.cpp                                                        *
  3. *                                                                             *
  4. * DESCRIPTION:                                                                *
  5. *                                                                             *
  6. * Classes                                                                     *
  7. *   AcctPage                                                                  *
  8. *   AcctCnrObj                                                                *
  9. *                                                                             *
  10. * COPYRIGHT:                                                                  *
  11. *   Licensed Materials - Property of IBM                                      *
  12. *   (C) Copyright IBM Corporation 1992, 1995                                  *
  13. *   All Rights Reserved                                                       *
  14. *   US Government Users Restricted Rights - Use, duplication, or disclosure   *
  15. *   restricted by GSA ADP Schedule Contract with IBM Corp.                    *
  16. *                                                                             *
  17. *******************************************************************************/
  18.  
  19. #ifndef _IBASE_                         //Make sure ibase.hpp is included
  20.   #include <ibase.hpp>                  //  since that is where IC_<environ>
  21. #endif                                  //  is defined.
  22. #include <ireslib.hpp>
  23. #include <ihelp.hpp>
  24. #include "lancelot.h"
  25. #include "lacct.hpp"
  26.  
  27. /******************************************************************************
  28. * Class AccountPage :: AccountPage - Constructor for the account page         *
  29. *                                                                             *
  30. * Define yourself as an IMultiCellCanvas                                      *
  31. * Create generic page buttons                                                 *
  32. * Create generic page container buttons                                       *
  33. * Create static text for the user ID                                          *
  34. * Create static text for the node                                             *
  35. * Create entryfield for the user ID                                           *
  36. * Create entryfield for the node                                              *
  37. * Define a null container pointer                                             *
  38. * Define a null container object pointer                                      *
  39. * Define a null container column pointer                                      *
  40. * Define a null container column pointer                                      *
  41. * Create an account data object given the key                                 *
  42. * Create a empty account data object                                          *
  43. * Set the key in your private data                                            *
  44. * Set the isQuery in your private data                                        *
  45. * Create the notebook page settings                                           *
  46. * Create a select handler and later attach to the container                   *
  47. ******************************************************************************/
  48. AccountPage::AccountPage(  IWindow* pParent,
  49.                            const IString& aKey )
  50.      :IMultiCellCanvas     ( ID_ACCOUNT_PAGE, pParent, pParent ),
  51.       pageButtons          ( ID_ACCOUNT_PAGE_BUTTONS, this, this, false ),
  52.       pageCnrButtons       ( ID_ACCOUNT_PAGE_CNRBUTTONS,
  53.                              this, this, false ),
  54.       userIdText           ( ID_NO_ITEM, this, this ),
  55.       nodeSysText          ( ID_NO_ITEM, this, this ),
  56.       userId               ( ID_ACC_USERID_EF, this, this,
  57.                              IRectangle(),
  58.                              IEntryField::classDefaultStyle
  59.                              | IControl::tabStop),
  60.       nodeSys              ( ID_ACC_NODESYS_EF, this, this,
  61.                              IRectangle(),
  62.                              IEntryField::classDefaultStyle
  63.                              | IControl::tabStop ),
  64.       pCnr                 ( (IContainerControl*) NULL ),
  65.       pAcctCnrObj          ( (AcctCnrObj*) NULL ),
  66.       pColUserID           ( (IContainerColumn*) NULL ),
  67.       pColNodeSys          ( (IContainerColumn*) NULL ),
  68.       acctData             ( aKey ),
  69.       origAcctData         (),
  70.       Key                  ( aKey ),
  71.       isAquery             ( false ),
  72.       thePageSettings      ( IApplication::current().userResourceLibrary().
  73.                              loadString( STR_ACC_ACCOUNT_TAB ), NULL,
  74.                              INotebook::PageSettings::autoPageSize
  75.                              | INotebook::PageSettings::majorTab ),
  76.       cnrSelHandler        ( this )
  77.  
  78. {
  79. /*-----------------------------------------------------------------------------
  80. | Save the account data to another object in case the user wishes to          |
  81. |  undo any changes.                                                          |
  82. | Label the static text objects.                                              |
  83. | Set the limit for the entryfields.                                          |
  84. -----------------------------------------------------------------------------*/
  85.    origAcctData = acctData;
  86.    userIdText.setText( STR_ACC_USERID );
  87.    nodeSysText.setText( STR_ACC_NODESYS );
  88.    userId.setLimit(  DISPLAY_LARGE );
  89.    nodeSys.setLimit( DISPLAY_LARGE );
  90.  
  91. /*-----------------------------------------------------------------------------
  92. | Fill the container from the database.                                       |
  93. | Set the objects on yourself (IMultiCellCanvas).                             |
  94. | Start handling the events.                                                  |
  95. -----------------------------------------------------------------------------*/
  96.    fillCnr();
  97.    setCells();
  98.    handleIt();
  99. };
  100.  
  101. /******************************************************************************
  102. * Class AccountPage :: AccountPage - Constructor for the account page         *
  103. *                                                                             *
  104. * Define yourself as an IMultiCellCanvas                                      *
  105. * Create generic page buttons                                                 *
  106. * Create generic page container buttons                                       *
  107. * Create static text for the user ID                                          *
  108. * Create static text for the node                                             *
  109. * Create entryfield for the user ID                                           *
  110. * Create entryfield for the node                                              *
  111. * Define a null container pointer                                             *
  112. * Define a null container object pointer                                      *
  113. * Define a null container column pointer                                      *
  114. * Define a null container column pointer                                      *
  115. * Create an account data object given the query information                   *
  116. * Create a empty account data object                                          *
  117. * Set the key in your private data                                            *
  118. * Set the isQuery in your private data                                        *
  119. * Create the notebook page settings                                           *
  120. * Create a select handler and later attach to the container                   *
  121. ******************************************************************************/
  122. AccountPage::AccountPage(  IWindow* pParent,
  123.                            LQueryData& qd )
  124.      :IMultiCellCanvas     ( ID_ACCOUNT_PAGE, pParent, pParent ),
  125.       pageButtons          ( ID_ACCOUNT_PAGE_BUTTONS, this, this, true ),
  126.       pageCnrButtons       ( ID_ACCOUNT_PAGE_CNRBUTTONS,
  127.                              this, this, false),
  128.       userIdText           ( ID_NO_ITEM, this, this ),
  129.       nodeSysText          ( ID_NO_ITEM, this, this ),
  130.       userId               ( ID_ACC_USERID_EF, this, this,
  131.                              IRectangle(),
  132.                              IEntryField::classDefaultStyle
  133.                              | IControl::tabStop ),
  134.       nodeSys              ( ID_ACC_NODESYS_EF, this, this,
  135.                              IRectangle(),
  136.                              IEntryField::classDefaultStyle |
  137.                              IControl::tabStop ),
  138.       pCnr                 ( (IContainerControl*) NULL ),
  139.       pAcctCnrObj          ( (AcctCnrObj*) NULL ),
  140.       pColUserID           ( (IContainerColumn*) NULL ),
  141.       pColNodeSys          ( (IContainerColumn*) NULL ),
  142.       acctData             ( qd ),
  143.       origAcctData         (),
  144.       Key                  ( qd.queryName() ),
  145.       isAquery             ( true ),
  146.       thePageSettings      ( IApplication::current().userResourceLibrary().
  147.                              loadString( STR_ACC_ACCOUNT_TAB ), NULL,
  148.                              INotebook::PageSettings::autoPageSize
  149.                              | INotebook::PageSettings::majorTab ),
  150.       cnrSelHandler        ( this )
  151.  
  152. {
  153. /*-----------------------------------------------------------------------------
  154. | Save the account data to another object in case the user wishes to          |
  155. |  undo any changes.                                                          |
  156. | Label the static text objects.                                              |
  157. | Set the limit for the entryfields.                                          |
  158. -----------------------------------------------------------------------------*/
  159.    origAcctData = acctData;
  160.    userIdText.setText( STR_ACC_USERID  );
  161.    nodeSysText.setText( STR_ACC_NODESYS );
  162.    userId.setLimit( DISPLAY_LARGE );
  163.    nodeSys.setLimit( DISPLAY_LARGE );
  164.  
  165. /*-----------------------------------------------------------------------------
  166. | Fill the container from the database.                                       |
  167. | Set the objects on yourself (IMultiCellCanvas).                             |
  168. | Start handling the events.                                                  |
  169. -----------------------------------------------------------------------------*/
  170.    fillCnr();
  171.    setCells();
  172.    handleIt();
  173. };
  174.  
  175.  
  176. /******************************************************************************
  177. * Class AccountPage :: ~AccountPage - Destructor for the account page         *
  178. ******************************************************************************/
  179. AccountPage::~AccountPage()
  180. {
  181. /*-----------------------------------------------------------------------------
  182. | Stop handling events.                                                       |
  183. -----------------------------------------------------------------------------*/
  184.    ICommandHandler::stopHandlingEventsFor( &pageButtons );
  185.    ICommandHandler::stopHandlingEventsFor( &pageCnrButtons );
  186.    cnrSelHandler.stopHandlingEventsFor( pCnr );
  187. };
  188.  
  189.  
  190. /******************************************************************************
  191. * Class AccountPage :: handleIt - Handle events for the account page          *
  192. ******************************************************************************/
  193. AccountPage& AccountPage::handleIt()
  194. {
  195. /*-----------------------------------------------------------------------------
  196. | Start handling events.                                                      |
  197. | Return yourself.                                                            |
  198. -----------------------------------------------------------------------------*/
  199.    ICommandHandler::handleEventsFor( &pageButtons );
  200.    ICommandHandler::handleEventsFor( &pageCnrButtons );
  201.    return *this;
  202. }
  203.  
  204.  
  205. /******************************************************************************
  206. * Class AccountPage :: fillCnr - Set up the container                         *
  207. ******************************************************************************/
  208. AccountPage& AccountPage::fillCnr()
  209. {
  210. /*-----------------------------------------------------------------------------
  211. | If the container already exists,                                            |
  212. |  delete all the objects                                                     |
  213. | Else create a new container.                                                |
  214. -----------------------------------------------------------------------------*/
  215.    if ( pCnr )
  216.       pCnr->deleteAllObjects();
  217.    else
  218.    {
  219.       pCnr = new IContainerControl( ID_ACC_CNR,
  220.                                     this, this,
  221.                                     IRectangle(),
  222.                                     IContainerControl::classDefaultStyle
  223.                                     | IContainerControl::readOnly,
  224.                                     IContainerControl::readOnlyTitle
  225.                                     | IContainerControl::detailsView );
  226.  
  227. /*-----------------------------------------------------------------------------
  228. | Handle selection events for the new container.                              |
  229. -----------------------------------------------------------------------------*/
  230.       cnrSelHandler.handleEventsFor( pCnr );
  231.  
  232. /*-----------------------------------------------------------------------------
  233. | Delete the objects when the container is deleted.                           |
  234. | Tell the container to allow multiple selection.                             |
  235. | Tell the container to automatically refresh upon changes.                   |
  236. -----------------------------------------------------------------------------*/
  237.       pCnr->setDeleteObjectsOnClose();
  238.       pCnr->setDeleteColumnsOnClose();
  239.       pCnr->setMultipleSelection();
  240.       pCnr->setRefreshOn();
  241.  
  242. /*-----------------------------------------------------------------------------
  243. | Create two container columns.                                               |
  244. -----------------------------------------------------------------------------*/
  245.       pColUserID =
  246.          new IContainerColumn( pAcctCnrObj->currentUserIdOffset(),
  247.                                IContainerColumn::defaultHeadingStyle(),
  248.                                IContainerColumn::string );
  249.       pColNodeSys =
  250.          new IContainerColumn( pAcctCnrObj->nodeSysOffset(),
  251.                                IContainerColumn::defaultHeadingStyle(),
  252.                                IContainerColumn::string );
  253.  
  254. /*-----------------------------------------------------------------------------
  255. | Label the container column headings.                                        |
  256. | Show the headings.                                                          |
  257. | Show the headings.                                                          |
  258. -----------------------------------------------------------------------------*/
  259.       pColUserID->setHeadingText( STR_ACC_USERID );
  260.       pColNodeSys->setHeadingText( STR_ACC_NODESYS );
  261.       pCnr->showDetailsViewTitles();
  262.  
  263. /*-----------------------------------------------------------------------------
  264. | Add the columns to the container.                                           |
  265. | Add column separators between the columns.                                  |
  266. -----------------------------------------------------------------------------*/
  267.       pCnr->addColumn( pColUserID );
  268.       pCnr->addColumn( pColNodeSys );
  269.       pColUserID->showSeparators( IContainerColumn::verticalSeparator
  270.                                   | IContainerColumn::horizontalSeparator );
  271.       pColNodeSys->showSeparators( IContainerColumn::horizontalSeparator );
  272.    }
  273.  
  274. /*-----------------------------------------------------------------------------
  275. | Start from the beginning of the account data.                               |
  276. | While there exists items,                                                   |
  277. |   add objects to the container.                                             |
  278. | Refresh the container.                                                      |
  279. | Return yourself.                                                            |
  280. -----------------------------------------------------------------------------*/
  281.    IString
  282.       user,
  283.       node;
  284.    LAcctData::Rule
  285.       rule;
  286.  
  287.    acctData.setFirst();
  288.    while ( acctData.getItem( user, node, rule ) )
  289.    {
  290.       addAcct( user, node );
  291.       acctData.getNext();
  292.    }
  293.  
  294.    pCnr->refresh();
  295.  
  296.    return *this;
  297. };
  298.  
  299.  
  300. /******************************************************************************
  301. * Class AccountPage :: setCells - Set up your multicell canvas cells          *
  302. ******************************************************************************/
  303. AccountPage& AccountPage::setCells()
  304. {
  305. /*-----------------------------------------------------------------------------
  306. | Add the objects to your multicell canvas.                                   |
  307. | Allow the container to expand horizontally.                                 |
  308. | Allow the page buttons to expand horizontally.                              |
  309. | Return yourself.                                                            |
  310. -----------------------------------------------------------------------------*/
  311.    addToCell( &userIdText,        2,  2 );
  312.    addToCell( &userId,            2,  3 );
  313.  
  314.    addToCell( &nodeSysText,       2,  4 );
  315.    addToCell( &nodeSys,           2,  5 );
  316.  
  317.    addToCell( pCnr,               2,  7,  3,  3 );
  318.    addToCell( &pageCnrButtons,    5,  8 );
  319.    setColumnWidth(                4,  0, true );
  320.  
  321.    addToCell( &pageButtons,       2, 10,  2,  3 );
  322.    setColumnWidth(                3,  0, true );
  323.  
  324.    return *this;
  325. };
  326.  
  327.  
  328. /******************************************************************************
  329. * Class AccountPage :: verifyAndSave - Save page information to the database  *
  330. ******************************************************************************/
  331. IBase::Boolean AccountPage::verifyAndSave( IString& theString,
  332.                                            IString& theEntry,
  333.                                            const IString saveName )
  334. {
  335. /*-----------------------------------------------------------------------------
  336. | If there is no data or is a query, return.                                  |
  337. -----------------------------------------------------------------------------*/
  338.    if ( ( ! saveName.length() )
  339.         && ( ! Key.length() )
  340.         || isAquery )
  341.       return true;
  342.  
  343. /*-----------------------------------------------------------------------------
  344. | If able to retrieve the container information,                              |
  345. |  save the information to the database based on the key or query name.       |
  346. -----------------------------------------------------------------------------*/
  347.    if ( setAcctData() )
  348.    {
  349.       if ( ( saveName.length() > 0 ) && ( saveName.isAlphanumeric() ) )
  350.          acctData.save( saveName );
  351.        else
  352.          if ( ( Key.length() > 0 ) && ( Key.isAlphanumeric() ) )
  353.             acctData.save( Key );
  354.    }
  355.  
  356.    return true;
  357. };
  358.  
  359.  
  360. /******************************************************************************
  361. * Class AccountPage :: setAcctData - Retrieve the page information            *
  362. ******************************************************************************/
  363. IBase::Boolean AccountPage::setAcctData()
  364. {
  365.    IContainerControl::ObjectCursor
  366.       iterator( *pCnr );
  367.  
  368.    iterator.setToFirst();
  369.    if ( ! iterator.isValid() )
  370.       return false;
  371.  
  372.    AcctCnrObj
  373.       *cnrEntry;
  374.    IString
  375.       it1,
  376.       it2;
  377.  
  378. /*-----------------------------------------------------------------------------
  379. | Empty the bag.                                                              |
  380. | Iterate through the cursor and add objects to the bag.                      |
  381. -----------------------------------------------------------------------------*/
  382.    acctData.emptyBag();
  383.    while ( iterator.isValid() )
  384.    {
  385.       cnrEntry = (AcctCnrObj *) iterator.current();
  386.       this->acctData.putItem( cnrEntry->getUserId(), cnrEntry->getNode() );
  387.       cnrEntry = (AcctCnrObj *) iterator.next();
  388.    }
  389.  
  390.    return true;
  391. };
  392.  
  393.  
  394. /******************************************************************************
  395. * Class AccountPage :: fillEntryfields - Fill the entryfields for the object  *
  396. ******************************************************************************/
  397. AccountPage& AccountPage::fillEntryfields( AcctCnrObj* pCnrObject )
  398. {
  399. /*-----------------------------------------------------------------------------
  400. | Set the entryfields for the given account container object.                 |
  401. | Return yourself.                                                            |
  402. -----------------------------------------------------------------------------*/
  403.    userId.setText( pCnrObject->getUserId() );
  404.    nodeSys.setText( pCnrObject->getNode() );
  405.  
  406.    return *this;
  407. };
  408.  
  409.  
  410. /******************************************************************************
  411. * Class AccountPage :: command - Catch and process command events.            *
  412. ******************************************************************************/
  413. IBase::Boolean AccountPage::command( ICommandEvent& cmdEvent )
  414. {
  415.    IString
  416.       theUser = userId.text(),
  417.       theNode = nodeSys.text();
  418.    LAcctData::Rule
  419.       theRule = LAcctData::na;
  420.    Boolean
  421.       rc = false;
  422.    unsigned int
  423.       count = 0;
  424.  
  425. /*-----------------------------------------------------------------------------
  426. | Create a container object cursor based on the selected objects.             |
  427. | Process the command events.                                                 |
  428. -----------------------------------------------------------------------------*/
  429.    IContainerControl::ObjectCursor
  430.       soc( *pCnr, IContainerObject::selected );
  431.  
  432.    switch ( cmdEvent.commandId() )
  433.    {
  434. /*-----------------------------------------------------------------------------
  435. | User pressed the UNDO button.                                               |
  436. | Reset the account data to the original account data.                        |
  437. | Reset the container.                                                        |
  438. | Reset the entryfields.                                                      |
  439. -----------------------------------------------------------------------------*/
  440.       case ID_BUTTON_UNDO:
  441.       {
  442.          acctData = origAcctData;
  443.          fillCnr();
  444.          userId.setText( "" );
  445.          nodeSys.setText( "" );
  446.          rc = true;
  447.          break;
  448.       }
  449.  
  450. /*-----------------------------------------------------------------------------
  451. | User pressed the REMOVE button.                                             |
  452. | Iterate through the selected objects,                                       |
  453. |  remove the object from the the database.                                   |
  454. -----------------------------------------------------------------------------*/
  455.       case ID_BUTTON_REMOVE:
  456.       {
  457.          for ( soc.setToFirst();
  458.                soc.isValid();
  459.                soc.setToNext() )
  460.          {
  461.             AcctCnrObj
  462.                *pObj = (AcctCnrObj *) soc.current();
  463.             acctData.putItem( pObj->getUserId(),
  464.                               pObj->getNode(),
  465.                               LAcctData::remove );
  466.             ++count;
  467.          }
  468.  
  469. /*-----------------------------------------------------------------------------
  470. | If no container objects were selected,                                      |
  471. |  notify the user.                                                           |
  472. -----------------------------------------------------------------------------*/
  473.          if ( ! count )
  474.          {
  475.             IMessageBox
  476.                warning( owner() );
  477.             warning.show( STR_MSG_REMOVE,
  478.                           IMessageBox::enterButton
  479.                           | IMessageBox::informationIcon );
  480.          }
  481. /*-----------------------------------------------------------------------------
  482. | Else remove the selected objects from the container.                        |
  483. | Refresh the container.                                                      |
  484. -----------------------------------------------------------------------------*/
  485.          else
  486.          {
  487.             pCnr->removeSelectedObjects();
  488.             userId.setText( "" );
  489.             nodeSys.setText( "" );
  490.             pCnr->refresh();
  491.          }
  492.          rc = true;
  493.          break;
  494.       }
  495.  
  496. /*-----------------------------------------------------------------------------
  497. | User pressed the CHANGE button.                                             |
  498. | Ignore all but the first selected container object.                         |
  499. | Update the entryfields with the selected container object information.      |
  500. -----------------------------------------------------------------------------*/
  501.       case ID_BUTTON_CHANGE:
  502.       {
  503.          soc.setToFirst();
  504.          if ( soc.isValid() )
  505.          {
  506.             if ( theUser.length() )
  507.             {
  508.                changeAcct( theUser, theNode, (AcctCnrObj*) soc.current() );
  509.                userId.setText( "" );
  510.                nodeSys.setText( "" );
  511.             }
  512.  
  513.          }
  514. /*-----------------------------------------------------------------------------
  515. | If no container objects were selected,                                      |
  516. |  notify the user.                                                           |
  517. -----------------------------------------------------------------------------*/
  518.          else
  519.          {
  520.             IMessageBox
  521.                warning( owner() );
  522.             warning.show( STR_MSG_CHANGE,
  523.                           IMessageBox::enterButton
  524.                           | IMessageBox::informationIcon );
  525.          }
  526.  
  527. /*-----------------------------------------------------------------------------
  528. | Deselect any container objects.                                             |
  529. -----------------------------------------------------------------------------*/
  530.          unMark();
  531.          rc = true;
  532.          break;
  533.       }
  534.  
  535. /*-----------------------------------------------------------------------------
  536. | User pressed the ADD button.                                                |
  537. | Add the entryfield information to the database and container.               |
  538. | Reset the entryfields.                                                      |
  539. -----------------------------------------------------------------------------*/
  540.       case ID_BUTTON_ADD:
  541.       {
  542.          if ( theUser.length() )
  543.          {
  544.             addAcct( theUser, theNode );
  545.             userId.setText( "" );
  546.             nodeSys.setText( "" );
  547.          }
  548.  
  549. /*-----------------------------------------------------------------------------
  550. | Deselect any container objects.                                             |
  551. -----------------------------------------------------------------------------*/
  552.          unMark();
  553.          rc = true;
  554.          break;
  555.       }
  556.  
  557. /*-----------------------------------------------------------------------------
  558. | User pressed the HELP button.                                               |
  559. | Show the help for the account page.                                         |
  560. -----------------------------------------------------------------------------*/
  561.       case ID_BUTTON_HELP:
  562.       {
  563.          IHelpWindow::helpWindow( this )->
  564.             show( IResourceId( ID_ACCOUNT_PAGE ) );
  565.          rc = true;
  566.          break;
  567.       }
  568.  
  569.    }
  570.  
  571.    return rc;
  572. };
  573.  
  574.  
  575. /******************************************************************************
  576. * Class AccountPage :: addAcct - Add the account information to the container *
  577. ******************************************************************************/
  578. IBase::Boolean AccountPage::addAcct( IString& user, IString& node )
  579. {
  580.    Boolean
  581.       rc = true;
  582.  
  583. /*-----------------------------------------------------------------------------
  584. | Create a container text cursor based on the user ID.                        |
  585. -----------------------------------------------------------------------------*/
  586.    IContainerControl::TextCursor
  587.       txtCur( *pCnr, IString( user ), true, false, true );
  588.  
  589. /*-----------------------------------------------------------------------------
  590. | Start at the beginning of the cursor.                                       |
  591. | If the cursor contains a duplicate, set the return code to false.           |
  592. -----------------------------------------------------------------------------*/
  593.    for ( txtCur.setToFirst();
  594.          txtCur.isValid();
  595.          txtCur.setToNext() )
  596.    {
  597.       if ( ( (AcctCnrObj*) txtCur.current() )->getNode() == node )
  598.       {
  599.          rc = false;
  600.          break;
  601.       }
  602.    }
  603.  
  604. /*-----------------------------------------------------------------------------
  605. | If the object doesn't exist,                                                |
  606. |  Add the object to the database.                                            |
  607. |  Create an account container object.                                        |
  608. |  Add the object to the container.                                           |
  609. |  Refresh the container.                                                     |
  610. -----------------------------------------------------------------------------*/
  611.    if ( rc )
  612.    {
  613.       if ( isAquery )
  614.       {
  615.          if ( ! user.length() )
  616.             user = "*";
  617.          if ( ! node.length() )
  618.             node = "*";
  619.       }
  620.  
  621.       acctData.putItem( user, node, LAcctData::add );
  622.       pAcctCnrObj = new AcctCnrObj( user, node );
  623.       pCnr->addObject( pAcctCnrObj );
  624.       pCnr->refresh();
  625.    }
  626.  
  627.    return rc;
  628. }
  629.  
  630. /******************************************************************************
  631. * Class AccountPage :: changeAcct - Change the account information for the    *
  632. *  selected container object.                                                 *
  633. ******************************************************************************/
  634. IBase::Boolean AccountPage::changeAcct( IString& user, IString& node,
  635.                                         AcctCnrObj* pCnrObj )
  636. {
  637.    Boolean
  638.       rc = true;
  639.  
  640. /*-----------------------------------------------------------------------------
  641. | Create a container text cursor based on the user ID.                        |
  642. -----------------------------------------------------------------------------*/
  643.    IContainerControl::TextCursor
  644.       txtCur( *pCnr, IString( user ), true, false, true );
  645.  
  646. /*-----------------------------------------------------------------------------
  647. | Start at the beginning of the cursor.                                       |
  648. | If the cursor contains a duplicate, set the return code to false.           |
  649. -----------------------------------------------------------------------------*/
  650.    for ( txtCur.setToFirst();
  651.          txtCur.isValid();
  652.          txtCur.setToNext() )
  653.    {
  654.       if ( ( (AcctCnrObj*) txtCur.current() )->getNode() == node )
  655.       {
  656.          rc = false;
  657.          break;
  658.       }
  659.    }
  660.  
  661. /*-----------------------------------------------------------------------------
  662. | If the container object exists -and- the user-ID/node combination do        |
  663. |  not exist,                                                                 |
  664. |  Set the container object's user ID and node.                               |
  665. |  Reset the entryfields.                                                     |
  666. |  Deselect the container objects.                                            |
  667. -----------------------------------------------------------------------------*/
  668.    if ( pCnrObj && rc )
  669.    {
  670.       pCnrObj->setUserId( user );
  671.       pCnrObj->setNode( node );
  672.  
  673.    }
  674.  
  675.    return rc;
  676. }
  677.  
  678. /******************************************************************************
  679. * Class AccountPage :: unMark - Deselect the selected container objects.      *
  680. ******************************************************************************/
  681. AccountPage& AccountPage::unMark()
  682. {
  683.    IContainerControl::ObjectCursor
  684.       co ( *pCnr );
  685.  
  686.    for ( co.setToFirst();
  687.          co.isValid();
  688.          co.setToNext() )
  689.    {
  690.       try
  691.       {
  692.          pCnr->removeSelected( pCnr->objectAt( co ) );
  693.       }
  694.       catch ( IException& exc )
  695.       {}
  696.    }
  697.  
  698.    return *this;
  699. };
  700.  
  701.  
  702. /******************************************************************************
  703. * Class AcctCnrObj :: AcctCnrObj - Constructor for account container objects  *
  704. *                                                                             *
  705. * Define yourself as a container object.                                      *
  706. * Set the current user ID in your private data.                               *
  707. * Set the node in your private data.                                          *
  708. ******************************************************************************/
  709. AcctCnrObj::AcctCnrObj( const IString& stCurrentUserId,
  710.                         const IString& stNodeSystem )
  711.      :IContainerObject(),
  712.       currentUserId( stCurrentUserId ),
  713.       nodeSystem( stNodeSystem )
  714. {};
  715.  
  716.  
  717. /******************************************************************************
  718. * Class AcctCnrObj :: ~AcctCnrObj - Destructor for account container objects  *
  719. ******************************************************************************/
  720. AcctCnrObj::~AcctCnrObj()
  721. {};
  722.