Early support of operation fusion and formula

This commit is contained in:
2010-08-06 21:20:19 +02:00
parent 8ad5e7d0ad
commit 8568c42339
3 changed files with 14 additions and 4 deletions

View File

@@ -306,6 +306,7 @@ void Database::LoadYear(User* user, int year)
{
Operation op;
op.id = set.GetAsString(wxT("id"));
op.parent = set.GetAsString(wxT("parent"));
op.account = set.GetAsString(wxT("account"));
op.day = set.GetInt(wxT("day"));
op.month = set.GetInt(wxT("month"));
@@ -315,6 +316,7 @@ void Database::LoadYear(User* user, int year)
op.category = set.GetAsString(wxT("category"));
op.fix_cost = set.GetBool(wxT("fix_cost"));
op.checked = set.GetBool(wxT("checked"));
op.formula = set.GetAsString(wxT("formula"));
(*user->_operations[op.year])[op.month].push_back(op);
}
@@ -351,7 +353,8 @@ void Database::UpdateOperation(Operation& op)
{
wxString req;
req = wxT("UPDATE operation SET ") ;
req += wxT("account='") + op.account + wxT("'");
req += wxT("parent='") + op.parent + wxT("'");
req += wxT(", account='") + op.account + wxT("'");
req += wxT(", year='") + wxString::Format(wxT("%d"), op.year) + wxT("'");
req += wxT(", month='") + wxString::Format(wxT("%d"), op.month) + wxT("'");
req += wxT(", day='") + wxString::Format(wxT("%d"), op.day) + wxT("'");
@@ -362,6 +365,7 @@ void Database::UpdateOperation(Operation& op)
req += wxT(", checked='1'");
else
req += wxT(", checked='0'");
req += wxT(", forumla='") + op.formula + wxT("'");
req += wxT(" WHERE id='") + op.id + wxT("'");
EXECUTE_SQL_UPDATE(req, );
@@ -372,8 +376,9 @@ wxString Database::AddOperation(User* user, Operation& op)
wxString req, res;
wxSQLite3ResultSet set;
req = wxT("INSERT INTO operation ('user', 'account', 'year', 'month', 'day', 'amount', 'description', 'category', 'fix_cost') VALUES ('") ;
req = wxT("INSERT INTO operation ('user', 'parent', 'account', 'year', 'month', 'day', 'amount', 'description', 'category', 'fix_cost', 'formula') VALUES ('") ;
req += user->_id + wxT("'");
req += wxT(", '") + op.parent + wxT("'");
req += wxT(", '") + op.account + wxT("'");
req += wxT(", '") + wxString::Format(wxT("%d"), op.year) + wxT("'");
req += wxT(", '") + wxString::Format(wxT("%d"), op.month) + wxT("'");
@@ -385,12 +390,14 @@ wxString Database::AddOperation(User* user, Operation& op)
req += wxT(", '1'") ;
else
req += wxT(", '0'") ;
req += wxT(", '") + op.formula + wxT("'");
req += wxT(")");
EXECUTE_SQL_UPDATE(req, wxT("0"));
req = wxT("SELECT id FROM operation WHERE ");
req += wxT("user='") + user->_id + wxT("'");
req += wxT(" AND parent='") + op.parent + wxT("'");
req += wxT(" AND account='") + op.account + wxT("'");
req += wxT(" AND year='") + wxString::Format(wxT("%d"), op.year) + wxT("'");
req += wxT(" AND month='") + wxString::Format(wxT("%d"), op.month) + wxT("'");
@@ -402,7 +409,8 @@ wxString Database::AddOperation(User* user, Operation& op)
req += wxT(" AND fix_cost='1'") ;
else
req += wxT(" AND fix_cost='0'") ;
req += wxT("ORDER BY ID DESC") ;
req += wxT(" AND formula='") + op.formula + wxT("'");
req += wxT("ORDER BY id DESC") ;
EXECUTE_SQL_QUERY(req , set, wxT("0"));

View File

@@ -23,6 +23,7 @@ along with KissCount. If not, see <http://www.gnu.org/licenses/>.
class Operation {
public:
wxString id;
wxString parent;
unsigned int day;
unsigned int month;
unsigned int year;
@@ -32,6 +33,7 @@ class Operation {
bool fix_cost;
wxString account;
bool checked;
wxString formula;
} ;
#endif