Esempio n. 1
0
void dspCheckRegister::sFillList()
{
  MetaSQLQuery mql = mqlLoad(":/ap/displays/CheckRegister/FillListDetail.mql");

  ParameterList params;
  if (!setParams(params))
    return;
  
  q = mql.toQuery(params);
  if (q.lastError().type() != QSqlError::None)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }
  
  _check->clear();
  XTreeWidgetItem *header = NULL;
  int           checkid = -1;
  while (q.next())
  {
    if (q.value("checkid").toInt() != checkid)
    {
      checkid = q.value("checkid").toInt();
      header = new XTreeWidgetItem( _check, header, checkid, q.value("extra").toInt(),
				  q.value("f_void"), q.value("f_misc"),
				  q.value("f_printed"), q.value("f_posted"), q.value("number"),
				  q.value("description"), q.value("f_checkdate"),
				  q.value("f_amount"), q.value("currAbbr"));
    }
    else if (header)
    {
      XTreeWidgetItem *item = new XTreeWidgetItem( header, checkid, 0);
      item->setText(4, q.value("number"));
      item->setText(5, q.value("description"));
      item->setText(7, q.value("f_amount"));
    }
  }
  if (q.lastError().type() != QSqlError::None)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }

  if(_showDetail->isChecked())
    _check->expandAll();
	
    QString tots("SELECT formatMoney(SUM(currToCurr(checkhead_curr_id,"
	       "									bankaccnt_curr_id,"
	       "									checkhead_amount,"
	       "									checkhead_checkdate))) AS f_amount,"
	       "									currConcat(bankaccnt_curr_id) AS currAbbr "
	       "FROM checkhead, bankaccnt "
	       "WHERE ((NOT checkhead_void)"
	       " AND (checkhead_checkdate BETWEEN <? value(\"startDate\") ?> AND <? value(\"endDate\") ?>) "
	       " AND (bankaccnt_id=checkhead_bankaccnt_id) "
	       " AND (checkhead_bankaccnt_id=<? value(\"bankaccnt_id\") ?>)" 
		   " <? if exists(\"check_number\") ?>"
           " AND   (checkhead_number=<? value(\"check_number\") ?>)"
           " <? endif ?>"
           " <? if exists(\"recip\") ?>"
           " <? if exists(\"recip_type_v\") ?>"
           " AND   (checkhead_recip_type = 'V' )"
           " <? endif ?>"
           " <? if exists(\"recip_type_c\") ?>"
           " AND   (checkhead_recip_type = 'C' )"
		   " <? endif ?>"
           " <? if exists(\"recip_type_t\") ?>"
		   " AND   (checkhead_recip_type = 'T' )"
           " <? endif ?>"
           " <? if exists(\"recip_id\") ?>"
           " AND   (checkhead_recip_id = <? value(\"recip_id\") ?> )"
           " <? endif ?>"
           " <? endif ?>)"
	       " GROUP BY bankaccnt_curr_id;" );
  MetaSQLQuery totm(tots);
  q = totm.toQuery(params);	// reused from above
  if(q.first())
  {
    _total->setText(q.value("f_amount").toString());
    _totalCurr->setText(q.value("currAbbr").toString());
  }
  else if (q.lastError().type() != QSqlError::None)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }
}
Esempio n. 2
0
void dspCheckRegister::sFillList()
{
  MetaSQLQuery mql = mqlLoad("checkRegister", "detail");

  ParameterList params;
  if (!setParams(params))
    return;
  
  q = mql.toQuery(params);
  _check->populate(q, true);
  if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }

  if(_showDetail->isChecked())
    _check->expandAll();
	
  QString tots("SELECT SUM(currToCurr(checkhead_curr_id, bankaccnt_curr_id,"
               "           checkhead_amount, checkhead_checkdate)) AS amount, "
               "       currConcat(bankaccnt_curr_id) AS currAbbr "
               "  FROM bankaccnt LEFT OUTER JOIN"
               "       checkhead ON ((bankaccnt_id=checkhead_bankaccnt_id)"
               "                AND  (checkhead_checkdate BETWEEN <? value(\"startDate\") ?> AND <? value(\"endDate\") ?> ) "
               "                AND  (NOT checkhead_void)"
               " <? if exists(\"check_number\") ?>"
               " AND   (CAST(checkhead_number AS text) ~ <? value(\"check_number\") ?>)"
               " <? endif ?>"
               " <? if exists(\"recip\") ?>"
               " <? if exists(\"recip_type_v\") ?>"
               " AND   (checkhead_recip_type = 'V' )"
               " <? endif ?>"
               " <? if exists(\"recip_type_c\") ?>"
               " AND   (checkhead_recip_type = 'C' )"
               " <? endif ?>"
               " <? if exists(\"recip_type_t\") ?>"
               " AND   (checkhead_recip_type = 'T' )"
               " <? endif ?>"
               " <? if exists(\"recip_id\") ?>"
               " AND   (checkhead_recip_id = <? value(\"recip_id\") ?> )"
               " <? endif ?>"
               " <? endif ?>)"
               "       LEFT OUTER JOIN "
               "       checkrecip ON ((checkhead_recip_id=checkrecip_id) "
               "                 AND  (checkhead_recip_type=checkrecip_type)) "
               " WHERE(bankaccnt_id=<? value(\"bankaccnt_id\") ?>)  "
               "GROUP BY bankaccnt_curr_id;" );
  MetaSQLQuery totm(tots);
  q = totm.toQuery(params);	// reused from above
  if(q.first())
  {
    _total->setDouble(q.value("amount").toDouble());
    _totalCurr->setText(q.value("currAbbr").toString());
  }
  else if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }
}
Esempio n. 3
0
void dspCheckRegister::sFillList()
{
  XSqlQuery dspFillList;
  MetaSQLQuery mql = mqlLoad("checkRegister", "detail");

  ParameterList params;
  if (!setParams(params))
    return;
  
  dspFillList = mql.toQuery(params);
  _check->populate(dspFillList, true);
  if (ErrorReporter::error(QtCriticalMsg, this, tr("Error Retrieving Check Register Information"),
                                dspFillList, __FILE__, __LINE__))
  {
    return;
  }

  if(_showDetail->isChecked())
    _check->expandAll();
	
  QString tots("SELECT SUM(currToCurr(checkhead_curr_id, bankaccnt_curr_id,"
               "           checkhead_amount, checkhead_checkdate)) AS amount, "
               "       currConcat(bankaccnt_curr_id) AS currAbbr "
               "  FROM bankaccnt LEFT OUTER JOIN"
               "       checkhead ON ((bankaccnt_id=checkhead_bankaccnt_id)"
               "                AND  (checkhead_checkdate BETWEEN <? value(\"startDate\") ?> AND <? value(\"endDate\") ?> ) "
               "                AND  (NOT checkhead_void)"
               " <? if exists(\"check_number\") ?>"
               " AND   (CAST(checkhead_number AS text) ~ <? value(\"check_number\") ?>)"
               " <? endif ?>"
               " <? if exists(\"recip\") ?>"
               " <? if exists(\"recip_type_v\") ?>"
               " AND   (checkhead_recip_type = 'V' )"
               " <? endif ?>"
               " <? if exists(\"recip_type_c\") ?>"
               " AND   (checkhead_recip_type = 'C' )"
               " <? endif ?>"
               " <? if exists(\"recip_type_t\") ?>"
               " AND   (checkhead_recip_type = 'T' )"
               " <? endif ?>"
               " <? if exists(\"recip_id\") ?>"
               " AND   (checkhead_recip_id = <? value(\"recip_id\") ?> )"
               " <? endif ?>"
               " <? endif ?>)"
               "       LEFT OUTER JOIN "
               "       checkrecip ON ((checkhead_recip_id=checkrecip_id) "
               "                 AND  (checkhead_recip_type=checkrecip_type)) "
               " WHERE(bankaccnt_id=<? value(\"bankaccnt_id\") ?>)  "
               "GROUP BY bankaccnt_curr_id;" );
  MetaSQLQuery totm(tots);
  dspFillList = totm.toQuery(params);	// reused from above
  if(dspFillList.first())
  {
    _total->setDouble(dspFillList.value("amount").toDouble());
    _totalCurr->setText(dspFillList.value("currAbbr").toString());
  }
  else if (ErrorReporter::error(QtCriticalMsg, this, tr("Error Retrieving Check Register Information"),
                                dspFillList, __FILE__, __LINE__))
  {
    return;
  }
}