Example #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());
    _taxzone->setId(prospect.value("prospect_taxzone_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::NoError)
  {
    systemError(this, prospect.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }

  sFillQuotesList();
  emit populated();
}
Example #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;
}
void printSinglecopyDocument::sPopulate()
{
  ParameterList getp = getParamsDocList();

  MetaSQLQuery getm(_docinfoQueryString);
  XSqlQuery getq = getm.toQuery(getp);
  if (getq.first())
    emit populated(&getq);
}
Example #4
0
void warehouse::populate()
{
  XSqlQuery getq;
  getq.prepare( "SELECT *, formatScrap(warehous_shipping_commission) AS f_commission "
             "FROM whsinfo "
             "WHERE (warehous_id=:warehous_id);" );
  getq.bindValue(":warehous_id", _warehousid);
  getq.exec();
  if (getq.first())
  {
    _code->setText(getq.value("warehous_code"));
    _sitetype->setId(getq.value("warehous_sitetype_id").toInt());
    _active->setChecked(getq.value("warehous_active").toBool());
    _description->setText(getq.value("warehous_descrip"));
    _contact->setId(getq.value("warehous_cntct_id").toInt());
    _address->setId(getq.value("warehous_addr_id").toInt());
    _defaultFOB->setText(getq.value("warehous_fob"));
    _bolPrefix->setText(getq.value("warehous_bol_prefix"));
    _bolNumber->setText(getq.value("warehous_bol_number"));
    _shipping->setChecked(getq.value("warehous_shipping").toBool());
    _countTagPrefix->setText(getq.value("warehous_counttag_prefix"));
    _countTagNumber->setText(getq.value("warehous_counttag_number"));
    _useSlips->setChecked(getq.value("warehous_useslips").toBool());
    _arblGroup->setChecked(getq.value("warehous_enforceARBL").toBool());
    _aisleSize->setValue(getq.value("warehous_aislesize").toInt());
    _aisleAlpha->setChecked(getq.value("warehous_aislealpha").toBool());
    _rackSize->setValue(getq.value("warehous_racksize").toInt());
    _rackAlpha->setChecked(getq.value("warehous_rackalpha").toBool());
    _binSize->setValue(getq.value("warehous_binsize").toInt());
    _binAlpha->setChecked(getq.value("warehous_binalpha").toBool());
    _locationSize->setValue(getq.value("warehous_locationsize").toInt());
    _locationAlpha->setChecked(getq.value("warehous_locationalpha").toBool());
    _useZones->setChecked(getq.value("warehous_usezones").toBool());
    _account->setId(getq.value("warehous_default_accnt_id").toInt());
    _shipcomm->setText(getq.value("f_commission").toString());
    _taxzone->setId(getq.value("warehous_taxzone_id").toInt());
    _transit->setChecked(getq.value("warehous_transit").toBool());
    _shipform->setId(getq.value("warehous_shipform_id").toInt());
    _pickList->setId(getq.value("warehous_picklist_shipform_id").toInt());
    _shipvia->setId(getq.value("warehous_shipvia_id").toInt());
    _shipcomments->setText(getq.value("warehous_shipcomments").toString());
    _costcat->setId(getq.value("warehous_costcat_id").toInt());
    _sequence->setValue(getq.value("warehous_sequence").toInt());

    sFillList();
    _comments->setId(_warehousid);

    emit populated();
    emit newId(_warehousid);
  }

}
Example #5
0
void project::populate()
{
  q.prepare( "SELECT prj_number, prj_name, prj_descrip,"
             "       prj_so, prj_wo, prj_po, prj_status, "
             "       prj_owner_username, prj_username, prj_start_date, "
             "       prj_assigned_date, prj_due_date, prj_completed_date,"
             "       prj_recurring_prj_id "
             "FROM prj "
             "WHERE (prj_id=:prj_id);" );
  q.bindValue(":prj_id", _prjid);
  q.exec();
  if (q.first())
  {
    _saved = true;
    _owner->setUsername(q.value("prj_owner_username").toString());
    _number->setText(q.value("prj_number").toString());
    _name->setText(q.value("prj_name").toString());
    _descrip->setText(q.value("prj_descrip").toString());
    _so->setChecked(q.value("prj_so").toBool());
    _wo->setChecked(q.value("prj_wo").toBool());
    _po->setChecked(q.value("prj_po").toBool());
    _assignedTo->setUsername(q.value("prj_username").toString());
    _started->setDate(q.value("prj_start_date").toDate());
    _assigned->setDate(q.value("prj_assigned_date").toDate());
    _due->setDate(q.value("prj_due_date").toDate());
    _completed->setDate(q.value("prj_completed_date").toDate());
    QString status = q.value("prj_status").toString();

    _recurring->setParent(q.value("prj_recurring_prj_id").isNull() ?
                            _prjid : q.value("prj_recurring_prj_id").toInt(),
                          "J");

    if("P" == status)
      _status->setCurrentIndex(0);
    else if("O" == status)
      _status->setCurrentIndex(1);
    else if("C" == status)
      _status->setCurrentIndex(2);
  }

  sFillTaskList();
  _comments->setId(_prjid);
  _documents->setId(_prjid);
  emit populated(_prjid);
}
void printMulticopyDocument::populate()
{
  ParameterList getp = getParamsDocList();

  MetaSQLQuery getm(_docinfoQueryString);
  XSqlQuery getq = getm.toQuery(getp);
  if (getq.first())
  {
    if (getq.value("posted").toBool())
    {
      _data->_post->setChecked(false);
      _data->_post->hide();
    }
    else
      _data->_post->setVisible(! _data->_postPrivilege.isEmpty());
    emit populated(&getq);
  }
}
Example #7
0
voucherItem::voucherItem(QWidget* parent, const char* name, bool modal, Qt::WFlags fl)
    : XDialog(parent, name, modal, fl)
{
  setupUi(this);

  connect(_new, SIGNAL(clicked()), this, SLOT(sNew()));
  connect(_edit, SIGNAL(clicked()), this, SLOT(sEdit()));
  connect(_delete, SIGNAL(clicked()), this, SLOT(sDelete()));
  connect(_save, SIGNAL(clicked()), this, SLOT(sSave()));
  connect(_uninvoiced, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(sToggleReceiving(QTreeWidgetItem*)));
  connect(_uninvoiced, SIGNAL(populateMenu(QMenu*,QTreeWidgetItem*)), this, SLOT(sPopulateMenu(QMenu*, QTreeWidgetItem*)));
  connect(_freightToVoucher, SIGNAL(lostFocus()), this, SLOT(sFillList()));
  connect(_vodist, SIGNAL(populated()), this, SLOT(sCalculateTax()));
  connect(_taxtype,	  SIGNAL(newID(int)), this, SLOT(sCalculateTax()));
  connect(_taxLit, SIGNAL(leftClickedURL(const QString&)), this, SLOT(sTaxDetail()));

  _item->setReadOnly(TRUE);
  
  _unitPrice->setPrecision(omfgThis->priceVal());
  _extPrice->setPrecision(omfgThis->moneyVal());
  _lineFreight->setPrecision(omfgThis->moneyVal());

  _ordered->setValidator(omfgThis->qtyVal());
  _received->setValidator(omfgThis->qtyVal());
  _rejected->setValidator(omfgThis->qtyVal());
  _uninvoicedReceived->setValidator(omfgThis->qtyVal());
  _uninvoicedRejected->setValidator(omfgThis->qtyVal());

  _qtyToVoucher->setValidator(omfgThis->qtyVal());
  
  _vodist->addColumn(tr("Cost Element"), -1,           Qt::AlignLeft, true, "costelem_type");
  _vodist->addColumn(tr("Amount"),       _priceColumn, Qt::AlignRight,true, "vodist_amount");

  _uninvoiced->addColumn(tr("Receipt/Reject"), -1,          Qt::AlignCenter, true, "action");
  _uninvoiced->addColumn(tr("Date"),           _dateColumn, Qt::AlignCenter, true, "item_date");
  _uninvoiced->addColumn(tr("Qty."),           _qtyColumn,  Qt::AlignRight,  true, "qty");
  _uninvoiced->addColumn(tr("Tagged"),         _ynColumn,   Qt::AlignCenter, true, "f_tagged");
  
  _rejectedMsg = tr("The application has encountered an error and must "
                    "stop editing this Voucher Item.\n%1");

  _inTransaction = TRUE;
  q.exec("BEGIN;"); //Lot's of things can happen in here that can cause problems if cancelled out.  Let's make it easy to roll it back.
}
Example #8
0
voucherItem::voucherItem(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl)
    : XDialog(parent, name, modal, fl)
{
    XSqlQuery voucherItem;
    setupUi(this);

    connect(_new,              SIGNAL(clicked()),        this, SLOT(sNew()));
    connect(_edit,             SIGNAL(clicked()),        this, SLOT(sEdit()));
    connect(_delete,           SIGNAL(clicked()),        this, SLOT(sDelete()));
    connect(_save,             SIGNAL(clicked()),        this, SLOT(sSave()));
    connect(_uninvoiced,       SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(sToggleReceiving(QTreeWidgetItem*)));
    connect(_uninvoiced,       SIGNAL(populateMenu(QMenu*,XTreeWidgetItem*)), this, SLOT(sPopulateMenu(QMenu*, XTreeWidgetItem*)));
    connect(_freightToVoucher, SIGNAL(editingFinished()), this, SLOT(sCalculateTax()));
    connect(_freightToVoucher, SIGNAL(editingFinished()), this, SLOT(sFillList()));
    connect(_vodist,           SIGNAL(populated()),       this, SLOT(sCalculateTax()));
    connect(_taxtype,          SIGNAL(newID(int)),        this, SLOT(sCalculateTax()));
    connect(_taxLit,           SIGNAL(leftClickedURL(const QString&)), this, SLOT(sTaxDetail()));

    _item->setReadOnly(true);

    _unitPrice->setPrecision(omfgThis->priceVal());
    _extPrice->setPrecision(omfgThis->moneyVal());
    _lineFreight->setPrecision(omfgThis->moneyVal());

    _ordered->setValidator(omfgThis->qtyVal());
    _received->setValidator(omfgThis->qtyVal());
    _rejected->setValidator(omfgThis->qtyVal());
    _uninvoicedReceived->setValidator(omfgThis->qtyVal());
    _uninvoicedRejected->setValidator(omfgThis->qtyVal());

    _qtyToVoucher->setValidator(omfgThis->qtyVal());
    _amtToVoucher->setValidator(omfgThis->moneyVal());

    _vodist->addColumn(tr("Cost Element"), -1,           Qt::AlignLeft, true, "costelem_type");
    _vodist->addColumn(tr("Amount"),       _priceColumn, Qt::AlignRight,true, "vodist_amount");

    _uninvoiced->addColumn(tr("Receipt/Reject"), -1,          Qt::AlignCenter, true, "action");
    _uninvoiced->addColumn(tr("Date"),           _dateColumn, Qt::AlignCenter, true, "item_date");
    _uninvoiced->addColumn(tr("Qty."),           _qtyColumn,  Qt::AlignRight,  true, "qty");
    _uninvoiced->addColumn(tr("Unit Price"),     _moneyColumn,Qt::AlignRight,  true, "unitprice");
    _uninvoiced->addColumn(tr("Tagged"),         _ynColumn,   Qt::AlignCenter, true, "f_tagged");
}
dspRunningAvailability::dspRunningAvailability(QWidget* parent, const char*, Qt::WindowFlags fl)
  : display(parent, "dspRunningAvailability", fl)
{
  setupUi(optionsWidget());
  setWindowTitle(tr("Running Availability"));
  setListLabel(tr("Running Availability"));
  setReportName("RunningAvailability");
  setMetaSQLOptions("runningAvailability", "detail");
  setUseAltId(true);

  _ready = true;

  connect(list(),       SIGNAL(populated()), this, SLOT(sHandleResort()));
  connect(list(),       SIGNAL(resorted()), this, SLOT(sHandleResort()));

  list()->addColumn(tr("Order Type"),             _itemColumn,  Qt::AlignLeft,  true, "ordertype");
  list()->addColumn(tr("Order #"),                _itemColumn,  Qt::AlignLeft,  true, "ordernumber");
  list()->addColumn(tr("Source/Destination"),     -1,           Qt::AlignLeft,  true, "item_number");
  list()->addColumn(tr("Due Date"),               _dateColumn,  Qt::AlignLeft,  true, "duedate");
  list()->addColumn(tr("Amount"),                 _moneyColumn, Qt::AlignRight, true, "amount");
  list()->addColumn(tr("Ordered"),                _qtyColumn,   Qt::AlignRight, true, "qtyordered");
  list()->addColumn(tr("Received"),               _qtyColumn,   Qt::AlignRight, true, "qtyreceived");
  list()->addColumn(tr("Balance"),                _qtyColumn,   Qt::AlignRight, true, "balance");
  list()->addColumn(tr("Running Avail."),         _qtyColumn,   Qt::AlignRight, true, "runningavail");
  list()->addColumn(tr("Running Netable"),        _qtyColumn,   Qt::AlignRight, true, "runningnetable");
  list()->addColumn(tr("Notes"),                  _itemColumn,  Qt::AlignLeft,  true, "notes");

  _qoh->setValidator(omfgThis->qtyVal());
  _netableqoh->setValidator(omfgThis->qtyVal());
  _reorderLevel->setValidator(omfgThis->qtyVal());
  _orderMultiple->setValidator(omfgThis->qtyVal());
  _orderToQty->setValidator(omfgThis->qtyVal());

  connect(omfgThis, SIGNAL(workOrdersUpdated(int, bool)), this, SLOT(sFillList()));

  if (!_metrics->boolean("MultiWhs"))
  {
    _warehouseLit->hide();
    _warehouse->hide();
  }
}
Example #10
0
void costCategory::populate()
{
  XSqlQuery costpopulate;
  costpopulate.prepare( "SELECT * "
             "FROM costcat "
             "WHERE (costcat_id=:costcat_id);" );
  costpopulate.bindValue(":costcat_id", _costcatid);
  costpopulate.exec();
  if (costpopulate.first())
  {
    if (_mode != cCopy)
    {
      _category->setText(costpopulate.value("costcat_code").toString());
      _description->setText(costpopulate.value("costcat_descrip").toString());
    }

    _asset->setId(costpopulate.value("costcat_asset_accnt_id").toInt());
    _expense->setId(costpopulate.value("costcat_exp_accnt_id").toInt());
    _inventoryCost->setId(costpopulate.value("costcat_invcost_accnt_id").toInt());
    _liability->setId(costpopulate.value("costcat_liability_accnt_id").toInt());
    _freight->setId(costpopulate.value("costcat_freight_accnt_id").toInt());
    _adjustment->setId(costpopulate.value("costcat_adjustment_accnt_id").toInt());
    _invScrap->setId(costpopulate.value("costcat_scrap_accnt_id").toInt());
    _mfgScrap->setId(costpopulate.value("costcat_mfgscrap_accnt_id").toInt());
    _wip->setId(costpopulate.value("costcat_wip_accnt_id").toInt());
    _transformClearing->setId(costpopulate.value("costcat_transform_accnt_id").toInt());
    _purchasePrice->setId(costpopulate.value("costcat_purchprice_accnt_id").toInt());
    _shippingAsset->setId(costpopulate.value("costcat_shipasset_accnt_id").toInt());
    _toLiabilityClearing->setId(costpopulate.value("costcat_toliability_accnt_id").toInt());

    emit populated(_costcatid);
  }
  else if (costpopulate.lastError().type() != QSqlError::NoError)
  {
    systemError(this, costpopulate.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }
}
Example #11
0
void ui_menu::do_handle()
{
	if(!populated())
		populate();
	handle();
}
Example #12
0
void vendor::populate()
{
  MetaSQLQuery mql(
            "SELECT vendinfo.*, crmacct_id, "
            "<? if exists(\"key\") ?>"
            "       CASE WHEN LENGTH(vend_ach_routingnumber) > 0 THEN"
            "       formatbytea(decrypt(setbytea(vend_ach_routingnumber),"
            "                           setbytea(<? value(\"key\") ?>), 'bf'))"
            "            ELSE '' END AS routingnum,"
            "       CASE WHEN LENGTH(vend_ach_accntnumber) > 0 THEN"
            "       formatbytea(decrypt(setbytea(vend_ach_accntnumber),"
            "                           setbytea(<? value(\"key\") ?>), 'bf'))"
            "            ELSE '' END AS accntnum "
            "<? else ?>"
            "       <? value(\"na\") ?> AS routingnum,"
            "       <? value(\"na\") ?> AS accntnum "
            "<? endif ?>"
            "FROM vendinfo "
            "  JOIN crmacct ON (vend_id=crmacct_vend_id) "
            "WHERE (vend_id=<? value(\"vend_id\") ?>);" );
  ParameterList params;
  params.append("vend_id", _vendid);
  params.append("key",     omfgThis->_key);
  params.append("na",      tr("N/A"));
  q = mql.toQuery(params);
  if (q.first())
  {
    _notice = FALSE;
    _cachedNumber = q.value("vend_number").toString();

    _number->setText(q.value("vend_number"));
    _accountNumber->setText(q.value("vend_accntnum"));
    _vendtype->setId(q.value("vend_vendtype_id").toInt());
    _active->setChecked(q.value("vend_active").toBool());
    _name->setText(q.value("vend_name"));
    _contact1->setId(q.value("vend_cntct1_id").toInt());
    _contact1->setSearchAcct(q.value("crmacct_id").toInt());
    _contact2->setId(q.value("vend_cntct2_id").toInt());
    _contact2->setSearchAcct(q.value("crmacct_id").toInt());
    _address->setId(q.value("vend_addr_id").toInt());
    _defaultTerms->setId(q.value("vend_terms_id").toInt());
    _defaultShipVia->setText(q.value("vend_shipvia").toString());
    _defaultCurr->setId(q.value("vend_curr_id").toInt());
    _poItems->setChecked(q.value("vend_po").toBool());
    _restrictToItemSource->setChecked(q.value("vend_restrictpurch").toBool());
    _receives1099->setChecked(q.value("vend_1099").toBool());
    _match->setChecked(q.value("vend_match").toBool());
    _qualified->setChecked(q.value("vend_qualified").toBool());
    _notes->setText(q.value("vend_comments").toString());
    _poComments->setText(q.value("vend_pocomments").toString());
    
    _taxzone->setId(q.value("vend_taxzone_id").toInt());

    if (q.value("vend_fobsource").toString() == "V")
    {
      _useVendorFOB->setChecked(TRUE);
      _vendorFOB->setText(q.value("vend_fob"));
    }
    else
      _useWarehouseFOB->setChecked(TRUE);

    _achGroup->setChecked(q.value("vend_ach_enabled").toBool());
    _routingNumber->setText(q.value("routingnum").toString());
    _achAccountNumber->setText(q.value("accntnum").toString());
    _useACHSpecial->setChecked(! q.value("vend_ach_use_vendinfo").toBool());
    _individualId->setText(q.value("vend_ach_indiv_number").toString());
    _individualName->setText(q.value("vend_ach_indiv_name").toString());

    _accountType->setCode(q.value("vend_ach_accnttype").toString());

    sFillAddressList();
    sFillTaxregList();
    _comments->setId(_vendid);

    _crmacctid = q.value("crmacct_id").toInt();
    _address->setSearchAcct(_crmacctid);

    emit newId(_vendid);
  }
  else if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }
  else
  {
    systemError(this, tr("Could not find the Vendor information. Perhaps the "
                         "Vendor and CRM Account have been disconnected."),
                __FILE__, __LINE__);
    return;
  }

  emit populated();
}
Example #13
0
bool employee::sPopulate()
{
  XSqlQuery getq;
  if (_empid > 0)
  {
    getq.prepare("SELECT emp.*, crmacct_id, crmacct_owner_username,"
                 "       crmacct_salesrep_id, crmacct_usr_username, crmacct_vend_id"
                 "  FROM emp JOIN crmacct ON (emp_id=crmacct_emp_id)"
                 " WHERE (emp_id=:id);");
    getq.bindValue(":id", _empid);
  }
  else if (_crmacctid > 0)
  {
    getq.prepare("SELECT crmacct_number     AS emp_code, NULL AS emp_number,"
                 "       crmacct_name       AS emp_name,"
                 "       crmacct_active     AS emp_active,"
                 "       crmacct_cntct_id_1 AS emp_cntct_id,"
                 "       NULL AS emp_startdate,      NULL AS emp_mgr_emp_id,"
                 "       NULL AS emp_warehous_id,    NULL AS emp_wage_type,"
                 "       NULL AS emp_wage,           NULL AS emp_wage_curr_id,"
                 "       NULL AS emp_extrate,        NULL AS emp_wage_period,"
                 "       NULL AS emp_extrate_period, NULL AS emp_dept_id,"
                 "       NULL AS emp_shift_id,       NULL AS emp_notes,"
                 "       NULL AS emp_image_id,"
                 "crmacct_id, crmacct_owner_username"
                 "  FROM crmacct"
                 " WHERE (crmacct_id=:id);");
    getq.bindValue(":id", _crmacctid);
  }

  getq.exec();
  if (getq.first())
  {
    _code->setText(getq.value("emp_code").toString());
    _name->setText(getq.value("emp_name").toString());
    _number->setText(getq.value("emp_number").toString());
    _active->setChecked(getq.value("emp_active").toBool());
    _startDate->setDate(getq.value("emp_startdate").toDate());
    _contact->setId(getq.value("emp_cntct_id").toInt());
    _site->setId(getq.value("emp_warehous_id").toInt());
    _mgr->setId(getq.value("emp_mgr_emp_id").toInt());
    _wagetype->setCode(getq.value("emp_wage_type").toString());
    _rate->set(getq.value("emp_wage").toDouble(),
               getq.value("emp_wage_curr_id").toInt(),
               QDate::currentDate());
    _externalRate->set(getq.value("emp_extrate").toDouble(),
                       getq.value("emp_wage_curr_id").toInt(),
                       QDate::currentDate());
    _per->setCode(getq.value("emp_wage_period").toString());
    _perExt->setCode(getq.value("emp_extrate_period").toString());
    _dept->setId(getq.value("emp_dept_id").toInt());
    _shift->setId(getq.value("emp_shift_id").toInt());
    _notes->setText(getq.value("emp_notes").toString());
    _image->setId(getq.value("emp_image_id").toInt());

    _crmacctid  = getq.value("crmacct_id").toInt();
    _crmowner   = getq.value("crmacct_owner_username").toString();

    if (DEBUG)
      qDebug("image %s and %s",
             qPrintable(getq.value("image").toString()),
             qPrintable(_image->number()));

    sFillCharassList();
    sFillGroupsList();
    _comments->setId(_empid);
    _comments->setReadOnly(_empid==-1);
    emit populated();
  }
  else if (ErrorReporter::error(QtCriticalMsg, this,
                                tr("Error getting Employee"),
                                getq, __FILE__, __LINE__))
    return false;

  sHandleButtons();
  return true;
}
Example #14
0
void shipTo::populate()
{
  XSqlQuery popq;
  popq.prepare( "SELECT cust_number, cust_name, shipto_active, shipto_default,"
                "       shipto_cust_id,"
                "       shipto_num, shipto_name, shipto_cntct_id,"
                "       shipto_shipvia, shipto_commission,"
                "       shipto_comments, shipto_shipcomments,"
                "       shipto_taxzone_id, shipto_shipchrg_id,"
                "       COALESCE(shipto_salesrep_id,-1) AS shipto_salesrep_id,"
                "       COALESCE(shipto_shipzone_id,-1) AS shipto_shipzone_id,"
                "       COALESCE(shipto_shipform_id,-1) AS shipto_shipform_id,"
                "       shipto_preferred_warehous_id, shipto_addr_id,"
                "       crmacct_id "
                "FROM shiptoinfo "
                "  LEFT OUTER JOIN custinfo ON (shipto_cust_id=cust_id) "
                "  LEFT OUTER JOIN crmacct ON (cust_id=crmacct_cust_id) "
                "WHERE (shipto_id=:shipto_id);" );
  popq.bindValue(":shipto_id", _shiptoid);
  popq.exec();
  if (popq.first())
  {
    double commission = popq.value("shipto_commission").toDouble();
    _custid = popq.value("shipto_cust_id").toInt();
    _custNum->setText(popq.value("cust_number").toString());
    _custName->setText(popq.value("cust_name").toString());
    _active->setChecked(popq.value("shipto_active").toBool());
    _default->setChecked(popq.value("shipto_default").toBool());
    _shipToNumber->setText(popq.value("shipto_num"));
    _name->setText(popq.value("shipto_name"));
    _contact->setId(popq.value("shipto_cntct_id").toInt());
    _contact->setSearchAcct(popq.value("crmacct_id").toInt());
    _address->setSearchAcct(popq.value("crmacct_id").toInt());
    _comments->setText(popq.value("shipto_comments").toString());
    _shippingComments->setText(popq.value("shipto_shipcomments").toString());
    _taxzone->setId(popq.value("shipto_taxzone_id").toInt());
    _shipZone->setId(popq.value("shipto_shipzone_id").toInt());
    _shipform->setId(popq.value("shipto_shipform_id").toInt());
    _shipchrg->setId(popq.value("shipto_shipchrg_id").toInt());
    _sellingWarehouse->setId(popq.value("shipto_preferred_warehous_id").toInt());
    _address->setId(popq.value("shipto_addr_id").toInt());

    //  Handle the free-form Ship Via
    _shipVia->setCurrentIndex(-1);
    QString shipvia = popq.value("shipto_shipvia").toString();
    if (shipvia.trimmed().length() != 0)
    {
      for (int counter = 0; counter < _shipVia->count(); counter++)
        if (_shipVia->itemText(counter) == shipvia)
          _shipVia->setCurrentIndex(counter);

      if (_shipVia->id() == -1)
      {
        _shipVia->addItem(shipvia);
        _shipVia->setCurrentIndex(_shipVia->count() - 1);
      }
    }

    _salesRep->setId(popq.value("shipto_salesrep_id").toInt());
    _commission->setDouble(commission * 100);

    emit newId(_shiptoid);
    emit populated();
  }
  else if (popq.lastError().type() != QSqlError::NoError)
  {
    systemError(this, popq.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }
}
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;
  }

  sCalculateExtendedPrice();

  _saved = true;
  emit populated();
}
Example #16
0
void employee::sPopulate()
{
  q.prepare("SELECT *, curr_id, curr_abbr "
            "FROM api.employee LEFT OUTER JOIN"
            "     curr_symbol ON (wage_currency = curr_abbr) "
            "WHERE (code=:code);");
  q.bindValue(":code", _empcode);
  q.exec();
  if (q.first())
  {
    _code->setText(q.value("code").toString());
    _number->setText(q.value("number").toString());
    _active->setChecked(q.value("active").toBool());
	_startDate->setDate(q.value("start_date").toDate());
    _contact->setNumber(q.value("contact_number").toString());
    _contact->setHonorific(q.value("honorific").toString());
    _contact->setFirst(q.value("first").toString());
    _contact->setLast(q.value("last").toString());
    _contact->setTitle(q.value("job_title").toString());
    _contact->setPhone(q.value("voice").toString());
    _contact->setPhone2(q.value("alternate").toString());
    _contact->setFax(q.value("fax").toString());
    _contact->setEmailAddress(q.value("email").toString());
    _contact->setWebAddress(q.value("web").toString());
    _contact->addressWidget()->setLine1(q.value("address1").toString());
    _contact->addressWidget()->setLine2(q.value("address2").toString());
    _contact->addressWidget()->setLine3(q.value("address3").toString());
    _contact->addressWidget()->setCity(q.value("city").toString());
    _contact->addressWidget()->setState(q.value("state").toString());
    _contact->addressWidget()->setPostalCode(q.value("postalcode").toString());
    _contact->addressWidget()->setCountry(q.value("country").toString());
    _site->setCode(q.value("site").toString());
    _mgr->setNumber(q.value("manager_code").toString());
    _wagetype->setCode(q.value("wage_type").toString());
    _rate->set(q.value("wage").toDouble(),
               q.value("curr_id").toInt(),
               QDate::currentDate());
    _externalRate->set(q.value("rate").toDouble(),
               q.value("curr_id").toInt(),
               QDate::currentDate());
	_currabbr = q.value("curr_abbr").toString();
    _per->setCode(q.value("wage_period").toString());
    _perExt->setCode(q.value("billing_period").toString());
	_dept->setNumber(q.value("department").toString());
    _shift->setNumber(q.value("shift").toString());

    _user->setChecked(q.value("is_user").toBool());
    _salesrep->setChecked(q.value("is_salesrep").toBool());
    _vendor->setChecked(q.value("is_vendor").toBool());
	_notes->setText(q.value("notes").toString());
    _image->setNumber(q.value("image").toString());

    _user->setEnabled(_createUsers && ! _user->isChecked());
    _userButton->setEnabled(_privileges->check("MaintainUsers") &&
                            _user->isChecked());

    _salesrep->setEnabled(_privileges->check("MaintainSalesReps") &&
                          ! _salesrep->isChecked());
    _salesrepButton->setEnabled((_privileges->check("MaintainSalesReps") ||
                                 _privileges->check("ViewSalesReps")) &&
                                _salesrep->isChecked());

	_vendor->setEnabled(_privileges->check("MaintainVendors") &&
                          ! _vendor->isChecked());
    _vendorButton->setEnabled((_privileges->check("MaintainVendors") ||
                                 _privileges->check("ViewVendors")) &&
                                _vendor->isChecked());


    if (DEBUG)
      qDebug("image %s and %s",
             qPrintable(q.value("image").toString()),
             qPrintable(_image->number()));

    sFillCharassList();
    sFillGroupsList();
    _comments->setId(_empid);
    _comments->setReadOnly(_empid==-1);
    emit populated();
  }
  else if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }
}
Example #17
0
void incident::populate()
{
  XSqlQuery incidentpopulate;
  incidentpopulate.prepare("SELECT incdt_number,"
            "       incdt_crmacct_id,"
            "       COALESCE(incdt_cntct_id,-1) AS incdt_cntct_id,"
            "       (cntct_first_name || ' ' || cntct_last_name) AS cntct_name,"
            "       incdt_summary, incdt_descrip,"
            "       incdt_item_id, incdt_ls_id,"
            "       incdt_status, incdt_assigned_username,"
            "       incdt_incdtcat_id, incdt_incdtseverity_id,"
            "       incdt_incdtpriority_id, incdt_incdtresolution_id,"
            "       incdt_owner_username, incdt_recurring_incdt_id,"
            "       COALESCE(incdt_aropen_id, -1) AS docId,"
            "       COALESCE(aropen_docnumber, '') AS docNumber,"
            "       CASE WHEN (aropen_doctype='C') THEN :creditMemo"
            "            WHEN (aropen_doctype='D') THEN :debitMemo"
            "            WHEN (aropen_doctype='I') THEN :invoice"
            "            WHEN (aropen_doctype='R') THEN :cashdeposit"
            "            ELSE ''"
            "       END AS docType, "
            "       COALESCE(incdt_prj_id,-1) AS incdt_prj_id,"
            "       COALESCE(incdt_public, false) AS incdt_public,"
            "       aropen_doctype "
            "FROM incdt LEFT OUTER JOIN cntct ON (incdt_cntct_id=cntct_id)"
            "           LEFT OUTER JOIN aropen ON (incdt_aropen_id=aropen_id) "
            "WHERE (incdt_id=:incdt_id); ");
  incidentpopulate.bindValue(":incdt_id", _incdtid);
  incidentpopulate.bindValue(":creditMemo", tr("Credit Memo"));
  incidentpopulate.bindValue(":debitMemo", tr("Debit Memo"));
  incidentpopulate.bindValue(":invoice", tr("Invoice"));
  incidentpopulate.bindValue(":cashdeposit", tr("Customer Deposit"));
  incidentpopulate.exec();
  if(incidentpopulate.first())
  {
    _cntct->setId(incidentpopulate.value("incdt_cntct_id").toInt());
    _crmacct->setId(incidentpopulate.value("incdt_crmacct_id").toInt());
    _owner->setUsername(incidentpopulate.value("incdt_owner_username").toString());
    _number->setText(incidentpopulate.value("incdt_number").toString());
    _assignedTo->setUsername(incidentpopulate.value("incdt_assigned_username").toString());
    _category->setNull();
    if(!incidentpopulate.value("incdt_incdtcat_id").toString().isEmpty())
      _category->setId(incidentpopulate.value("incdt_incdtcat_id").toInt());
    _status->setCurrentIndex(_statusCodes.indexOf(incidentpopulate.value("incdt_status").toString()));
    _severity->setNull();
    if(!incidentpopulate.value("incdt_incdtseverity_id").toString().isEmpty())
      _severity->setId(incidentpopulate.value("incdt_incdtseverity_id").toInt());
    _priority->setNull();
    if(!incidentpopulate.value("incdt_incdtpriority_id").toString().isEmpty())
      _priority->setId(incidentpopulate.value("incdt_incdtpriority_id").toInt());
    _resolution->setNull();
    if(!incidentpopulate.value("incdt_incdtresolution_id").toString().isEmpty())
      _resolution->setId(incidentpopulate.value("incdt_incdtresolution_id").toInt());
    if(!incidentpopulate.value("incdt_item_id").toString().isEmpty())
      _item->setId(incidentpopulate.value("incdt_item_id").toInt());
    else
      _item->setId(-1);
    if(!incidentpopulate.value("incdt_ls_id").toString().isEmpty())
      _lotserial->setId(incidentpopulate.value("incdt_ls_id").toInt());
    else
      _lotserial->setId(-1);
    _description->setText(incidentpopulate.value("incdt_summary").toString());
    _notes->setText(incidentpopulate.value("incdt_descrip").toString());

    _comments->setId(_incdtid);
    _documents->setId(_incdtid);
    _charass->setId(_incdtid);
    _alarms->setId(_incdtid);

    _project->setId(incidentpopulate.value("incdt_prj_id").toInt());
    _public->setChecked(incidentpopulate.value("incdt_public").toBool());
        
    _docType->setText(incidentpopulate.value("docType").toString());
    _docNumber->setText(incidentpopulate.value("docNumber").toString());
    _aropenid = incidentpopulate.value("docId").toInt();
    _ardoctype = incidentpopulate.value("aropen_doctype").toString();
    if (_aropenid > 0)
      _viewAR->setEnabled(true);

    _recurring->setParent(incidentpopulate.value("incdt_recurring_incdt_id").isNull() ?
                          _incdtid : incidentpopulate.value("incdt_recurring_incdt_id").toInt(),
                          "INCDT");

    sFillHistoryList();
    sFillTodoList();

    emit populated();
  }
}
Example #18
0
bool vendor::sPopulate()
{
  if (DEBUG)
    qDebug("vendor::sPopulate() entered with _vendid %d and _crmacctid %d",
           _vendid, _crmacctid);

  MetaSQLQuery mql(
            "<? if exists('vend_id') ?>"
            "SELECT vendinfo.*, crmacct_id, crmacct_owner_username, "
            "<? if exists('key') ?>"
            "       CASE WHEN LENGTH(vend_ach_routingnumber) > 0 THEN"
            "       formatbytea(decrypt(setbytea(vend_ach_routingnumber),"
            "                           setbytea(<? value('key') ?>), 'bf'))"
            "            ELSE '' END AS routingnum,"
            "       CASE WHEN LENGTH(vend_ach_accntnumber) > 0 THEN"
            "       formatbytea(decrypt(setbytea(vend_ach_accntnumber),"
            "                           setbytea(<? value('key') ?>), 'bf'))"
            "            ELSE '' END AS accntnum "
            "<? else ?>"
            "       <? value('na') ?> AS routingnum,"
            "       <? value('na') ?> AS accntnum "
            "<? endif ?>"
            "FROM vendinfo "
            "  JOIN crmacct ON (vend_id=crmacct_vend_id) "
            "WHERE (vend_id=<? value('vend_id') ?>);"
            "<? elseif exists('crmacct_id') ?>"
            "SELECT crmacct_number AS vend_number, crmacct_name   AS vend_name,"
            "       crmacct_active AS vend_active,"
            "       crmacct_cntct_id_1 AS vend_cntct1_id,"
            "       crmacct_cntct_id_2 AS vend_cntct2_id,"
            "       fetchMetricText('DefaultPOShipVia') AS vend_shipvia,"
            "       NULL AS vend_accntnum,    NULL AS vend_vendtype_id,"
            "       NULL AS vend_name,        NULL AS vend_addr_id,"
            "       fetchMetricValue('DefaultTerms') AS vend_terms_id,"
            "       NULL  AS vend_curr_id,"
            "       FALSE AS vend_po,         FALSE AS vend_restrictpurch,"
            "       FALSE AS vend_1099,       NULL AS vend_match,"
            "       FALSE  AS vend_qualified, NULL AS vend_comments,"
            "       NULL AS vend_pocomments,  NULL AS vend_taxzone_id,"
            "       'W'  AS vend_fobsource,   NULL AS vend_fob,"
            "       NULL AS vend_ach_enabled, NULL AS routingnum,"
            "       NULL AS accntnum,         NULL AS vend_ach_use_vendinfo,"
            "       NULL AS vend_ach_indiv_number, NULL AS vend_ach_indiv_name,"
            "       NULL AS vend_ach_accnttype,"
            "       crmacct_id, crmacct_owner_username"
            "  FROM crmacct"
            " WHERE crmacct_id=<? value('crmacct_id') ?>;"
            "<? endif ?>");
  ParameterList params;
  if (_vendid > 0)
    params.append("vend_id", _vendid);
  else if (_crmacctid > 0)
    params.append("crmacct_id", _crmacctid);

  params.append("key",     omfgThis->_key);
  params.append("na",      tr("N/A"));
  XSqlQuery getq = mql.toQuery(params);
  if (getq.first())
  {
    _notice = FALSE;
    _cachedNumber = getq.value("vend_number").toString();

    _crmacctid = getq.value("crmacct_id").toInt();
    _crmowner = getq.value("crmacct_owner_username").toString();
    _number->setText(getq.value("vend_number"));
    _accountNumber->setText(getq.value("vend_accntnum"));
    _vendtype->setId(getq.value("vend_vendtype_id").toInt());
    _active->setChecked(getq.value("vend_active").toBool());
    _name->setText(getq.value("vend_name"));
    _contact1->setId(getq.value("vend_cntct1_id").toInt());
    _contact1->setSearchAcct(_crmacctid);
    _contact2->setId(getq.value("vend_cntct2_id").toInt());
    _contact2->setSearchAcct(_crmacctid);
    _address->setId(getq.value("vend_addr_id").toInt());
    _defaultTerms->setId(getq.value("vend_terms_id").toInt());
    _defaultShipVia->setText(getq.value("vend_shipvia").toString());
    _defaultCurr->setId(getq.value("vend_curr_id").toInt());
    _poItems->setChecked(getq.value("vend_po").toBool());
    _restrictToItemSource->setChecked(getq.value("vend_restrictpurch").toBool());
    _receives1099->setChecked(getq.value("vend_1099").toBool());
    _match->setChecked(getq.value("vend_match").toBool());
    _qualified->setChecked(getq.value("vend_qualified").toBool());
    _notes->setText(getq.value("vend_comments").toString());
    _poComments->setText(getq.value("vend_pocomments").toString());

    _taxzone->setId(getq.value("vend_taxzone_id").toInt());

    if (getq.value("vend_fobsource").toString() == "V")
    {
      _useVendorFOB->setChecked(TRUE);
      _vendorFOB->setText(getq.value("vend_fob"));
    }
    else
      _useWarehouseFOB->setChecked(TRUE);

    _achGroup->setChecked(getq.value("vend_ach_enabled").toBool());
    _routingNumber->setText(getq.value("routingnum").toString());
    _achAccountNumber->setText(getq.value("accntnum").toString());
    _useACHSpecial->setChecked(! getq.value("vend_ach_use_vendinfo").toBool());
    _individualId->setText(getq.value("vend_ach_indiv_number").toString());
    _individualName->setText(getq.value("vend_ach_indiv_name").toString());

    _accountType->setCode(getq.value("vend_ach_accnttype").toString());

    _account->setId(getq.value("vend_accnt_id").toInt());
    if(getq.value("vend_expcat_id").toInt() != -1)
    {
      _expcatSelected->setChecked(TRUE);
      _expcat->setId(getq.value("vend_expcat_id").toInt());
    }
    if(getq.value("vend_tax_id").toInt() != -1)
    {
      _taxSelected->setChecked(TRUE);
      _taxCode->setId(getq.value("vend_tax_id").toInt());
    }

    sFillAddressList();
    sFillTaxregList();
    sFillCharacteristic();

    _comments->setId(_crmacctid);
    _address->setSearchAcct(_crmacctid);

    emit newId(_vendid);
  }
  else if (ErrorReporter::error(QtCriticalMsg, this, tr("Getting Vendor"),
                                getq, __FILE__, __LINE__))
    return false;
  else
  {
    ErrorReporter::error(QtCriticalMsg, this, tr("Getting Vendor"),
                         tr("Could not find the Vendor information. Perhaps "
                            "the Vendor and CRM Account have been disconnected."),
                __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"))));

  emit populated();
  return true;
}