Ejemplo n.º 1
0
enum SetResponse taxCode::set(const ParameterList &pParams)
{
  XDialog::set(pParams);
  QVariant param;
  bool     valid;

  param = pParams.value("tax_id", &valid); 
  if (valid) 
  {
    _taxid = param.toInt();
    populate();
  }

  param = pParams.value("mode", &valid);
  if (valid)
  {
    connect(_taxitems, SIGNAL(valid(bool)), _view, SLOT(setEnabled(bool)));
    if ( (param.toString() == "new") || (param.toString() == "edit") )
    {
      connect(_taxitems, SIGNAL(valid(bool)), _edit, SLOT(setEnabled(bool)));
      connect(_taxitems, SIGNAL(valid(bool)), _expire, SLOT(setEnabled(bool)));
      connect(_taxitems, SIGNAL(valid(bool)), _delete, SLOT(setEnabled(bool)));
      connect(_taxitems, SIGNAL(itemSelected(int)), _edit, SLOT(animateClick()));
    }
  
    if (param.toString() == "new") 
    {
      _mode = cNew;
      _code->setFocus();
	  initTaxCode(); 
	  populateBasis();
    }
    else if (param.toString() == "edit")
    {
      _mode = cEdit;
      _description->setFocus();

    }
    else if (param.toString() == "view")
    {
      _mode = cView;
      _code->setEnabled(FALSE);
      _description->setEnabled(FALSE);
      _account->setReadOnly(TRUE); 
      _taxClass->setEnabled(FALSE);
      _taxauth->setEnabled(FALSE);
      _basis->setEnabled(FALSE);
      _new->setEnabled(FALSE);
      _edit->setEnabled(FALSE);
      _expire->setEnabled(FALSE);
      _delete->setEnabled(FALSE);
      _buttonBox->clear();
      _buttonBox->addButton(QDialogButtonBox::Close);
      _buttonBox->setFocus();
    }
  }  
  return NoError;
}
Ejemplo n.º 2
0
enum SetResponse taxCode::set(const ParameterList &pParams)
{
  XDialog::set(pParams);
  QVariant param;
  bool     valid;

  param = pParams.value("tax_id", &valid); 
  if (valid) 
  {
    _taxid = param.toInt();
    populate();
  }

  param = pParams.value("mode", &valid);
  if (valid)
  {
    connect(_taxitems, SIGNAL(valid(bool)), _view, SLOT(setEnabled(bool)));
    if ( (param.toString() == "new") || (param.toString() == "edit") )
    {
      connect(_taxitems, SIGNAL(valid(bool)), _edit, SLOT(setEnabled(bool)));
      connect(_taxitems, SIGNAL(valid(bool)), _expire, SLOT(setEnabled(bool)));
      connect(_taxitems, SIGNAL(valid(bool)), _delete, SLOT(setEnabled(bool)));
      connect(_taxitems, SIGNAL(itemSelected(int)), _edit, SLOT(animateClick()));
    }
  
    if (param.toString() == "new") 
    {
      _mode = cNew;

      XSqlQuery newq;
      newq.prepare("INSERT INTO tax (tax_code)"
                   "  VALUES ('TEMPORARY' || CURRENT_TIMESTAMP)"
                   " RETURNING tax_id;");
      newq.exec();
      if (newq.first())
        _taxid = newq.value("tax_id").toInt();
      else if (ErrorReporter::error(QtCriticalMsg, this,
                                    tr("Error Creating Temporary Record"),
                                    newq, __FILE__, __LINE__))
        return UndefinedError;

      populateBasis();
    }
    else if (param.toString() == "edit")
    {
      _mode = cEdit;
    }
    else if (param.toString() == "view")
    {
      _mode = cView;
      _code->setEnabled(false);
      _description->setEnabled(false);
      _account->setReadOnly(true); 
      _distaccount->setReadOnly(true);
      _taxClass->setEnabled(false);
      _taxauth->setEnabled(false);
      _basis->setEnabled(false);
      _new->setEnabled(false);
      _edit->setEnabled(false);
      _expire->setEnabled(false);
      _delete->setEnabled(false);
      _buttonBox->clear();
      _buttonBox->addButton(QDialogButtonBox::Close);
    }
  }  
  return NoError;
}