QSqlRecord artikl
= modelArtikl
->record
(proxyArtikl
->mapToSource
(proxyArtikl
->index
(sifraCombo
->currentIndex
(),
0)).
row());
artiklRacun.setValue(0, artikl.value(0));
artiklRacun.setValue(1, artikl.value(1));
artiklRacun.setValue(2, artikl.value(2));
artiklRacun.setValue(3, artikl.value(3));
artiklRacun.setValue(4, artikl.value(4));
artiklRacun.setValue(5, artikl.value(5));
pomocna = kolicinaLineEdit->text().toDouble();
artiklRacun.
setValue(6,
QString::number(pomocna.
toDouble(),
'f',
3).
replace('.',
','));
pomocna = artikl.value(4).toDouble() * kolicinaLineEdit->text().toDouble();
QString ukupno
= pomocna.
toString();
artiklRacun.
setValue(7,
QString::number(ukupno.
toDouble(),
'f',
2).
replace('.',
','));
modelRacun->insertRecord(-1, artiklRacun);
modelRacun->submit();
QSqlRecord artikl = modelArtikl->record(proxyArtikl->mapToSource(proxyArtikl->index(sifraCombo->currentIndex(), 0)).row());
QSqlRecord artiklRacun = modelRacun->record();
QVariant pomocna;
artiklRacun.setValue(0, artikl.value(0));
artiklRacun.setValue(1, artikl.value(1));
artiklRacun.setValue(2, artikl.value(2));
artiklRacun.setValue(3, artikl.value(3));
artiklRacun.setValue(4, artikl.value(4));
artiklRacun.setValue(5, artikl.value(5));
pomocna = kolicinaLineEdit->text().toDouble();
artiklRacun.setValue(6, QString::number(pomocna.toDouble(), 'f', 3).replace('.',','));
pomocna = artikl.value(4).toDouble() * kolicinaLineEdit->text().toDouble();
QString ukupno = pomocna.toString();
artiklRacun.setValue(7, QString::number(ukupno.toDouble(), 'f', 2).replace('.',','));
modelRacun->insertRecord(-1, artiklRacun);
modelRacun->submit();
To copy to clipboard, switch view to plain text mode
if(watched == racunTableView)
{
if(e
->type
() == QEvent::KeyPress) {
QKeyEvent *tipka
= static_cast<QKeyEvent
*>
(e
);
if(tipka->key() == Qt::Key_Delete)
if(racunTableView->currentIndex().isValid())
{
upit.setWindowTitle(tr("Upit"));
upit.setText(tr("Do you want to do this?"));
upit.exec();
if(upit.clickedButton() == daButton)
{
modelRacun->removeRow(racunTableView->currentIndex().row());
}
}
}
}
if(watched == racunTableView)
{
if(e->type() == QEvent::KeyPress)
{
QKeyEvent *tipka = static_cast<QKeyEvent*>(e);
if(tipka->key() == Qt::Key_Delete)
if(racunTableView->currentIndex().isValid())
{
QMessageBox upit;
upit.setIcon(QMessageBox::Question);
upit.setWindowTitle(tr("Upit"));
upit.setText(tr("Do you want to do this?"));
QPushButton *daButton = upit.addButton(tr("Yes"), QMessageBox::YesRole);
upit.addButton(tr("No"), QMessageBox::NoRole);
upit.setDefaultButton(QMessageBox::Yes);
upit.exec();
if(upit.clickedButton() == daButton)
{
modelRacun->removeRow(racunTableView->currentIndex().row());
}
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks