Esempio n. 1
0
void financialLayout::populate()
{
  XSqlQuery financialpopulate;
  financialpopulate.prepare( "SELECT flhead_name, flhead_descrip, flhead_showtotal,"
             "       flhead_showstart, flhead_showend,"
             "       flhead_showdelta, flhead_showbudget, flhead_showdiff,"
             "       flhead_showcustom, flhead_type, flhead_active, "
             "       flhead_custom_label,"
             "       flhead_usealtbegin, flhead_altbegin,"
             "       flhead_usealtend, flhead_altend,"
             "       flhead_usealtdebits, flhead_altdebits,"
             "       flhead_usealtcredits, flhead_altcredits,"
             "       flhead_usealtbudget, flhead_altbudget,"
             "       flhead_usealtdiff, flhead_altdiff,"
             "       flhead_usealttotal, flhead_alttotal, "
             "       flhead_notes "
             "FROM flhead "
             "WHERE (flhead_id=:flhead_id);" );
  financialpopulate.bindValue(":flhead_id", _flheadid);
  financialpopulate.exec();
  if (financialpopulate.first())
  {
    _name->setText(financialpopulate.value("flhead_name").toString());
    _descrip->setText(financialpopulate.value("flhead_descrip").toString());
    _notes->setPlainText(financialpopulate.value("flhead_notes").toString());
    if(_showTotal->isChecked())
    {
      _showStart->setChecked(financialpopulate.value("flhead_showstart").toBool());
      _showEnd->setChecked(financialpopulate.value("flhead_showend").toBool());
      _showDelta->setChecked(financialpopulate.value("flhead_showdelta").toBool());
      _showBudget->setChecked(financialpopulate.value("flhead_showbudget").toBool());
      _showDiff->setChecked(financialpopulate.value("flhead_showdiff").toBool());
      _showCustom->setChecked(financialpopulate.value("flhead_showcustom").toBool());
    }
    if ( financialpopulate.value("flhead_type").toString() == "I" )
    {
      _showGrandTotal->setChecked(financialpopulate.value("flhead_showtotal").toBool());
      _cachedType = cIncome;
      _income->setChecked(true);
    }
    else if ( financialpopulate.value("flhead_type").toString() == "B" )
    {
      _showGrandTotal->setChecked(financialpopulate.value("flhead_showtotal").toBool());
      _cachedType = cBalance;
      _balance->setChecked(true);
    }
    else if ( financialpopulate.value("flhead_type").toString() == "C" )
    {
      _showGrandTotal->setChecked(financialpopulate.value("flhead_showtotal").toBool());
      _cachedType = cCash;
      _cash->setChecked(true);
    }
    else if ( financialpopulate.value("flhead_type").toString() == "A" )
    {
      _showTotal->setChecked(financialpopulate.value("flhead_showtotal").toBool());
      _cachedType = cAdHoc;
      _adHoc->setChecked(true);
    }
    _active->setChecked(financialpopulate.value("flhead_active").toBool());
    _customText->setText(financialpopulate.value("flhead_custom_label").toString());
    _altTotal->setChecked(financialpopulate.value("flhead_usealttotal").toBool());
    _altTotalText->setText(financialpopulate.value("flhead_alttotal").toString());
    _altBegin->setChecked(financialpopulate.value("flhead_usealtbegin").toBool());
    _altBeginText->setText(financialpopulate.value("flhead_altbegin").toString());
    _altEnd->setChecked(financialpopulate.value("flhead_usealtend").toBool());
    _altEndText->setText(financialpopulate.value("flhead_altend").toString());
    _altDebits->setChecked(financialpopulate.value("flhead_usealtdebits").toBool());
    _altDebitsText->setText(financialpopulate.value("flhead_altdebits").toString());
    _altCredits->setChecked(financialpopulate.value("flhead_usealtcredits").toBool());
    _altCreditsText->setText(financialpopulate.value("flhead_altcredits").toString());
    _altBudget->setChecked(financialpopulate.value("flhead_usealtbudget").toBool());
    _altBudgetText->setText(financialpopulate.value("flhead_altbudget").toString());
    _altDiff->setChecked(financialpopulate.value("flhead_usealtdiff").toBool());
    _altDiffText->setText(financialpopulate.value("flhead_altdiff").toString());
  }
  else if (financialpopulate.lastError().type() != QSqlError::NoError)
  {
    systemError(this, financialpopulate.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }
  
  sSetType();
}
Esempio n. 2
0
enum SetResponse financialLayout::set(const ParameterList &pParams)
{
  XSqlQuery financialet;
  XDialog::set(pParams);
  QVariant param;
  bool     valid;

  param = pParams.value("flhead_id", &valid);
  if (valid)
  {
    _flheadid = param.toInt();
    populate();
  }

  param = pParams.value("mode", &valid);
  if (valid)
  {
    if (param.toString() == "new")
    {
      _mode = cNew;
      
      financialet.prepare("SELECT NEXTVAL('flhead_flhead_id_seq') AS flhead_id;");
      financialet.exec();
      if (financialet.first())
      {
        _flheadid = financialet.value("flhead_id").toInt();
        financialet.prepare("INSERT INTO flhead (flhead_id) values(:flhead_id);");
        financialet.bindValue(":flhead_id", _flheadid);
        financialet.exec();
      }
      
      sSetType();
//  ToDo
    }
    /*else if (param.toString() == "edit")
    {
      _mode = cEdit;

      _view->setHidden(TRUE);
      _viewCol->setHidden(TRUE);
    }*/
    else if (param.toString() == "view")
    {
      _mode = cView;

      _name->setEnabled(FALSE);
      _descrip->setEnabled(FALSE);
      _showTotal->setEnabled(FALSE);
      _showGrandTotal->setEnabled(FALSE);
      _altLabels->setEnabled(FALSE);
      _addTopLevelGroup->setHidden(TRUE);
      _addGroup->setHidden(TRUE);
      _addAccount->setHidden(TRUE);
      _edit->setHidden(TRUE);
      _delete->setHidden(TRUE);
      _moveUp->setHidden(TRUE);
      _moveDown->setHidden(TRUE);
      _reportType->setEnabled(FALSE);
      _addCol->setHidden(TRUE);
      _editCol->setHidden(TRUE);
      _deleteCol->setHidden(TRUE);
    }
  }

  return NoError;
}
Esempio n. 3
0
void financialLayout::populate()
{
  q.prepare( "SELECT flhead_name, flhead_descrip, flhead_showtotal,"
             "       flhead_showstart, flhead_showend,"
             "       flhead_showdelta, flhead_showbudget, flhead_showdiff,"
             "       flhead_showcustom, flhead_type, flhead_active, "
             "       flhead_custom_label,"
             "       flhead_usealtbegin, flhead_altbegin,"
             "       flhead_usealtend, flhead_altend,"
             "       flhead_usealtdebits, flhead_altdebits,"
             "       flhead_usealtcredits, flhead_altcredits,"
             "       flhead_usealtbudget, flhead_altbudget,"
             "       flhead_usealtdiff, flhead_altdiff,"
             "       flhead_usealttotal, flhead_alttotal "
             "FROM flhead "
             "WHERE (flhead_id=:flhead_id);" );
  q.bindValue(":flhead_id", _flheadid);
  q.exec();
  if (q.first())
  {
    _name->setText(q.value("flhead_name").toString());
    _descrip->setText(q.value("flhead_descrip").toString());
    if(_showTotal->isChecked())
    {
      _showStart->setChecked(q.value("flhead_showstart").toBool());
      _showEnd->setChecked(q.value("flhead_showend").toBool());
      _showDelta->setChecked(q.value("flhead_showdelta").toBool());
      _showBudget->setChecked(q.value("flhead_showbudget").toBool());
      _showDiff->setChecked(q.value("flhead_showdiff").toBool());
      _showCustom->setChecked(q.value("flhead_showcustom").toBool());
    }
    if ( q.value("flhead_type").toString() == "I" )
    {
      _showGrandTotal->setChecked(q.value("flhead_showtotal").toBool());
      _cachedType = cIncome;
      _income->setChecked(true);
    }
    else if ( q.value("flhead_type").toString() == "B" )
    {
      _showGrandTotal->setChecked(q.value("flhead_showtotal").toBool());
      _cachedType = cBalance;
      _balance->setChecked(true);
    }
    else if ( q.value("flhead_type").toString() == "C" )
    {
      _showGrandTotal->setChecked(q.value("flhead_showtotal").toBool());
      _cachedType = cCash;
      _cash->setChecked(true);
    }
    else if ( q.value("flhead_type").toString() == "A" )
    {
      _showTotal->setChecked(q.value("flhead_showtotal").toBool());
      _cachedType = cAdHoc;
      _adHoc->setChecked(true);
    }
    _active->setChecked(q.value("flhead_active").toBool());
    _customText->setText(q.value("flhead_custom_label").toString());
    _altTotal->setChecked(q.value("flhead_usealttotal").toBool());
    _altTotalText->setText(q.value("flhead_alttotal").toString());
    _altBegin->setChecked(q.value("flhead_usealtbegin").toBool());
    _altBeginText->setText(q.value("flhead_altbegin").toString());
    _altEnd->setChecked(q.value("flhead_usealtend").toBool());
    _altEndText->setText(q.value("flhead_altend").toString());
    _altDebits->setChecked(q.value("flhead_usealtdebits").toBool());
    _altDebitsText->setText(q.value("flhead_altdebits").toString());
    _altCredits->setChecked(q.value("flhead_usealtcredits").toBool());
    _altCreditsText->setText(q.value("flhead_altcredits").toString());
    _altBudget->setChecked(q.value("flhead_usealtbudget").toBool());
    _altBudgetText->setText(q.value("flhead_altbudget").toString());
    _altDiff->setChecked(q.value("flhead_usealtdiff").toBool());
    _altDiffText->setText(q.value("flhead_altdiff").toString());
  }
//  ToDo
  
  sSetType();
}