void selectPayments::sClear() { bool update = FALSE; QList<XTreeWidgetItem*> list = _apopen->selectedItems(); XTreeWidgetItem * cursor = 0; q.prepare("SELECT clearPayment(:apopen_id) AS result;"); for(int i = 0; i < list.size(); i++) { cursor = (XTreeWidgetItem*)list.at(i); q.bindValue(":apopen_id", cursor->altId()); q.exec(); if (q.first()) { int result = q.value("result").toInt(); if (result < 0) { systemError(this, cursor->text(0) + " " + cursor->text(2) + "\n" + storedProcErrorLookup("clearPayment", result), __FILE__, __LINE__); return; } } else if (q.lastError().type() != QSqlError::NoError) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return; } update = TRUE; } if(update) omfgThis->sPaymentsUpdated(-1, -1, TRUE); }
void dspVendorAPHistory::sSearchInvoiceNum() { QString sub = _searchInvoiceNum->text().trimmed(); if(sub.isEmpty()) return; XTreeWidgetItem *item = 0; XTreeWidgetItem *foundSub = 0; for (int i = 0; i < list()->topLevelItemCount(); i++) { item = list()->topLevelItem(i); if (item->text(3) == sub) { foundSub = item; break; } else if (foundSub == 0 && item->text(3).startsWith(sub)) foundSub = item; } if (foundSub) { list()->setCurrentItem(foundSub); list()->scrollToItem(foundSub); } }
void selectPayments::sClear() { XSqlQuery selectClear; bool update = false; QList<XTreeWidgetItem*> list = _apopen->selectedItems(); XTreeWidgetItem * cursor = 0; selectClear.prepare("SELECT clearPayment(:apopen_id) AS result;"); for(int i = 0; i < list.size(); i++) { cursor = (XTreeWidgetItem*)list.at(i); selectClear.bindValue(":apopen_id", cursor->altId()); selectClear.exec(); if (selectClear.first()) { int result = selectClear.value("result").toInt(); if (result < 0) { ErrorReporter::error(QtCriticalMsg, this, cursor->text(0) + " " + cursor->text(2) + "\n" + tr(" Error Clearing Payment Information"), storedProcErrorLookup("clearPayment", result), __FILE__, __LINE__); return; } } else if (ErrorReporter::error(QtCriticalMsg, this, tr("Error Clearing Payment Information"), selectClear, __FILE__, __LINE__)) { return; } update = true; } if(update) omfgThis->sPaymentsUpdated(-1, -1, true); }
void dspVendorAPHistory::sPopulateMenu(QMenu *pMenu, QTreeWidgetItem *pSelected) { int menuItem; XTreeWidgetItem * item = (XTreeWidgetItem*)pSelected; if (item->id() != -1) { menuItem = pMenu->insertItem(tr("Edit..."), this, SLOT(sEdit()), 0); if (!_privileges->check("EditSalesHistory")) pMenu->setItemEnabled(menuItem, FALSE); pMenu->insertItem(tr("View A/P Open..."), this, SLOT(sView()), 0); menuItem = pMenu->insertItem(tr("View G/L Series..."), this, SLOT(sViewGLSeries()), 0); if (!_privileges->check("ViewGLTransactions")) pMenu->setItemEnabled(menuItem, FALSE); if(item->altId() == -1 && item->text(1)==tr("Voucher")) { menuItem = pMenu->insertItem(tr("View Voucher..."), this, SLOT(sViewVoucher()), 0); if (!_privileges->check("ViewVouchers")) pMenu->setItemEnabled(menuItem, FALSE); if(item->text(7)==item->text(8)) { pMenu->insertSeparator(); menuItem = pMenu->insertItem(tr("Void"), this, SLOT(sVoidVoucher()), 0); if (!_privileges->check("MaintainAPMemos")) pMenu->setItemEnabled(menuItem, FALSE); } } } }
void selectPayments::sSelectLine() { XSqlQuery selectSelectLine; ParameterList params; params.append("type", "P"); int bankaccntid = _bankaccnt->id(); if(bankaccntid == -1) { selectBankAccount newdlg(this, "", TRUE); newdlg.set(params); bankaccntid = newdlg.exec(); } if (bankaccntid != -1) { bool update = FALSE; QList<XTreeWidgetItem*> list = _apopen->selectedItems(); XTreeWidgetItem * cursor = 0; selectSelectLine.prepare("SELECT selectPayment(:apopen_id, :bankaccnt_id) AS result;"); XSqlQuery slctln; slctln.prepare( "SELECT apopen_status FROM apopen WHERE apopen_id=:apopen_id;"); for(int i = 0; i < list.size(); i++) { cursor = (XTreeWidgetItem*)list.at(i); selectSelectLine.bindValue(":apopen_id", cursor->id()); selectSelectLine.bindValue(":bankaccnt_id", bankaccntid); slctln.bindValue(":apopen_id", cursor->id()); slctln.exec(); if (slctln.first()) { if (slctln.value("apopen_status").toString() != "H") { selectSelectLine.exec(); if (selectSelectLine.first()) { int result = selectSelectLine.value("result").toInt(); if (result < 0) { systemError(this, cursor->text(0) + " " + cursor->text(2) + "\n" + storedProcErrorLookup("selectPayment", result), __FILE__, __LINE__); return; } } else if (selectSelectLine.lastError().type() != QSqlError::NoError) { systemError(this, selectSelectLine.lastError().databaseText(), __FILE__, __LINE__); return; } } update = TRUE; } } if(update) omfgThis->sPaymentsUpdated(-1, -1, TRUE); } }
void dspFinancialReport::sEditPeriodLabel() { XTreeWidgetItem * item = (XTreeWidgetItem*)_periods->currentItem(); if(!item) return; bool ok; QString text = QInputDialog::getText( tr("Alternate Label"), tr("Enter an alternate label for the period %1:").arg(item->text(0)), QLineEdit::Normal, item->text(1), &ok, this ); if(ok) item->setText(1, text); }
void unpostedGLTransactions::sPopulateMenu(QMenu * menuThis, QTreeWidgetItem* pItem) { menuThis->insertItem(tr("View..."), this, SLOT(sViewTrans()), 0); XTreeWidgetItem * item = (XTreeWidgetItem*)pItem; if(0 == item) return; if(item->text(2) == "VO") menuThis->insertItem(tr("View Voucher..."), this, SLOT(sViewDocument())); else if(item->text(2) == "IN") menuThis->insertItem(tr("View Invoice..."), this, SLOT(sViewDocument())); else if(item->text(2) == "PO") menuThis->insertItem(tr("View Purchase Order..."), this, SLOT(sViewDocument())); }
QString itemSourceSearch::manufItemDescrip() { XTreeWidgetItem * item = (XTreeWidgetItem*)_itemsrc->currentItem(); if(item) return item->text(7); return QString(); }
QString XTreeWidgetItemProto::text(int p) const { XTreeWidgetItem *item = qscriptvalue_cast<XTreeWidgetItem*>(thisObject()); if (item) return item->text(p); return QString(); }
QString itemSourceSearch::vendItemNumber() { XTreeWidgetItem * item = (XTreeWidgetItem*)_itemsrc->currentItem(); if(item) return item->text(3); return QString(); }
void dspVendorAPHistory::sPopulateMenu(QMenu *pMenu, QTreeWidgetItem *pSelected, int) { QAction *menuItem; XTreeWidgetItem * item = (XTreeWidgetItem*)pSelected; if (item->id() != -1) { menuItem = pMenu->addAction(tr("Edit..."), this, SLOT(sEdit())); menuItem->setEnabled(_privileges->check("EditAPOpenItem")); pMenu->addAction(tr("View A/P Open..."), this, SLOT(sView())); menuItem = pMenu->addAction(tr("View G/L Series..."), this, SLOT(sViewGLSeries())); menuItem->setEnabled(_privileges->check("ViewGLTransactions")); if(item->altId() == -1 && item->text(1)==tr("Voucher")) { menuItem = pMenu->addAction(tr("View Voucher..."), this, SLOT(sViewVoucher())); menuItem->setEnabled(_privileges->check("ViewVouchers") || _privileges->check("MaintainVouchers")); if(item->rawValue("amount")==item->rawValue("balance")) { pMenu->addSeparator(); menuItem = pMenu->addAction(tr("Void"), this, SLOT(sVoidVoucher())); menuItem->setEnabled(_privileges->check("VoidPostedVouchers")); } } } }
void reconcileBankaccount::sChecksToggleCleared() { XSqlQuery reconcileChecksToggleCleared; XTreeWidgetItem *item = (XTreeWidgetItem*)_checks->currentItem(); if(0 == item) return; _checks->scrollToItem(item); double rate = item->rawValue("doc_exchrate").toDouble(); double baseamount = item->rawValue("base_amount").toDouble(); double amount = item->rawValue("amount").toDouble(); if (_allowEdit->isChecked() && item->text(0) != tr("Yes")) { ParameterList params; params.append("transtype", "check"); params.append("bankaccntid", _bankaccnt->id()); params.append("bankrecid", _bankrecid); params.append("sourceid", item->id()); if(item->altId()==1) params.append("source", "GL"); else if(item->altId()==2) params.append("source", "SL"); else if(item->altId()==3) params.append("source", "AD"); toggleBankrecCleared newdlg(this, "", TRUE); newdlg.set(params); newdlg.exec(); populate(); } else { reconcileChecksToggleCleared.prepare("SELECT toggleBankrecCleared(:bankrecid, :source, :sourceid, :currrate, :amount) AS cleared"); reconcileChecksToggleCleared.bindValue(":bankrecid", _bankrecid); reconcileChecksToggleCleared.bindValue(":sourceid", item->id()); if(item->altId()==1) reconcileChecksToggleCleared.bindValue(":source", "GL"); else if(item->altId()==2) reconcileChecksToggleCleared.bindValue(":source", "SL"); else if(item->altId()==3) reconcileChecksToggleCleared.bindValue(":source", "AD"); reconcileChecksToggleCleared.bindValue(":currrate", rate); reconcileChecksToggleCleared.bindValue(":amount", amount); reconcileChecksToggleCleared.exec(); if(reconcileChecksToggleCleared.first()) item->setText(0, (reconcileChecksToggleCleared.value("cleared").toBool() ? tr("Yes") : tr("No") )); else { populate(); if (reconcileChecksToggleCleared.lastError().type() != QSqlError::NoError) { systemError(this, reconcileChecksToggleCleared.lastError().databaseText(), __FILE__, __LINE__); return; } } } }
QString OrderList::type() const { if(selectedAtDone.count() > 0) { XTreeWidgetItem * item = (XTreeWidgetItem*)selectedAtDone.at(0); return item->text(1); } return ""; }
void printShippingForm::sEditShippingFormWatermark() { QList<QTreeWidgetItem*>selected = _shipformWatermarks->selectedItems(); for (int counter = 0; counter < selected.size(); counter++) { XTreeWidgetItem *cursor = static_cast<XTreeWidgetItem*>(selected[counter]); ParameterList params; params.append("watermark", cursor->text(1)); params.append("showPrices", (cursor->text(2) == tr("Yes"))); editICMWatermark newdlg(this, "", TRUE); newdlg.set(params); if (newdlg.exec() == XDialog::Accepted) { cursor->setText(1, newdlg.watermark()); cursor->setText(2, ((newdlg.showPrices()) ? tr("Yes") : tr("No"))); } } }
void configureIM::sEditShippingFormWatermark() { XTreeWidgetItem *cursor = (XTreeWidgetItem*)(_shipformWatermarks->currentItem()); if (cursor) { ParameterList params; params.append("watermark", cursor->text(1)); params.append("showPrices", (cursor->text(2) == tr("Yes"))); editICMWatermark newdlg(this, "", TRUE); newdlg.set(params); if (newdlg.exec() == XDialog::Accepted) { cursor->setText(1, newdlg.watermark()); cursor->setText(2, ((newdlg.showPrices()) ? tr("Yes") : tr("No"))); } } }
bool XDocCopySetter::save() { if (_x_metrics) { if (! _numCopiesMetric.isEmpty()) _x_metrics->set(_numCopiesMetric, _numOfCopies->value()); QString fullmetric("%1%2"); for (int i = 0; i < _watermarks->topLevelItemCount(); i++) { XTreeWidgetItem *item = _watermarks->topLevelItem(i); if (! _watermarkMetric.isEmpty()) _x_metrics->set(fullmetric.arg(_watermarkMetric).arg(i), item->text(1)); if (! _showPriceMetric.isEmpty()) _x_metrics->set(fullmetric.arg(_showPriceMetric).arg(i), (item->text(2) == yesStr)); } } return true; }
void dspVendorAPHistory::sPopulateMenu(QMenu *pMenu, QTreeWidgetItem *pSelected) { int menuItem; XTreeWidgetItem * item = (XTreeWidgetItem*)pSelected; if (item->id() != -1) { menuItem = pMenu->insertItem(tr("Edit..."), this, SLOT(sEdit()), 0); if (!_privleges->check("EditSalesHistory")) pMenu->setItemEnabled(menuItem, FALSE); pMenu->insertItem(tr("View..."), this, SLOT(sView()), 0); if(item->altId() == -1 && item->text(1)==tr("Voucher") && item->text(6)==item->text(7)) { menuItem = pMenu->insertItem(tr("Void"), this, SLOT(sVoidVoucher()), 0); if (!_privleges->check("MaintainAPMemos")) pMenu->setItemEnabled(menuItem, FALSE); } } }
void dspGLSeries::sPopulateMenu(QMenu * pMenu) { int menuItem; bool reversible = false; XTreeWidgetItem * item = (XTreeWidgetItem*)_gltrans->currentItem(); if(0 != item) { if(item->altId() != -1) item = (XTreeWidgetItem*)item->parent(); if(0 != item) { if(item->text(3) == "ST" || item->text(3) == "JE") reversible = true; } } menuItem = pMenu->insertItem(tr("Reverse Journal..."), this, SLOT(sReverse()), 0); if (!reversible || !_privileges->check("PostStandardJournals")) pMenu->setItemEnabled(menuItem, false); }
/* do this differently than VirtualList::sSearch(QString&): look for any consecutive characters that match, not just the first field */ void AddressList::sSearch(const QString& pTarget) { XTreeWidgetItem *target = 0; for (int i = 0; i < _listTab->topLevelItemCount(); i++) { target = _listTab->topLevelItem(i); if (target == NULL || (target->text(0) + " " + target->text(1) + " " + target->text(2) + " " + target->text(3) + " " + target->text(4) + " " + target->text(5) + " " + target->text(6) + " " + target->text(7)).contains(pTarget.toUpper(), Qt::CaseInsensitive)) break; } if (target) { _listTab->setCurrentItem(target); _listTab->scrollToItem(target); } }
QString OrderSearch::type() const { QList<QTreeWidgetItem*> items = (selectedAtDone.size() > 0) ? selectedAtDone : _listTab->selectedItems(); if(items.count() > 0) { XTreeWidgetItem * item = (XTreeWidgetItem*)items.at(0); return item->text(1); } return ""; }
void dspFinancialReport::sCollapsed( QTreeWidgetItem * item ) { for (int i = 0; i < item->childCount(); i++) { XTreeWidgetItem *child = (XTreeWidgetItem*)item->child(i); if(child->altId() == -1) { for (int i = 1; i < _layout->columnCount(); i++) item->setText(i, child->text(i)); return; } } }
void dspAROpenItems::sPopulateMenu(QMenu *pMenu, QTreeWidgetItem *pItem) { int menuItem; menuItem = pMenu->insertItem(tr("Edit..."), this, SLOT(sEdit()), 0); if (!_privleges->check("EditAROpenItem")) pMenu->setItemEnabled(menuItem, FALSE); pMenu->insertItem(tr("View..."), this, SLOT(sView()), 0); XTreeWidgetItem* item = (XTreeWidgetItem*)pItem; { if (item->text(0) == "Invoice") pMenu->insertItem(tr("View Invoice..."), this, SLOT(sViewInvoice()), 0); } }
QString XTreeWidgetItemProto::toString() const { QString returnVal = QString("XTreeWidgetItem"); XTreeWidgetItem *item = qscriptvalue_cast<XTreeWidgetItem*>(thisObject()); if (item) { QStringList data; for (int i = 0; i < item->columnCount(); i++) data << item->text(i); returnVal += QString("(id = %1, altId = %2, data = [%3])") .arg(item->id()).arg(item->altId()).arg(data.join(", ")); } else returnVal += "(unknown)"; return "[" + returnVal + "]"; }
void CRMAcctList::sSearch(const QString& pTarget) { XTreeWidgetItem *target = 0; for (int i = 0; i < _listTab->topLevelItemCount(); i++) { target = _listTab->topLevelItem(i); if (target == NULL || target->text(0).startsWith(pTarget, Qt::CaseInsensitive) || target->text(1).startsWith(pTarget, Qt::CaseInsensitive)) break; } if (target) { _listTab->setCurrentItem(target); _listTab->scrollToItem(target); } }
void arWorkBench::sViewAropen() { ParameterList params; XTreeWidgetItem * item = static_cast<XTreeWidgetItem*>(_aropen->currentItem()); if(_aropen->altId() == 1 && item) { params.append("invoiceNumber", item->text(1)); dspInvoiceInformation * newdlg = new dspInvoiceInformation(); newdlg->set(params); omfgThis->handleNewWindow(newdlg); } else { params.append("mode", "view"); params.append("aropen_id", _aropen->id()); arOpenItem newdlg(this, "", TRUE); newdlg.set(params); newdlg.exec(); } }
void dspAROpenItems::sPopulateMenu(QMenu *pMenu, QTreeWidgetItem *pItem) { int menuItem; if (((XTreeWidgetItem *)pItem)->id() != -1) { menuItem = pMenu->insertItem(tr("Edit..."), this, SLOT(sEdit()), 0); if (!_privileges->check("EditAROpenItem")) pMenu->setItemEnabled(menuItem, FALSE); pMenu->insertItem(tr("View..."), this, SLOT(sView()), 0); XTreeWidgetItem* item = (XTreeWidgetItem*)pItem; { if (item->text(0) == "Invoice") { pMenu->insertItem(tr("View Invoice..."), this, SLOT(sViewInvoice()), 0); pMenu->insertItem(tr("View Invoice Details..."), this, SLOT(sViewInvoiceDetails()), 0); } } menuItem = pMenu->insertItem(tr("Create Incident..."), this, SLOT(sIncident()), 0); if (!_privileges->check("AddIncidents")) pMenu->setItemEnabled(menuItem, FALSE); } else { menuItem = pMenu->insertItem(tr("Edit..."), this, SLOT(sEditIncident()), 0); if (!_privileges->check("MaintainIncidents")) pMenu->setItemEnabled(menuItem, FALSE); pMenu->insertItem(tr("View..."), this, SLOT(sViewIncident()), 0); if (!_privileges->check("ViewIncidents")) pMenu->setItemEnabled(menuItem, FALSE); } }
void voucherItem::sToggleReceiving(QTreeWidgetItem *pItem) { XSqlQuery voucherToggleReceiving; double vch = 0; double amt = 0; double rcv = 0; double rej = 0; QString s; XTreeWidgetItem* item = (XTreeWidgetItem*)pItem; if(item->id() == -1) return; // TODO: translation if (item->text(4) == "Yes") item->setText(4, "No"); else item->setText(4, "Yes"); for (int i = 0; i < _uninvoiced->topLevelItemCount(); i++) { XTreeWidgetItem *item = _uninvoiced->topLevelItem(i); double pp = item->data(3, Xt::RawRole).toDouble(); double qty = item->data(2, Xt::RawRole).toDouble(); if (item->text(4) == "Yes") { vch = vch + qty; amt = amt + (qty * pp); } else { if (item->text(0) == "Receiving") { rcv = rcv + qty; } else { rej = rej + qty; } } } _qtyToVoucher->setDouble(vch); _amtToVoucher->setDouble(amt); _uninvoicedReceived->setDouble(rcv); _uninvoicedRejected->setDouble(rej); // Check PO Close flag if ( ((_ordered->toDouble() <= (_received->toDouble() - _rejected->toDouble()))) && (_uninvoicedReceived->toDouble() == 0) && (_uninvoicedRejected->toDouble() == 0) ) _closePoitem->setChecked(true); else _closePoitem->setChecked(false); // Update the receipt record if (item->text("f_tagged") == "Yes") { if (item->altId() == 1) voucherToggleReceiving.prepare( "UPDATE recv " "SET recv_vohead_id=:vohead_id " "WHERE (recv_id=:target_id);" ); else if (item->altId() == 2) voucherToggleReceiving.prepare( "UPDATE poreject " "SET poreject_vohead_id=:vohead_id,poreject_voitem_id=:voitem_id " "WHERE (poreject_id=:target_id);" ); } else { if (item->altId() == 1) voucherToggleReceiving.prepare( "UPDATE recv " "SET recv_vohead_id=NULL " "WHERE ((recv_id=:target_id)" " AND (recv_vohead_id=:vohead_id));" ); else if (item->altId() == 2) voucherToggleReceiving.prepare( "UPDATE poreject " "SET poreject_vohead_id=NULL,poreject_voitem_id=NULL " "WHERE ((poreject_id=:target_id)" " AND (poreject_vohead_id=:vohead_id));" ); } voucherToggleReceiving.bindValue(":vohead_id", _voheadid); voucherToggleReceiving.bindValue(":voitem_id", _voitemid); voucherToggleReceiving.bindValue(":target_id", item->id()); voucherToggleReceiving.exec(); if (ErrorReporter::error(QtCriticalMsg, this, tr("Error Saving Voucher Item Information"), voucherToggleReceiving, __FILE__, __LINE__)) { reject(); return; } }
void voucherItem::sToggleReceiving(QTreeWidgetItem *pItem) { double n; QString s; XTreeWidgetItem* item = (XTreeWidgetItem*)pItem; if(item->id() == -1) return; if (item->text(3) == "Yes") { item->setText(3, "No"); if (item->text(0) == "Receiving") { n = _qtyToVoucher->toDouble(); _qtyToVoucher->setText(item->text(2)); n = n - _qtyToVoucher->toDouble(); _qtyToVoucher->setText(s.setNum(n)); n = _uninvoicedReceived->toDouble(); _uninvoicedReceived->setText(item->text(2)); n = n + _uninvoicedReceived->toDouble(); _uninvoicedReceived->setText(s.setNum(n)); } else { n = _qtyToVoucher->toDouble(); _qtyToVoucher->setText(item->text(2)); n = n - _qtyToVoucher->toDouble(); _qtyToVoucher->setText(s.setNum(n)); n = _uninvoicedRejected->toDouble(); _uninvoicedRejected->setText(item->text(2)); n = n + _rejected->toDouble(); _uninvoicedRejected->setText(s.setNum(n)); } } else { item->setText(3, "Yes"); if (item->text(0) == "Receiving") { n = _qtyToVoucher->toDouble(); _qtyToVoucher->setText(item->text(2)); n = n + _qtyToVoucher->toDouble(); _qtyToVoucher->setText(s.setNum(n)); n = _uninvoicedReceived->toDouble(); _uninvoicedReceived->setText(item->text(2)); n = n - _uninvoicedReceived->toDouble(); _uninvoicedReceived->setText(s.setNum(n)); } else { n = _qtyToVoucher->toDouble(); _qtyToVoucher->setText(item->text(2)); n = n + _qtyToVoucher->toDouble(); _qtyToVoucher->setText(s.setNum(n)); n = _uninvoicedRejected->toDouble(); _uninvoicedRejected->setText(item->text(2)); n = n + _uninvoicedRejected->toDouble(); _uninvoicedRejected->setText(s.setNum(n)); } } //Check PO Close flag if ( ((_ordered->toDouble() <= (_received->toDouble() - _rejected->toDouble()))) && (_uninvoicedReceived->toDouble() == 0) && (_uninvoicedRejected->toDouble() == 0) ) _closePoitem->setChecked(true); else _closePoitem->setChecked(false); // Save the voitem information if (_voitemid != -1) { q.prepare( "UPDATE voitem " "SET voitem_qty=:voitem_qty " "WHERE (voitem_id=:voitem_id);" ); q.bindValue(":voitem_id", _voitemid); } else { // Get next voitem id q.prepare("SELECT NEXTVAL('voitem_voitem_id_seq') AS voitemid"); q.exec(); if (q.first()) _voitemid = (q.value("voitemid").toInt()); else if (q.lastError().type() != QSqlError::NoError) { systemError(this, _rejectedMsg.arg(q.lastError().databaseText()), __FILE__, __LINE__); reject(); return; } q.prepare( "INSERT INTO voitem " "(voitem_id, voitem_vohead_id, voitem_poitem_id, voitem_close, voitem_qty, voitem_freight) " "VALUES " "(:voitem_id, :vohead_id, :poitem_id, :voitem_close, :voitem_qty, :voitem_freight);" ); } q.bindValue(":voitem_id", _voitemid); q.bindValue(":vohead_id", _voheadid); q.bindValue(":poitem_id", _poitemid); q.bindValue(":voitem_close", QVariant(_closePoitem->isChecked())); q.bindValue(":voitem_qty", _qtyToVoucher->toDouble()); q.bindValue(":voitem_freight", _freightToVoucher->localValue()); q.exec(); if (q.lastError().type() != QSqlError::NoError) { systemError(this, _rejectedMsg.arg(q.lastError().databaseText()), __FILE__, __LINE__); reject(); return; } //Update the receipt record if (item->text(3) == "Yes") { if (item->altId() == 1) q.prepare( "UPDATE recv " "SET recv_vohead_id=:vohead_id,recv_voitem_id=:voitem_id " "WHERE (recv_id=:target_id);" ); else if (item->altId() == 2) q.prepare( "UPDATE poreject " "SET poreject_vohead_id=:vohead_id,poreject_voitem_id=:voitem_id " "WHERE (poreject_id=:target_id);" ); } else { if (item->altId() == 1) q.prepare( "UPDATE recv " "SET recv_vohead_id=NULL,recv_voitem_id=NULL " "WHERE ((recv_id=:target_id)" " AND (recv_vohead_id=:vohead_id));" ); else if (item->altId() == 2) q.prepare( "UPDATE poreject " "SET poreject_vohead_id=NULL,poreject_voitem_id=NULL " "WHERE ((poreject_id=:target_id)" " AND (poreject_vohead_id=:vohead_id));" ); } q.bindValue(":vohead_id", _voheadid); q.bindValue(":voitem_id", _voitemid); q.bindValue(":target_id", item->id()); q.exec(); if (q.lastError().type() != QSqlError::NoError) { systemError(this, _rejectedMsg.arg(q.lastError().databaseText()), __FILE__, __LINE__); reject(); return; } }
enum SetResponse hotkey::set(const ParameterList &pParams) { XDialog::set(pParams); QVariant param; bool valid; param = pParams.value("mode", &valid); if (valid) { if (param.toString() == "new") _mode = cNew; else if (param.toString() == "edit") { _mode = cEdit; _hotkey->setEnabled(FALSE); } } param = pParams.value("username", &valid); if (valid) { _username = param.toString(); _currentUser = FALSE; } param = pParams.value("currentUser", &valid); if (valid) _currentUser = TRUE; param = pParams.value("hotkey", &valid); if (valid) { QString value; if (_currentUser) value = _preferences->value(param.toString()); else { q.prepare( "SELECT usrpref_value " "FROM usrpref " "WHERE ( (usrpref_username=:username)" " AND (usrpref_name=:name) );" ); q.bindValue(":username", _username); q.bindValue(":name", param.toString()); q.exec(); if (q.first()) value = q.value("usrpref_value").toString(); // ToDo } if (!value.isNull()) { for (int i = 0; i < _action->topLevelItemCount(); i++) { XTreeWidgetItem *cursor = _action->topLevelItem(i); if (param.toString().left(1) == "F") _hotkey->setText(QString("F%1").arg(param.toString().right(1))); else if (param.toString().left(1) == "C") _hotkey->setText(QString("Ctrl+%1").arg(param.toString().right(1))); if (cursor->text(0) == value) { _action->setCurrentItem(cursor); _action->scrollToItem(cursor); break; } } } } return NoError; }
void reconcileBankaccount::sReceiptsToggleCleared() { XTreeWidgetItem *item = (XTreeWidgetItem*)_receipts->currentItem(); XTreeWidgetItem *child = 0; bool setto = true; if(0 == item) return; _receipts->scrollToItem(item); if(item->altId() == 3) { setto = item->text(0) == tr("No"); for (int i = 0; i < item->childCount(); i++) { child = item->child(i); if(child->text(0) != (setto ? tr("Yes") : tr("No"))) { q.prepare("SELECT toggleBankrecCleared(:bankrecid, :source, :sourceid) AS cleared"); q.bindValue(":bankrecid", _bankrecid); q.bindValue(":sourceid", child->id()); if(child->altId()==1) q.bindValue(":source", "GL"); else if(child->altId()==2) q.bindValue(":source", "AD"); q.exec(); if(q.first()) child->setText(0, (q.value("cleared").toBool() ? tr("Yes") : tr("No") )); else if (q.lastError().type() != QSqlError::NoError) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return; } } } item->setText(0, (setto ? tr("Yes") : tr("No"))); } else { q.prepare("SELECT toggleBankrecCleared(:bankrecid, :source, :sourceid) AS cleared"); q.bindValue(":bankrecid", _bankrecid); q.bindValue(":sourceid", item->id()); if(item->altId()==1) q.bindValue(":source", "GL"); else if(item->altId()==2) q.bindValue(":source", "AD"); q.exec(); if(q.first()) { item->setText(0, (q.value("cleared").toBool() ? tr("Yes") : tr("No") )); item = (XTreeWidgetItem*)item->QTreeWidgetItem::parent(); if(item != 0 && item->altId() == 3) { setto = true; for (int i = 0; i < item->childCount(); i++) { setto = (setto && (item->child(i)->text(0) == tr("Yes"))); } item->setText(0, (setto ? tr("Yes") : tr("No"))); } } else { populate(); if (q.lastError().type() != QSqlError::NoError) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return; } } } }