示例#1
0
enum SetResponse state::set(const ParameterList &pParams)
{
  qDebug("state::set() entered");
  XDialog::set(pParams);
  QVariant param;
  bool     valid;

  qDebug("state::set() about to check for country");
  param = pParams.value("country_id", &valid);
  if (valid)
  {
    qDebug("setting country");
    _country->setId(param.toInt());
  }

  qDebug("state::set() about to check for state");
  param = pParams.value("state_id", &valid);
  if (valid)
  {
    qDebug("setting state");
    _stateid = param.toInt();
    populate();
  }

  qDebug("state::set() about to check for mode");
  param = pParams.value("mode", &valid);
  if (valid)
  {
    qDebug("setting mode");
    if (param.toString() == "new")
    {
      _mode = cNew;
      if (_country->isValid())
        _abbr->setFocus();
      else
        _country->setFocus();
      enableWindowModifiedSetting();
    }
    else if (param.toString() == "edit")
    {
      _mode = cEdit;
      _abbr->setFocus();
      enableWindowModifiedSetting();
    }
    else if (param.toString() == "view")
    {
      _mode = cView;

      _country->setEnabled(FALSE);
      _abbr->setEnabled(FALSE);
      _name->setEnabled(FALSE);

      _buttonBox->clear();
      _buttonBox->addButton(QDialogButtonBox::Close);
      _buttonBox->setFocus();
    }
  }

  return NoError;
}
示例#2
0
文件: state.cpp 项目: AlFoX/qt-client
enum SetResponse state::set(const ParameterList &pParams)
{
  XDialog::set(pParams);
  QVariant param;
  bool     valid;

  param = pParams.value("country_id", &valid);
  if (valid)
  {
    _country->setId(param.toInt());
    if (_country->isValid())
      _country->setEnabled(false);
  }

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

  param = pParams.value("mode", &valid);
  if (valid)
  {
    if (param.toString() == "new")
    {
      _mode = cNew;
      enableWindowModifiedSetting();
    }
    else if (param.toString() == "edit")
    {
      _mode = cEdit;
      enableWindowModifiedSetting();
    }
    else if (param.toString() == "view")
    {
      _mode = cView;

      _country->setEnabled(FALSE);
      _abbr->setEnabled(FALSE);
      _name->setEnabled(FALSE);

      _buttonBox->clear();
      _buttonBox->addButton(QDialogButtonBox::Close);
    }
  }

  return NoError;
}
示例#3
0
enum SetResponse voucher::set(const ParameterList &pParams)
{
  XWidget::set(pParams);
  QVariant param;
  bool     valid;

  param = pParams.value("mode", &valid);
  if (valid)
  {
    if (param.toString() == "new")
    {
      _mode = cNew;

      q.exec("SELECT NEXTVAL('vohead_vohead_id_seq') AS vohead_id");
      if (q.first())
        _voheadid = q.value("vohead_id").toInt();
      else
      {
        systemError(this, tr("A System Error occurred at %1::%2.")
                          .arg(__FILE__)
                          .arg(__LINE__) );
        return UndefinedError;
      }

      if (_metrics->value("VoucherNumberGeneration") == "A")
      {
        populateNumber();
        _poNumber->setFocus();
      }
      else
        _voucherNumber->setFocus();

      q.prepare("INSERT INTO vohead (vohead_id,   vohead_number, vohead_posted)"
		"            VALUES (:vohead_id, :vohead_number, false);" );
      q.bindValue(":vohead_id",     _voheadid);
      q.bindValue(":vohead_number", _voucherNumber->text());
      q.exec();
      if (q.lastError().type() != QSqlError::NoError)
      {
	systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
	return UndefinedError;
      }
      enableWindowModifiedSetting();
    }
    else if (param.toString() == "edit")
    {
      _mode = cEdit;

      _voucherNumber->setEnabled(FALSE);
      _poNumber->setEnabled(FALSE);
      _poNumber->setListVisible(false);

      _save->setFocus();
    }
    else if (param.toString() == "view")
    {
      _mode = cView;

      _poNumber->setAllowedStatuses(OrderLineEdit::AnyStatus);
 
      _voucherNumber->setEnabled(FALSE);
      _poNumber->setEnabled(FALSE);
      _poNumber->setListVisible(false);
      _taxzone->setEnabled(FALSE);
      _amountToDistribute->setEnabled(FALSE);
      _distributionDate->setEnabled(FALSE);
      _invoiceDate->setEnabled(FALSE);
      _dueDate->setEnabled(FALSE);
      _invoiceNum->setEnabled(FALSE);
      _reference->setEnabled(FALSE);
      _poitem->setEnabled(FALSE);
      _distributions->setEnabled(FALSE);
      _miscDistrib->setEnabled(FALSE);
      _new->setEnabled(FALSE);
      _terms->setEnabled(FALSE);
      _terms->setType(XComboBox::Terms);
      _flagFor1099->setEnabled(FALSE);
      _distributeall->setEnabled(FALSE);
      _notes->setEnabled(false);
      _close->setText(tr("&Close"));
      _save->hide();

      _close->setFocus();
      disconnect(_poNumber, SIGNAL(valid(bool)), _distributeall, SLOT(setEnabled(bool)));
    }
  }

  param = pParams.value("pohead_id", &valid);
  if (valid)
    _poNumber->setId(param.toInt(), "PO");

  param = pParams.value("vohead_id", &valid);
  if (valid)
  {
    _voheadid = param.toInt();
    populate();
    enableWindowModifiedSetting();
  }

  return NoError;
}