Esempio n. 1
0
void financialLayout::sFillList()
{
  XSqlQuery financialFillList;
  int pId = -1, pType = -1;

  XTreeWidgetItem * item = (XTreeWidgetItem*)(_layout->currentItem());
  if(0 != item)
  {
    pId = item->id();
    pType = item->altId();
  }

  _layout->clear();
  _lastStack.clear();
  _last = 0;
  if (_adHoc->isChecked())
  {
    insertFlGroupAdHoc(-1, "", 0, pId, pType);
  }
  else
  {
    insertFlGroup(-1, "", 0, pId, pType);
   }
  _layout->expandAll();

  item = (XTreeWidgetItem*)(_layout->currentItem());
  if(0 != item)
    _layout->scrollToItem(item);

  financialFillList.prepare ("SELECT flcol_id, flcol_name, flcol_descrip "
             " FROM flcol "
             " WHERE flcol_flhead_id=:flhead_id "
             " ORDER BY flcol_name, flcol_descrip; ");
  financialFillList.bindValue(":flhead_id", _flheadid);
  financialFillList.exec();
  _layouts->populate(financialFillList);
  if (financialFillList.lastError().type() != QSqlError::NoError)
  {
    systemError(this, financialFillList.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }
}
Esempio n. 2
0
void financialLayout::sFillList()
{
  int pId = -1, pType = -1;

  XTreeWidgetItem * item = (XTreeWidgetItem*)(_layout->currentItem());
  if(0 != item)
  {
    pId = item->id();
    pType = item->altId();
  }

  _layout->clear();
  _lastStack.clear();
  _last = 0;
  if (_adHoc->isChecked())
  {
    insertFlGroupAdHoc(-1, "", 0, pId, pType);
  }
  else
  {
    insertFlGroup(-1, "", 0, pId, pType);
   }
  _layout->expandAll();

  item = (XTreeWidgetItem*)(_layout->currentItem());
  if(0 != item)
    _layout->scrollToItem(item);

// fill Column layouts
  _layouts->clear();
  q.prepare ("SELECT flcol_id, flcol_name, flcol_descrip "
             " FROM flcol "
             " WHERE flcol_flhead_id=:flhead_id "
             " ORDER BY flcol_name, flcol_descrip; ");
  q.bindValue(":flhead_id", _flheadid);
  q.exec();
  if (q.first())
    _layouts->populate(q);
}
Esempio n. 3
0
void financialLayout::insertFlGroup(int pFlgrpid, QString pFlgrpname, XTreeWidgetItem *pParent, int pId, int pType)
{
  XTreeWidgetItem *root = 0;
  XSqlQuery thisLevel;

  if (pFlgrpid != -1)
  {
    thisLevel.prepare("SELECT CASE WHEN(flgrp_summarize) THEN 'Summarized'"
                      "            WHEN(flgrp_subtotal) THEN 'Subtotal'"
                      "            ELSE ''"
                      "       END AS summary,"
                      "       flgrp_subtract as subtract "
                      "  FROM flgrp"
                      " WHERE ((flgrp_id=:flgrp_id)"
                      "   AND  (flgrp_flhead_id=:flhead_id) ); ");
    thisLevel.bindValue(":flgrp_id", pFlgrpid);
    thisLevel.bindValue(":flhead_id", _flheadid);
    thisLevel.exec();
    thisLevel.first();
    if (pParent)
      _last = root = new XTreeWidgetItem(pParent, _last, pFlgrpid, cFlGroup, pFlgrpname,
                               thisLevel.value("summary").toString(),
                               ( thisLevel.value("subtract").toBool() ? tr("-") : tr("+") ) );
    else
      _last = root = new XTreeWidgetItem(_layout, _last, pFlgrpid, cFlGroup, pFlgrpname,
                               thisLevel.value("summary").toString(),
                               ( thisLevel.value("subtract").toBool() ? tr("-") : tr("+") ) );

    if ( (pFlgrpid == pId) && (pType == cFlGroup) )
    {
      _layout->setCurrentItem(root);
      _layout->scrollToItem(root);
    }

    _lastStack.push(_last);
    _last = 0;
  }

  thisLevel.prepare( "SELECT flgrp_id AS id, :group AS type, flgrp_order AS orderby,"
                     "       flgrp_name AS name,"
                     "       flgrp_subtract AS subtract "
                     "FROM flgrp "
                     "WHERE ( (flgrp_flgrp_id=:flgrp_id)"
                     " AND (flgrp_flhead_id=:flhead_id) ) "

                     "UNION SELECT flitem_id AS id, :item AS type, flitem_order AS orderby,"
                     "             formatflitemdescrip(flitem_id) AS name,"
                     "             flitem_subtract AS subtract "
                     "FROM flitem "
                     "WHERE (flitem_flgrp_id=:flgrp_id) "

                     "UNION SELECT flspec_id AS id, :spec AS type, flspec_order AS orderby,"
                     "             flspec_name AS name,"
                     "             flspec_subtract AS subtract "
                     "FROM flspec "
                     "WHERE (flspec_flgrp_id=:flgrp_id) "

                     "ORDER BY orderby;" );
  thisLevel.bindValue(":group", cFlGroup);
  thisLevel.bindValue(":item", cFlItem);
  thisLevel.bindValue(":spec", cFlSpec);
  thisLevel.bindValue(":flgrp_id", pFlgrpid);
  thisLevel.bindValue(":flhead_id", _flheadid);
  thisLevel.exec();
  while (thisLevel.next())
  {
    if (thisLevel.value("type").toInt() == cFlGroup)
      insertFlGroup(thisLevel.value("id").toInt(), thisLevel.value("name").toString(), root, pId, pType);
    else if (pFlgrpid != -1)
    {
      _last = new XTreeWidgetItem( root, _last,
                                thisLevel.value("id").toInt(), thisLevel.value("type").toInt(),
                                thisLevel.value("name"), "",
                                ( thisLevel.value("subtract").toBool() ? tr("-") : tr("+") ) );

      if ( (thisLevel.value("id").toInt() == pId) && (thisLevel.value("type").toInt() == pType) )
      {
        _layout->setCurrentItem(_last);
        _layout->scrollToItem(root);
      }
    }
  }

  _last = _lastStack.pop();
}