Exemplo n.º 1
0
void prospect::populate()
{
  XSqlQuery prospect;
  prospect.prepare("SELECT prospect.*, crmacct_id "
                "FROM prospect, crmacct "
                "WHERE ((prospect_id=:prospect_id)"
		"  AND  (prospect_id=crmacct_prospect_id));" );
  prospect.bindValue(":prospect_id", _prospectid);
  prospect.exec();
  if (prospect.first())
  {
    _crmacct->setId(prospect.value("crmacct_id").toInt());

    _number->setText(prospect.value("prospect_number"));
    _cachedNumber = prospect.value("prospect_number").toString();
    _name->setText(prospect.value("prospect_name").toString());
    _contact->setId(prospect.value("prospect_cntct_id").toInt());
    _taxauth->setId(prospect.value("prospect_taxauth_id").toInt());
    _salesrep->setId(prospect.value("prospect_salesrep_id").toInt());
    _site->setId(prospect.value("prospect_warehous_id").toInt());
    _notes->setText(prospect.value("prospect_comments").toString());
    _active->setChecked(prospect.value("prospect_active").toBool());
  }
  else if (prospect.lastError().type() != QSqlError::None)
  {
    systemError(this, prospect.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }

  sFillQuotesList();
}
Exemplo n.º 2
0
bool prospect::sPopulate()
{
  XSqlQuery getq;
  if (_prospectid >= 0)
  {
    getq.prepare("SELECT prospect.*, crmacct_id, crmacct_owner_username"
                 "  FROM prospect, crmacct"
                 " WHERE ((prospect_id=:prospect_id)"
                 "   AND  (prospect_id=crmacct_prospect_id));" );
    getq.bindValue(":prospect_id", _prospectid);
  }
  else if (_crmacctid >= 0)
  {
    getq.prepare("SELECT crmacct_active AS prospect_active,"
                 "       crmacct_name   AS prospect_name,"
                 "       crmacct_number AS prospect_number,"
                 "       crmacct_cntct_id_1 AS prospect_cntct_id,"
                 "       crmacct_owner_username AS prospect_owner_username,"
                 "       NULL AS prospect_comments, -1 AS prospect_taxzone_id,"
                 "      -1 AS prospect_salesrep_id, -1 AS prospect_warehous_id,"
                 "      crmacct_id, crmacct_owner_username"
                 "  FROM crmacct"
                 " WHERE (crmacct_id=:id);");
    getq.bindValue(":id", _crmacctid);
  }

  getq.exec();
  if (getq.first())
  {
    _crmacctid = getq.value("crmacct_id").toInt();

    _number->setText(getq.value("prospect_number").toString());
    _cachedNumber = getq.value("prospect_number").toString();
    _name->setText(getq.value("prospect_name").toString());
    _contact->setId(getq.value("prospect_cntct_id").toInt());
    _taxzone->setId(getq.value("prospect_taxzone_id").toInt());
    _salesrep->setId(getq.value("prospect_salesrep_id").toInt());
    _site->setId(getq.value("prospect_warehous_id").toInt());
    _notes->setText(getq.value("prospect_comments").toString());
    _active->setChecked(getq.value("prospect_active").toBool());
    _crmowner = getq.value("crmacct_owner_username").toString();
  }
  else if (ErrorReporter::error(QtCriticalMsg, this, tr("Getting Prospect"),
                                getq, __FILE__, __LINE__))
    return false;

  _crmacct->setEnabled(_crmacctid > 0 &&
                       (_privileges->check("MaintainAllCRMAccounts") ||
                        _privileges->check("ViewAllCRMAccounts") ||
                        (omfgThis->username() == _crmowner && _privileges->check("MaintainPersonalCRMAccounts")) ||
                        (omfgThis->username() == _crmowner && _privileges->check("ViewPersonalCRMAccounts"))));

  sFillQuotesList();
  emit populated();

  return true;
}