Exemple #1
0
void SoLineEdit::setCustId(int pId)
{
  if (pId == _custid)
    return;
    
  _custid=pId;
  setNumber(_number);
  
  emit custidChanged(_custid);
}
Exemple #2
0
void SoLineEdit::setId(int pId)
{
  if (pId == _id)
    return;

  XSqlQuery sohead;
  sohead.prepare( "SELECT cohead_number, cohead_cust_id, cohead_billtoname "
                  "FROM cohead, cust "
                  "WHERE ( (cohead_cust_id=cust_id)"
                  " AND (cohead_id=:sohead_id) );" );
  sohead.bindValue(":sohead_id", pId);
  sohead.exec();
  if (sohead.first())
  {
    _id     = pId;
    _number = sohead.value("cohead_number").toInt();
    _custid = sohead.value("cohead_cust_id").toInt();
    _valid  = TRUE;

    emit numberChanged(sohead.value("cohead_number").toString());
    emit custNameChanged(sohead.value("cohead_billtoname").toString());

    setText(sohead.value("cohead_number").toString());
  }
  else
  {
    _id     = -1;
    _number = -1;
    _custid = -1;
    _valid  = FALSE;

    emit numberChanged("");
    emit custNameChanged("");
    setText("");
  }

  emit newId(_id);
  emit custidChanged(_custid);
  emit numberChanged(_number);
  emit valid(_valid);

  _parsed = TRUE;
}
Exemple #3
0
void SoLineEdit::setId(int pId)
{
  if (pId == _id)
    return;

  if ((_x_preferences) && (pId != -1) && (_sitePrivs))
  {
    if (_x_preferences->boolean("selectedSites"))
    {
      QString sql("SELECT coitem_id "
                  "FROM coitem, itemsite "
                  "WHERE ((coitem_cohead_id=<? value(\"sohead_id\") ?>) "
                  "  AND (coitem_itemsite_id=itemsite_id) "
                  "  AND (itemsite_warehous_id NOT IN ("
                  "       SELECT usrsite_warehous_id "
                  "       FROM usrsite "
                  "       WHERE (usrsite_username=current_user)))) "
                  "UNION "
                  "SELECT cohead_warehous_id "
                  "FROM cohead "
                  "WHERE ((cohead_id=<? value(\"sohead_id\") ?>) "
                  "  AND (cohead_warehous_id NOT IN ("
                  "       SELECT usrsite_warehous_id "
                  "       FROM usrsite "
                  "       WHERE (usrsite_username=current_user))));");
      MetaSQLQuery mql(sql);
      ParameterList params;
      params.append("sohead_id", pId);
      XSqlQuery chk = mql.toQuery(params);
      if (chk.first())
      {
              QMessageBox::critical(this, tr("Access Denied"),
                                    tr("You may not view or edit this Sales Order as it references "
                                       "a warehouse for which you have not been granted privileges.")) ;
              setId(-1);
              return;
      }
    }
  }


  XSqlQuery sohead;
  sohead.prepare( "SELECT cohead_number, cohead_cust_id, cohead_billtoname "
                  "FROM cohead, cust "
                  "WHERE ( (cohead_cust_id=cust_id)"
                  " AND (cohead_id=:sohead_id) );" );
  sohead.bindValue(":sohead_id", pId);
  sohead.exec();
  if (sohead.first())
  {
    _id     = pId;
    _number = sohead.value("cohead_number").toInt();
    _custid = sohead.value("cohead_cust_id").toInt();
    _valid  = TRUE;

    emit numberChanged(sohead.value("cohead_number").toString());
    emit custNameChanged(sohead.value("cohead_billtoname").toString());

    setText(sohead.value("cohead_number").toString());
    
    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());
  }
  else
  {
    _id     = -1;
    _number = -1;
    _custid = -1;
    _valid  = FALSE;

    emit numberChanged("");
    emit custNameChanged("");
    setText("");
  }

  emit newId(_id);
  emit custidChanged(_custid);
  emit numberChanged(_number);
  emit valid(_valid);

  _parsed = TRUE;
}