Example #1
0
    int database::executef(char const* sql, ...)
    {
        va_list ap;
        va_start(ap, sql);
        std::unique_ptr<char, void (*)(void *)> msql(sqlite3_vmprintf(sql, ap), sqlite3_free);
        va_end(ap);

        return eexecute(msql.get());
    }
Example #2
0
  int database::executef(char const* sql, ...)
  {
    va_list ap;
    va_start(ap, sql);
    boost::shared_ptr<char> msql(sqlite3_vmprintf(sql, ap), sqlite3_free);
    va_end(ap);

    return execute(msql.get());
  }
Example #3
0
void RaLineEdit::setId(const int pId)
{
  if ((_x_preferences) && (pId != -1))
  {
    if (_x_preferences->boolean("selectedSites"))
    {
      QString msql("SELECT raitem_id "
                "FROM raitem, itemsite "
                "WHERE ((raitem_rahead_id=<? value(\"rahead_id\") ?>) "
                "  AND (raitem_itemsite_id=itemsite_id) "
                "  AND (itemsite_warehous_id NOT IN ("
                "       SELECT usrsite_warehous_id "
                "       FROM usrsite "
                "       WHERE (usrsite_username=current_user)))) "
                "UNION "
                "SELECT raitem_id "
                "FROM raitem, itemsite "
                "WHERE ((raitem_rahead_id=<? value(\"rahead_id\") ?>) "
                "  AND (raitem_coitem_itemsite_id=itemsite_id) "
                "  AND (itemsite_warehous_id NOT IN ("
                "       SELECT usrsite_warehous_id "
                "       FROM usrsite "
                "       WHERE (usrsite_username=current_user))));");
      MetaSQLQuery mql(msql);
      ParameterList params;
      params.append("rahead_id", pId);
      XSqlQuery chk = mql.toQuery(params);
      if (chk.first())
      {
              QMessageBox::critical(this, tr("Access Denied"),
                                    tr("You may not view or edit this Return Authorization as it references "
                                       "a warehouse for which you have not been granted privileges.")) ;
              VirtualClusterLineEdit::setId(-1);
      }
      else
        VirtualClusterLineEdit::setId(pId);
    }
    else
      VirtualClusterLineEdit::setId(pId);
  }
  else 
    VirtualClusterLineEdit::setId(pId);
}
Example #4
0
void PoLineEdit::setId(int pId)
{
  if ((_x_preferences) && (pId != -1))
  {
    if (_x_preferences->boolean("selectedSites"))
    {
      QString msql("SELECT poitem_id "
                  "FROM poitem, itemsite "
                  "WHERE ((poitem_pohead_id=<? value(\"pohead_id\") ?>) "
                  "  AND (poitem_itemsite_id=itemsite_id) "
                  "  AND (itemsite_warehous_id NOT IN ("
                  "       SELECT usrsite_warehous_id "
                  "       FROM usrsite "
                  "       WHERE (usrsite_username=current_user)))) "
                  "UNION "
                  "SELECT pohead_warehous_id "
                  "FROM pohead "
                  "WHERE ((pohead_id=<? value(\"pohead_id\") ?>) "
                  "  AND (pohead_warehous_id NOT IN ("
                  "       SELECT usrsite_warehous_id "
                  "       FROM usrsite "
                  "       WHERE (usrsite_username=current_user))));");
      MetaSQLQuery mql(msql);
      ParameterList params;
      params.append("pohead_id", pId);
      XSqlQuery chk = mql.toQuery(params);
      if (chk.first())
      {
              QMessageBox::critical(this, tr("Access Denied"),
                                    tr("You may not view or edit this Purchase Order as it references "
                                       "a warehouse for which you have not been granted privileges.")) ;
              setId(-1);
              return;
      }
    }
  }

  QString sql( "SELECT pohead_number, pohead_vend_id,"
               "       vend_name, vend_address1, vend_address2, vend_address3,"
               "       (vend_city || '  ' || vend_state || '  ' || vend_zip) AS citystatezip "
               "FROM pohead, vend "
               "WHERE ( (pohead_vend_id=vend_id)"
               " AND (pohead_id=:pohead_id)" );

  if (_type & (cPOUnposted | cPOOpen | cPOClosed))
  {
    bool qualifier = FALSE;

    sql += " AND (pohead_status IN (";

    if (_type & cPOUnposted)
    {
      qualifier = TRUE;
      sql += "'U'";
    }
    
    if (_type & cPOOpen)
    {
      if (qualifier)
        sql += ", ";
      else
        qualifier = TRUE;

      sql += "'O'";
    }

    if (_type & cPOClosed)
    {
      if (qualifier)
        sql += ", ";
      else
        qualifier = TRUE;

      sql += "'C'";
    }

    sql += "))";
  }

  sql += " );";
  XSqlQuery pohead;
  pohead.prepare(sql);
  pohead.bindValue(":pohead_id", pId);
  pohead.exec();
  if (pohead.first())
  {
    _id     = pId;
    _number = pohead.value("pohead_number").toInt();
    _vendid = pohead.value("pohead_vend_id").toInt();
    _valid  = TRUE;

    emit numberChanged(pohead.value("pohead_number").toString());
    emit vendNameChanged(pohead.value("vend_name").toString());
    emit vendAddress1Changed(pohead.value("vend_address1").toString());
    emit vendAddress2Changed(pohead.value("vend_address2").toString());
    emit vendAddress3Changed(pohead.value("vend_address3").toString());
    emit vendCityStateZipChanged(pohead.value("citystatezip").toString());
    setText(pohead.value("pohead_number").toString());
  }
  else
  {
    _id     = -1;
    _number = -1;
    _vendid = -1;
    _valid  = FALSE;

    emit numberChanged("");
    emit vendNameChanged("");
    emit vendAddress1Changed("");
    emit vendAddress2Changed("");
    emit vendAddress3Changed("");
    emit vendCityStateZipChanged("");
    setText("");
  }

  emit newId(_id);
  emit vendidChanged(_vendid);
  emit numberChanged(_number);
  emit valid(_valid);

  if (_mapper->model() &&
      _mapper->model()->data(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(this))).toString() != text())
    _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(this)), text());
              
  _parsed = TRUE;
}