Beispiel #1
0
bool MainWindow::deleteCustomer(Customer customer) {

    QString messageResult = _dbManager->deleteCustomer(customer);
    if( messageResult != NULL)
    {

        QMessageBox::critical(this, tr("Delete attempt failed"), "Could not delete \"" + customer.getCompanyName() + "\" from the database: \n" + messageResult);
        ui->statusBar->showMessage("Database remove unsuccessful: " + customer.getCompanyName());
        return false;

    } else {

        ui->statusBar->showMessage("Successfully deleted \"" + customer.getCompanyName() + "\" from the databse");
        ui->tableTabWidget->removeTab(ui->tableTabWidget->currentIndex());
    }

    return true;
}
Beispiel #2
0
// PUBLIC FUNCTIONS
bool MainWindow::addCustomerToList(Customer customer) {

    QString messageResult = _dbManager->addCustomer(customer);
    if( messageResult != NULL)
    {

        QMessageBox::critical(this, tr("Save attempt failed"), "Could not save \"" + customer.getCompanyName() + "\" into the database: \n" + messageResult);
        ui->statusBar->showMessage("Add to database unsuccessful: " + customer.getCompanyName());
        return false;
    } else {

        ui->statusBar->showMessage("Successfully added \"" + customer.getCompanyName() + "\" to the databse");

        // Close the current tab
        ui->tableTabWidget->removeTab(ui->tableTabWidget->currentIndex());

        // Open the company invoice tab
        QWidget *customerInvoiceTab = new AllCompanyInvoices(0, this, &customer);
        ui->tableTabWidget->setCurrentIndex(ui->tableTabWidget->addTab(customerInvoiceTab, customer.getCompanyName() + " Invoices"));
    }

    return true;

}
Beispiel #3
0
void MainWindow::on_listView_doubleClicked(const QModelIndex &index)
{
    // Open the company invoice tab
    QAbstractItemModel *model = ui->listView->model();
    QString cNameFromList = model->data(index, Qt::DisplayRole).toString();
    Customer *customer = _dbManager->getCustomerByName(cNameFromList);

    QWidget *customerInvoiceTab = new AllCompanyInvoices(0, this, customer);
    ui->tableTabWidget->setCurrentIndex(ui->tableTabWidget->addTab(customerInvoiceTab, customer->getCompanyName() + " Invoices"));
}