Esempio n. 1
0
void postAPCheck::sPost()
{
  q.prepare( "SELECT apchk_posted FROM apchk WHERE (apchk_id=:apchk_id); ");
  q.bindValue(":apchk_id", _apchk->id());
  q.exec();
  if(q.first() && q.value("apchk_posted").toBool())
  {
    QMessageBox::information( this, tr("Check Already Posted"),
          tr("The selected A/P Check has already been posted.") );
    return;
  }

  q.prepare( "SELECT apchk_bankaccnt_id, postAPCheck(apchk_id) AS result "
             "FROM apchk "
             "WHERE ((apchk_id=:apchk_id)"
             " AND  (NOT apchk_posted) );" );
  q.bindValue(":apchk_id", _apchk->id());
  q.exec();
  if (q.first())
  {
    omfgThis->sAPChecksUpdated(q.value("apchk_bankaccnt_id").toInt(), _apchk->id(), TRUE);

    if (_captive)
      accept();
    else
    {
      sHandleBankAccount(_bankaccnt->id());
      _close->setText(tr("&Close"));
    }
  }
  else if (q.lastError().type() != QSqlError::NoError)
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);

}
Esempio n. 2
0
void printCheck::markCheckAsPrinted(const int pcheckid)
{
  XSqlQuery markq;
  markq.prepare("SELECT checkhead_bankaccnt_id,"
                "       markCheckAsPrinted(checkhead_id) AS result "
                "FROM checkhead "
                "WHERE (checkhead_id=:checkhead_id);" );
  markq.bindValue(":checkhead_id", pcheckid);
  markq.exec();
  if (markq.first())
  {
    int result = markq.value("result").toInt();
    if (result < 0)
    {
      systemError(this, storedProcErrorLookup("markCheckAsPrinted", result),
                  __FILE__, __LINE__);
      return;
    }
    omfgThis->sChecksUpdated(markq.value("checkhead_bankaccnt_id").toInt(),
                             pcheckid, TRUE);

    if (_captive)
      accept();
    else
    {
      sHandleBankAccount(_bankaccnt->id());
      _close->setText(tr("&Close"));
    }
  }
}
Esempio n. 3
0
void postCheck::sPost()
{
  q.prepare( "SELECT checkhead_bankaccnt_id,"
	     "       postCheck(checkhead_id, NULL) AS result "
             "FROM checkhead "
             "WHERE ((checkhead_id=:checkhead_id)"
             " AND  (NOT checkhead_posted) );" );
  q.bindValue(":checkhead_id", _check->id());
  q.exec();
  if (q.first())
  {
    int result = q.value("result").toInt();
    if (result < 0)
    {
      systemError(this, storedProcErrorLookup("postCheck", result),
		  __FILE__, __LINE__);
      return;
    }
    omfgThis->sChecksUpdated(q.value("checkhead_bankaccnt_id").toInt(), _check->id(), TRUE);

    if (_captive)
      accept();
    else
    {
      sHandleBankAccount(_bankaccnt->id());
      _close->setText(tr("&Close"));
    }
  }
  else if (q.lastError().type() != QSqlError::None)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }
}
Esempio n. 4
0
postCheck::postCheck(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl)
    : XDialog(parent, name, modal, fl)
{
  setupUi(this);

  connect(_post, SIGNAL(clicked()), this, SLOT(sPost()));
  connect(_bankaccnt, SIGNAL(newID(int)), this, SLOT(sHandleBankAccount(int)));

  _captive = false;

  _check->setAllowNull(true);

  _bankaccnt->setType(XComboBox::APBankAccounts);
  sHandleBankAccount(_bankaccnt->id());
}
Esempio n. 5
0
postChecks::postChecks(QWidget* parent, const char* name, bool modal, Qt::WFlags fl)
    : XDialog(parent, name, modal, fl)
{
  setupUi(this);

  connect(_post, SIGNAL(clicked()), this, SLOT(sPost()));
  connect(_bankaccnt, SIGNAL(newID(int)), this, SLOT(sHandleBankAccount(int)));

  _numberOfChecks->setPrecision(0);

  sHandleBankAccount(_bankaccnt->id());

  if (_preferences->boolean("XCheckBox/forgetful"))
    _printJournal->setChecked(true);

}
printCheck::printCheck(QWidget* parent, const char* name, Qt::WindowFlags fl)
    : XWidget(parent, name, fl)
{
  setupUi(this);

  connect(_bankaccnt, SIGNAL(newID(int)), this, SLOT(sHandleBankAccount(int)));
  connect(_check,     SIGNAL(newID(int)), this, SLOT(sEnableCreateEFT()));
  connect(_createEFT, SIGNAL(clicked()),  this, SLOT(sCreateEFT()));
  connect(_print,     SIGNAL(clicked()),  this, SLOT(sPrint()));
  connect(_printed,   SIGNAL(clicked()),  this, SLOT(sPrintedAlready()));

  _captive = false;
  _setCheckNumber = -1;

  _check->setAllowNull(true);

  _bankaccnt->setType(XComboBox::APBankAccounts);
  sHandleBankAccount(_bankaccnt->id());

  _createEFT->setVisible(_metrics->boolean("ACHSupported") && _metrics->boolean("ACHEnabled"));
}
Esempio n. 7
0
void printCheck::sPrint()
{
  if (_createACH->isEnabled() &&
      QMessageBox::question(this, tr("Print Anyway?"),
                            tr("<p>The recipient of this check has been "
                               "configured for ACH transactions. Do you want "
                               "to print this check for them anyway?<p>If you "
                               "answer 'Yes' then a check will be printed. "
                               "If you say 'No' then you should click Create "
                               "ACH File."),
                            QMessageBox::Yes | QMessageBox::Default,
                            QMessageBox::No) == QMessageBox::No)
    return;
  q.prepare( "SELECT checkhead_printed, report_name, bankaccnt_id "
             "FROM checkhead, bankaccnt, form, report "
             "WHERE ((checkhead_bankaccnt_id=bankaccnt_id)"
             "  AND  (bankaccnt_check_form_id=form_id)"
             "  AND  (form_report_id=report_id)"
             "  AND  (checkhead_id=:checkhead_id) );" );
  q.bindValue(":checkhead_id", _check->id());
  q.exec();
  if (q.first())
  {
    if(q.value("checkhead_printed").toBool())
    {
      QMessageBox::information( this, tr("Check Already Printed"),
		    tr("<p>The selected Check has already been printed.") );
      return;
    }
    QString reportname = q.value("report_name").toString();

// get the report definition out of the database
// this should somehow be condensed into a common code call or something
// in the near future to facilitate easier conversion in other places
// of the application to use the new rendering engine directly
    XSqlQuery report;
    report.prepare( "SELECT report_source "
                    "  FROM report "
                    " WHERE (report_name=:report_name) "
                    "ORDER BY report_grade DESC LIMIT 1;" );
    report.bindValue(":report_name", reportname);
    report.exec();
    QDomDocument docReport;
    if (report.first())
    {
      QString errorMessage;
      int     errorLine;
  
      if (!docReport.setContent(report.value("report_source").toString(), &errorMessage, &errorLine))
      {
        systemError(this, errorMessage, __FILE__, __LINE__);
        return;
      }
    }
    else
    {
      systemError(this, report.lastError().databaseText(), __FILE__, __LINE__);
      return;
    }
// end getting the report definition out the database

    if(_setCheckNumber != -1 && _setCheckNumber != _nextCheckNum->text().toInt())
    {
      q.prepare("SELECT setNextCheckNumber(:bankaccnt_id, :nextCheckNumber) AS result;");
      q.bindValue(":bankaccnt_id", _bankaccnt->id());
      q.bindValue(":nextCheckNumber", _nextCheckNum->text().toInt());
      q.exec();
      if (q.first())
      {
        int result = q.value("result").toInt();
        if (result < 0)
        {
          systemError(this, storedProcErrorLookup("setNextCheckNumber", result),
                      __FILE__, __LINE__);
          return;
        }
      }
      else if (q.lastError().type() != QSqlError::NoError)
      {
        systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
        return;
      }
    }

    q.prepare("UPDATE checkhead SET checkhead_number=fetchNextCheckNumber(checkhead_bankaccnt_id)"
              " WHERE(checkhead_id=:checkhead_id);");
    q.bindValue(":checkhead_id", _check->id());
    q.exec();
    if (q.lastError().type() != QSqlError::NoError)
    {
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
      return;
    }

    ParameterList params;

    params.append("checkhead_id", _check->id());
    params.append("apchk_id", _check->id());

// replace with new renderer code so we can get a page count
    ORPreRender pre;
    pre.setDom(docReport);
    pre.setParamList(params);
    ORODocument * doc = pre.generate();

    QPrinter printer(QPrinter::HighResolution);
    ORPrintRender render;
    render.setupPrinter(doc, &printer);

    QPrintDialog pd(&printer);
    pd.setMinMax(1, doc->pages());
    if(pd.exec() == XDialog::Accepted)
    {
      render.setPrinter(&printer);
      render.render(doc);
    }
    else
      return;

    int page_num = 1;
    while(page_num < doc->pages())
    {
      page_num++;

      XSqlQuery qq;
      qq.prepare("INSERT INTO checkhead"
                 "      (checkhead_recip_id, checkhead_recip_type,"
                 "       checkhead_bankaccnt_id, checkhead_printed,"
                 "       checkhead_checkdate, checkhead_number,"
                 "       checkhead_amount, checkhead_void,"
                 "       checkhead_misc,"
                 "       checkhead_for, checkhead_notes,"
                 "       checkhead_curr_id, checkhead_deleted) "
                 "SELECT checkhead_recip_id, checkhead_recip_type,"
                 "       checkhead_bankaccnt_id, TRUE,"
                 "       checkhead_checkdate, fetchNextCheckNumber(checkhead_bankaccnt_id),"
                 "       checkhead_amount, TRUE, TRUE,"
                 "       'Continuation of Check #'||checkhead_number,"
                 "       'Continuation of Check #'||checkhead_number,"
                 "       checkhead_curr_id, TRUE"
                 "  FROM checkhead"
                 " WHERE(checkhead_id=:checkhead_id);");
      qq.bindValue(":checkhead_id", _check->id());
      if(!qq.exec())
      {
        systemError(this, "Received error but will continue anyway:\n"+qq.lastError().databaseText(), __FILE__, __LINE__);
      }
    }

    omfgThis->sChecksUpdated(_bankaccnt->id(), _check->id(), TRUE);
  }
  else if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }
  else // join failed
  {
    QMessageBox::critical(this, tr("Cannot Print Check"),
                          tr("<p>The selected Check cannot be printed as the "
			     "Bank Account that it is to draw upon does not "
			     "have a valid Check Format assigned to it. "
			     "Please assign a valid Check Format to this Bank "
			     "Account before attempting to print this Check."));
    return;
  }

  if ( QMessageBox::question( this, tr("Check Printed"),
                             tr("Was the selected Check printed successfully?"),
			     QMessageBox::Yes,
			     QMessageBox::No | QMessageBox::Default) == QMessageBox::Yes)
    markCheckAsPrinted(_check->id());
  else if ( QMessageBox::question(this, tr("Mark Check as Voided"),
                                  tr("<p>Would you like to mark the selected "
				     "Check as Void and create a replacement "
				     "check?"),
				   QMessageBox::Yes,
				   QMessageBox::No | QMessageBox::Default) == QMessageBox::Yes)
  {
    q.prepare("SELECT voidCheck(:checkhead_id) AS result;");
    q.bindValue(":checkhead_id", _check->id());
    q.exec();
    if (q.first())
    {
      int result = q.value("result").toInt();
      if (result < 0)
      {
	systemError(this, storedProcErrorLookup("voidCheck", result),
		    __FILE__, __LINE__);
	return;
      }
    }
    else if (q.lastError().type() != QSqlError::NoError)
    {
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
      return;
    }

    q.prepare( "SELECT checkhead_bankaccnt_id,"
	       "       replaceVoidedCheck(checkhead_id) AS result "
               "FROM checkhead "
               "WHERE (checkhead_id=:checkhead_id);" );
    q.bindValue(":checkhead_id", _check->id());
    q.exec();
    if (q.first())
    {
      int result = q.value("result").toInt();
      if (result < 0)
      {
	systemError(this, storedProcErrorLookup("replaceVoidedCheck", result),
		    __FILE__, __LINE__);
	return;
      }
      omfgThis->sChecksUpdated(q.value("checkhead_bankaccnt_id").toInt(),
			       _check->id(), TRUE);

      sHandleBankAccount(_bankaccnt->id());
      _print->setFocus();
    }
    else if (q.lastError().type() != QSqlError::NoError)
    {
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
      return;
    }
  }
}
Esempio n. 8
0
void printChecks::sPrint()
{
  QList<int> printedChecks;
  bool firstRun = TRUE;

  ParameterList params;
  params.append("bankaccnt_id", _bankaccnt->id());

  bool setup = true;

  QList<ORODocument*> singleCheckPrerendered;
  XSqlQuery checks;
  checks.prepare( "SELECT checkhead_id, checkhead_number, report_name, checkhead_recip_id, checkhead_recip_type "
                  "FROM checkhead "
                  "LEFT OUTER JOIN vendinfo ON((checkhead_recip_id = vend_id) "
                  "                       AND(checkhead_recip_type = 'V')) "
                  "LEFT OUTER JOIN custinfo ON((checkhead_recip_id = cust_id) "
                  "                         AND(checkhead_recip_type = 'C')) "
                  "LEFT OUTER JOIN taxauth ON((checkhead_recip_id = taxauth_id) "
                  "                        AND(checkhead_recip_type = 'T')), "
                  " bankaccnt, form, report "
                  "WHERE ( (checkhead_bankaccnt_id=bankaccnt_id)"
                  " AND (bankaccnt_check_form_id=form_id)"
                  " AND (form_report_id=report_id)"
                  " AND (NOT checkhead_printed) "
                  " AND (NOT checkhead_void) "
                  " AND (bankaccnt_id=:bankaccnt_id) ) "
                  "ORDER BY checkhead_recip_type DESC, COALESCE(vend_number, cust_number, taxauth_code) "
                  "LIMIT :numtoprint; " );
  checks.bindValue(":bankaccnt_id", _bankaccnt->id());
  checks.bindValue(":numtoprint", _numberOfChecks->value());
  checks.exec();
  QDomDocument docReport;

  while (checks.next())
  {
    if (setup)
    {
      // get the report definition out of the database
      // this should somehow be condensed into a common code call or something
      // in the near future to facilitate easier conversion in other places
      // of the application to use the new rendering engine directly
      XSqlQuery report;
      report.prepare( "SELECT report_source "
                      "  FROM report "
                      " WHERE (report_name=:report_name) "
                      "ORDER BY report_grade DESC LIMIT 1;" );
      report.bindValue(":report_name", checks.value("report_name").toString());
      report.exec();
      if (report.first())
      {
        QString errorMessage;
        int     errorLine;

        if (!docReport.setContent(report.value("report_source").toString(), &errorMessage, &errorLine))
        {
          systemError(this, errorMessage, __FILE__, __LINE__);
          return;
        }
      }
      else
      {
        systemError(this, report.lastError().databaseText(), __FILE__, __LINE__);
        return;
      }
      // end getting the report definition out the database

      if(_setCheckNumber != -1 && _setCheckNumber != _nextCheckNum->text().toInt() && firstRun)
      {
        q.prepare("SELECT setNextCheckNumber(:bankaccnt_id, :nextCheckNumber) AS result;");
        q.bindValue(":bankaccnt_id", _bankaccnt->id());
        q.bindValue(":nextCheckNumber", _nextCheckNum->text().toInt());
        q.exec();
        if (q.first())
        {
          int result = q.value("result").toInt();
          if (result < 0)
          {
            systemError(this, storedProcErrorLookup("setNextCheckNumber", result),
                        __FILE__, __LINE__);
            return;
          }
        }
        else if (q.lastError().type() != QSqlError::NoError)
        {
          systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
          return;
        }
       firstRun = FALSE;
      }
    }

    q.prepare("UPDATE checkhead SET checkhead_number=fetchNextCheckNumber(checkhead_bankaccnt_id)"
              " WHERE(checkhead_id=:checkhead_id);");
    q.bindValue(":checkhead_id", checks.value("checkhead_id").toInt());
    q.exec();
    if (q.lastError().type() != QSqlError::NoError)
    {
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
      return;
    }

    ParameterList params;
    params.append("checkhead_id", checks.value("checkhead_id").toInt());
    params.append("apchk_id", checks.value("checkhead_id").toInt());

    ORPreRender pre;
    pre.setDom(docReport);
    pre.setParamList(params);
    ORODocument * doc = pre.generate();

    printedChecks.append(checks.value("checkhead_id").toInt());

    int page_num = 1;
    while(page_num < doc->pages())
    {
      page_num++;

      XSqlQuery qq;
      qq.prepare("INSERT INTO checkhead"
                 "      (checkhead_recip_id, checkhead_recip_type,"
                 "       checkhead_bankaccnt_id, checkhead_printed,"
                 "       checkhead_checkdate, checkhead_number,"
                 "       checkhead_amount, checkhead_void,"
                 "       checkhead_misc,"
                 "       checkhead_for, checkhead_notes,"
                 "       checkhead_curr_id, checkhead_deleted) "
                 "SELECT checkhead_recip_id, checkhead_recip_type,"
                 "       checkhead_bankaccnt_id, TRUE,"
                 "       checkhead_checkdate, fetchNextCheckNumber(checkhead_bankaccnt_id),"
                 "       checkhead_amount, TRUE, TRUE,"
                 "       'Continuation of Check #'||checkhead_number,"
                 "       'Continuation of Check #'||checkhead_number,"
                 "       checkhead_curr_id, TRUE"
                 "  FROM checkhead"
                 " WHERE(checkhead_id=:checkhead_id);");
      qq.bindValue(":checkhead_id", checks.value("checkhead_id").toInt());
      if(!qq.exec())
      {
        systemError(this, "Received error but will continue anyway:\n"+qq.lastError().databaseText(), __FILE__, __LINE__);
      }
    }
    singleCheckPrerendered.append(doc);
  }
  if (checks.lastError().type() != QSqlError::None)
  {
    systemError(this, checks.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }

  if(!printedChecks.empty())
  {
    QPrinter printer(QPrinter::HighResolution);
    ORODocument entireCheckRunPrerendered;
    for (int j = 0; j < singleCheckPrerendered.size(); j++)
    {
      for (int i = 0; i < singleCheckPrerendered.at(j)->pages(); i++)
      {
        entireCheckRunPrerendered.addPage(singleCheckPrerendered.at(j)->page(i));
      }
    }

    ORPrintRender render;
    render.setupPrinter(&entireCheckRunPrerendered, &printer);

    QPrintDialog pd(&printer);
    pd.setMinMax(1, entireCheckRunPrerendered.pages());
    if(pd.exec() != XDialog::Accepted)
      return;
    render.setPrinter(&printer);
    render.render(&entireCheckRunPrerendered);

    QList<int>::iterator it;

    if ( QMessageBox::question(this, tr("All Checks Printed"),
			       tr("<p>Did all the Checks print successfully?"),
				QMessageBox::Yes,
				QMessageBox::No | QMessageBox::Default) == QMessageBox::Yes)
    {
      XSqlQuery postCheck;
      postCheck.prepare( "SELECT markCheckAsPrinted(:checkhead_id) AS result;");
      for( it = printedChecks.begin(); it != printedChecks.end(); ++it)
      {
        postCheck.bindValue(":checkhead_id", (*it));
        postCheck.exec();
	if (postCheck.first())
	{
	  int result = postCheck.value("result").toInt();
	  if (result < 0)
	  {
	    systemError(this, storedProcErrorLookup("markCheckAsPrinted",
						   result), __FILE__, __LINE__);
	    return;
	  }
	}
	else if (postCheck.lastError().type() != QSqlError::None)
	{
	  systemError(this, postCheck.lastError().databaseText(), __FILE__, __LINE__);
	  return;
	}
      }
    }
    else
    {
      printChecksReview newdlg(this, "", TRUE);
      QString query = QString( "SELECT checkhead_id, checkhead_number"
                               "  FROM checkhead"
                               " WHERE (checkhead_id IN (" );
      bool first = true;
      for( it = printedChecks.begin(); it != printedChecks.end(); ++it)
      {
        if(!first)
          query += ",";
        query += QString::number((*it)); 
        first = false;
      }
      query += ") ); ";
      newdlg._checks->populate(query);
      newdlg.sSelectAll();
      newdlg.sMarkPrinted();
      newdlg._checks->clearSelection();
      newdlg.exec();
    }
  }
  else
    QMessageBox::information( this, tr("No Checks Printed"),
			     tr("<p>No Checks were printed for the selected "
				"Bank Account.") );

  omfgThis->sChecksUpdated(_bankaccnt->id(), -1, TRUE);
  sHandleBankAccount(_bankaccnt->id());
}
Esempio n. 9
0
void printChecks::sCreateACH()
{
  if (_somerecips_ach_enabled && !_allrecips_ach_enabled &&
      QMessageBox::question(this, tr("Print Anyway?"),
                            tr("<p>Some but not all of the checks in this run "
                               "are for Vendors configured to receive ACH "
                               "transactions. Do you want to create the ACH "
                               "file anyway?<p>If you answer 'Yes' then an "
                               "ACH file will be created but you will have to "
                               "click Print to get the remainder of the "
                               "checks in this run. If you say 'No' then you "
                               "will get a warning when you click Print "
                               "asking whether you want to print checks for "
                               "ACH recipients."),
                            QMessageBox::Yes | QMessageBox::Default,
                            QMessageBox::No) == QMessageBox::No)
    return;

  XSqlQuery releasenum;
  releasenum.prepare("SELECT releaseNumber('ACHBatch', :batch);");

  QString batch;

  q.prepare("SELECT * FROM formatACHChecks(:bankaccnt_id, NULL, :key);");
  q.bindValue(":bankaccnt_id", _bankaccnt->id());
  q.bindValue(":key",          omfgThis->_key);
  q.exec();
  if (q.first())
  {
    batch = q.value("achline_batch").toString();
    releasenum.bindValue(":batch", batch);
    if (printCheck::achFileDir.isEmpty())
    {
      printCheck::achFileDir = xtsettingsValue("ACHOutputDirectory").toString();
    }
    QString suffixes = "*.ach *.dat *.txt";
    if (! suffixes.contains(_metrics->value("ACHDefaultSuffix")))
      suffixes = "*" + _metrics->value("ACHDefaultSuffix") + " " + suffixes;
    QString filename = QFileDialog::getSaveFileName(this, tr("ACH Output File"),
                            printCheck::achFileDir + QDir::separator() +
                            "ach" + batch + _metrics->value("ACHDefaultSuffix"),
                            "(" + suffixes + ")");
    if (filename.isEmpty())
    {
      releasenum.exec();
      return;
    }
    QFileInfo fileinfo(filename);
    printCheck::achFileDir = fileinfo.absolutePath();
    QFile achfile(filename);
    if (! achfile.open(QIODevice::WriteOnly))
    {
      releasenum.exec();
      QMessageBox::critical(this, tr("Could Not Open File"),
                            tr("Could not open %1 for writing ACH data.")
                            .arg(filename));
      return;
    }
    do
    {
      achfile.write(q.value("achline_value").toString().toAscii());
      achfile.write("\n");
    } while (q.next());
    achfile.close();
    if (q.lastError().type() != QSqlError::NoError)
    {
      releasenum.exec();
      achfile.remove();
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
      return;
    }

    if (confirmAchOK::askOK(this, achfile))
      markChecksAsPrinted(batch);
    else
    {
      releasenum.exec();
      XSqlQuery clearq;
      clearq.prepare("UPDATE checkhead "
                     "SET checkhead_printed=false,"
                     "    checkhead_ach_batch=NULL "
                     "WHERE (checkhead_ach_batch=:checkhead_ach_batch);");
      clearq.bindValue(":checkhead_ach_batch", batch);
      clearq.exec();
      if (clearq.lastError().type() != QSqlError::NoError)
      {
        systemError(this, clearq.lastError().databaseText(), __FILE__, __LINE__);
        return;
      }
    }
    sHandleBankAccount(_bankaccnt->id());
  }
  else if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }
}
Esempio n. 10
0
void printAPCheck::sPrint()
{
  q.prepare( "SELECT apchk_printed, report_name, bankaccnt_id "
             "FROM apchk, bankaccnt, form, report "
             "WHERE ( (apchk_bankaccnt_id=bankaccnt_id)"
             " AND (bankaccnt_check_form_id=form_id)"
             " AND (form_report_id=report_id)"
             " AND (apchk_id=:apchk_id) );" );
  q.bindValue(":apchk_id", _apchk->id());
  q.exec();
  if (q.first())
  {
    if(q.value("apchk_printed").toBool())
    {
      QMessageBox::information( this, tr("Check Already Printed"),
          tr("The selected A/P Check has already been printed.") );
      return;
    }

    ParameterList params;

    params.append("apchk_id", _apchk->id());

    orReport report(q.value("report_name").toString(), params);
    if (report.isValid())
      report.print();

    omfgThis->sAPChecksUpdated(q.value("bankaccnt_id").toInt(), _apchk->id(), TRUE);
  }
  else
  {
    QMessageBox::critical( this, tr("Cannot Print Check"),
                           tr( "The selected A/P Check cannot be printed as the Bank Account that it is to draw upon\n"
                               "does not have a valid Check Format assigned to it.  Please assign a valid Check Format\n"
                               "to this Bank Account before attempting to print this A/P Check." ) );
    return;
  }

  if ( QMessageBox::information( this, tr("Check Printed"),
                                 tr("Was the selected Check printed sucessfully?"),
                                 tr("&Yes"), tr("&No"), QString::null, 1, 0 ) == 0 )
  {
    q.prepare( "SELECT apchk_bankaccnt_id, markAPCheckAsPrinted(apchk_id) AS result "
               "FROM apchk "
               "WHERE (apchk_id=:apchk_id);" );
    q.bindValue(":apchk_id", _apchk->id());
    q.exec();
    if (q.first())
    {
      omfgThis->sAPChecksUpdated(q.value("apchk_bankaccnt_id").toInt(), _apchk->id(), TRUE);

      if (_captive)
        accept();
      else
      {
        sHandleBankAccount(_bankaccnt->id());
        _close->setText(tr("&Close"));
      }
    }
  }
  else if ( QMessageBox::information( this, tr("Mark Check as Voided"),
                                      tr("Would you like to mark the selected Check as Void and create a replacement check?"),
                                      tr("&Yes"), tr("&No"), QString::null, 1, 0 ) == 0)
  {
    q.prepare("SELECT voidAPCheck(:apchk_id) AS result;");
    q.bindValue(":apchk_id", _apchk->id());
    q.exec();

    q.prepare( "SELECT apchk_bankaccnt_id, replaceVoidedAPCheck(apchk_id) AS result "
               "FROM apchk "
               "WHERE (apchk_id=:apchk_id);" );
    q.bindValue(":apchk_id", _apchk->id());
    q.exec();
    if (q.first())
    {
      omfgThis->sAPChecksUpdated(q.value("apchk_bankaccnt_id").toInt(), _apchk->id(), TRUE);

      sHandleBankAccount(_bankaccnt->id());
      _print->setFocus();
    }
    else
      systemError(this, tr("A System Error occurred at %1::%2.")
                        .arg(__FILE__)
                        .arg(__LINE__) );
  }
}