Accounts events caught
This commit is contained in:
parent
8d2d985e2e
commit
c353c02d5b
|
@ -83,3 +83,8 @@ void KissCount::DeleteOperation(struct operation op)
|
||||||
{
|
{
|
||||||
_db->DeleteOperation(op);
|
_db->DeleteOperation(op);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KissCount::SetAccountAmount(int month, int year, wxString accountId, double amount)
|
||||||
|
{
|
||||||
|
_db->SetAccountAmount(month, year, accountId, amount);
|
||||||
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ class KissCount
|
||||||
void UpdateOperation(struct operation op);
|
void UpdateOperation(struct operation op);
|
||||||
void AddOperation(struct operation op);
|
void AddOperation(struct operation op);
|
||||||
void DeleteOperation(struct operation op);
|
void DeleteOperation(struct operation op);
|
||||||
|
void SetAccountAmount(int month, int year, wxString accountId, double value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxUI* _wxUI;
|
wxUI* _wxUI;
|
||||||
|
|
|
@ -318,3 +318,15 @@ void Database::DeleteOperation(struct operation op)
|
||||||
|
|
||||||
EXECUTE_SQL_UPDATE(req, );
|
EXECUTE_SQL_UPDATE(req, );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Database::SetAccountAmount(int month, int year, wxString accountId, double amount)
|
||||||
|
{
|
||||||
|
wxString req;
|
||||||
|
req = _("UPDATE account_amount SET ") ;
|
||||||
|
req += _("amount='") + wxString::Format(_("%.2lf"), amount) + _("'");
|
||||||
|
req += _(" WHERE id='") + accountId + _("'");
|
||||||
|
req += _(" AND year='") + wxString::Format(_("%d"), year) + _("'");
|
||||||
|
req += _(" AND month='") + wxString::Format(_("%d"), month) + _("'");
|
||||||
|
|
||||||
|
EXECUTE_SQL_UPDATE(req, );
|
||||||
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ class Database
|
||||||
void UpdateOperation(struct operation op);
|
void UpdateOperation(struct operation op);
|
||||||
void AddOperation(User* user, struct operation op);
|
void AddOperation(User* user, struct operation op);
|
||||||
void DeleteOperation(struct operation op);
|
void DeleteOperation(struct operation op);
|
||||||
|
void SetAccountAmount(int month, int year, wxString accountId, double amount);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxSQLite3Database _db;
|
wxSQLite3Database _db;
|
||||||
|
|
|
@ -4,6 +4,7 @@ static wxString colsName[] = {_("Description"), _("Date"), _("Debit"), _("Credit
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(AccountPanel, wxPanel)
|
BEGIN_EVENT_TABLE(AccountPanel, wxPanel)
|
||||||
EVT_GRID_CMD_CELL_CHANGE(OPS_GRID_ID, AccountPanel::OnOperationModified)
|
EVT_GRID_CMD_CELL_CHANGE(OPS_GRID_ID, AccountPanel::OnOperationModified)
|
||||||
|
EVT_GRID_CMD_CELL_CHANGE(ACCOUNTS_GRID_ID, AccountPanel::OnAccountModified)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)), _kiss(kiss), _wxUI(parent), _tree(this, CALENDAR_TREE_ID)
|
AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)), _kiss(kiss), _wxUI(parent), _tree(this, CALENDAR_TREE_ID)
|
||||||
|
@ -329,7 +330,7 @@ void AccountPanel::InsertOperation(User* user, operation* op, int line, bool fix
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_grid->SetCellEditor(line, DATE, new CalendarEditor(0, _curMonth, _curYear));
|
_grid->SetCellEditor(line, DATE, new CalendarEditor(1, _curMonth, _curYear));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -601,3 +602,13 @@ void AccountPanel::OnOperationModified(wxGridEvent& event)
|
||||||
|
|
||||||
inModification = false ;
|
inModification = false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AccountPanel::OnAccountModified(wxGridEvent& event)
|
||||||
|
{
|
||||||
|
User* user = _kiss->GetUser();
|
||||||
|
int row = event.GetRow();
|
||||||
|
double amount;
|
||||||
|
|
||||||
|
_accountsGrid->GetCellValue(row, event.GetCol()).ToDouble(&amount);
|
||||||
|
_kiss->SetAccountAmount(_curMonth, _curYear, user->GetAccountId(_accounts[row]), amount);
|
||||||
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ public:
|
||||||
void ShowMonth(int year, int month);
|
void ShowMonth(int year, int month);
|
||||||
|
|
||||||
void OnOperationModified(wxGridEvent& event);
|
void OnOperationModified(wxGridEvent& event);
|
||||||
|
void OnAccountModified(wxGridEvent& event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KissCount* _kiss;
|
KissCount* _kiss;
|
||||||
|
|
|
@ -22,14 +22,13 @@ void CalendarEditor::BeginEdit(int row, int col, wxGrid *grid)
|
||||||
|
|
||||||
wxGridCellEditor* CalendarEditor::Clone() const
|
wxGridCellEditor* CalendarEditor::Clone() const
|
||||||
{
|
{
|
||||||
std::cout << "Cloned\n" ;
|
|
||||||
return new CalendarEditor(_day, _month, _year);
|
return new CalendarEditor(_day, _month, _year);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CalendarEditor::Create(wxWindow *parent, wxWindowID id, wxEvtHandler *evtHandler)
|
void CalendarEditor::Create(wxWindow *parent, wxWindowID id, wxEvtHandler *evtHandler)
|
||||||
{
|
{
|
||||||
_parent = parent;
|
_parent = parent;
|
||||||
_calendar->Create(parent, id, wxDateTime(_day, _month, _year));
|
_calendar->Create(_parent, id, wxDateTime(_day, _month, _year));
|
||||||
_calendar->EnableHolidayDisplay(false);
|
_calendar->EnableHolidayDisplay(false);
|
||||||
_calendar->EnableMonthChange(false);
|
_calendar->EnableMonthChange(false);
|
||||||
_calendar->EnableYearChange(false);
|
_calendar->EnableYearChange(false);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user