void vendor::sCheck() { // Make sure that the newly entered vend_number is not already in use. // Switch to cEdit and populate if so. _number->setText(_number->text().trimmed().toUpper()); if (_number->text().length() && _cachedNumber != _number->text()) { if(cNew == _mode && -1 != _NumberGen && _number->text().toInt() != _NumberGen) { XSqlQuery query; query.prepare( "SELECT releaseCRMAccountNumber(:Number);" ); query.bindValue(":Number", _NumberGen); query.exec(); _NumberGen = -1; } q.prepare( "SELECT vend_id, 1 AS type " "FROM vendinfo " "WHERE (vend_number=:vend_number) " "UNION " "SELECT crmacct_id, 2 AS type " "FROM crmacct " "WHERE (crmacct_number=:vend_number) " "ORDER BY type; "); q.bindValue(":vend_number", _number->text()); q.exec(); if (q.first()) { if ((q.value("type").toInt() == 1) && (_notice)) { if (QMessageBox::question(this, tr("Vendor Exists"), tr("<p>This number is currently " "used by an existing Vendor. " "Do you want to edit " "that Vendor?"), QMessageBox::Yes, QMessageBox::No | QMessageBox::Default) == QMessageBox::No) { _number->setText(_cachedNumber); _number->setFocus(); return; } else { _vendid = q.value("vend_id").toInt(); _mode = cEdit; populate(); _name->setFocus(); } } else if ( (_mode == cEdit) && ((q.value("type").toInt() == 2) ) && (_notice)) { if (QMessageBox::critical(this, tr("Invalid Number"), tr("<p>This number is currently " "assigned to another CRM account."))) { _number->setText(_cachedNumber); _number->setFocus(); _notice = false; return; } } else if ((q.value("type").toInt() == 2) && (_notice)) { if (QMessageBox::question(this, tr("Convert"), tr("<p>This number is currently " "assigned to CRM Account. " "Do you want to convert the " "CRM Account to a Vendor?"), QMessageBox::Yes, QMessageBox::No | QMessageBox::Default) == QMessageBox::No) { _number->clear(); _number->setFocus(); return; } else sLoadCrmAcct(q.value("vend_id").toInt()); } } } }
enum SetResponse customer::set(const ParameterList &pParams) { QVariant param; bool valid; param = pParams.value("cust_id", &valid); if (valid) { _custid = param.toInt(); populate(); } param = pParams.value("mode", &valid); if (valid) { if (param.toString() == "new") { _mode = cNew; if (_custid <= 0 ) { q.exec("SELECT NEXTVAL('cust_cust_id_seq') AS cust_id"); if (q.first()) _custid = q.value("cust_id").toInt(); else { systemError(this, tr("A System Error occurred at %1::%2.") .arg(__FILE__) .arg(__LINE__) ); return UndefinedError; } } _comments->setId(_custid); _salesrep->setId(_metrics->value("DefaultSalesRep").toInt()); _terms->setId(_metrics->value("DefaultTerms").toInt()); _taxauth->setCurrentItem(-1); _shipform->setId(_metrics->value("DefaultShipFormId").toInt()); _shipvia->setId(_metrics->value("DefaultShipViaId").toInt()); _custtype->setId(_metrics->value("DefaultCustType").toInt()); _backorders->setChecked(_metrics->boolean("DefaultBackOrders")); _partialShipments->setEnabled(_metrics->boolean("DefaultBackOrders")); _partialShipments->setChecked(_metrics->boolean("DefaultPartialShipments")); _allowFFShipto->setChecked(_metrics->boolean("DefaultFreeFormShiptos")); _creditLimit->setBaseValue(_metrics->value("SOCreditLimit").toDouble()); _creditRating->setText(_metrics->value("SOCreditRate")); if (_metrics->value("DefaultBalanceMethod") == "B") _balanceMethod->setCurrentItem(0); else if (_metrics->value("DefaultBalanceMethod") == "O") _balanceMethod->setCurrentItem(1); if(!_privleges->check("MaintainCustomerMastersCustomerType") && !_privleges->check("MaintainCustomerMastersCustomerTypeOnCreate") && (_custtype->id() != -1)) _custtype->setEnabled(false); connect(_shipto, SIGNAL(valid(bool)), _editShipto, SLOT(setEnabled(bool))); connect(_shipto, SIGNAL(valid(bool)), _deleteShipto, SLOT(setEnabled(bool))); connect(_shipto, SIGNAL(itemSelected(int)), _editShipto, SLOT(animateClick())); connect(_cc, SIGNAL(valid(bool)), _editCC, SLOT(setEnabled(bool))); connect(_cc, SIGNAL(itemSelected(int)), _editCC, SLOT(animateClick())); connect(_charass, SIGNAL(valid(bool)), _editCharacteristic, SLOT(setEnabled(bool))); connect(_charass, SIGNAL(valid(bool)), _deleteCharacteristic, SLOT(setEnabled(bool))); connect(_backorders, SIGNAL(toggled(bool)), _partialShipments, SLOT(setEnabled(bool))); connect(_backorders, SIGNAL(toggled(bool)), _partialShipments, SLOT(setChecked(bool))); _number->setFocus(); } else if (param.toString() == "edit") { _mode = cEdit; if(!_privleges->check("MaintainCustomerMastersCustomerType") && (_custtype->id() != -1)) _custtype->setEnabled(false); connect(_shipto, SIGNAL(valid(bool)), _editShipto, SLOT(setEnabled(bool))); connect(_shipto, SIGNAL(valid(bool)), _deleteShipto, SLOT(setEnabled(bool))); connect(_shipto, SIGNAL(itemSelected(int)), _editShipto, SLOT(animateClick())); connect(_cc, SIGNAL(valid(bool)), _editCC, SLOT(setEnabled(bool))); connect(_cc, SIGNAL(itemSelected(int)), _editCC, SLOT(animateClick())); connect(_charass, SIGNAL(valid(bool)), _editCharacteristic, SLOT(setEnabled(bool))); connect(_charass, SIGNAL(valid(bool)), _deleteCharacteristic, SLOT(setEnabled(bool))); connect(_backorders, SIGNAL(toggled(bool)), _partialShipments, SLOT(setEnabled(bool))); connect(_backorders, SIGNAL(toggled(bool)), _partialShipments, SLOT(setChecked(bool))); _save->setFocus(); } else if (param.toString() == "view") { _mode = cView; _number->setEnabled(FALSE); _name->setEnabled(FALSE); _custtype->setEnabled(FALSE); _active->setEnabled(FALSE); _corrCntct->setEnabled(FALSE); _billCntct->setEnabled(FALSE); _terms->setEnabled(FALSE); _balanceMethod->setEnabled(FALSE); _defaultDiscountPrcnt->setEnabled(FALSE); _creditLimit->setEnabled(FALSE); _creditRating->setEnabled(FALSE); _creditStatusGroup->setEnabled(FALSE); _autoUpdateStatus->setEnabled(FALSE); _autoHoldOrders->setEnabled(FALSE); _taxauth->setEnabled(FALSE); _sellingWarehouse->setEnabled(FALSE); _salesrep->setEnabled(FALSE); _defaultCommissionPrcnt->setEnabled(FALSE); _shipvia->setEnabled(FALSE); _shipform->setEnabled(FALSE); _shipchrg->setEnabled(FALSE); _backorders->setEnabled(FALSE); _usesPOs->setEnabled(FALSE); _blanketPos->setEnabled(FALSE); _allowFFShipto->setEnabled(FALSE); _allowFFBillto->setEnabled(FALSE); _notes->setReadOnly(TRUE); _comments->setReadOnly(TRUE); _ediProfile->setEnabled(FALSE); _ediGroup->setEnabled(FALSE); _soEdiProfile->setEnabled(FALSE); _soEdiGroup->setEnabled(FALSE); _newShipto->setEnabled(FALSE); _newCharacteristic->setEnabled(FALSE); _newTaxreg->setEnabled(FALSE); _currency->setEnabled(FALSE); _partialShipments->setEnabled(FALSE); _save->hide(); connect(_shipto, SIGNAL(itemSelected(int)), _viewShipto, SLOT(animateClick())); connect(_cc, SIGNAL(itemSelected(int)), _viewCC, SLOT(animateClick())); disconnect(_taxreg, SIGNAL(valid(bool)), _deleteTaxreg, SLOT(setEnabled(bool))); disconnect(_taxreg, SIGNAL(valid(bool)), _editTaxreg, SLOT(setEnabled(bool))); disconnect(_taxreg, SIGNAL(itemSelected(int)), _editTaxreg, SLOT(animateClick())); connect(_taxreg, SIGNAL(itemSelected(int)), _viewTaxreg, SLOT(animateClick())); _close->setFocus(); } } param = pParams.value("crmacct_id", &valid); if (valid) sLoadCrmAcct(param.toInt()); param = pParams.value("prospect_id", &valid); if (valid) sLoadProspect(param.toInt()); return NoError; }
void customer::sCheck() { _number->setText(_number->text().stripWhiteSpace().upper()); q.prepare( "SELECT cust_id, 1 AS type " "FROM custinfo " "WHERE (cust_number=:cust_number) " "UNION " "SELECT prospect_id, 2 AS type " "FROM prospect " "WHERE (prospect_number=:cust_number) " "UNION " "SELECT crmacct_id, 3 AS type " "FROM crmacct " "WHERE (crmacct_number=:cust_number) " "ORDER BY type; "); q.bindValue(":cust_number", _number->text()); q.exec(); if (q.first()) { if ((q.value("type").toInt() == 1) && (_notice)) { if (QMessageBox::question(this, tr("Customer Exists"), tr("<p>This number is currently " "used by an existing Customer. " "Do you want to edit " "that Customer?"), QMessageBox::Yes, QMessageBox::No | QMessageBox::Default) == QMessageBox::No) { _number->clear(); _number->setFocus(); return; } else { _custid = q.value("cust_id").toInt(); _mode = cEdit; populate(); _name->setFocus(); } } else if ((q.value("type").toInt() == 2) && (_notice)) { if (QMessageBox::question(this, tr("Convert"), tr("<p>This number is currently " "assigned to a Prospect. " "Do you want to convert the " "Prospect to a Customer?"), QMessageBox::Yes, QMessageBox::No | QMessageBox::Default) == QMessageBox::No) { _number->clear(); _number->setFocus(); return; } else sLoadProspect(q.value("cust_id").toInt()); } else if ((q.value("type").toInt() == 3) && (_notice)) { if (QMessageBox::question(this, tr("Convert"), tr("<p>This number is currently " "assigned to CRM Account. " "Do you want to convert the " "CRM Account to a Customer?"), QMessageBox::Yes, QMessageBox::No | QMessageBox::Default) == QMessageBox::No) { _number->clear(); _number->setFocus(); return; } else sLoadCrmAcct(q.value("cust_id").toInt()); } } }
void vendor::sCheck() { _number->setText(_number->text().trimmed().toUpper()); if (_number->text().length() && _cachedNumber != _number->text()) { if(cNew == _mode && -1 != _NumberGen && _number->text().toInt() != _NumberGen) { XSqlQuery query; query.prepare( "SELECT releaseCRMAccountNumber(:Number);" ); query.bindValue(":Number", _NumberGen); query.exec(); ErrorReporter::error(QtCriticalMsg, this, tr("Releasing Number"), query, __FILE__, __LINE__); _NumberGen = -1; } XSqlQuery dupq; dupq.prepare("SELECT vend_id, 1 AS type" " FROM vendinfo " " WHERE (vend_number=:vend_number)" " UNION " "SELECT crmacct_id, 2 AS type " " FROM crmacct " " WHERE (crmacct_number=:vend_number)" " ORDER BY type;"); dupq.bindValue(":vend_number", _number->text()); dupq.exec(); if (dupq.first()) { if ((dupq.value("type").toInt() == 1) && (_notice)) { if (QMessageBox::question(this, tr("Vendor Exists"), tr("<p>This number is currently " "used by an existing Vendor. " "Do you want to edit " "that Vendor?"), QMessageBox::Yes, QMessageBox::No | QMessageBox::Default) == QMessageBox::No) { _number->setText(_cachedNumber); _number->setFocus(); return; } _vendid = dupq.value("vend_id").toInt(); _mode = cEdit; sPopulate(); _name->setFocus(); } else if ( (_mode == cEdit) && ((dupq.value("type").toInt() == 2) ) && (_notice)) { QMessageBox::critical(this, tr("Invalid Number"), tr("<p>This number is currently " "assigned to another CRM account.")); _number->setText(_cachedNumber); _number->setFocus(); _notice = false; return; } else if ((dupq.value("type").toInt() == 2) && (_notice)) { if (QMessageBox::question(this, tr("Convert"), tr("<p>This number is currently assigned to CRM Account. " "Do you want to convert the CRM Account to a Vendor?"), QMessageBox::Yes, QMessageBox::No | QMessageBox::Default) == QMessageBox::No) { _number->clear(); _number->setFocus(); return; } sLoadCrmAcct(dupq.value("vend_id").toInt()); } } else if (ErrorReporter::error(QtCriticalMsg, this, tr("Getting Vendor"), dupq, __FILE__, __LINE__)) return; } }