Fixed camp settings saving. Added about messagebox. Methods IGridForm::handleNewRecord and IGridForm::handleEditRecord are virtual now.
This commit is contained in:
+4
-6
@@ -1,21 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<author/>
|
||||
<comment/>
|
||||
<exportmacro/>
|
||||
<class>CampForm</class>
|
||||
<widget class="QWidget" name="CampForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
<width>462</width>
|
||||
<height>403</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
</widget>
|
||||
<pixmapfunction/>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <settingsservice.h>
|
||||
#include <QScroller>
|
||||
#include <QMessageBox>
|
||||
|
||||
CampSettingsForm::CampSettingsForm(QWidget *parent) :
|
||||
FormBinder<CampSettings>(parent),
|
||||
@@ -58,13 +59,47 @@ bool CampSettingsForm::saveRecord()
|
||||
|
||||
Service<PersonPrice> personSrv;
|
||||
Service<Sale> saleSrv;
|
||||
bool ret = true;
|
||||
|
||||
connect(&personSrv, &IService::dbErrorDelete, [&ret, this](QString){
|
||||
QMessageBox::critical(this, tr("Cannot delete"), tr("Price already used"));
|
||||
ret = false;
|
||||
});
|
||||
|
||||
foreach (PersonPricePtr p, personSrv.all()) {
|
||||
personSrv.erase(p);
|
||||
bool found = false;
|
||||
foreach (PersonPricePtr price, m_personPriceModel->list()) {
|
||||
if (price->id() == p->id())
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
personSrv.erase(p);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (PersonPricePtr p, m_personPriceModel->list()) {
|
||||
personSrv.save(p);
|
||||
bool found = false;
|
||||
foreach (PersonPricePtr price, personSrv.all()) {
|
||||
if (price->id() == p->id())
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
personSrv.save(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
personSrv.update(p);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (SalePtr s, saleSrv.all()) {
|
||||
@@ -75,7 +110,7 @@ bool CampSettingsForm::saveRecord()
|
||||
saleSrv.save(s);
|
||||
}
|
||||
|
||||
return true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void CampSettingsForm::loadEntity()
|
||||
|
||||
Reference in New Issue
Block a user