本文整理汇总了C++中XSqlQuery::exec方法的典型用法代码示例。如果您正苦于以下问题:C++ XSqlQuery::exec方法的具体用法?C++ XSqlQuery::exec怎么用?C++ XSqlQuery::exec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XSqlQuery
的用法示例。
在下文中一共展示了XSqlQuery::exec方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sSave
void bankAdjustment::sSave()
{
XSqlQuery bankSave;
QList<GuiErrorCheck> errors;
errors << GuiErrorCheck(!_date->isValid(), _date,
tr("You must enter a date before posting this Bank Adjustment."))
<< GuiErrorCheck(_amount->isZero(), _amount,
tr("You must enter an amount before posting this Bank Adjustment."))
;
bankSave.prepare ("SELECT period_id "
"FROM period "
"WHERE :date BETWEEN period_start and period_end;");
bankSave.bindValue(":date", _date->date());
bankSave.exec();
if (!bankSave.first())
{
errors << GuiErrorCheck(true, _date,
tr("You must enter a valid fiscal period date before posting this Bank Adjustment."));
}
if (GuiErrorCheck::reportErrors(this, tr("Cannot Save Bank Adjustment"), errors))
return;
if (_mode == cNew)
bankSave.prepare("INSERT INTO bankadj "
"(bankadj_bankaccnt_id, bankadj_bankadjtype_id,"
" bankadj_date, bankadj_docnumber, bankadj_amount, "
" bankadj_notes, bankadj_curr_id ) "
"VALUES "
"(:bankaccnt_id, :bankadjtype_id,"
" :date, :docnumber, :amount, :notes, :curr_id);" );
else if (_mode == cEdit)
{
bankSave.prepare ("UPDATE bankadj "
"SET bankadj_bankaccnt_id=:bankaccnt_id,"
" bankadj_bankadjtype_id=:bankadjtype_id,"
" bankadj_date=:date,"
" bankadj_docnumber=:docnumber,"
" bankadj_amount=:amount,"
" bankadj_notes=:notes, "
" bankadj_curr_id=:curr_id "
"WHERE ((bankadj_id=:bankadj_id)"
" AND (NOT bankadj_posted) ); ");
bankSave.bindValue(":bankadj_id", _bankadjid);
}
bankSave.bindValue(":bankaccnt_id", _bankaccnt->id());
bankSave.bindValue(":bankadjtype_id", _bankadjtype->id());
bankSave.bindValue(":date", _date->date());
bankSave.bindValue(":docnumber", _docNumber->text());
bankSave.bindValue(":amount", _amount->localValue());
bankSave.bindValue(":notes", _notes->toPlainText());
bankSave.bindValue(":curr_id", _amount->id());
if(!bankSave.exec())
{
ErrorReporter::error(QtCriticalMsg, this, tr("Error Saving Bank Adjustment"),
bankSave, __FILE__, __LINE__);
return;
}
omfgThis->sBankAdjustmentsUpdated(_bankadjid, true);
close();
}
示例2: sHandleSo
void shipOrder::sHandleSo()
{
XSqlQuery shipHandleSo;
_coitem->clear();
_shipment->setEnabled(false);
_shipment->removeOrderLimit();
sHandleButtons();
shipHandleSo.prepare( "SELECT cohead_holdtype, cust_name, cohead_shiptoname, "
" cohead_shiptoaddress1, cohead_curr_id, cohead_freight "
"FROM cohead, custinfo "
"WHERE ((cohead_cust_id=cust_id) "
" AND (cohead_id=:sohead_id));" );
shipHandleSo.bindValue(":sohead_id", _order->id());
shipHandleSo.exec();
if (shipHandleSo.first())
{
QString msg;
if ( (shipHandleSo.value("cohead_holdtype").toString() == "C"))
msg = storedProcErrorLookup("shipShipment", -12);
else if (shipHandleSo.value("cohead_holdtype").toString() == "P")
msg = storedProcErrorLookup("shipShipment", -13);
else if (shipHandleSo.value("cohead_holdtype").toString() == "R")
msg = storedProcErrorLookup("shipShipment", -14);
else if (shipHandleSo.value("cohead_holdtype").toString() == "S")
msg = storedProcErrorLookup("shipShipment", -15);
if (! msg.isEmpty())
{
QMessageBox::warning(this, tr("Cannot Ship Order"), msg);
if (_captive)
{
_reject = true; // so set() can return an error
reject(); // this only works if shipOrder has been exec()'ed
}
else
{
_order->setId(-1);
return;
}
}
_freight->setId(shipHandleSo.value("cohead_curr_id").toInt());
_freight->setLocalValue(shipHandleSo.value("cohead_freight").toDouble());
_billToName->setText(shipHandleSo.value("cust_name").toString());
_shipToName->setText(shipHandleSo.value("cohead_shiptoname").toString());
_shipToAddr1->setText(shipHandleSo.value("cohead_shiptoaddress1").toString());
QString sql( "SELECT shiphead_id "
"FROM shiphead "
"WHERE ( (NOT shiphead_shipped)"
"<? if exists(\"shiphead_id\") ?>"
" AND (shiphead_id=<? value(\"shiphead_id\") ?>)"
"<? endif ?>"
" AND (shiphead_order_id=<? value(\"sohead_id\") ?>)"
" AND (shiphead_order_type='SO'));" );
ParameterList params;
params.append("sohead_id", _order->id());
if (_shipment->isValid())
params.append("shiphead_id", _shipment->id());
MetaSQLQuery mql(sql);
shipHandleSo = mql.toQuery(params);
if (shipHandleSo.first())
{
if (_shipment->id() != shipHandleSo.value("shiphead_id").toInt())
_shipment->setId(shipHandleSo.value("shiphead_id").toInt());
if (shipHandleSo.next())
{
_shipment->setType("SO");
_shipment->limitToOrder(_order->id());
_shipment->setEnabled(true);
}
}
else if (shipHandleSo.lastError().type() != QSqlError::NoError)
{
systemError(this, shipHandleSo.lastError().databaseText(), __FILE__, __LINE__);
return;
}
else if (_shipment->isValid())
{
params.clear();
params.append("sohead_id", _order->id());
MetaSQLQuery mql(sql);
shipHandleSo = mql.toQuery(params);
if (shipHandleSo.first())
{
_shipment->setId(shipHandleSo.value("shiphead_id").toInt());
if (shipHandleSo.next())
{
_shipment->setType("SO");
_shipment->limitToOrder(_order->id());
_shipment->setEnabled(true);
}
}
else if (shipHandleSo.lastError().type() != QSqlError::NoError)
{
systemError(this, shipHandleSo.lastError().databaseText(), __FILE__, __LINE__);
//.........这里部分代码省略.........
示例3: setParams
bool dspGLTransactions::setParams(ParameterList ¶ms)
{
if (!display::setParams(params))
return false;
bool valid;
QVariant param;
param = params.value("accnttype_id", &valid);
if (valid)
{
int typid = param.toInt();
QString type;
if (typid == 1)
type = "A";
else if (typid ==2)
type = "E";
else if (typid ==3)
type = "L";
else if (typid ==4)
type = "Q";
else if (typid ==5)
type = "R";
params.append("accntType", type);
}
param = params.value("source_id", &valid);
if (valid)
params.append("source", _sources.at(param.toInt()));
param = params.value("num_id", &valid);
if (valid)
{
XSqlQuery num;
num.prepare("SELECT accnt_number "
"FROM accnt "
"WHERE (accnt_id=:accnt_id);");
num.bindValue(":accnt_id", params.value("num_id").toInt());
num.exec();
if (num.first())
params.append("accnt_number", num.value("accnt_number").toString());
}
param = params.value("accnt_id", &valid);
if (valid)
{
if (_showRunningTotal->isChecked() &&
_showRunningTotal->isVisible())
{
double beginning = 0;
QDate periodStart = params.value("startDate").toDate();
XSqlQuery begq;
begq.prepare("SELECT "
" CASE WHEN accnt_type IN ('A','E') THEN "
" trialbal_beginning * -1 "
" ELSE trialbal_beginning END AS trialbal_beginning,"
" period_start "
"FROM trialbal "
" JOIN accnt ON (trialbal_accnt_id=accnt_id), "
" period "
"WHERE ((trialbal_period_id=period_id)"
" AND (trialbal_accnt_id=:accnt_id)"
" AND (:start BETWEEN period_start AND period_end));");
begq.bindValue(":accnt_id", params.value("accnt_id").toInt());
begq.bindValue(":start", params.value("startDate").toDate());
begq.exec();
if (begq.first())
{
beginning = begq.value("trialbal_beginning").toDouble();
periodStart = begq.value("period_start").toDate();
}
else if (begq.lastError().type() != QSqlError::NoError)
{
systemError(this, begq.lastError().databaseText(), __FILE__, __LINE__);
return false;
}
XSqlQuery glq;
glq.prepare("SELECT CASE WHEN accnt_type IN ('A','E') THEN "
" COALESCE(SUM(gltrans_amount),0) * -1"
" ELSE COALESCE(SUM(gltrans_amount),0) END AS glamount "
"FROM gltrans "
" JOIN accnt ON (gltrans_accnt_id=accnt_id) "
"WHERE ((gltrans_date BETWEEN :periodstart AND date :querystart - interval '1 day')"
" AND (gltrans_accnt_id=:accnt_id)"
" AND (NOT gltrans_deleted)) "
"GROUP BY accnt_type;");
glq.bindValue(":periodstart", periodStart);
glq.bindValue(":querystart", params.value("startDate").toDate());
glq.bindValue(":accnt_id", params.value("accnt_id").toInt());
glq.exec();
if (glq.first())
beginning += glq.value("glamount").toDouble();
else if (glq.lastError().type() != QSqlError::NoError)
{
systemError(this, glq.lastError().databaseText(), __FILE__, __LINE__);
return false;
}
//.........这里部分代码省略.........
示例4: sSave
void company::sSave()
{
XSqlQuery companySave;
if (_number->text().length() == 0)
{
QMessageBox::warning( this, tr("Cannot Save Company"),
tr("You must enter a valid Number.") );
_number->setFocus();
return;
}
struct {
bool condition;
QString msg;
QWidget* widget;
} error[] = {
{ _external->isChecked() && _extServer->text().isEmpty(),
tr("<p>You must enter a Server if this is an external Company."),
_extServer
},
{ _external->isChecked() && _extPort->value() == 0,
tr("<p>You must enter a Port if this is an external Company."),
_extPort
},
{ _external->isChecked() && _extDB->text().isEmpty(),
tr("<p>You must enter a Database if this is an external Company."),
_extDB
},
{ true, "", NULL }
}; // error[]
int errIndex;
for (errIndex = 0; ! error[errIndex].condition; errIndex++)
;
if (! error[errIndex].msg.isEmpty())
{
QMessageBox::critical(this, tr("Cannot Save Company"),
error[errIndex].msg);
error[errIndex].widget->setFocus();
return;
}
companySave.prepare("SELECT company_id"
" FROM company"
" WHERE((company_id != :company_id)"
" AND (company_number=:company_number))");
companySave.bindValue(":company_id", _companyid);
companySave.bindValue(":company_number", _number->text());
companySave.exec();
if(companySave.first())
{
QMessageBox::critical(this, tr("Duplicate Company Number"),
tr("A Company Number already exists for the one specified.") );
_number->setFocus();
return;
}
if (_yearend->isValid() &&
_companyid != _yearend->companyId())
{
QMessageBox::critical(this, tr("Company Account Mismatch"),
tr("The Retained Earnings Account must belong to this Company.") );
_yearend->setFocus();
return;
}
if (_gainloss->isValid() &&
_companyid != _gainloss->companyId())
{
QMessageBox::critical(this, tr("Company Account Mismatch"),
tr("The Currency Gain/Loss Account must belong to this Company.") );
_gainloss->setFocus();
return;
}
if (_discrepancy->isValid() &&
_companyid != _discrepancy->companyId())
{
QMessageBox::critical(this, tr("Company Account Mismatch"),
tr("The G/L Discrepancy Account must belong to this Company.") );
_discrepancy->setFocus();
return;
}
if (_unrlzgainloss->isValid() &&
_companyid != _unrlzgainloss->companyId())
{
QMessageBox::critical(this, tr("Company Account Mismatch"),
tr("The Unrealized Currency Gain/Loss Account must belong to this Company.") );
_unrlzgainloss->setFocus();
return;
}
if (_mode == cNew)
{
companySave.exec("SELECT NEXTVAL('company_company_id_seq') AS company_id;");
if (companySave.first())
_companyid = companySave.value("company_id").toInt();
else if (companySave.lastError().type() != QSqlError::NoError)
{
//.........这里部分代码省略.........
示例5: XDialog
itemSource::itemSource(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl)
: XDialog(parent, name, modal, fl)
{
XSqlQuery itemitemSource;
setupUi(this);
connect(_add, SIGNAL(clicked()), this, SLOT(sAdd()));
connect(_close, SIGNAL(clicked()), this, SLOT(reject()));
connect(_delete, SIGNAL(clicked()), this, SLOT(sDelete()));
connect(_edit, SIGNAL(clicked()), this, SLOT(sEdit()));
connect(_itemsrcp,SIGNAL(populateMenu(QMenu*, XTreeWidgetItem*)), this, SLOT(sPopulateMenu(QMenu*)));
connect(_save, SIGNAL(clicked()), this, SLOT(sSaveClicked()));
connect(_vendor, SIGNAL(newId(int)), this, SLOT(sVendorChanged(int)));
connect(_vendorCurrency, SIGNAL(newID(int)), this, SLOT(sFillPriceList()));
connect(_contract, SIGNAL(newID(int)), this, SLOT(sContractChanged(int)));
connect(this, SIGNAL(rejected()), this, SLOT(sRejected()));
// TODO method doesn't exist?
// connect(_vendorUOM, SIGNAL(textChanged()), this, SLOT(sClearVendorUOM()));
// connect(_invVendorUOMRatio, SIGNAL(textChanged(QString)), this, SLOT(sClearVendorUOM()));
_vendorUOM->setType(XComboBox::UOMs);
_item->setType(ItemLineEdit::cGeneralPurchased | ItemLineEdit::cGeneralManufactured | ItemLineEdit::cTooling);
_item->setDefaultType(ItemLineEdit::cGeneralPurchased);
_dates->setStartNull(tr("Always"), omfgThis->startOfTime(), true);
_dates->setStartCaption(tr("Effective"));
_dates->setEndNull(tr("Never"), omfgThis->endOfTime(), true);
_dates->setEndCaption(tr("Expires"));
_captive = false;
_new = false;
QString base;
itemitemSource.exec("SELECT currConcat(baseCurrID()) AS base;");
if (itemitemSource.first())
base = itemitemSource.value("base").toString();
else
base = tr("Base");
if (_metrics->boolean("MultiWhs"))
{
_itemsrcp->addColumn(tr("Site"), _qtyColumn, Qt::AlignCenter,true, "warehous_code");
_itemsrcp->addColumn(tr("Order Type"), -1, Qt::AlignCenter,true, "itemsrcp_dropship");
}
_itemsrcp->addColumn(tr("Qty Break"), _qtyColumn, Qt::AlignRight, true, "itemsrcp_qtybreak");
_itemsrcp->addColumn(tr("Unit Price"), -1, Qt::AlignRight, true, "itemsrcp_price");
_itemsrcp->addColumn(tr("Currency"), _currencyColumn, Qt::AlignLeft, !omfgThis->singleCurrency(), "item_curr");
_itemsrcp->addColumn(tr("Discount Percent"), -1, Qt::AlignRight, true, "itemsrcp_discntprcnt" );
_itemsrcp->addColumn(tr("Discount Fixed Amt."), -1, Qt::AlignRight, true, "itemsrcp_fixedamtdiscount" );
_itemsrcp->addColumn(tr("Unit Price\n(%1)").arg(base),_moneyColumn, Qt::AlignRight, !omfgThis->singleCurrency(), "price_base");
_itemsrcp->addColumn(tr("Type"), _orderColumn, Qt::AlignLeft, true, "type" );
_itemsrcp->addColumn(tr("Method"), _orderColumn, Qt::AlignLeft, true, "method" );
_invVendorUOMRatio->setValidator(omfgThis->ratioVal());
_minOrderQty->setValidator(omfgThis->qtyVal());
_multOrderQty->setValidator(omfgThis->qtyVal());
_contractedQty->setValidator(omfgThis->qtyVal());
_contractedQty->setAlignment(Qt::AlignRight);
_vendorCurrency->setType(XComboBox::Currencies);
_vendorCurrency->setLabel(_vendorCurrencyLit);
itemitemSource.exec("SELECT MAX(itemsrc_id),itemsrc_manuf_name, itemsrc_manuf_name "
"FROM itemsrc "
"WHERE (itemsrc_manuf_name != '') "
"GROUP BY itemsrc_manuf_name "
"ORDER BY itemsrc_manuf_name;");
_manufName->populate(itemitemSource);
_manufName->setCurrentIndex(0);
}
示例6: 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();
_documents->setId(_itemsrcid);
populate();
}
param = pParams.value("item_id", &valid);
if (valid)
{
_item->setId(param.toInt());
_item->setEnabled(false);
}
param = pParams.value("vend_id", &valid);
if (valid)
{
_vendor->setId(param.toInt());
_vendor->setEnabled(false);
}
param = pParams.value("contrct_id", &valid);
if (valid)
{
_contract->setId(param.toInt());
}
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();
_documents->setId(_itemsrcid);
}
else if (ErrorReporter::error(QtCriticalMsg, this, tr("Error Retrieving Item Source Information"),
itemet, __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);
_documents->setReadOnly(true);
_add->setEnabled(false);
_delete->setEnabled(false);
_close->setText(tr("&Close"));
_save->hide();
}
if (param.toString() == "copy")
{
_mode = cCopy;
_new = true;
//.........这里部分代码省略.........
示例7: sSave
bool itemSource::sSave()
{
XSqlQuery itemSave;
QList<GuiErrorCheck> errors;
errors << GuiErrorCheck(!_item->isValid(), _item,
tr( "You must select an Item that this Item Source represents\n"
"before you may save this Item Source." ) )
<< GuiErrorCheck(!_vendor->isValid(), _vendor,
tr( "You must select this Vendor that this Item Source is sold by\n"
"before you may save this Item Source." ) )
<< GuiErrorCheck(_dates->endDate() < _dates->startDate(), _dates,
tr("The expiration date cannot be earlier than the effective date."))
<< GuiErrorCheck(_vendorUOM->currentText().length() == 0, _vendorUOM,
tr( "You must indicate the Unit of Measure that this Item Source is sold in\n"
"before you may save this Item Source." ) )
<< GuiErrorCheck(_invVendorUOMRatio->toDouble() == 0.0, _invVendorUOMRatio,
tr( "You must indicate the Ratio of Inventory to Vendor Unit of Measures\n"
"before you may save this Item Source." ) )
;
itemSave.prepare( "SELECT itemsrc_id "
" FROM itemsrc "
" WHERE ((itemsrc_item_id=:itemsrc_item_id) "
" AND (itemsrc_vend_id=:itemsrc_vend_id) "
" AND ((itemsrc_contrct_id=:itemsrc_contrct_id) "
" OR (itemsrc_contrct_id IS NULL AND :itemsrc_contrct_id IS NULL)) "
" AND (itemsrc_effective=:itemsrc_effective) "
" AND (itemsrc_expires=:itemsrc_expires) "
" AND (itemsrc_vend_item_number=:itemsrc_vend_item_number) "
" AND (UPPER(itemsrc_manuf_name)=UPPER(:itemsrc_manuf_name)) "
" AND (UPPER(itemsrc_manuf_item_number)=UPPER(:itemsrc_manuf_item_number)) "
" AND (itemsrc_id != :itemsrc_id) );");
itemSave.bindValue(":itemsrc_id", _itemsrcid);
itemSave.bindValue(":itemsrc_item_id", _item->id());
itemSave.bindValue(":itemsrc_vend_id", _vendor->id());
if (_contract->isValid())
itemSave.bindValue(":itemsrc_contrct_id", _contract->id());
itemSave.bindValue(":itemsrc_effective", _dates->startDate());
itemSave.bindValue(":itemsrc_expires", _dates->endDate());
itemSave.bindValue(":itemsrc_vend_item_number", _vendorItemNumber->text());
itemSave.bindValue(":itemsrc_manuf_name", _manufName->currentText());
itemSave.bindValue(":itemsrc_manuf_item_number", _manufItemNumber->text());
itemSave.exec();
if(itemSave.first())
{
errors << GuiErrorCheck(true, _item,
tr("An Item Source already exists for the Item Number, Vendor,\n"
"Contract, Effective Date, Expires Date,\n"
"Vendor Item, Manfacturer Name and Manufacturer Item Number you have specified."));
}
else if (ErrorReporter::error(QtCriticalMsg, this, tr("Error Saving Item Source Information"),
itemSave, __FILE__, __LINE__))
{
return false;
}
if(_active->isChecked())
{
itemSave.prepare("SELECT item_id "
"FROM item "
"WHERE ((item_id=:item_id)"
" AND (item_active)) "
"LIMIT 1; ");
itemSave.bindValue(":item_id", _item->id());
itemSave.exec();
if (!itemSave.first())
{
errors << GuiErrorCheck(true, _active,
tr("This Item Source refers to an inactive Item and must be marked as inactive.") );
}
}
if (GuiErrorCheck::reportErrors(this, tr("Cannot Save Item Source"), errors))
return false;
if (_mode == cNew || _mode == cCopy)
{
itemSave.prepare( "INSERT INTO itemsrc "
"( itemsrc_id, itemsrc_item_id, itemsrc_active, itemsrc_default, itemsrc_vend_id,"
" itemsrc_contrct_id, itemsrc_effective, itemsrc_expires, itemsrc_contrct_min,"
" itemsrc_vend_item_number, itemsrc_vend_item_descrip,"
" itemsrc_vend_uom, itemsrc_invvendoruomratio,"
" itemsrc_minordqty, itemsrc_multordqty, itemsrc_upccode,"
" itemsrc_leadtime, itemsrc_ranking,"
" itemsrc_comments, itemsrc_manuf_name, "
" itemsrc_manuf_item_number, itemsrc_manuf_item_descrip ) "
"VALUES "
"( :itemsrc_id, :itemsrc_item_id, :itemsrc_active, :itemsrc_default, :itemsrc_vend_id,"
" :itemsrc_contrct_id, :itemsrc_effective, :itemsrc_expires, :itemsrc_contrct_min,"
" :itemsrc_vend_item_number, :itemsrc_vend_item_descrip,"
" :itemsrc_vend_uom, :itemsrc_invvendoruomratio,"
" :itemsrc_minordqty, :itemsrc_multordqty, :itemsrc_upccode,"
" :itemsrc_leadtime, :itemsrc_ranking,"
" :itemsrc_comments, :itemsrc_manuf_name, "
" :itemsrc_manuf_item_number, :itemsrc_manuf_item_descrip );" );
}
if (_mode == cEdit)
{
itemSave.prepare( "UPDATE itemsrc "
//.........这里部分代码省略.........
示例8: populate
void applyAPCreditMemo::populate()
{
XSqlQuery applypopulate;
applypopulate.prepare( "SELECT apopen_vend_id, apopen_docnumber, apopen_docdate,"
" (apopen_amount - apopen_paid) AS available, apopen_curr_id, "
" COALESCE(SUM(currToCurr(apcreditapply_curr_id,"
" apopen_curr_id, apcreditapply_amount, "
" CURRENT_DATE)), 0) AS f_applied "
"FROM apopen LEFT OUTER JOIN apcreditapply ON (apcreditapply_source_apopen_id=apopen_id) "
"WHERE (apopen_id=:apopen_id) "
"GROUP BY apopen_vend_id, apopen_docnumber, apopen_docdate,"
" apopen_curr_id, apopen_amount, apopen_paid;" );
applypopulate.bindValue(":apopen_id", _apopenid);
applypopulate.exec();
if (applypopulate.first())
{
_vend->setId(applypopulate.value("apopen_vend_id").toInt());
_docDate->setDate(applypopulate.value("apopen_docdate").toDate(), true);
_available->setId(applypopulate.value("apopen_curr_id").toInt());
_available->setLocalValue(applypopulate.value("available").toDouble());
_applied->setLocalValue(applypopulate.value("f_applied").toDouble());
_balance->setLocalValue(_available->localValue() - _applied->localValue());
_docNumber->setText(applypopulate.value("apopen_docnumber").toString());
_cachedAmount = applypopulate.value("available").toDouble();
}
else if (applypopulate.lastError().type() != QSqlError::NoError)
systemError(this, applypopulate.lastError().databaseText(), __FILE__, __LINE__);
applypopulate.prepare( "SELECT apopen_id,"
" CASE WHEN (apopen_doctype='V') THEN :voucher"
" WHEN (apopen_doctype='D') THEN :debitMemo"
" END AS doctype,"
" apopen_docnumber,"
" apopen_docdate, apopen_duedate,"
" (apopen_amount - apopen_paid - COALESCE(selected,0.0) -"
" COALESCE(prepared,0.0)) AS openamount,"
" currConcat(apopen_curr_id) AS opencurrabbr, "
" apcreditapply_amount, "
" currConcat(apcreditapply_curr_id) AS appliedcurrabbr,"
" 'curr' AS openamount_xtnumericrole,"
" 'curr' AS apcreditapply_amount_xtnumericrole"
" FROM apopen LEFT OUTER JOIN apcreditapply "
" ON ( (apcreditapply_source_apopen_id=:parentApopenid) AND (apcreditapply_target_apopen_id=apopen_id) ) "
" LEFT OUTER JOIN (SELECT apopen_id AS selected_apopen_id,"
" SUM(currToCurr(apselect_curr_id, apopen_curr_id, apselect_amount + apselect_discount, apselect_date)) AS selected"
" FROM apselect JOIN apopen ON (apselect_apopen_id=apopen_id)"
" GROUP BY apopen_id) AS sub1"
" ON (apopen_id=selected_apopen_id)"
" LEFT OUTER JOIN (SELECT apopen_id AS prepared_apopen_id,"
" SUM(checkitem_amount + checkitem_discount) AS prepared"
" FROM checkhead JOIN checkitem ON (checkitem_checkhead_id=checkhead_id)"
" JOIN apopen ON (checkitem_apopen_id=apopen_id)"
" WHERE ((NOT checkhead_posted)"
" AND (NOT checkhead_void))"
" GROUP BY apopen_id) AS sub2"
" ON (prepared_apopen_id=apopen_id)"
" WHERE ( (apopen_doctype IN ('V', 'D'))"
" AND (apopen_open)"
" AND ((apopen_amount - apopen_paid - COALESCE(selected,0.0) - COALESCE(prepared,0.0)) > 0.0)"
" AND (apopen_vend_id=:vend_id) ) "
" ORDER BY apopen_duedate, apopen_docnumber;" );
applypopulate.bindValue(":parentApopenid", _apopenid);
applypopulate.bindValue(":vend_id", _vend->id());
applypopulate.bindValue(":voucher", tr("Voucher"));
applypopulate.bindValue(":debitMemo", tr("Debit Memo"));
applypopulate.exec();
_apopen->populate(applypopulate);
if (applypopulate.lastError().type() != QSqlError::NoError)
systemError(this, applypopulate.lastError().databaseText(), __FILE__, __LINE__);
}
示例9: sSave
bool configureSO::sSave()
{
XSqlQuery configureSave;
emit saving();
const char *dispositionTypes[] = { "C", "R", "P", "V", "M", "" };
const char *timingTypes[] = { "I", "R", "" };
const char *creditMethodTypes[] = { "N", "M", "K", "C", "" };
if ( (_metrics->boolean("EnableSOReservationsByLocation")) &&
(!_locationGroup->isChecked()) )
{
if (QMessageBox::warning(this, tr("Reserve by Location Disabled"),
tr("<p>All existing location reservations will be removed. Are you sure you want to continue?"),
QMessageBox::Yes, QMessageBox::No | QMessageBox::Default) == QMessageBox::No)
{
return false;
}
else
{
configureSave.prepare("DELETE FROM itemlocrsrv "
" WHERE (itemlocrsrv_source='SO');");
configureSave.exec();
}
}
_metrics->set("ShowQuotesAfterSO", _quoteafterSO->isChecked());
_metrics->set("AllowDiscounts", _allowDiscounts->isChecked());
_metrics->set("AllowASAPShipSchedules", _allowASAP->isChecked());
_metrics->set("CustomerChangeLog", _customerChangeLog->isChecked());
_metrics->set("SalesOrderChangeLog", _salesOrderChangeLog->isChecked());
_metrics->set("RestrictCreditMemos", _restrictCreditMemos->isChecked());
_metrics->set("AutoSelectForBilling", _autoSelectForBilling->isChecked());
_metrics->set("AlwaysShowSaveAndAdd", _saveAndAdd->isChecked());
_metrics->set("FirmSalesOrderPackingList", _firmAndAdd->isChecked());
_metrics->set("DisableSalesOrderPriceOverride", _priceOverride->isChecked());
_metrics->set("AutoAllocateCreditMemos", _autoAllocateCM->isChecked());
_metrics->set("HideSOMiscCharge", _hideSOMiscChrg->isChecked());
_metrics->set("EnableSOShipping", _enableSOShipping->isChecked());
_metrics->set("CONumberGeneration", _orderNumGeneration->methodCode());
_metrics->set("QUNumberGeneration", _quoteNumGeneration->methodCode());
_metrics->set("CMNumberGeneration", _creditMemoNumGeneration->methodCode());
_metrics->set("InvcNumberGeneration", _invoiceNumGeneration->methodCode());
_metrics->set("DefaultShipFormId", _shipform->id());
_metrics->set("DefaultShipViaId", _shipvia->id());
_metrics->set("DefaultCustType", _custtype->id());
_metrics->set("DefaultSalesRep", _salesrep->id());
_metrics->set("DefaultTerms", _terms->id());
_metrics->set("DefaultPartialShipments", _partial->isChecked());
_metrics->set("DefaultBackOrders", _backorders->isChecked());
_metrics->set("DefaultFreeFormShiptos", _freeFormShiptos->isChecked());
_metrics->set("DefaultPrintSOOnSave", _printSO->isChecked());
_metrics->set("UsePromiseDate", _enablePromiseDate->isChecked());
_metrics->set("CalculateFreight", _calcFreight->isChecked());
_metrics->set("IncludePackageWeight", _includePkgWeight->isChecked());
_metrics->set("EnableReturnAuth", _enableReturns->isChecked());
_metrics->set("EnableSOReservations", _enableReservations->isChecked());
_metrics->set("EnableSOReservationsByLocation", _locationGroup->isChecked());
//SOReservationLocationMethod are three Options Either
// Lowest quantity first,
// Highest quantity first,
// Alpha by Location Name
if(_lowest->isChecked())
_metrics->set("SOReservationLocationMethod", 1);
else if (_highest->isChecked())
_metrics->set("SOReservationLocationMethod", 2);
else if(_alpha->isChecked())
_metrics->set("SOReservationLocationMethod", 3);
_metrics->set("SOCreditLimit", _creditLimit->text());
_metrics->set("SOCreditRate", _creditRating->text());
if (_priceOrdered->isChecked())
_metrics->set("soPriceEffective", QString("OrderDate"));
else if (_priceScheduled->isChecked())
_metrics->set("soPriceEffective", QString("ScheduleDate"));
else
_metrics->set("soPriceEffective", QString("CurrentDate"));
//UpdatePriceLineEdit are three Options Either
// Don't Update price
// Ask to Update Price,
// Update Price
if(_dontUpdatePrice->isChecked())
_metrics->set("UpdatePriceLineEdit", 1);
else if (_askUpdatePrice->isChecked())
_metrics->set("UpdatePriceLineEdit", 2);
else if(_updatePrice->isChecked())
_metrics->set("UpdatePriceLineEdit", 3);
_metrics->set("IgnoreCustDisc", _askUpdatePrice->isChecked() && _ignoreCustDisc->isChecked());
if(_invcScheddate->isChecked())
_metrics->set("InvoiceDateSource", QString("scheddate"));
else if(_invcShipdate->isChecked())
_metrics->set("InvoiceDateSource", QString("shipdate"));
else
_metrics->set("InvoiceDateSource", QString("currdate"));
if (! _invoiceCopies->save())
//.........这里部分代码省略.........
示例10: if
configureSO::configureSO(QWidget* parent, const char* name, bool /*modal*/, Qt::WFlags fl)
: XAbstractConfigure(parent, fl)
{
XSqlQuery configureconfigureSO;
setupUi(this);
if (name)
setObjectName(name);
connect(_creditLimit, SIGNAL(editingFinished()), this, SLOT(sEditCreditLimit()));
connect(_askUpdatePrice, SIGNAL(toggled(bool)), _ignoreCustDisc, SLOT(setEnabled(bool)));
_nextSoNumber->setValidator(omfgThis->orderVal());
_nextQuNumber->setValidator(omfgThis->orderVal());
_nextRaNumber->setValidator(omfgThis->orderVal());
_nextCmNumber->setValidator(omfgThis->orderVal());
_nextInNumber->setValidator(omfgThis->orderVal());
_creditLimit->setValidator(omfgThis->moneyVal());
_orderNumGeneration->setMethod(_metrics->value("CONumberGeneration"));
_quoteNumGeneration->setMethod(_metrics->value("QUNumberGeneration"));
_creditMemoNumGeneration->setMethod(_metrics->value("CMNumberGeneration"));
_invoiceNumGeneration->setMethod(_metrics->value("InvcNumberGeneration"));
QString metric;
metric = _metrics->value("InvoiceDateSource");
if (metric == "scheddate")
_invcScheddate->setChecked(true);
else if (metric == "shipdate")
_invcShipdate->setChecked(true);
else
_invcCurrdate->setChecked(true);
configureconfigureSO.exec( "SELECT sonumber.orderseq_number AS sonumber,"
" qunumber.orderseq_number AS qunumber,"
" cmnumber.orderseq_number AS cmnumber,"
" innumber.orderseq_number AS innumber "
"FROM orderseq AS sonumber,"
" orderseq AS qunumber,"
" orderseq AS cmnumber,"
" orderseq AS innumber "
"WHERE ( (sonumber.orderseq_name='SoNumber')"
" AND (qunumber.orderseq_name='QuNumber')"
" AND (cmnumber.orderseq_name='CmNumber')"
" AND (innumber.orderseq_name='InvcNumber') );" );
if (configureconfigureSO.first())
{
_nextSoNumber->setText(configureconfigureSO.value("sonumber"));
_nextQuNumber->setText(configureconfigureSO.value("qunumber"));
_nextCmNumber->setText(configureconfigureSO.value("cmnumber"));
_nextInNumber->setText(configureconfigureSO.value("innumber"));
}
else if (configureconfigureSO.lastError().type() != QSqlError::NoError)
{
systemError(this, configureconfigureSO.lastError().databaseText(), __FILE__, __LINE__);
return;
}
_allowDiscounts->setChecked(_metrics->boolean("AllowDiscounts"));
_allowASAP->setChecked(_metrics->boolean("AllowASAPShipSchedules"));
_customerChangeLog->setChecked(_metrics->boolean("CustomerChangeLog"));
_salesOrderChangeLog->setChecked(_metrics->boolean("SalesOrderChangeLog"));
_restrictCreditMemos->setChecked(_metrics->boolean("RestrictCreditMemos"));
_autoSelectForBilling->setChecked(_metrics->boolean("AutoSelectForBilling"));
_saveAndAdd->setChecked(_metrics->boolean("AlwaysShowSaveAndAdd"));
_firmAndAdd->setChecked(_metrics->boolean("FirmSalesOrderPackingList"));
_priceOverride->setChecked(_metrics->boolean("DisableSalesOrderPriceOverride"));
_autoAllocateCM->setChecked(_metrics->boolean("AutoAllocateCreditMemos"));
_hideSOMiscChrg->setChecked(_metrics->boolean("HideSOMiscCharge"));
_enableSOShipping->setChecked(_metrics->boolean("EnableSOShipping"));
_printSO->setChecked(_metrics->boolean("DefaultPrintSOOnSave"));
_enablePromiseDate->setChecked(_metrics->boolean("UsePromiseDate"));
_calcFreight->setChecked(_metrics->boolean("CalculateFreight"));
_includePkgWeight->setChecked(_metrics->boolean("IncludePackageWeight"));
_quoteafterSO->setChecked(_metrics->boolean("ShowQuotesAfterSO"));
_shipform->setId(_metrics->value("DefaultShipFormId").toInt());
_shipvia->setId(_metrics->value("DefaultShipViaId").toInt());
if (_metrics->value("DefaultBalanceMethod") == "B")
_balanceMethod->setCurrentIndex(0);
else if (_metrics->value("DefaultBalanceMethod") == "O")
_balanceMethod->setCurrentIndex(1);
_custtype->setId(_metrics->value("DefaultCustType").toInt());
_salesrep->setId(_metrics->value("DefaultSalesRep").toInt());
_terms->setId(_metrics->value("DefaultTerms").toInt());
_partial->setChecked(_metrics->boolean("DefaultPartialShipments"));
_backorders->setChecked(_metrics->boolean("DefaultBackOrders"));
_freeFormShiptos->setChecked(_metrics->boolean("DefaultFreeFormShiptos"));
_creditLimit->setText(_metrics->value("SOCreditLimit"));
_creditRating->setText(_metrics->value("SOCreditRate"));
if (_metrics->value("soPriceEffective") == "OrderDate")
_priceOrdered->setChecked(true);
else if (_metrics->value("soPriceEffective") == "ScheduleDate")
_priceScheduled->setChecked(true);
//.........这里部分代码省略.........
示例11: sHandleItemsite
void plannedOrder::sHandleItemsite(int pWarehousid)
{
if (_metrics->boolean("UseSiteCalendar"))
{
_dueDate->setCalendarSiteId(pWarehousid);
_startDate->setCalendarSiteId(pWarehousid);
}
XSqlQuery plannedHandleItemsite;
plannedHandleItemsite.prepare( "SELECT itemsite_leadtime, itemsite_wosupply, itemsite_posupply, item_type "
"FROM itemsite JOIN item ON (item_id=itemsite_item_id) "
"WHERE ( (itemsite_item_id=:item_id)"
" AND (itemsite_warehous_id=:warehous_id) );" );
plannedHandleItemsite.bindValue(":item_id", _item->id());
plannedHandleItemsite.bindValue(":warehous_id", pWarehousid);
plannedHandleItemsite.exec();
if (!plannedHandleItemsite.first())
{
systemError(this, plannedHandleItemsite.lastError().databaseText(), __FILE__, __LINE__);
return;
}
_leadTime->setValue(plannedHandleItemsite.value("itemsite_leadtime").toInt());
if ( plannedHandleItemsite.value("itemsite_posupply").toBool() &&
(plannedHandleItemsite.value("item_type").toString() == "P" ||
plannedHandleItemsite.value("item_type").toString() == "O" ||
plannedHandleItemsite.value("item_type").toString() == "T" ||
plannedHandleItemsite.value("item_type").toString() == "M") )
_poButton->setEnabled(TRUE);
else
_poButton->setEnabled(FALSE);
if ( plannedHandleItemsite.value("itemsite_wosupply").toBool() &&
(plannedHandleItemsite.value("item_type").toString() == "P" ||
plannedHandleItemsite.value("item_type").toString() == "T" ||
plannedHandleItemsite.value("item_type").toString() == "M") )
_woButton->setEnabled(TRUE);
else
_woButton->setEnabled(FALSE);
if ( plannedHandleItemsite.value("itemsite_wosupply").toBool() && plannedHandleItemsite.value("itemsite_posupply").toBool() && plannedHandleItemsite.value("item_type").toString() == "P" )
{
_poButton->setChecked(TRUE);
_woButton->setChecked(FALSE);
}
else if ( plannedHandleItemsite.value("itemsite_wosupply").toBool() )
{
_poButton->setChecked(FALSE);
_woButton->setChecked(TRUE);
}
else
{
_poButton->setChecked(TRUE);
_woButton->setChecked(FALSE);
}
plannedHandleItemsite.prepare( "SELECT COALESCE(COUNT(*), 0) AS supplysites "
"FROM itemsite "
"WHERE ( (itemsite_item_id=:item_id)"
" AND (itemsite_warehous_id <> :warehous_id) );" );
plannedHandleItemsite.bindValue(":item_id", _item->id());
plannedHandleItemsite.bindValue(":warehous_id", pWarehousid);
plannedHandleItemsite.exec();
if (!plannedHandleItemsite.first())
{
systemError(this, plannedHandleItemsite.lastError().databaseText(), __FILE__, __LINE__);
return;
}
if (plannedHandleItemsite.value("supplysites").toInt() > 0)
_toButton->setEnabled(TRUE);
else
_toButton->setEnabled(FALSE);
plannedHandleItemsite.prepare( "SELECT COALESCE(supply.itemsite_id, -1) AS supplyitemsiteid,"
" COALESCE(supply.itemsite_warehous_id, -1) AS supplywarehousid "
"FROM itemsite LEFT OUTER JOIN itemsite supply ON (supply.itemsite_id=itemsite.itemsite_supply_itemsite_id)"
"WHERE ( (itemsite.itemsite_item_id=:item_id)"
" AND (itemsite.itemsite_warehous_id=:warehous_id) );" );
plannedHandleItemsite.bindValue(":item_id", _item->id());
plannedHandleItemsite.bindValue(":warehous_id", pWarehousid);
plannedHandleItemsite.exec();
if (!plannedHandleItemsite.first())
{
systemError(this, plannedHandleItemsite.lastError().databaseText(), __FILE__, __LINE__);
return;
}
if (plannedHandleItemsite.value("supplyitemsiteid").toInt() != -1)
{
_toButton->setChecked(TRUE);
_fromWarehouse->setId(plannedHandleItemsite.value("supplywarehousid").toInt());
}
else
_fromWarehouse->setId(pWarehousid);
}
示例12: sSave
void returnAuthCheck::sSave()
{
XSqlQuery returnSave;
if (!_date->isValid())
{
QMessageBox::warning( this, tr("Cannot Create Miscellaneous Check"),
tr("<p>You must enter a date for this check.") );
_date->setFocus();
return;
}
else if (_amount->isZero())
{
QMessageBox::warning( this, tr("Cannot Create Miscellaneous Check"),
tr("<p>You must enter an amount for this check.") );
return;
}
else if (!_bankaccnt->isValid())
{
QMessageBox::warning( this, tr("Cannot Create Miscellaneous Check"),
tr("<p>You must select a bank account for this check.") );
_date->setFocus();
return;
}
else
{
returnSave.prepare("SELECT createCheck(:bankaccnt_id, 'C', :recipid,"
" :checkDate, :amount, :curr_id, NULL,"
" NULL, :for, :notes, true, :aropen_id) AS result; ");
returnSave.bindValue(":bankaccnt_id", _bankaccnt->id());
returnSave.bindValue(":recipid", _custid);
returnSave.bindValue(":checkDate", _date->date());
returnSave.bindValue(":amount", _amount->localValue());
returnSave.bindValue(":curr_id", _amount->id());
returnSave.bindValue(":for", _for->text().trimmed());
returnSave.bindValue(":notes", _notes->toPlainText().trimmed());
returnSave.bindValue(":aropen_id", _aropenid);
returnSave.exec();
if (returnSave.first())
{
_checkid = returnSave.value("result").toInt();
if (_checkid < 0)
{
ErrorReporter::error(QtCriticalMsg, this, tr("Error Retrieving Check Information"),
storedProcErrorLookup("createCheck", _checkid),
__FILE__, __LINE__);
return;
}
returnSave.prepare( "SELECT checkhead_number "
"FROM checkhead "
"WHERE (checkhead_id=:check_id);" );
returnSave.bindValue(":check_id", _checkid);
returnSave.exec();
if (ErrorReporter::error(QtCriticalMsg, this, tr("Error Retrieving Check Information"),
returnSave, __FILE__, __LINE__))
{
return;
}
done(true);
}
else if (ErrorReporter::error(QtCriticalMsg, this, tr("Error Retrieving Check Information"),
returnSave, __FILE__, __LINE__))
{
return;
}
}
}
示例13: sPopulate
void allocateARCreditMemo::sPopulate()
{
XSqlQuery populateCM;
if (_coheadid == -1)
{
// get the cohead_id associated with the invoice
populateCM.prepare("SELECT cohead_id "
" FROM invchead JOIN cohead ON (cohead_number=invchead_ordernumber)"
" WHERE (invchead_id=:invchead_id);");
populateCM.bindValue(":invchead_id", _invcheadid);
populateCM.exec();
if (populateCM.first())
_coheadid = populateCM.value("cohead_id").toInt();
if (populateCM.lastError().type() != QSqlError::NoError)
{
systemError(this, populateCM.lastError().databaseText(), __FILE__, __LINE__);
return;
}
}
// Get the list of Unallocated CM's with amount
populateCM.prepare("SELECT aropen_id, "
" docnumber, doctype, docdate, duedate,"
" amount, paid, balance, allocated, totalallocated, "
" CASE WHEN (doctype='C') THEN :creditmemo"
" WHEN (doctype='R') THEN :cashdeposit"
" WHEN (doctype='S') THEN :salesorder"
" WHEN (doctype='I') THEN :invoice"
" END AS doctype_qtdisplayrole, "
" indent AS xtindentrole "
" FROM ( "
"SELECT aropen_id, 0 AS indent, "
" aropen_docnumber AS docnumber, aropen_doctype AS doctype, "
" aropen_docdate AS docdate, aropen_duedate AS duedate,"
" currToCurr(aropen_curr_id, :curr_id, aropen_amount, :effective) AS amount,"
" currToCurr(aropen_curr_id, :curr_id, aropen_paid, :effective) AS paid,"
" currToCurr(aropen_curr_id, :curr_id, noNeg(aropen_amount - aropen_paid), :effective) AS balance,"
" COALESCE(SUM(CASE WHEN ((aropenalloc_doctype='S' AND aropenalloc_doc_id=:cohead_id) OR "
" (aropenalloc_doctype='I' AND aropenalloc_doc_id=:invchead_id)) THEN "
" currToCurr(aropenalloc_curr_id, :curr_id, aropenalloc_amount, :effective)"
" ELSE 0.00 END), 0.0) AS allocated,"
" COALESCE(SUM(currToCurr(aropenalloc_curr_id, :curr_id, aropenalloc_amount, :effective)), 0.0) AS totalallocated "
" FROM aropen LEFT OUTER JOIN aropenalloc ON (aropenalloc_aropen_id=aropen_id)"
" WHERE ( (aropen_cust_id=:cust_id)"
" AND (aropen_doctype IN ('C', 'R'))"
" AND (aropen_open) )"
" GROUP BY aropen_id, aropen_docnumber, aropen_doctype, aropen_docdate, aropen_duedate,"
" aropen_curr_id, aropen_amount, aropen_paid "
"UNION "
"SELECT aropen_id, 1 AS indent, "
" cohead_number AS docnumber, 'S' AS doctype, "
" cohead_orderdate AS docdate, NULL AS duedate,"
" NULL AS amount,"
" NULL AS paid,"
" NULL AS balance,"
" NULL AS allocated,"
" COALESCE(currToCurr(aropenalloc_curr_id, :curr_id, aropenalloc_amount, :effective), 0.0) AS totalallocated "
" FROM aropen JOIN aropenalloc ON (aropenalloc_aropen_id=aropen_id AND aropenalloc_doctype='S')"
" JOIN cohead ON (cohead_id=aropenalloc_doc_id) "
" WHERE ( (aropen_cust_id=:cust_id)"
" AND (aropen_doctype IN ('C', 'R'))"
" AND (aropen_open) ) "
"UNION "
"SELECT aropen_id, 1 AS indent, "
" invchead_invcnumber AS docnumber, 'I' AS doctype, "
" invchead_invcdate AS docdate, NULL AS duedate,"
" NULL AS amount,"
" NULL AS paid,"
" NULL AS balance,"
" NULL AS allocated,"
" COALESCE(currToCurr(aropenalloc_curr_id, :curr_id, aropenalloc_amount, :effective), 0.0) AS totalallocated "
" FROM aropen JOIN aropenalloc ON (aropenalloc_aropen_id=aropen_id AND aropenalloc_doctype='I')"
" JOIN invchead ON (invchead_id=aropenalloc_doc_id) "
" WHERE ( (aropen_cust_id=:cust_id)"
" AND (aropen_doctype IN ('C', 'R'))"
" AND (aropen_open) )"
" ) AS data "
" ORDER BY aropen_id, indent, duedate;");
populateCM.bindValue(":cohead_id", _coheadid);
populateCM.bindValue(":invchead_id", _invcheadid);
populateCM.bindValue(":cust_id", _custid);
populateCM.bindValue(":curr_id", _total->id());
populateCM.bindValue(":effective", _total->effective());
populateCM.bindValue(":creditmemo", tr("Credit Memo"));
populateCM.bindValue(":cashdeposit", tr("Customer Deposit"));
populateCM.bindValue(":salesorder", tr("Sales Order"));
populateCM.bindValue(":invoice", tr("Invoice"));
populateCM.exec();
if (populateCM.lastError().type() != QSqlError::NoError)
{
systemError(this, populateCM.lastError().databaseText(), __FILE__, __LINE__);
return;
}
_aropen->populate(populateCM, false);
}
示例14: sViewDocument
void dspGLTransactions::sViewDocument()
{
XSqlQuery dspViewDocument;
XTreeWidgetItem * item = (XTreeWidgetItem*)list()->currentItem();
if(0 == item)
return;
ParameterList params;
if(item->rawValue("gltrans_doctype").toString() == "VO")
{
dspViewDocument.prepare("SELECT vohead_id, vohead_misc"
" FROM vohead"
" WHERE (vohead_number=:vohead_number)");
dspViewDocument.bindValue(":vohead_number", item->rawValue("docnumber").toString());
dspViewDocument.exec();
if(!dspViewDocument.first())
return;
params.append("vohead_id", dspViewDocument.value("vohead_id").toInt());
params.append("mode", "view");
if(dspViewDocument.value("vohead_misc").toBool())
{
miscVoucher *newdlg = new miscVoucher();
newdlg->set(params);
omfgThis->handleNewWindow(newdlg, Qt::ApplicationModal);
}
else
{
voucher *newdlg = new voucher();
newdlg->set(params);
omfgThis->handleNewWindow(newdlg, Qt::ApplicationModal);
}
}
else if(item->rawValue("gltrans_doctype").toString() == "IN")
{
dspViewDocument.prepare("SELECT invchead_id"
" FROM invchead"
" WHERE (invchead_invcnumber=:invchead_invcnumber)");
dspViewDocument.bindValue(":invchead_invcnumber", item->rawValue("docnumber").toString());
dspViewDocument.exec();
if(!dspViewDocument.first())
return;
invoice::viewInvoice(dspViewDocument.value("invchead_id").toInt());
}
else if(item->rawValue("gltrans_doctype").toString() == "PO")
{
QStringList docnumber = item->rawValue("docnumber").toString().split("-");
dspViewDocument.prepare("SELECT pohead_id"
" FROM pohead"
" WHERE (pohead_number=:docnumber)");
dspViewDocument.bindValue(":docnumber", docnumber[0]);
dspViewDocument.exec();
if(!dspViewDocument.first())
return;
params.append("pohead_id", dspViewDocument.value("pohead_id").toInt());
params.append("mode", "view");
purchaseOrder *newdlg = new purchaseOrder();
newdlg->set(params);
omfgThis->handleNewWindow(newdlg, Qt::ApplicationModal);
}
else if(item->rawValue("gltrans_doctype").toString() == "SH")
{
dspViewDocument.prepare("SELECT shiphead_id"
" FROM shiphead"
" WHERE (shiphead_number=:shiphead_number)");
dspViewDocument.bindValue(":shiphead_number", item->rawValue("docnumber").toString());
dspViewDocument.exec();
if(!dspViewDocument.first())
return;
params.append("shiphead_id", dspViewDocument.value("shiphead_id").toInt());
dspShipmentsByShipment *newdlg = new dspShipmentsByShipment();
newdlg->set(params);
omfgThis->handleNewWindow(newdlg, Qt::ApplicationModal);
}
else if( (item->rawValue("gltrans_doctype").toString() == "CM") || (item->rawValue("gltrans_doctype").toString() == "DM") )
{
if(item->rawValue("gltrans_source").toString() == "A/P")
{
dspViewDocument.prepare("SELECT apopen_id"
" FROM apopen"
" WHERE ( (apopen_docnumber=:docnumber) "
" AND (apopen_journalnumber=:journalnumber)"
" AND (apopen_doctype IN ('C', 'D')) );");
dspViewDocument.bindValue(":docnumber", item->rawValue("docnumber").toString());
dspViewDocument.bindValue(":journalnumber", item->rawValue("gltrans_journalnumber").toString());
dspViewDocument.exec();
if(!dspViewDocument.first())
return;
params.append("mode", "view");
params.append("apopen_id", dspViewDocument.value("apopen_id").toInt());
apOpenItem newdlg(this, "", TRUE);
newdlg.set(params);
//.........这里部分代码省略.........
示例15: sTest
void company::sTest()
{
XSqlQuery companyTest;
if (DEBUG)
qDebug("company::sTest()");
QString dbURL;
QString protocol = "psql";
QString host = _extServer->text();
QString db = _extDB->text();
QString port = _extPort->cleanText();
buildDatabaseURL(dbURL, protocol, host, db, port);
if (DEBUG)
qDebug("company::sTest() dbURL before login2 = %s", qPrintable(dbURL));
ParameterList params;
params.append("databaseURL", dbURL);
params.append("multipleConnections");
login2 newdlg(this, "testLogin", false);
newdlg.set(params);
if (newdlg.exec() == QDialog::Rejected)
return;
dbURL = newdlg._databaseURL;
if (DEBUG)
qDebug("company::sTest() dbURL after login2 = %s", qPrintable(dbURL));
parseDatabaseURL(dbURL, protocol, host, db, port);
QSqlDatabase testDB = QSqlDatabase::addDatabase("QPSQL7", db);
testDB.setHostName(host);
testDB.setDatabaseName(db);
testDB.setUserName(newdlg.username());
testDB.setPassword(newdlg.password());
testDB.setPort(port.toInt());
if (testDB.open())
{
if (DEBUG)
qDebug("company::sTest() opened testDB!");
XSqlQuery rmq(testDB);
rmq.prepare("SELECT fetchMetricText('ServerVersion') AS result;");
rmq.exec();
if (rmq.first())
{
if (rmq.value("result").toString() != _metrics->value("ServerVersion"))
{
QMessageBox::warning(this, tr("Versions Incompatible"),
tr("<p>The version of the child database is not "
"the same as the version of the parent "
"database (%1 vs. %2). The data cannot safely "
"be synchronized.")
.arg(rmq.value("result").toString())
.arg(_metrics->value("ServerVersion")));
return;
}
}
else if (rmq.lastError().type() != QSqlError::NoError)
{
systemError(this, rmq.lastError().databaseText(), __FILE__, __LINE__);
return;
}
rmq.exec("SELECT * FROM curr_symbol WHERE curr_base;");
if (_external->isChecked())
{
companyTest.prepare("SELECT * FROM curr_symbol WHERE curr_id=:curr_id;");
companyTest.bindValue(":curr_id", _currency->id());
companyTest.exec();
}
else
companyTest.exec("SELECT * FROM curr_symbol WHERE curr_base;");
if (companyTest.first() && rmq.first())
{
if (rmq.value("curr_symbol").toString() != companyTest.value("curr_symbol").toString() &&
rmq.value("curr_abbr").toString() != companyTest.value("curr_abbr").toString())
{
QMessageBox::warning(this, tr("Currencies Incompatible"),
tr("<p>The currency of the child database does "
"not appear to match the selected currency for "
"the company (%1 %2 %3 vs. %4 %5 %6). The data may "
"not synchronize properly.")
.arg(rmq.value("curr_name").toString())
.arg(rmq.value("curr_symbol").toString())
.arg(rmq.value("curr_abbr").toString())
.arg(companyTest.value("curr_name").toString())
.arg(companyTest.value("curr_symbol").toString())
.arg(companyTest.value("curr_abbr").toString()));
return;
}
}
else if (rmq.lastError().type() != QSqlError::NoError)
{
systemError(this, rmq.lastError().databaseText(), __FILE__, __LINE__);
return;
}
else if (companyTest.lastError().type() != QSqlError::NoError)
{
//.........这里部分代码省略.........