void viewCheckRun::sDelete() { q.prepare( "SELECT checkhead_bankaccnt_id, deleteCheck(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("deleteCheck", result), __FILE__, __LINE__); return; } omfgThis->sChecksUpdated(q.value("checkhead_bankaccnt_id").toInt(), _check->id(), TRUE); } else if (q.lastError().type() != QSqlError::NoError) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return; } }
void checkFormats::sDelete() { q.prepare("SELECT deleteForm(:form_id) AS result;"); q.bindValue(":form_id", _form->id()); q.exec(); if (q.first()) { int result = q.value("result").toInt(); if (result < 0) { systemError(this, storedProcErrorLookup("deleteForm", result), __FILE__, __LINE__); return; } } else if (q.lastError().type() != QSqlError::NoError) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return; } sFillList(); }
void opportunityList::sDelete() { q.prepare("SELECT deleteOpportunity(:ophead_id) AS result;"); q.bindValue(":ophead_id", list()->id()); q.exec(); if (q.first()) { int result = q.value("result").toInt(); if (result < 0) { systemError(this, storedProcErrorLookup("deleteOpportunity", result)); return; } else sFillList(); } else if (q.lastError().type() != QSqlError::NoError) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return; } }
void freightClasses::sDelete() { XSqlQuery freightDelete; freightDelete.prepare("SELECT deleteFreightClass(:freightclass_id) AS result;"); freightDelete.bindValue(":freightclass_id", _freightClass->id()); freightDelete.exec(); if (freightDelete.first()) { int result = freightDelete.value("result").toInt(); if (result < 0) { systemError(this, storedProcErrorLookup("deleteFreightClass", result), __FILE__, __LINE__); return; } } else if (freightDelete.lastError().type() != QSqlError::NoError) { systemError(this, freightDelete.lastError().databaseText(), __FILE__, __LINE__); return; } sFillList(-1); }
void dspUnbalancedQOHByClassCode::sBalance() { XSqlQuery dspBalance; dspBalance.prepare("SELECT balanceItemsite(:itemsite_id) AS result;"); dspBalance.bindValue(":itemsite_id", list()->id()); dspBalance.exec(); if (dspBalance.first()) { int result = dspBalance.value("result").toInt(); if (result < 0) { systemError(this, storedProcErrorLookup("balanceItemsite", result), __FILE__, __LINE__); return; } } else if (dspBalance.lastError().type() != QSqlError::NoError) { systemError(this, dspBalance.lastError().databaseText(), __FILE__, __LINE__); return; } sFillList(); }
void accountingYearPeriods::sOpenPeriod() { q.prepare("SELECT openAccountingYearPeriod(:period_id) AS result;"); q.bindValue(":period_id", _period->id()); q.exec(); if (q.first()) { int result = q.value("result").toInt(); if (result < 0) { systemError(this, storedProcErrorLookup("openAccountingYearPeriod", result), __FILE__, __LINE__); return; } sFillList(); } else if (q.lastError().type() != QSqlError::NoError) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return; } }
void maintainShipping::sReturnAllStock() { XSqlQuery maintainReturnAllStock; XSqlQuery rollback; rollback.prepare("ROLLBACK;"); maintainReturnAllStock.exec("BEGIN"); maintainReturnAllStock.prepare("SELECT returnShipmentTransaction(:ship_id) AS result;"); maintainReturnAllStock.bindValue(":ship_id", _ship->altId()); maintainReturnAllStock.exec(); if (maintainReturnAllStock.first()) { int result = maintainReturnAllStock.value("result").toInt(); if (maintainReturnAllStock.value("result").toInt() < 0) { rollback.exec(); systemError(this, storedProcErrorLookup("returnShipmentTransaction", result), __FILE__, __LINE__); return; } else if (distributeInventory::SeriesAdjust(result, this) == XDialog::Rejected) { rollback.exec(); QMessageBox::information( this, tr("Issue to Shipping"), tr("Return Canceled") ); return; } maintainReturnAllStock.exec("COMMIT;"); sFillList(); } else if (maintainReturnAllStock.lastError().type() != QSqlError::NoError) { rollback.exec(); systemError(this, maintainReturnAllStock.lastError().databaseText(), __FILE__, __LINE__); return; } }
void bankAdjustmentTypes::sDelete() { q.prepare( "SELECT deleteBankAdjustmentType(:bankadjtype_id) AS result;" ); q.bindValue(":bankadjtype_id", _bankadjtype->id()); q.exec(); if (q.first()) { int result = q.value("result").toInt(); if (result < 0) { systemError(this, storedProcErrorLookup("deleteBankAdjustmentType", result), __FILE__, __LINE__); return; } } else if (q.lastError().type() != QSqlError::NoError) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return; } sFillList(); }
void customerTypes::sDelete() { XSqlQuery customerDelete; customerDelete.prepare("SELECT deleteCustomerType(:custtype_id) AS result;"); customerDelete.bindValue(":custtype_id", _custtype->id()); customerDelete.exec(); if (customerDelete.first()) { int result = customerDelete.value("result").toInt(); if (result < 0) { ErrorReporter::error(QtCriticalMsg, this, tr("Error Deleting Customer Type"), storedProcErrorLookup("deleteCustomerType", result), __FILE__, __LINE__); return; } } else if (ErrorReporter::error(QtCriticalMsg, this, tr("Error Deleting Customer Type"), customerDelete, __FILE__, __LINE__)) { return; } sFillList(); }
void user::sRevokeAll() { XSqlQuery privq; privq.prepare("SELECT revokeAllModulePriv(:username, :module) AS result;"); privq.bindValue(":username", _cUsername); privq.bindValue(":module", _module->currentText()); privq.exec(); if (privq.first()) { int result = privq.value("result").toInt(); if (result < 0) { ErrorReporter::error(QtCriticalMsg, this, tr("Revoking Privileges"), storedProcErrorLookup("revokeAllModulePriv", result), __FILE__, __LINE__); return; } } else if (ErrorReporter::error(QtCriticalMsg, this, tr("Revoking Privileges"), privq, __FILE__, __LINE__)) return; sModuleSelected(_module->currentText()); }
void selectOrderForBilling::sSelectBalance() { XSqlQuery selectSelectBalance; selectSelectBalance.prepare("SELECT selectBalanceForBilling(:sohead_id) AS result;"); selectSelectBalance.bindValue(":sohead_id", _so->id()); selectSelectBalance.exec(); if (selectSelectBalance.first()) { int result = selectSelectBalance.value("result").toInt(); if (result < 0) { systemError(this, storedProcErrorLookup("selectBalanceForBilling", result), __FILE__, __LINE__); return; } } else if (selectSelectBalance.lastError().type() != QSqlError::NoError) { systemError(this, selectSelectBalance.lastError().databaseText(), __FILE__, __LINE__); return; } sFillList(); }
void user::sRevokeAll() { q.prepare("SELECT revokeAllModulePriv(:username, :module) AS result;"); q.bindValue(":username", _cUsername); q.bindValue(":module", _module->currentText()); q.exec(); if (q.first()) { int result = q.value("result").toInt(); if (result < 0) { systemError(this, storedProcErrorLookup("revokeAllModulePriv", result), __FILE__, __LINE__); return; } } else if (q.lastError().type() != QSqlError::NoError) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return; } sModuleSelected(_module->currentText()); }
void commentType::sRevokeAll() { q.prepare("SELECT revokeAllModuleCmnttypeSource(:cmnttype_id, :module) AS result;"); q.bindValue(":cmnttype_id", _cmnttypeid); q.bindValue(":module", _module->currentText()); q.exec(); if (q.first()) { int result = q.value("result").toInt(); if (result < 0) { systemError(this, storedProcErrorLookup("revokeAllModuleCmnttypeSource", result), __FILE__, __LINE__); return; } } else if (q.lastError().type() != QSqlError::NoError) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return; } sModuleSelected(_module->currentText()); }
void packages::sDisable() { XSqlQuery dq; dq.prepare("SELECT disablePackage(:id) AS result;"); dq.bindValue(":id", _package->id()); dq.exec(); if (dq.first()) { int result = dq.value("result").toInt(); if (result < 0) { systemError(this, storedProcErrorLookup("disablePackage", result) .arg(_package->id()), __FILE__, __LINE__); return; } } else if (dq.lastError().type() != QSqlError::NoError) { systemError(this, dq.lastError().databaseText(), __FILE__, __LINE__); return; } sFillList(); }
void bankAdjustmentEditList::sPost() { XSqlQuery bankPost; bankPost.prepare("SELECT postBankAdjustment(:bankadjid) AS result;"); bankPost.bindValue(":bankadjid", _adjustments->id()); bankPost.exec(); if (bankPost.first()) { int result = bankPost.value("result").toInt(); if (result < 0) { ErrorReporter::error(QtCriticalMsg, this, tr("Error Posting Bank Adjustment"), storedProcErrorLookup("postBankAdjustment", result), __FILE__, __LINE__); return; } sFillList(); } else if (ErrorReporter::error(QtCriticalMsg, this, tr("Error Posting Bank Adjustment"), bankPost, __FILE__, __LINE__)) { return; } }
void dspUnbalancedQOHByClassCode::sBalance() { XSqlQuery dspBalance; dspBalance.prepare("SELECT balanceItemsite(:itemsite_id) AS result;"); dspBalance.bindValue(":itemsite_id", list()->id()); dspBalance.exec(); if (dspBalance.first()) { int result = dspBalance.value("result").toInt(); if (result < 0) { ErrorReporter::error(QtCriticalMsg, this, tr("Error Retrieving Item Information"), storedProcErrorLookup("balanceItemsite", result), __FILE__, __LINE__); return; } } else if (ErrorReporter::error(QtCriticalMsg, this, tr("Error Retrieving Item Information"), dspBalance, __FILE__, __LINE__)) { return; } sFillList(); }
void incident::sCancel() { if (_saved && cNew == _mode) { q.prepare("SELECT deleteIncident(:incdt_id) AS result;"); q.bindValue(":incdt_id", _incdtid); q.exec(); if (q.first()) { int result = q.value("result").toInt(); if (result < 0) { systemError(this, storedProcErrorLookup("deleteIncident", result)); return; } } else if (q.lastError().type() != QSqlError::None) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return; } } reject(); }
void unpostedInvoices::sDelete() { if ( QMessageBox::warning( this, tr("Delete Selected Invoices"), tr("<p>Are you sure that you want to delete the " "selected Invoices?"), tr("Delete"), tr("Cancel"), QString::null, 1, 1 ) == 0) { q.prepare("SELECT deleteInvoice(:invchead_id) AS result;"); QList<XTreeWidgetItem*> selected = _invchead->selectedItems(); for (int i = 0; i < selected.size(); i++) { if (checkSitePrivs(((XTreeWidgetItem*)(selected[i]))->id())) { q.bindValue(":invchead_id", ((XTreeWidgetItem*)(selected[i]))->id()); q.exec(); if (q.first()) { int result = q.value("result").toInt(); if (result < 0) { systemError(this, storedProcErrorLookup("deleteInvoice", result), __FILE__, __LINE__); } } else if (q.lastError().type() != QSqlError::NoError) systemError(this, tr("Error deleting Invoice %1\n").arg(selected[i]->text(0)) + q.lastError().databaseText(), __FILE__, __LINE__); } } omfgThis->sInvoicesUpdated(-1, TRUE); omfgThis->sBillingSelectionUpdated(-1, -1); } }
void empGroups::sDelete() { XSqlQuery empDelete; empDelete.prepare( "SELECT deleteEmpgrp(:grpid) AS result;"); empDelete.bindValue(":grpid", _empgrp->id()); empDelete.exec(); if (empDelete.first()) { int result = empDelete.value("result").toInt(); if (result < 0) { systemError(this, storedProcErrorLookup("deleteEmpgrp", result), __FILE__, __LINE__); return; } } else if (empDelete.lastError().type() != QSqlError::NoError) { systemError(this, empDelete.lastError().databaseText(), __FILE__, __LINE__); return; } sFillList(); }
void opportunity::sCancel() { if (_saved && cNew == _mode) { q.prepare("SELECT deleteOpportunity(:ophead_id) AS result;"); q.bindValue(":ophead_id", _opheadid); q.exec(); if (q.first()) { int result = q.value("result").toInt(); if (result < 0) { systemError(this, storedProcErrorLookup("deleteOpportunity", result)); return; } } else if (q.lastError().type() != QSqlError::NoError) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return; } } reject(); }
void budgets::sDelete() { XSqlQuery budgetsDelete; budgetsDelete.prepare( "SELECT deleteBudget(:budghead_id) AS result;"); budgetsDelete.bindValue(":budghead_id", _budget->id()); budgetsDelete.exec(); if (budgetsDelete.first()) { int result = budgetsDelete.value("result").toInt(); if (result < 0) { systemError(this, storedProcErrorLookup("deleteBudget", result), __FILE__, __LINE__); return; } } else if (budgetsDelete.lastError().type() != QSqlError::NoError) { systemError(this, budgetsDelete.lastError().databaseText(), __FILE__, __LINE__); return; } sFillList(); }
void openVouchers::sDelete() { if (QMessageBox::question(this, tr("Delete Selected Vouchers"), tr("<p>Are you sure that you want to delete the " "selected Vouchers?"), QMessageBox::Yes, QMessageBox::No | QMessageBox::Default) == QMessageBox::Yes) { q.prepare("SELECT deleteVoucher(:vohead_id) AS result;"); QList<XTreeWidgetItem*>selected = _vohead->selectedItems(); for (int i = 0; i < selected.size(); i++) { if (checkSitePrivs(((XTreeWidgetItem*)(selected[i]))->id())) { int id = ((XTreeWidgetItem*)(selected[i]))->id(); q.bindValue(":vohead_id", id); q.exec(); if (q.first()) { int result = q.value("result").toInt(); if (result < 0) { systemError(this, storedProcErrorLookup("deleteVoucher", result), __FILE__, __LINE__); } } else if (q.lastError().type() != QSqlError::NoError) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); } } } omfgThis->sVouchersUpdated(); } }
void applyAPCreditMemo::sApplyBalance() { XSqlQuery applyApplyBalance; applyApplyBalance.prepare("SELECT applyAPCreditMemoToBalance(:apopen_id) AS result;"); applyApplyBalance.bindValue(":apopen_id", _apopenid); applyApplyBalance.exec(); if (applyApplyBalance.first()) { int result = applyApplyBalance.value("result").toInt(); if (result < 0) { systemError(this, storedProcErrorLookup("applyAPCreditMemoToBalance", result), __FILE__, __LINE__); return; } } else if (applyApplyBalance.lastError().type() != QSqlError::NoError) { systemError(this, applyApplyBalance.lastError().databaseText(), __FILE__, __LINE__); return; } populate(); }
void dspInventoryAvailabilityByCustomerType::sReserveLineBalance() { q.prepare("SELECT reserveSoLineBalance(:soitem_id) AS result;"); q.bindValue(":soitem_id", _avail->altId()); q.exec(); if (q.first()) { int result = q.value("result").toInt(); if (result < 0) { systemError(this, storedProcErrorLookup("reserveSoLineBalance", result), __FILE__, __LINE__); return; } } else if (q.lastError().type() != QSqlError::None) { systemError(this, tr("Error\n") + q.lastError().databaseText(), __FILE__, __LINE__); return; } sFillList(); }
void todoList::sDelete() { if ( QMessageBox::warning(this, tr("Delete List Item?"), tr("<p>Are you sure that you want to completely " "delete the selected item?"), QMessageBox::Yes, QMessageBox::No | QMessageBox::Default) == QMessageBox::Yes) { if (_todoList->altId() == 1) q.prepare("SELECT deleteTodoItem(:todoitem_id) AS result;"); else if (_todoList->altId() == 3) q.prepare("DELETE FROM prjtask" " WHERE (prjtask_id=:todoitem_id); "); else if (_todoList->altId() == 4) q.prepare("SELECT deleteProject(:todoitem_id) AS result"); else return; q.bindValue(":todoitem_id", _todoList->id()); q.exec(); if (q.first()) { int result = q.value("result").toInt(); if (result < 0) { systemError(this, storedProcErrorLookup("deleteTodoItem", result)); return; } } else if (q.lastError().type() != QSqlError::NoError) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return; } sFillList(); } }
void characteristics::sDelete() { q.prepare("SELECT deleteCharacteristic(:char_id) AS result;"); q.bindValue(":char_id", _char->id()); q.exec(); if (q.first()) { int returnVal = q.value("result").toInt(); if (returnVal < 0) { QMessageBox::critical( this, tr("Cannot Delete Characteristic"), storedProcErrorLookup("deleteCharacteristic", returnVal)); return; } sFillList(); } else if (q.lastError().type() != QSqlError::NoError) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return; } }
void dspCheckRegister::sVoidPosted() { XSqlQuery dspVoidPosted; ParameterList params; XDateInputDialog newdlg(this, "", true); params.append("label", tr("On what date did you void this check?")); newdlg.set(params); int returnVal = newdlg.exec(); if (returnVal == XDialog::Accepted) { QDate voidDate = newdlg.getDate(); dspVoidPosted.prepare("SELECT voidPostedCheck(:check_id, fetchJournalNumber('AP-CK')," " DATE :voidDate) AS result;"); dspVoidPosted.bindValue(":check_id", _check->id()); dspVoidPosted.bindValue(":voidDate", voidDate); dspVoidPosted.exec(); if (dspVoidPosted.first()) { int result = dspVoidPosted.value("result").toInt(); if (result < 0) { ErrorReporter::error(QtCriticalMsg, this, tr("Error Voiding Posted Check"), storedProcErrorLookup("voidPostedCheck", result), __FILE__, __LINE__); return; } } else if (ErrorReporter::error(QtCriticalMsg, this, tr("Error Voiding Posted Check"), dspVoidPosted, __FILE__, __LINE__)) { return; } } sFillList(); }
void profitCenters::sDelete() { XSqlQuery profitDelete; profitDelete.prepare( "SELECT deleteProfitCenter(:id) AS result;" ); profitDelete.bindValue(":id", _prftcntr->id()); profitDelete.exec(); if (profitDelete.first()) { int result = profitDelete.value("result").toInt(); if (result < 0) { systemError(this, storedProcErrorLookup("deleteProfitCenter", result), __FILE__, __LINE__); return; } } else if (profitDelete.lastError().type() != QSqlError::NoError) { systemError(this, profitDelete.lastError().databaseText(), __FILE__, __LINE__); return; } sFillList(); }
void openVouchers::sPost() { bool changeDate = false; QDate newDate = QDate::currentDate(); if (_privleges->check("ChangeVOPostDate")) { getGLDistDate newdlg(this, "", TRUE); newdlg.sSetDefaultLit(tr("Distribution Date")); if (newdlg.exec() == QDialog::Accepted) { newDate = newdlg.date(); changeDate = (newDate.isValid()); } else return; } XSqlQuery setDate; setDate.prepare("UPDATE vohead SET vohead_gldistdate=:distdate " "WHERE vohead_id=:vohead_id;"); QList<QTreeWidgetItem*>selected = _vohead->selectedItems(); QList<QTreeWidgetItem*>triedToClosed; for (int i = 0; i < selected.size(); i++) { int id = ((XTreeWidgetItem*)(selected[i]))->id(); if (changeDate) { setDate.bindValue(":distdate", newDate); setDate.bindValue(":vohead_id", id); setDate.exec(); if (setDate.lastError().type() != QSqlError::None) { systemError(this, setDate.lastError().databaseText(), __FILE__, __LINE__); } } } XSqlQuery post; post.prepare("SELECT fetchJournalNumber('AP-VO') AS result;"); post.exec(); int journalNumber = 0; if(post.first()) journalNumber = post.value("result").toInt(); else { systemError(this, post.lastError().databaseText(), __FILE__, __LINE__); return; } post.prepare("SELECT postVoucher(:vohead_id, :journalNumber, FALSE) AS result;"); bool tryagain = false; do { for (int i = 0; i < selected.size(); i++) { int id = ((XTreeWidgetItem*)(selected[i]))->id(); post.bindValue(":vohead_id", id); post.bindValue(":journalNumber", journalNumber); post.exec(); if (post.first()) { int result = post.value("result").toInt(); if (result < 0) systemError(this, storedProcErrorLookup("postVoucher", result), __FILE__, __LINE__); } // contains() string is hard-coded in stored procedure else if (post.lastError().databaseText().contains("posted to closed period")) { if (changeDate) { triedToClosed = selected; break; } else triedToClosed.append(selected[i]); } else if (post.lastError().type() != QSqlError::None) { systemError(this, post.lastError().databaseText(), __FILE__, __LINE__); } } if (triedToClosed.size() > 0) { failedPostList newdlg(this, "", true); newdlg.sSetList(triedToClosed, _vohead->headerItem(), _vohead->header()); tryagain = (newdlg.exec() == QDialog::Accepted); selected = triedToClosed; triedToClosed.clear(); } } while (tryagain); if (_printJournal->isChecked()) { ParameterList params; params.append("journalNumber", journalNumber); orReport report("PayablesJournal", params); if (report.isValid()) report.print(); else report.reportError(this); } omfgThis->sVouchersUpdated(); }
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; } } }