本文整理汇总了C++中XSqlQuery::lastError方法的典型用法代码示例。如果您正苦于以下问题:C++ XSqlQuery::lastError方法的具体用法?C++ XSqlQuery::lastError怎么用?C++ XSqlQuery::lastError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XSqlQuery
的用法示例。
在下文中一共展示了XSqlQuery::lastError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set
enum SetResponse itemSource::set(const ParameterList &pParams)
{
XSqlQuery itemet;
XDialog::set(pParams);
QVariant param;
bool valid;
param = pParams.value("itemsrc_id", &valid);
if (valid)
{
_itemsrcid = param.toInt();
populate();
}
param = pParams.value("item_id", &valid);
if (valid)
{
_item->setId(param.toInt());
_item->setEnabled(FALSE);
}
param = pParams.value("mode", &valid);
if (valid)
{
if (param.toString() == "new")
{
_mode = cNew;
_new = true;
itemet.exec("SELECT NEXTVAL('itemsrc_itemsrc_id_seq') AS _itemsrc_id;");
if (itemet.first())
_itemsrcid = itemet.value("_itemsrc_id").toInt();
else if (itemet.lastError().type() != QSqlError::NoError)
{
systemError(this, itemet.lastError().databaseText(), __FILE__, __LINE__);
return UndefinedError;
}
_captive = true;
connect(_itemsrcp, SIGNAL(valid(bool)), _edit, SLOT(setEnabled(bool)));
connect(_itemsrcp, SIGNAL(valid(bool)), _delete, SLOT(setEnabled(bool)));
connect(_itemsrcp, SIGNAL(itemSelected(int)), _edit, SLOT(animateClick()));
}
else if (param.toString() == "edit")
{
_mode = cEdit;
connect(_itemsrcp, SIGNAL(valid(bool)), _edit, SLOT(setEnabled(bool)));
connect(_itemsrcp, SIGNAL(valid(bool)), _delete, SLOT(setEnabled(bool)));
connect(_itemsrcp, SIGNAL(itemSelected(int)), _edit, SLOT(animateClick()));
_item->setReadOnly(TRUE);
_vendor->setEnabled(FALSE);
}
else if (param.toString() == "view")
{
_mode = cView;
_item->setReadOnly(TRUE);
_active->setEnabled(FALSE);
_default->setEnabled(FALSE);
_vendor->setEnabled(FALSE);
_dates->setEnabled(FALSE);
_vendorItemNumber->setEnabled(FALSE);
_vendorItemDescrip->setEnabled(FALSE);
_vendorUOM->setEnabled(FALSE);
_invVendorUOMRatio->setEnabled(FALSE);
_vendorRanking->setEnabled(FALSE);
_minOrderQty->setEnabled(FALSE);
_multOrderQty->setEnabled(FALSE);
_leadTime->setEnabled(FALSE);
_notes->setEnabled(FALSE);
_upcCode->setEnabled(FALSE);
_add->setEnabled(FALSE);
_delete->setEnabled(FALSE);
_close->setText(tr("&Close"));
_save->hide();
}
if (param.toString() == "copy")
{
_mode = cCopy;
_new = true;
_captive = true;
int itemsrcidold = _itemsrcid;
itemet.exec("SELECT NEXTVAL('itemsrc_itemsrc_id_seq') AS _itemsrc_id;");
if (itemet.first())
_itemsrcid = itemet.value("_itemsrc_id").toInt();
else if (itemet.lastError().type() != QSqlError::NoError)
{
systemError(this, itemet.lastError().databaseText(), __FILE__, __LINE__);
return UndefinedError;
}
connect(_itemsrcp, SIGNAL(valid(bool)), _edit, SLOT(setEnabled(bool)));
connect(_itemsrcp, SIGNAL(valid(bool)), _delete, SLOT(setEnabled(bool)));
connect(_itemsrcp, SIGNAL(itemSelected(int)), _edit, SLOT(animateClick()));
_item->setReadOnly(TRUE);
_vendorItemNumber->setText(_vendorItemNumber->text().prepend("Copy Of "));
//.........这里部分代码省略.........
示例2: save
bool userPreferences::save()
{
XSqlQuery userave;
if (_currentpassword->text().length() == 0)
{
QMessageBox::warning( this, tr("Cannot save User"),
tr( "You must enter a valid Current Password before you can save this User." ));
_currentpassword->setFocus();
return false;
}
if (_newpassword->text().length() == 0)
{
QMessageBox::warning( this, tr("Cannot save User"),
tr( "You must enter a valid Password before you can save this User." ));
_newpassword->setFocus();
return false;
}
QString passwd = _newpassword->text();
QString currentpasswd = _currentpassword->text();
// TODO: have to compare this against something usefull
if(currentpasswd != __password)
{
QMessageBox::warning( this, tr("Cannot save User"),
tr( "Please Verify Current Password." ));
_currentpassword->setFocus();
return false;
}
if (_newpassword->text() != _retypepassword->text())
{
QMessageBox::warning( this, tr("Password do not Match"),
tr( "The entered password and verify do not match\n"
"Please enter both again carefully." ));
_newpassword->clear();
_retypepassword->clear();
_newpassword->setFocus();
return false;
}
if (_newpassword->text() != " ")
{
userave.prepare( "SELECT usrpref_value "
" FROM usrpref "
" WHERE ( (usrpref_name = 'UseEnhancedAuthentication') "
" AND (usrpref_username=:username) ); ");
userave.bindValue(":username", _username->text().trimmed().toLower());
userave.exec();
if(userave.first())
{
if (userave.value("usrpref_value").toString()=="t")
{
QRegExp xtuplecloud(".*\\.xtuplecloud\\.com.*");
QRegExp xtuple(".*\\.xtuple\\.com.*");
bool isCloud = xtuplecloud.exactMatch(omfgThis->databaseURL());
bool isXtuple = xtuple.exactMatch(omfgThis->databaseURL());
QString salt;
if(isCloud || isXtuple)
{
salt = "private";
}
else
{
salt = "xTuple";
}
passwd = passwd + salt + _username->text();
passwd = QMd5(passwd);
}
}
userave.prepare( QString( "ALTER USER \"%1\" WITH PASSWORD :password;")
.arg(_username->text()) );
userave.bindValue(":password", passwd);
userave.exec();
if (userave.lastError().type() != QSqlError::NoError)
{
systemError(this, userave.lastError().databaseText(), __FILE__, __LINE__);
return false;
}
}
return true;
}
示例3: sPostCashrcpt
void arWorkBench::sPostCashrcpt()
{
XSqlQuery arPostCashrcpt;
int journalNumber = -1;
bool changeDate = false;
QDate newDate = QDate();
if (_privileges->check("ChangeCashRecvPostDate"))
{
getGLDistDate newdlg(this, "", TRUE);
newdlg.sSetDefaultLit(tr("Distribution Date"));
if (newdlg.exec() == XDialog::Accepted)
{
newDate = newdlg.date();
changeDate = (newDate.isValid());
}
else
return;
}
arPostCashrcpt.exec("BEGIN;");
arPostCashrcpt.exec("SELECT fetchJournalNumber('C/R') AS journalnumber;");
if (arPostCashrcpt.first())
journalNumber = arPostCashrcpt.value("journalnumber").toInt();
else if (arPostCashrcpt.lastError().type() != QSqlError::NoError)
{
systemError(this, arPostCashrcpt.lastError().databaseText(), __FILE__, __LINE__);
return;
}
XSqlQuery setDate;
setDate.prepare("UPDATE cashrcpt SET cashrcpt_distdate=:distdate,"
" cashrcpt_applydate=CASE WHEN (cashrcpt_applydate < :distdate) THEN :distdate"
" ELSE cashrcpt_applydate END "
"WHERE cashrcpt_id=:cashrcpt_id;");
QList<XTreeWidgetItem*> selected = _cashrcpt->selectedItems();
for (int i = 0; i < selected.size(); i++)
{
int id = ((XTreeWidgetItem*)(selected[i]))->id();
if (changeDate)
{
setDate.bindValue(":distdate", newDate);
setDate.bindValue(":cashrcpt_id", id);
setDate.exec();
ErrorReporter::error(QtCriticalMsg, this, tr("Changing Dist. Date"),
setDate, __FILE__, __LINE__);
}
}
for (int i = 0; i < selected.size(); i++)
{
arPostCashrcpt.prepare("SELECT postCashReceipt(:cashrcpt_id, :journalNumber) AS result;");
arPostCashrcpt.bindValue(":cashrcpt_id", ((XTreeWidgetItem*)(selected[i]))->id());
arPostCashrcpt.bindValue(":journalNumber", journalNumber);
arPostCashrcpt.exec();
if (arPostCashrcpt.first())
{
int result = arPostCashrcpt.value("result").toInt();
if (result < 0)
{
systemError(this, storedProcErrorLookup("postCashReceipt", result),
__FILE__, __LINE__);
arPostCashrcpt.exec("ROLLBACK;");
return;
}
}
else if (arPostCashrcpt.lastError().type() != QSqlError::NoError)
{
systemError(this, arPostCashrcpt.lastError().databaseText(), __FILE__, __LINE__);
arPostCashrcpt.exec("ROLLBACK;");
return;
}
}
arPostCashrcpt.exec("COMMIT;");
sFillList();
}
示例4: populate
void enterPoitemReceipt::populate()
{
XSqlQuery enterpopulate;
ParameterList params;
if (_metrics->boolean("MultiWhs"))
params.append("MultiWhs");
if (_metrics->boolean("EnableReturnAuth"))
params.append("EnableReturnAuth");
// NOTE: this crashes if popm is defined and toQuery() is called outside the blocks
if (_mode == cNew)
{
MetaSQLQuery popm = mqlLoad("itemReceipt", "populateNew");
params.append("ordertype", _ordertype);
params.append("orderitem_id", _orderitemid);
enterpopulate = popm.toQuery(params);
}
else if (_mode == cEdit)
{
MetaSQLQuery popm = mqlLoad("itemReceipt", "populateEdit");
params.append("recv_id", _recvid);
enterpopulate = popm.toQuery(params);
}
else
{
systemError(this, tr("<p>Incomplete Parameter List: "
"_orderitem_id=%1, _ordertype=%2, _mode=%3.")
.arg(_orderitemid)
.arg(_ordertype)
.arg(_mode) );
return;
}
if (enterpopulate.first())
{
_orderNumber->setText(enterpopulate.value("order_number").toString());
_lineNumber->setText(enterpopulate.value("orderitem_linenumber").toString());
_vendorItemNumber->setText(enterpopulate.value("vend_item_number").toString());
_vendorDescrip->setText(enterpopulate.value("vend_item_descrip").toString());
_vendorUOM->setText(enterpopulate.value("vend_uom").toString());
_invVendorUOMRatio->setDouble(enterpopulate.value("orderitem_qty_invuomratio").toDouble());
_dueDate->setDate(enterpopulate.value("duedate").toDate());
_ordered->setDouble(enterpopulate.value("orderitem_qty_ordered").toDouble());
_received->setDouble(enterpopulate.value("qtyreceived").toDouble());
_returned->setDouble(enterpopulate.value("qtyreturned").toDouble());
_receivable = enterpopulate.value("receivable").toDouble();
_notes->setText(enterpopulate.value("notes").toString());
_receiptDate->setDate(enterpopulate.value("effective").toDate());
_freight->setId(enterpopulate.value("curr_id").toInt());
_freight->setLocalValue(enterpopulate.value("recv_freight").toDouble());
if (_ordertype.isEmpty())
_ordertype = enterpopulate.value("recv_order_type").toString();
if (_ordertype == "PO")
_orderType->setText(tr("P/O"));
else if (_ordertype == "TO")
{
_returnedLit->setText(tr("Qty. Shipped:"));
_orderType->setText(tr("T/O"));
}
else if (_ordertype == "RA")
_orderType->setText(tr("R/A"));
int itemsiteid = enterpopulate.value("itemsiteid").toInt();
if (itemsiteid > 0)
_item->setItemsiteid(itemsiteid);
_item->setEnabled(false);
_purchCost->setId(enterpopulate.value("recv_purchcost_curr_id").toInt());
_purchCost->setLocalValue(enterpopulate.value("recv_purchcost").toDouble());
_purchCost->setEnabled(enterpopulate.value("costmethod_average").toBool() && _metrics->boolean("AllowReceiptCostOverride"));
_extendedCost->setId(enterpopulate.value("recv_purchcost_curr_id").toInt());
if (enterpopulate.value("inventoryitem").toBool() && itemsiteid <= 0)
{
MetaSQLQuery ism = mqlLoad("itemReceipt", "sourceItemSite");
XSqlQuery isq = ism.toQuery(params);
if (isq.first())
{
itemsiteid = itemSite::createItemSite(this,
isq.value("itemsite_id").toInt(),
isq.value("warehous_id").toInt(),
true);
if (itemsiteid < 0)
return;
_item->setItemsiteid(itemsiteid);
}
else if (isq.lastError().type() != QSqlError::NoError)
{
systemError(this, isq.lastError().databaseText(), __FILE__, __LINE__);
return;
}
}
}
else if (enterpopulate.lastError().type() != QSqlError::NoError)
{
//.........这里部分代码省略.........
示例5: set
enum SetResponse lotSerialRegistration::set(const ParameterList &pParams)
{
XSqlQuery lotet;
XDialog::set(pParams);
QVariant param;
bool valid;
param = pParams.value("crmacct_id", &valid);
if (valid)
_crmacct->setId(param.toInt());
param = pParams.value("item_id", &valid);
if (valid)
_item->setId(param.toInt());
param = pParams.value("ls_id", &valid);
if (valid)
_lotSerial->setId(param.toInt());
param = pParams.value("lsreg_id", &valid);
if (valid)
_lsregid=param.toInt();
param = pParams.value("mode", &valid);
if (valid)
{
_mode = cNew;
if (param.toString() == "new")
{
_mode = cNew;
lotet.exec ("SELECT fetchlsregnumber() AS number;");
if (lotet.first())
_regNumber->setText(lotet.value("number").toString());
else if(lotet.lastError().type() != QSqlError::NoError)
{
systemError(this, lotet.lastError().databaseText(), __FILE__, __LINE__);
reject();
}
lotet.exec("SELECT NEXTVAL('lsreg_lsreg_id_seq') AS _lsreg_id;");
if (lotet.first())
_lsregid = lotet.value("_lsreg_id").toInt();
else if (lotet.lastError().type() != QSqlError::NoError)
{
systemError(this, lotet.lastError().databaseText(), __FILE__, __LINE__);
reject();
}
_qty->setText("1");
}
else if (param.toString() == "edit")
{
_mode = cEdit;
populate();
_itemGroup->setEnabled(false);
}
else if (param.toString() == "view")
{
_mode = cView;
_regDate->setEnabled(false);
_soldDate->setEnabled(false);
_expireDate->setEnabled(false);
_crmacct->setEnabled(false);
_cntct->setEnabled(false);
_type->setEnabled(false);
_item->setReadOnly(true);
_lotSerial->setEnabled(false);
_newChar->setEnabled(false);
_editChar->setEnabled(false);
_deleteChar->setEnabled(false);
_notes->setEnabled(false);
_buttonBox->clear();
_buttonBox->addButton(QDialogButtonBox::Close);
}
}
param = pParams.value("crmacct_id", &valid);
if (valid)
{
_crmacct->setId(param.toInt());
_crmacct->setEnabled(false);
}
return NoError;
}
示例6: sSave
//.........这里部分代码省略.........
_crmacct->setFocus();
return;
}
if (!_regDate->isValid())
{
QMessageBox::warning(this, windowTitle(), tr("You must provide a registration date."));
_regDate->setFocus();
return;
}
if (!_soldDate->isValid())
{
QMessageBox::warning(this, windowTitle(), tr("You must provide a sold date."));
_soldDate->setFocus();
return;
}
if (!_expireDate->isValid())
{
QMessageBox::warning(this, windowTitle(), tr("You must provide a expiration date."));
_expireDate->setFocus();
return;
}
if (_lotSerial->id() == -1)
{
QMessageBox::warning(this, windowTitle(), tr("You must provide a lot/serial number."));
_lotSerial->setFocus();
return;
}
if (!(_qty->toDouble() > 0))
{
QMessageBox::warning(this, windowTitle(), tr("You must provide a quantity greater than zero."));
_qty->setFocus();
return;
}
if (_cntct->id() == -1)
{
QMessageBox::warning(this, windowTitle(), "You must provide a contact.");
_cntct->setFocus();
return;
}
if(cNew == _mode)
{
lotSave.prepare("INSERT INTO lsreg"
" (lsreg_id, lsreg_number, lsreg_regtype_id,"
" lsreg_ls_id, lsreg_qty, lsreg_regdate, lsreg_solddate,"
" lsreg_expiredate, lsreg_crmacct_id, lsreg_cntct_id,"
" lsreg_notes, lsreg_cohead_id, lsreg_shiphead_id) "
"VALUES(:lsreg_id, :lsreg_number, :lsreg_regtype_id,"
" :lsreg_ls_id, :lsreg_qty, :lsreg_regdate, :lsreg_solddate,"
" :lsreg_expiredate, :lsreg_crmacct_id, :lsreg_cntct_id,"
" :lsreg_notes, :lsreg_cohead_id, :lsreg_shiphead_id);");
}
else if(cEdit == _mode)
lotSave.prepare("UPDATE lsreg"
" SET lsreg_number=:lsreg_number,"
" lsreg_regtype_id=:lsreg_regtype_id,"
" lsreg_ls_id=:lsreg_ls_id,"
" lsreg_qty=:lsreg_qty,"
" lsreg_regdate=:lsreg_regdate,"
" lsreg_solddate=:lsreg_solddate,"
" lsreg_expiredate=:lsreg_expiredate,"
" lsreg_crmacct_id=:lsreg_crmacct_id,"
" lsreg_cntct_id=:lsreg_cntct_id,"
" lsreg_notes=:lsreg_notes,"
" lsreg_cohead_id=:lsreg_cohead_id,"
" lsreg_shiphead_id=:lsreg_shiphead_id"
" WHERE(lsreg_id=:lsreg_id);");
lotSave.bindValue(":lsreg_id", _lsregid);
lotSave.bindValue(":lsreg_number", _regNumber->text().trimmed());
lotSave.bindValue(":lsreg_regtype_id", _type->id());
lotSave.bindValue(":lsreg_ls_id", _lotSerial->id());
lotSave.bindValue(":lsreg_qty", _qty->toDouble());
lotSave.bindValue(":lsreg_regdate", _regDate->date());
lotSave.bindValue(":lsreg_solddate", _soldDate->date());
lotSave.bindValue(":lsreg_expiredate", _expireDate->date());
lotSave.bindValue(":lsreg_crmacct_id", _crmacct->id());
lotSave.bindValue(":lsreg_cntct_id", _cntct->id());
lotSave.bindValue(":lsreg_notes", _notes->toPlainText());
if(_so->id() != -1)
lotSave.bindValue(":lsreg_cohead_id", _so->id());
if(_shipment->id() != -1)
lotSave.bindValue(":lsreg_shiphead_id", _shipment->id());
lotSave.exec();
if (lotSave.lastError().type() != QSqlError::NoError)
{
systemError(this, lotSave.lastError().databaseText(), __FILE__, __LINE__);
return;
}
_mode = 0;
close();
}
示例7: set
enum SetResponse taxCodeRate::set( const ParameterList & pParams )
{
XDialog::set(pParams);
QVariant param;
bool valid;
param = pParams.value("taxrate_id", &valid);
if (valid)
_taxrateid = param.toInt();
param = pParams.value("tax_id", &valid);
if (valid)
_taxId = param.toInt();
param = pParams.value("mode", &valid);
if (valid)
{
if (param.toString() == "new")
{
_mode = cNew;
q.prepare(" (SELECT taxrate_id "
" FROM taxrate "
" WHERE taxrate_tax_id = :taxrate_tax_id); ");
q.bindValue(":taxrate_tax_id", _taxId);
q.exec();
if(q.first())
{
XSqlQuery maxdate;
maxdate.prepare(" (SELECT (MAX(taxrate_expires) + 1) AS max_expires"
" FROM taxrate "
" WHERE taxrate_tax_id = :taxrate_tax_id) ");
maxdate.bindValue(":taxrate_tax_id", _taxId);
maxdate.exec();
if(maxdate.first())
{
_dates->setStartDate(maxdate.value("max_expires").toDate());
}
else if (maxdate.lastError().type() != QSqlError::NoError)
{
systemError(this, maxdate.lastError().databaseText(), __FILE__, __LINE__);
return UndefinedError;
}
}
_dates->setFocus();
q.exec("SELECT NEXTVAL('taxrate_taxrate_id_seq') AS taxrate_id");
if (q.first())
_taxrateid = q.value("taxrate_id").toInt();
else if (q.lastError().type() != QSqlError::NoError)
{
systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
return UndefinedError;
}
}
else if (param.toString() == "edit")
{
_mode = cEdit;
sPopulate();
_save->setFocus();
}
else if (param.toString() == "view")
{
_mode = cView;
sPopulate();
_dates->setEnabled(FALSE);
_percent->setEnabled(FALSE);
_flat->setEnabled(FALSE);
_close->setText(tr("&Close"));
_save->hide();
_close->setFocus();
}
}
return NoError;
}
示例8: sParseInvoiceNumber
void dspInvoiceInformation::sParseInvoiceNumber()
{
XSqlQuery dspParseInvoiceNumber;
dspParseInvoiceNumber.prepare( "SELECT invchead_id, invchead_cust_id, invchead_ponumber,"
" invchead_shipdate, invchead_invcdate,"
" invoiceTotal(invchead_id) AS amount,"
" invchead_billto_name, invchead_billto_address1,"
" invchead_billto_address2, invchead_billto_address3,"
" invchead_billto_city, invchead_billto_state, invchead_billto_zipcode,"
" invchead_shipto_name, invchead_shipto_address1,"
" invchead_shipto_address2, invchead_shipto_address3,"
" invchead_shipto_city, invchead_shipto_state, invchead_shipto_zipcode,"
" invchead_notes "
"FROM invchead LEFT OUTER JOIN"
" ( invcitem LEFT OUTER JOIN item"
" ON (invcitem_item_id=item_id) )"
" ON (invcitem_invchead_id=invchead_id) "
"WHERE (invchead_invcnumber=:invoiceNumber) "
"GROUP BY invchead_id, invchead_cust_id, invchead_ponumber,"
" invchead_shipdate, invchead_invcdate,"
" invchead_misc_amount, invchead_freight,"
" invchead_billto_name, invchead_billto_address1,"
" invchead_billto_address2, invchead_billto_address3,"
" invchead_billto_city, invchead_billto_state, invchead_billto_zipcode,"
" invchead_shipto_name, invchead_shipto_address1,"
" invchead_shipto_address2, invchead_shipto_address3,"
" invchead_shipto_city, invchead_shipto_state, invchead_shipto_zipcode,"
" invchead_notes;" );
dspParseInvoiceNumber.bindValue(":invoiceNumber", _invoiceNumber->invoiceNumber());
dspParseInvoiceNumber.exec();
if (dspParseInvoiceNumber.first())
{
_print->setEnabled(true);
_view->setEnabled(true);
_invcheadid = dspParseInvoiceNumber.value("invchead_id").toInt();
_custPoNumber->setText(dspParseInvoiceNumber.value("invchead_ponumber").toString());
_cust->setId(dspParseInvoiceNumber.value("invchead_cust_id").toInt());
_invoiceDate->setDate(dspParseInvoiceNumber.value("invchead_invcdate").toDate());
_shipDate->setDate(dspParseInvoiceNumber.value("invchead_shipdate").toDate());
_invoiceAmount->setDouble(dspParseInvoiceNumber.value("amount").toDouble());
_billToName->setText(dspParseInvoiceNumber.value("invchead_billto_name"));
_billToAddress1->setText(dspParseInvoiceNumber.value("invchead_billto_address1"));
_billToAddress2->setText(dspParseInvoiceNumber.value("invchead_billto_address2"));
_billToAddress3->setText(dspParseInvoiceNumber.value("invchead_billto_address3"));
_billToCity->setText(dspParseInvoiceNumber.value("invchead_billto_city"));
_billToState->setText(dspParseInvoiceNumber.value("invchead_billto_state"));
_billToZip->setText(dspParseInvoiceNumber.value("invchead_billto_zipcode"));
_shipToName->setText(dspParseInvoiceNumber.value("invchead_shipto_name"));
_shipToAddress1->setText(dspParseInvoiceNumber.value("invchead_shipto_address1"));
_shipToAddress2->setText(dspParseInvoiceNumber.value("invchead_shipto_address2"));
_shipToAddress3->setText(dspParseInvoiceNumber.value("invchead_shipto_address3"));
_shipToCity->setText(dspParseInvoiceNumber.value("invchead_shipto_city"));
_shipToState->setText(dspParseInvoiceNumber.value("invchead_shipto_state"));
_shipToZip->setText(dspParseInvoiceNumber.value("invchead_shipto_zipcode"));
_notes->setText(dspParseInvoiceNumber.value("invchead_notes").toString());
MetaSQLQuery mql = mqlLoad("invoiceInformation", "detail");
ParameterList params;
if (! setParams(params))
return;
dspParseInvoiceNumber = mql.toQuery(params);
_arapply->populate(dspParseInvoiceNumber);
}
else
{
if (dspParseInvoiceNumber.lastError().type() != QSqlError::NoError)
systemError(this, dspParseInvoiceNumber.lastError().databaseText(), __FILE__, __LINE__);
_print->setEnabled(false);
_view->setEnabled(false);
_invoiceNumber->clear();
_arapply->clear();
_invcheadid = -1;
}
}
示例9: sReceive
void enterPoitemReceipt::sReceive()
{
XSqlQuery enterReceive;
XSqlQuery rollback;
rollback.prepare("ROLLBACK;");
if(_metrics->boolean("DisallowReceiptExcessQty") && _receivable < _toReceive->toDouble())
{
XMessageBox::message( (isVisible() ? this : parentWidget()), QMessageBox::Warning, tr("Cannot Receive"),
tr( "<p>Cannot receive more quantity than ordered." ),
QString::null, QString::null, _snooze );
return;
}
if(_ordertype == "RA" && _receivable < _toReceive->toDouble())
{
XMessageBox::message( (isVisible() ? this : parentWidget()), QMessageBox::Warning, tr("Cannot Receive"),
tr( "<p>Cannot receive more quantity than authorized." ),
QString::null, QString::null, _snooze );
return;
}
double tolerance = _metrics->value("ReceiptQtyTolerancePct").toDouble() / 100.0;
if(_metrics->boolean("WarnIfReceiptQtyDiffers") &&
(_receivable < _toReceive->toDouble() * (1.0 - tolerance) ||
_receivable > _toReceive->toDouble() * (1.0 + tolerance)))
{
if(XMessageBox::message( (isVisible() ? this : parentWidget()) , QMessageBox::Question, tr("Receipt Qty. Differs"),
tr("<p>The Qty entered does not match the receivable Qty for this order. "
"Do you wish to continue anyway?"),
tr("Yes"), tr("No"), _snooze, 0, 1) == 1)
return;
}
int result = 0;
QString storedProc;
if (_mode == cNew)
{
enterReceive.prepare("SELECT enterReceipt(:ordertype, :poitem_id, :qty, :freight, :notes, "
":curr_id, :effective, :purchcost) AS result;");
enterReceive.bindValue(":poitem_id", _orderitemid);
enterReceive.bindValue(":ordertype", _ordertype);
storedProc = "enterReceipt";
}
else if (_mode == cEdit)
{
enterReceive.exec("BEGIN;"); // because of possible lot, serial, or location distribution cancelations
enterReceive.prepare("UPDATE recv SET recv_notes = :notes WHERE (recv_id=:recv_id);" );
enterReceive.bindValue(":notes", _notes->toPlainText());
enterReceive.bindValue(":recv_id", _recvid);
enterReceive.exec();
if (enterReceive.lastError().type() != QSqlError::NoError)
{
rollback.exec();
systemError(this, enterReceive.lastError().databaseText(), __FILE__, __LINE__);
return;
}
enterReceive.prepare("SELECT correctReceipt(:recv_id, :qty, :freight, 0, "
":curr_id, :effective, :purchcost) AS result;");
enterReceive.bindValue(":recv_id", _recvid);
storedProc = "correctReceipt";
}
enterReceive.bindValue(":qty", _toReceive->toDouble());
enterReceive.bindValue(":freight", _freight->localValue());
enterReceive.bindValue(":notes", _notes->toPlainText());
enterReceive.bindValue(":curr_id", _freight->id());
enterReceive.bindValue(":effective", _receiptDate->date());
enterReceive.bindValue(":purchcost", _purchCost->localValue());
enterReceive.exec();
if (enterReceive.first())
{
result = enterReceive.value("result").toInt();
if (result < 0)
{
rollback.exec();
systemError(this, storedProcErrorLookup(storedProc, result),
__FILE__, __LINE__);
return;
}
}
else if (enterReceive.lastError().type() != QSqlError::NoError)
{
rollback.exec();
systemError(this, enterReceive.lastError().databaseText(), __FILE__, __LINE__);
return;
}
if(cEdit == _mode)
{
if (distributeInventory::SeriesAdjust(result, this) == XDialog::Rejected)
{
rollback.exec();
XMessageBox::message( (isVisible() ? this : parentWidget()), QMessageBox::Warning, tr("Enter PO Receipt"),
tr( "<p>Transaction Cancelled." ),
QString::null, QString::null, _snooze );
return;
}
//.........这里部分代码省略.........
示例10: sSave
void invoiceItem::sSave()
{
QList<GuiErrorCheck> errors;
errors << GuiErrorCheck(_itemSelected->isChecked() && !_item->isValid(), _item,
tr("<p>You must select an Item for this Invoice Item before you may save it."))
<< GuiErrorCheck(!_itemSelected->isChecked() && !_itemNumber->text().length(), _itemNumber,
tr("<p>You must enter an Item Number for this Miscellaneous Invoice Item before you may save it."))
<< GuiErrorCheck(!_itemSelected->isChecked() && !_itemDescrip->toPlainText().length(), _itemDescrip,
tr("<p>You must enter a Item Description for this Miscellaneous Invoice Item before you may save it."))
<< GuiErrorCheck(!_itemSelected->isChecked() && !_salescat->isValid(), _salescat,
tr("<p>You must select a Sales Category for this Miscellaneous Invoice Item before you may save it."))
;
if (GuiErrorCheck::reportErrors(this, tr("Cannot Save Invoice Item"), errors))
return;
XSqlQuery invoiceSave;
if (_mode == cNew)
{
invoiceSave.prepare( "INSERT INTO invcitem "
"( invcitem_id, invcitem_invchead_id, invcitem_linenumber,"
" invcitem_item_id, invcitem_warehous_id,"
" invcitem_number, invcitem_descrip, invcitem_salescat_id,"
" invcitem_custpn,"
" invcitem_ordered, invcitem_billed, invcitem_updateinv,"
" invcitem_qty_uom_id, invcitem_qty_invuomratio,"
" invcitem_custprice, invcitem_price,"
" invcitem_price_uom_id, invcitem_price_invuomratio,"
" invcitem_notes, "
" invcitem_taxtype_id, invcitem_rev_accnt_id) "
"VALUES "
"( :invcitem_id, :invchead_id, :invcitem_linenumber,"
" :item_id, :warehous_id,"
" :invcitem_number, :invcitem_descrip, :invcitem_salescat_id,"
" :invcitem_custpn,"
" :invcitem_ordered, :invcitem_billed, :invcitem_updateinv,"
" :qty_uom_id, :qty_invuomratio,"
" :invcitem_custprice, :invcitem_price,"
" :price_uom_id, :price_invuomratio,"
" :invcitem_notes, "
" :invcitem_taxtype_id, :invcitem_rev_accnt_id);");
invoiceSave.bindValue(":invchead_id", _invcheadid);
invoiceSave.bindValue(":invcitem_linenumber", _lineNumber->text());
}
else if (_mode == cEdit)
invoiceSave.prepare( "UPDATE invcitem "
"SET invcitem_item_id=:item_id, invcitem_warehous_id=:warehous_id,"
" invcitem_number=:invcitem_number, invcitem_descrip=:invcitem_descrip,"
" invcitem_salescat_id=:invcitem_salescat_id,"
" invcitem_custpn=:invcitem_custpn, invcitem_updateinv=:invcitem_updateinv,"
" invcitem_ordered=:invcitem_ordered, invcitem_billed=:invcitem_billed,"
" invcitem_qty_uom_id=:qty_uom_id, invcitem_qty_invuomratio=:qty_invuomratio,"
" invcitem_custprice=:invcitem_custprice, invcitem_price=:invcitem_price,"
" invcitem_price_uom_id=:price_uom_id, invcitem_price_invuomratio=:price_invuomratio,"
" invcitem_notes=:invcitem_notes,"
" invcitem_taxtype_id=:invcitem_taxtype_id,"
" invcitem_rev_accnt_id=:invcitem_rev_accnt_id "
"WHERE (invcitem_id=:invcitem_id);" );
if (_itemSelected->isChecked())
{
invoiceSave.bindValue(":item_id", _item->id());
invoiceSave.bindValue(":warehous_id", _warehouse->id());
}
else
{
invoiceSave.bindValue(":item_id", -1);
invoiceSave.bindValue(":warehous_id", -1);
}
invoiceSave.bindValue(":invcitem_id", _invcitemid);
invoiceSave.bindValue(":invcitem_number", _itemNumber->text());
invoiceSave.bindValue(":invcitem_descrip", _itemDescrip->toPlainText());
invoiceSave.bindValue(":invcitem_salescat_id", _salescat->id());
invoiceSave.bindValue(":invcitem_custpn", _custPn->text());
invoiceSave.bindValue(":invcitem_ordered", _ordered->toDouble());
invoiceSave.bindValue(":invcitem_billed", _billed->toDouble());
invoiceSave.bindValue(":invcitem_updateinv", QVariant(_updateInv->isChecked()));
if(!_miscSelected->isChecked())
invoiceSave.bindValue(":qty_uom_id", _qtyUOM->id());
invoiceSave.bindValue(":qty_invuomratio", _qtyinvuomratio);
invoiceSave.bindValue(":invcitem_custprice", _custPrice->localValue());
invoiceSave.bindValue(":invcitem_price", _price->localValue());
if(!_miscSelected->isChecked())
invoiceSave.bindValue(":price_uom_id", _pricingUOM->id());
invoiceSave.bindValue(":price_invuomratio", _priceinvuomratio);
invoiceSave.bindValue(":invcitem_notes", _notes->toPlainText());
if(_taxtype->isValid())
invoiceSave.bindValue(":invcitem_taxtype_id", _taxtype->id());
if (_altRevAccnt->isValid())
invoiceSave.bindValue(":invcitem_rev_accnt_id", _altRevAccnt->id());
invoiceSave.exec();
if (invoiceSave.lastError().type() != QSqlError::NoError)
{
systemError(this, invoiceSave.lastError().databaseText(), __FILE__, __LINE__);
return;
}
_saved = true;
//.........这里部分代码省略.........
示例11: populate
void invoiceItem::populate()
{
XSqlQuery invcitem;
invcitem.prepare( "SELECT invcitem.*, invchead_invcnumber,"
" CASE WHEN (item_id IS NULL) THEN :na"
" ELSE item_listprice"
" END AS f_listprice,"
" taxzone_id,"
" invchead_curr_id AS taxcurr_id,"
" itemsite_costmethod"
" FROM invcitem JOIN "
" invchead LEFT OUTER JOIN taxzone ON "
" (invchead_taxzone_id = taxzone_id) "
" ON (invcitem_invchead_id = invchead_id) LEFT OUTER JOIN "
" item ON (invcitem_item_id = item_id) "
" LEFT OUTER JOIN invcitemtax ON (invcitem_id = taxhist_parent_id) "
" LEFT OUTER JOIN itemsite ON (itemsite_item_id=item_id "
" AND itemsite_warehous_id=invcitem_warehous_id)"
"WHERE (invcitem_id = :invcitem_id);" );
invcitem.bindValue(":invcitem_id", _invcitemid);
invcitem.exec();
if (invcitem.first())
{
_invcheadid = invcitem.value("invcitem_invchead_id").toInt();
_invoiceNumber->setText(invcitem.value("invchead_invcnumber").toString());
_lineNumber->setText(invcitem.value("invcitem_linenumber").toString());
// TODO: should this check itemsite_controlmethod == N?
_trackqoh = (invcitem.value("invcitem_coitem_id").toInt() > 0 &&
invcitem.value("itemsite_costmethod").toString() != "J");
if (invcitem.value("invcitem_item_id").toInt() != -1)
{
_itemSelected->setChecked(TRUE);
_item->setId(invcitem.value("invcitem_item_id").toInt());
_warehouse->setId(invcitem.value("invcitem_warehous_id").toInt());
}
else
{
_miscSelected->setChecked(TRUE);
_itemNumber->setText(invcitem.value("invcitem_number"));
_itemDescrip->setText(invcitem.value("invcitem_descrip").toString());
_salescat->setId(invcitem.value("invcitem_salescat_id").toInt());
}
_qtyUOM->setId(invcitem.value("invcitem_qty_uom_id").toInt());
_qtyinvuomratio = invcitem.value("invcitem_qty_invuomratio").toDouble();
_pricingUOM->setId(invcitem.value("invcitem_price_uom_id").toInt());
_priceinvuomratio = invcitem.value("invcitem_price_invuomratio").toDouble();
// do tax stuff before invcitem_price and _tax_* to avoid signal cascade problems
if (! invcitem.value("taxzone_id").isNull())
_taxzoneid = invcitem.value("taxzone_id").toInt();
_tax->setId(invcitem.value("taxcurr_id").toInt());
_taxtype->setId(invcitem.value("invcitem_taxtype_id").toInt());
_altRevAccnt->setId(invcitem.value("invcitem_rev_accnt_id").toInt());
_ordered->setDouble(invcitem.value("invcitem_ordered").toDouble());
_billed->setDouble(invcitem.value("invcitem_billed").toDouble());
// TODO: why not setChecked then call sHandleUpdateInv
if ( (invcitem.value("invcitem_coitem_id").toInt() > 0) ||
(invcitem.value("itemsite_costmethod").toString() == "J") ||
(invcitem.value("invcitem_item_id").toInt() == -1) )
{
_updateInv->setChecked(false);
_updateInv->setEnabled(false);
}
else
{
_updateInv->setChecked(invcitem.value("invcitem_updateinv").toBool());
_updateInv->setEnabled(true);
}
_price->setLocalValue(invcitem.value("invcitem_price").toDouble());
_custPrice->setLocalValue(invcitem.value("invcitem_custprice").toDouble());
_listPrice->setBaseValue(invcitem.value("f_listprice").toDouble() * (_priceinvuomratio / _priceRatioCache));
_custPn->setText(invcitem.value("invcitem_custpn").toString());
_notes->setText(invcitem.value("invcitem_notes").toString());
}
else if (invcitem.lastError().type() != QSqlError::NoError)
{
systemError(this, invcitem.lastError().databaseText(), __FILE__, __LINE__);
return;
}
invcitem.prepare( "SELECT SUM(COALESCE(taxhist_tax, 0.00)) AS lineTaxTotal "
"FROM invcitem LEFT OUTER JOIN invcitemtax "
" ON (invcitem_id = taxhist_parent_id) "
"WHERE invcitem_id = :invcitem_id;" );
invcitem.bindValue(":invcitem_id", _invcitemid);
invcitem.exec();
if (invcitem.first())
_tax->setLocalValue(invcitem.value("lineTaxTotal").toDouble());
else if (invcitem.lastError().type() != QSqlError::NoError)
{
systemError(this, invcitem.lastError().databaseText(), __FILE__, __LINE__);
return;
}
//.........这里部分代码省略.........
示例12: sPopulateItemInfo
void invoiceItem::sPopulateItemInfo(int pItemid)
{
XSqlQuery invoicePopulateItemInfo;
if ( (_itemSelected->isChecked()) && (pItemid != -1) )
{
XSqlQuery uom;
uom.prepare("SELECT uom_id, uom_name"
" FROM item"
" JOIN uom ON (item_inv_uom_id=uom_id)"
" WHERE(item_id=:item_id)"
" UNION "
"SELECT uom_id, uom_name"
" FROM item"
" JOIN itemuomconv ON (itemuomconv_item_id=item_id)"
" JOIN uom ON (itemuomconv_to_uom_id=uom_id)"
" WHERE((itemuomconv_from_uom_id=item_inv_uom_id)"
" AND (item_id=:item_id))"
" UNION "
"SELECT uom_id, uom_name"
" FROM item"
" JOIN itemuomconv ON (itemuomconv_item_id=item_id)"
" JOIN uom ON (itemuomconv_from_uom_id=uom_id)"
" WHERE((itemuomconv_to_uom_id=item_inv_uom_id)"
" AND (item_id=:item_id))"
" ORDER BY uom_name;");
uom.bindValue(":item_id", _item->id());
uom.exec();
_qtyUOM->populate(uom);
_pricingUOM->populate(uom);
invoicePopulateItemInfo.prepare( "SELECT item_inv_uom_id, item_price_uom_id,"
" iteminvpricerat(item_id) AS invpricerat,"
" item_listprice, item_fractional, "
" stdcost(item_id) AS f_unitcost,"
" getItemTaxType(item_id, :taxzone) AS taxtype_id,"
" itemsite_costmethod"
" FROM item"
" JOIN itemsite ON (item_id=itemsite_item_id)"
" WHERE ((item_id=:item_id)"
" AND (itemsite_warehous_id=:whsid));" );
invoicePopulateItemInfo.bindValue(":item_id", pItemid);
invoicePopulateItemInfo.bindValue(":taxzone", _taxzoneid);
invoicePopulateItemInfo.bindValue(":whsid", _warehouse->id());
invoicePopulateItemInfo.exec();
if (invoicePopulateItemInfo.first())
{
_priceRatioCache = invoicePopulateItemInfo.value("invpricerat").toDouble();
_listPrice->setBaseValue(invoicePopulateItemInfo.value("item_listprice").toDouble());
_invuomid = invoicePopulateItemInfo.value("item_inv_uom_id").toInt();
_qtyUOM->setId(invoicePopulateItemInfo.value("item_inv_uom_id").toInt());
_pricingUOM->setId(invoicePopulateItemInfo.value("item_price_uom_id").toInt());
_qtyinvuomratio = 1.0;
_priceinvuomratio = invoicePopulateItemInfo.value("invpricerat").toDouble();
_unitCost->setBaseValue(invoicePopulateItemInfo.value("f_unitcost").toDouble());
_taxtype->setId(invoicePopulateItemInfo.value("taxtype_id").toInt());
if (invoicePopulateItemInfo.value("item_fractional").toBool())
{
_ordered->setValidator(omfgThis->qtyVal());
_billed->setValidator(omfgThis->qtyVal());
}
else
{
_ordered->setValidator(new XDoubleValidator(0, 999999, 0, this));
_billed->setValidator(new XDoubleValidator(0, 999999, 0, this));
}
sDeterminePrice();
// TODO: should this check itemsite_controlmethod == N?
_trackqoh = (invoicePopulateItemInfo.value("itemsite_costmethod").toString() != "J");
}
else if (invoicePopulateItemInfo.lastError().type() != QSqlError::NoError)
{
systemError(this, invoicePopulateItemInfo.lastError().databaseText(), __FILE__, __LINE__);
return;
}
}
else
{
_priceRatioCache = 1.0;
_qtyinvuomratio = 1.0;
_priceinvuomratio = 1.0;
_qtyUOM->clear();
_pricingUOM->clear();
_listPrice->clear();
_unitCost->clear();
}
}
示例13: set
enum SetResponse invoiceItem::set(const ParameterList &pParams)
{
XSqlQuery invoiceet;
XDialog::set(pParams);
QVariant param;
bool valid;
param = pParams.value("invchead_id", &valid);
if (valid)
{
_invcheadid = param.toInt();
invoiceet.prepare("SELECT * "
"FROM invchead "
"WHERE (invchead_id = :invchead_id);");
invoiceet.bindValue(":invchead_id", _invcheadid);
invoiceet.exec();
if (invoiceet.first())
{
_invoiceNumber->setText(invoiceet.value("invchead_invcnumber").toString());
_custid = invoiceet.value("invchead_cust_id").toInt();
_taxzoneid = invoiceet.value("invchead_taxzone_id").toInt();
_tax->setId(invoiceet.value("invchead_curr_id").toInt());
_price->setId(invoiceet.value("invchead_curr_id").toInt());
_price->setEffective(invoiceet.value("invchead_invcdate").toDate());
sPriceGroup();
}
else if (invoiceet.lastError().type() != QSqlError::NoError)
{
systemError(this, invoiceet.lastError().databaseText(), __FILE__, __LINE__);
return UndefinedError;
}
}
param = pParams.value("invcitem_id", &valid);
if (valid)
{
_invcitemid = param.toInt();
populate();
}
param = pParams.value("mode", &valid);
if (valid)
{
if (param.toString() == "new")
{
_mode = cNew;
invoiceet.exec("SELECT NEXTVAL('invcitem_invcitem_id_seq') AS invcitem_id;");
if (invoiceet.first())
_invcitemid = invoiceet.value("invcitem_id").toInt();
else if (invoiceet.lastError().type() != QSqlError::NoError)
{
systemError(this, invoiceet.lastError().databaseText(), __FILE__, __LINE__);
return UndefinedError;
}
invoiceet.prepare( "SELECT (COALESCE(MAX(invcitem_linenumber), 0) + 1) AS linenumber "
"FROM invcitem "
"WHERE (invcitem_invchead_id=:invchead_id);" );
invoiceet.bindValue(":invchead_id", _invcheadid);
invoiceet.exec();
if (invoiceet.first())
_lineNumber->setText(invoiceet.value("linenumber").toString());
else if (invoiceet.lastError().type() != QSqlError::NoError)
{
systemError(this, invoiceet.lastError().databaseText(), __FILE__, __LINE__);
return UndefinedError;
}
connect(_billed, SIGNAL(editingFinished()), this, SLOT(sDeterminePrice()));
connect(_billed, SIGNAL(editingFinished()), this, SLOT(sCalculateExtendedPrice()));
connect(_price, SIGNAL(editingFinished()), this, SLOT(sCalculateExtendedPrice()));
_item->setType(ItemLineEdit::cSold);
_salescat->setType(XComboBox::SalesCategoriesActive);
}
else if (param.toString() == "edit")
{
_mode = cEdit;
connect(_billed, SIGNAL(editingFinished()), this, SLOT(sDeterminePrice()));
connect(_billed, SIGNAL(editingFinished()), this, SLOT(sCalculateExtendedPrice()));
connect(_price, SIGNAL(editingFinished()), this, SLOT(sCalculateExtendedPrice()));
}
else if (param.toString() == "view")
{
_mode = cView;
_itemTypeGroup->setEnabled(FALSE);
_custPn->setEnabled(FALSE);
_ordered->setEnabled(FALSE);
_billed->setEnabled(FALSE);
_price->setEnabled(FALSE);
_notes->setReadOnly(TRUE);
_taxtype->setEnabled(false);
_altRevAccnt->setEnabled(false);
_qtyUOM->setEnabled(false);
_pricingUOM->setEnabled(false);
_save->hide();
//.........这里部分代码省略.........
示例14: sProcess
void returnAuthorizationWorkbench::sProcess()
{
XSqlQuery returnProcess;
if (!checkSitePrivs(_radue->id()))
return;
bool _post = ((_radue->altId() > 1) ||
(_radue->altId() == 1 && _postmemos->isChecked())) ;
returnProcess.prepare("SELECT createRaCreditMemo(:rahead_id,:post) AS result;");
returnProcess.bindValue(":rahead_id",_radue->id());
returnProcess.bindValue(":post",QVariant(_post));
returnProcess.exec();
if (returnProcess.first())
{
int cmheadid = returnProcess.value("result").toInt();
if (cmheadid < 0)
{
systemError(this, storedProcErrorLookup("createRaCreditMemo", cmheadid), __FILE__, __LINE__);
return;
}
returnProcess.prepare( "SELECT cmhead_number "
"FROM cmhead "
"WHERE (cmhead_id=:cmhead_id);" );
returnProcess.bindValue(":cmhead_id", cmheadid);
returnProcess.exec();
if (returnProcess.first())
{
QMessageBox::information( this, tr("New Return Created"),
tr("<p>A new Return has been created and "
"assigned #%1")
.arg(returnProcess.value("cmhead_number").toString()));
if (_printmemo->isChecked())
{
ParameterList params;
params.append("cmhead_id", cmheadid);
if (_post)
params.append("posted");
printCreditMemo newdlg(this, "", TRUE);
newdlg.set(params);
newdlg.exec();
}
if (_radue->altId() == 2)
{
ParameterList params;
params.append("cmhead_id", cmheadid);
returnAuthCheck newdlg(this, "", TRUE);
newdlg.set(params);
if (newdlg.exec() != XDialog::Rejected)
sFillListDue();
}
else if (_radue->altId() == 3)
{
ParameterList ccp;
ccp.append("cmhead_id", cmheadid);
MetaSQLQuery ccm = mqlLoad("creditMemoCreditCards", "detail");
XSqlQuery ccq = ccm.toQuery(ccp);
if (ccq.first())
{
int ccpayid = ccq.value("ccpay_id").toInt();
CreditCardProcessor *cardproc = CreditCardProcessor::getProcessor();
if (! cardproc)
QMessageBox::critical(this, tr("Credit Card Processing Error"),
CreditCardProcessor::errorMsg());
else if (! cardproc->errorMsg().isEmpty())
QMessageBox::critical(this, tr("Credit Card Processing Warning"),
cardproc->errorMsg());
else
{
QString docnum = returnProcess.value("cmhead_number").toString();
QString refnum = ccq.value("cohead_number").toString();
int refid = -1;
int returnValue = cardproc->credit(ccq.value("ccard_id").toInt(),
"-2",
ccq.value("total").toDouble(),
ccq.value("tax_in_cmcurr").toDouble(),
ccq.value("cmhead_tax_id").isNull(),
ccq.value("cmhead_freight").toDouble(),
0,
ccq.value("cmhead_curr_id").toInt(),
docnum, refnum, ccpayid,
QString(), refid);
if (returnValue < 0)
QMessageBox::critical(this, tr("Credit Card Processing Error"),
cardproc->errorMsg());
else if (returnValue > 0)
QMessageBox::warning(this, tr("Credit Card Processing Warning"),
cardproc->errorMsg());
else if (! cardproc->errorMsg().isEmpty())
QMessageBox::information(this, tr("Credit Card Processing Note"),
cardproc->errorMsg());
}
// requery regardless 'cause the new return means nothing's "due"
sFillListDue();
}
else if (ccq.lastError().type() != QSqlError::NoError)
{
systemError(this, ccq.lastError().databaseText(), __FILE__, __LINE__);
//.........这里部分代码省略.........
示例15: saveToDb
bool ReportWindow::saveToDb() {
// do what we need to do
DBFileDialog rptDiag;
rptDiag.setCaption(tr("Save Report to Database"));
if(!dbRecordName.isEmpty()) {
rptDiag._name->setText(dbRecordName);
} else {
rptDiag._name->setText(reportName());
}
rptDiag._grade->setValue(dbRecordGrade);
if(rptDiag.exec() == QDialog::Accepted) {
QString name = rptDiag.getName();
QString desc = reportDescription();
QString src = document().toString();
int grade = rptDiag.getGrade();
XSqlQuery q;
XSqlQuery qry;
q.prepare("SELECT report_id "
" FROM report "
" WHERE ((report_name=:report_name) "
" AND (report_grade=:report_grade)); ");
q.bindValue(":report_name", name);
q.bindValue(":report_grade", grade);
q.exec();
if(q.first()) {
// update old record
qry.prepare("UPDATE report "
" SET report_source=:report_source, "
" report_descrip=:report_descrip "
" WHERE (report_id=:report_id);");
qry.bindValue(":report_source", src);
qry.bindValue(":report_descrip", desc);
qry.bindValue(":report_id", q.value("report_id").toInt());
} else {
// insert new record
qry.prepare("INSERT INTO report "
" (report_name, report_source, report_descrip, report_grade) "
"VALUES (:report_name, :report_source, :report_descrip, :report_grade);");
qry.bindValue(":report_name", name);
qry.bindValue(":report_source", src);
qry.bindValue(":report_descrip", desc);
qry.bindValue(":report_grade", grade);
}
if(qry.exec()) {
lastSaveToDb = TRUE;
setModified(FALSE);
dbRecordName = name;
dbRecordGrade = grade;
if(_handler)
{
q.exec();
if(q.first())
_handler->sReportsChanged(q.value("report_id").toInt(), true);
else
_handler->sReportsChanged(-1, true);
}
return TRUE;
} else {
// no good lets tell the user
QSqlError sqlErr = qry.lastError();
QMessageBox::critical(this,tr("Error saving to database"),sqlErr.databaseText());
}
}
return FALSE;
}