Пример #1
0
void CompanyWidget::on_company_currentIndexChanged(int index)
{
    if (index < 0) {
        return;
    }
    Company *company = (Company *) ui->company->itemData(index, PPLib::entityRole).toInt();

    if (!ui->contactFrame->isHidden()) {
        contactF->setMatchValue(company->getId());
    }

    if (!ui->finFrame->isHidden()){
        Money credit = company->fields["company_credit"];
        ui->creditCustomer->setText(credit.toString());

        Money debt = company->fields["company_debt"];
        ui->debtCustomer->setText(debt.toString());
    }
    emit companyChanged(company);
}
Пример #2
0
// Set the widgets from the data object.
void
CustomerMaster::dataToWidget()
{
    _company->setChecked(_curr.company());
    _companyName = _curr.lastName();
    _lastName = _curr.lastName();
    _firstName = _curr.firstName();
    _contact = _curr.contact();
    if (_curr.company()) {
        _entry1->setText(_companyName);
        _entry2->setText(_contact);
    } else {
        _entry1->setText(_lastName);
        _entry2->setText(_firstName);
    }
    _number->setText(_curr.number());
    _type->setId(_curr.typeId());
    _street->setText(_curr.street());
    _street2->setText(_curr.street2());
    _city->setText(_curr.city());
    _province->setText(_curr.province());
    _country->setText(_curr.country());
    _postal->setText(_curr.postal());
    _phone_num->setText(_curr.phoneNumber());
    _phone2_num->setText(_curr.phone2Number());
    _fax_num->setText(_curr.faxNumber());
    _email->setText(_curr.email());
    _web_page->setText(_curr.webPage());
    _patgroup_id->setId(_curr.patGroupId());
    _account_id->setId(_curr.accountId());
    _term_id->setId(_curr.termsId());
    _exempt_id->setId(_curr.taxExemptId());
    _credit_limit->setFixed(_curr.creditLimit());
    _credit_hold->setChecked(_curr.creditHold());
    _sc_rate->setFixed(_curr.serviceCharge());
    _print_stmts->setChecked(_curr.printStatements());
    _charge->setChecked(_curr.canCharge());
    _withdraw->setChecked(_curr.canWithdraw());
    _payment->setChecked(_curr.canPayment());
    _check_bal->setChecked(_curr.checkWithdrawBalance());
    _second_rcpt->setChecked(_curr.secondReceipt());
    _inactive->setChecked(!_curr.isActive());

    // Set groups
    _groups->clear();
    unsigned int i;
    for (i = 0; i < _curr.groups().size(); ++i) {
        VectorRow* row = new VectorRow(_groups->columns());
        row->setValue(0, _curr.groups()[i]);
        _groups->appendRow(row);
    }
    _groups->appendRow(new VectorRow(_groups->columns()));

    // Set discounts
    _discs->clear();
    for (i = 0; i < _curr.discounts().size(); ++i) {
        VectorRow* row = new VectorRow(_discs->columns());
        row->setValue(0, _curr.discounts()[i]);
        _discs->appendRow(row);
    }
    _discs->appendRow(new VectorRow(_discs->columns()));

    // Set references
    _refs->clear();
    for (i = 0; i < _curr.references().size(); ++i) {
        VectorRow* row = new VectorRow(_refs->columns());
        row->setValue(0, _curr.references()[i]);
        _refs->appendRow(row);
    }
    _refs->appendRow(new VectorRow(_refs->columns()));

    // Extra info
    _extra->clear();
    ExtraSelect extraSelect;
    extraSelect.activeOnly = true;
    extraSelect.table = "Customer";
    vector<Extra> extras;
    _quasar->db()->select(extras, extraSelect);
    for (i = 0; i < extras.size(); ++i) {
        Id extra_id = extras[i].id();
        QString value = _curr.value(extra_id);

        VectorRow* row = new VectorRow(_extra->columns());
        row->setValue(0, extra_id);
        row->setValue(1, value);
        _extra->appendRow(row);
    }
    if (_extra->rows() > 0)
        _extra->setCurrentCell(0, 1);

    companyChanged(_company->isChecked());
}