void ServiceEditor::addEvent(void)
{
  connect(nameField(), SIGNAL(returnPressed ()), this, SLOT(handleReturnPressed() ) );
  connect(typeField(), SIGNAL(currentIndexChanged(const QString&)), this, SLOT(handleNodeTypeChanged( const QString& ) ) );
  connect(typeField(), SIGNAL(activated(const QString&)), this, SLOT(handleNodeTypeActivated( const QString& ) ) );
  connect(m_dataPointSearchField, SIGNAL(returnPressed()), this, SLOT(handleDataPointFieldReturnPressed()));
  connect(m_dataPointSearchField, SIGNAL(textEdited(const QString&)), this, SLOT(handleDataPointFilter(const QString&)));
  connect(m_searchDataPointButton, SIGNAL(clicked()), this, SLOT(handleDataPointSearch()));
  connect(m_addDataPointButton, SIGNAL(clicked()), this, SLOT(handleAddDataPointEntry()));
  connect(m_hostGroupFilterBox, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(handleUpdateDataPointsList()));
  connect(m_actionButtonBox, SIGNAL(accepted()), this, SLOT(handleSaveClick()));
  connect(m_actionButtonBox, SIGNAL(rejected()), this, SLOT(handleCloseClick()));
  connect(m_addThresholdButton, SIGNAL(clicked()), this, SLOT(handleAddThreshold()));
  connect(m_removeThresholdButton, SIGNAL(clicked()), this, SLOT(handleRemoveThreshold()));
  connect(m_thresholdRulesBox, SIGNAL(currentIndexChanged(int)), this, SLOT(handleThresholdRulesChanged()));
  connect(m_calcRulesBox, SIGNAL(currentIndexChanged(int)), this, SLOT(handleCalcRuleChanged()));
}
示例#2
0
void CreateReceiptDlg::accept()
{
    if (le_ownername->text().isEmpty()) {
        QMessageBox::critical(this,
                              trUtf8("Datos incompletos"),
                              trUtf8("El campo \"Emisión a nombre de\" no puede ser vacío"));
        le_ownername->setFocus();
        return;
    }
    if(!cb_building->currentIndex()) {
        QMessageBox::critical(this,
                              trUtf8("Datos incompletos"),
                              trUtf8("Seleccione la obra de la que se va generar el recibo."));
        cb_building->setFocus();
        return;
    }

    if(!cb_employed->currentIndex()) {
        QMessageBox::critical(this,
                              trUtf8("Datos incompletos"),
                              trUtf8("Seleccione el empleado al que le va generar el recibo."));
        cb_employed->setFocus();
        return;
    }

    if(amountSpinBox->value() == 0) {
        QMessageBox::critical(this,
                              trUtf8("Datos incompletos"),
                              trUtf8("Debe ingresar el monto."));
        return;
        amountSpinBox->setFocus();
    }

    int idEmployed = employedModel->data(employedModel->index(
            cb_employed->currentIndex(), 0)).toInt();
    int idBuilding = buildingModel->data(buildingModel->index(
            cb_building->currentIndex(), 0)).toInt();

    QSqlRecord rec;
    QSqlField employedFiel("idEmployed", QVariant::Int);
    QSqlField buildingField("idBuilding", QVariant::Int);
    QSqlField ownernameField("ownername", QVariant::String);
    QSqlField dateField("date", QVariant::Date);
    QSqlField typeField("type", QVariant::String);
    QSqlField amountField("amount", QVariant::Double);
    QSqlField conceptField("concept", QVariant::String);

    employedFiel.setValue(idEmployed);
    buildingField.setValue(idBuilding);
    ownernameField.setValue(le_ownername->text());
    dateField.setValue(dateEdit->date());
    if(extraRadioButton->isChecked())
        typeField.setValue("extra");
    else
        typeField.setValue("obra");
    amountField.setValue(amountSpinBox->value());
    conceptField.setValue(conceptTextBrowser->toPlainText());

    rec.append(employedFiel);
    rec.append(buildingField);
    rec.append(ownernameField);
    rec.append(dateField);
    rec.append(typeField);
    rec.append(amountField);
    rec.append(conceptField);

    if(!model->insertRecord(-1, rec)) {
        model->revertAll();
        if(errorCommon(this, CREATERECEIPT_WINDOW, model->lastError().number()))
            return;
    }

    int currentEmployed = cb_employed->currentIndex();
    if(!currentEmployed)
        return;

    QString employed = employedModel->data(employedModel->index(currentEmployed,
                                           EmployedModel::LastName)).toString();
    employed += trUtf8(", ");
    employed += employedModel->data(employedModel->index(currentEmployed,
                                    EmployedModel::Name)).toString();
    QString receiptNum = model->query().lastInsertId().toString();
    QString buildingName = buildingModel->data(buildingModel->index(
                               cb_building->currentIndex(), BuildingManageWindow::Name)).toString();
    QString buildingLocation = buildingModel->data(buildingModel->index(
                                   cb_building->currentIndex(), BuildingManageWindow::Address)).toString();

    ReceiptDlg *receipt = new ReceiptDlg(parentWidget(), receiptNum, le_ownername->text(), dateEdit->date(), employed,
                                         amountSpinBox->value(), buildingName, buildingLocation, conceptTextBrowser->toPlainText());
    receipt->show();

    QDialog::accept();
}