Proper month change into AccountPanel
This commit is contained in:
parent
6a8ce2164a
commit
e176e2f235
15
init.sql
15
init.sql
|
@ -17,11 +17,16 @@ INSERT INTO default_preference ("type", "name", "value") VALUES ("category_color
|
|||
-- No password
|
||||
INSERT INTO user ("id", "name", "password") VALUES ("0", "Greg", "da39a3ee5e6b4b0d3255bfef95601890afd80709");
|
||||
INSERT INTO account ("id", "user", "name", "number", "shared", "default_account") VALUES ("0", "0", "Compte Courant", "000" , "0", "1");
|
||||
INSERT INTO account_amount("id", "account", "year", "month", "amount") VALUES("0", "0", "2010", "5", "1000");
|
||||
INSERT INTO operation ("id", "user", "account", "year", "month", "day", "amount", "description", "category", "fix_cost", "checked") VALUES ("0", "0", "0", "2010", "5", "0", "1234", "Opé 1", "1", "1", "0");
|
||||
INSERT INTO operation ("id", "user", "account", "year", "month", "day", "amount", "description", "category", "fix_cost", "checked") VALUES ("1", "0", "0", "2010", "5", "1", "-56", "Opé 2", "2", "0", "0");
|
||||
INSERT INTO operation ("id", "user", "account", "year", "month", "day", "amount", "description", "category", "fix_cost", "checked") VALUES ("2", "0", "0", "2010", "5", "8", "12", "Opé 3", "3", "0", "1");
|
||||
INSERT INTO operation ("id", "user", "account", "year", "month", "day", "amount", "description", "category", "fix_cost", "checked") VALUES ("3", "0", "0", "2010", "5", "29", "-2056", "Opé 4", "4", "0", "0");
|
||||
-- May 2010
|
||||
INSERT INTO account_amount("id", "account", "year", "month", "amount") VALUES("1", "0", "2010", "4", "500");
|
||||
INSERT INTO operation ("id", "user", "account", "year", "month", "day", "amount", "description", "category", "fix_cost", "checked") VALUES ("1", "0", "0", "2010", "4", "0", "1234", "Opé May 1", "1", "1", "0");
|
||||
INSERT INTO operation ("id", "user", "account", "year", "month", "day", "amount", "description", "category", "fix_cost", "checked") VALUES ("2", "0", "0", "2010", "4", "1", "-56", "Opé May 2", "2", "0", "0");
|
||||
-- June 2010
|
||||
INSERT INTO account_amount("id", "account", "year", "month", "amount") VALUES("2", "0", "2010", "5", "1000");
|
||||
INSERT INTO operation ("id", "user", "account", "year", "month", "day", "amount", "description", "category", "fix_cost", "checked") VALUES ("3", "0", "0", "2010", "5", "0", "1234", "Opé 1", "1", "1", "0");
|
||||
INSERT INTO operation ("id", "user", "account", "year", "month", "day", "amount", "description", "category", "fix_cost", "checked") VALUES ("4", "0", "0", "2010", "5", "1", "-56", "Opé 2", "2", "0", "0");
|
||||
INSERT INTO operation ("id", "user", "account", "year", "month", "day", "amount", "description", "category", "fix_cost", "checked") VALUES ("5", "0", "0", "2010", "5", "8", "12", "Opé 3", "3", "0", "1");
|
||||
INSERT INTO operation ("id", "user", "account", "year", "month", "day", "amount", "description", "category", "fix_cost", "checked") VALUES ("6", "0", "0", "2010", "5", "29", "-2056", "Opé 4", "4", "0", "0");
|
||||
INSERT INTO preference ("user", "type", "name", "value") VALUES ("0", "category", "name", "Fixe");
|
||||
INSERT INTO preference ("user", "type", "name", "value") VALUES ("0", "category", "name", "Courses");
|
||||
INSERT INTO preference ("user", "type", "name", "value") VALUES ("0", "category", "name", "Loisirs");
|
||||
|
|
|
@ -10,6 +10,9 @@ static wxString colsName[] = {_("Description"), _("Date"), _("Debit"), _("Credit
|
|||
BEGIN_EVENT_TABLE(AccountPanel, wxPanel)
|
||||
EVT_GRID_CMD_CELL_CHANGE(OPS_GRID_ID, AccountPanel::OnOperationModified)
|
||||
EVT_GRID_CMD_CELL_CHANGE(ACCOUNTS_GRID_ID, AccountPanel::OnAccountModified)
|
||||
EVT_TREE_ITEM_RIGHT_CLICK(CALENDAR_TREE_ID, AccountPanel::OnTreeRightClick)
|
||||
EVT_TREE_SEL_CHANGED(CALENDAR_TREE_ID, AccountPanel::OnTreeChange)
|
||||
EVT_TREE_KEY_DOWN(CALENDAR_TREE_ID, AccountPanel::OnTreeChange)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)), _kiss(kiss), _wxUI(parent), _tree(this, CALENDAR_TREE_ID)
|
||||
|
@ -35,6 +38,7 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)),
|
|||
wxColour(0xFF, 0x93, 0x0E),
|
||||
wxColour(0xC5, 0x00, 0x0D),
|
||||
wxColour(0x00, 0x84, 0xD1)};
|
||||
wxBitmap bitmap(_(DELETE_ICON));
|
||||
SetSizer(hbox);
|
||||
|
||||
ColorScheme* colorScheme = new ColorScheme(categoryColors, WXSIZEOF(categoryColors));
|
||||
|
@ -75,6 +79,23 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)),
|
|||
_grid->SetColLabelSize(0);
|
||||
_grid->SetRowLabelSize(0);
|
||||
|
||||
_grid->CreateGrid(1, NUMBER_COLS_OPS);
|
||||
_grid->SetColSize (0, _grid->GetColSize(0)*3);
|
||||
_grid->SetDefaultCellFont(font);
|
||||
|
||||
font.SetWeight(wxFONTWEIGHT_BOLD);
|
||||
for(i=0; i<NUMBER_COLS_OPS; i++)
|
||||
{
|
||||
_grid->SetCellValue(0, i, colsName[i]);
|
||||
_grid->SetCellBackgroundColour(0, i, OWN_CYAN);
|
||||
_grid->SetCellFont(0, i, font);
|
||||
_grid->SetReadOnly(0, i, true);
|
||||
_grid->SetCellAlignment(0, i, wxALIGN_CENTRE, wxALIGN_CENTRE);
|
||||
}
|
||||
_grid->SetCellRenderer(0, DELETE, new wxGridCellBitmapRenderer(bitmap));
|
||||
|
||||
font.SetWeight(wxFONTWEIGHT_NORMAL);
|
||||
|
||||
_accountsGrid = new wxGrid(this, ACCOUNTS_GRID_ID);
|
||||
_accountsGrid->CreateGrid(0, NUMBER_COLS_ACCOUNTS);
|
||||
_accountsGrid->SetRowLabelSize(0);
|
||||
|
@ -88,10 +109,6 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)),
|
|||
_accountsGrid->SetColLabelValue(ACCOUNT_FINAL, _("Final value"));
|
||||
|
||||
_statsGrid = new wxGrid(this, -1);
|
||||
_statsGrid->CreateGrid(user->GetCategoriesNumber()+6, 2);
|
||||
_statsGrid->SetColLabelSize(0);
|
||||
_statsGrid->SetRowLabelSize(0);
|
||||
_statsGrid->EnableEditing(false);
|
||||
|
||||
InitStatsGrid(user);
|
||||
|
||||
|
@ -131,6 +148,16 @@ void AccountPanel::InitStatsGrid(User* user)
|
|||
|
||||
DEFAULT_FONT(font);
|
||||
|
||||
if (!_statsGrid->GetNumberRows())
|
||||
{
|
||||
_statsGrid->CreateGrid(user->GetCategoriesNumber()+6, 2);
|
||||
_statsGrid->SetColLabelSize(0);
|
||||
_statsGrid->SetRowLabelSize(0);
|
||||
_statsGrid->EnableEditing(false);
|
||||
}
|
||||
else
|
||||
_statsGrid->DeleteRows(0, _statsGrid->GetNumberRows());
|
||||
|
||||
_statsGrid->SetDefaultCellFont(font);
|
||||
|
||||
_statsGrid->SetCellValue(TOTAL_CREDIT, 0, _("Total Credit"));
|
||||
|
@ -236,32 +263,16 @@ void AccountPanel::ShowMonth(int year, int month)
|
|||
DEFAULT_FONT(font);
|
||||
std::vector<category>::iterator categoryIt;
|
||||
//wxGridCellChoiceEditor* categoryEditor, *accountEditor;
|
||||
int i;
|
||||
wxBitmap bitmap(_(DELETE_ICON));
|
||||
|
||||
_curMonth = month;
|
||||
_wxUI->SetTitle(user->_name + _(" - ") + months[month] + _(" ") + wxString::Format(wxT("%d"), year));
|
||||
|
||||
if (_grid->GetNumberRows() > 1)
|
||||
_grid->DeleteRows(1, _grid->GetNumberRows()-1);
|
||||
|
||||
// Operations are ordered
|
||||
_curOperations = &((*user->_operations[year])[month]);
|
||||
|
||||
//_grid->Clear();
|
||||
_grid->CreateGrid(1, NUMBER_COLS_OPS);
|
||||
// Creating headers
|
||||
_grid->SetColSize (0, _grid->GetColSize(0)*3);
|
||||
_grid->SetDefaultCellFont(font);
|
||||
|
||||
font.SetWeight(wxFONTWEIGHT_BOLD);
|
||||
for(i=0; i<NUMBER_COLS_OPS; i++)
|
||||
{
|
||||
_grid->SetCellValue(0, i, colsName[i]);
|
||||
_grid->SetCellBackgroundColour(0, i, OWN_CYAN);
|
||||
_grid->SetCellFont(0, i, font);
|
||||
_grid->SetReadOnly(0, i, true);
|
||||
_grid->SetCellAlignment(0, i, wxALIGN_CENTRE, wxALIGN_CENTRE);
|
||||
}
|
||||
_grid->SetCellRenderer(0, DELETE, new wxGridCellBitmapRenderer(bitmap));
|
||||
|
||||
it = _curOperations->begin();
|
||||
|
||||
for (;it->fix_cost && it != _curOperations->end(); it++)
|
||||
|
@ -390,6 +401,9 @@ void AccountPanel::InitAccountsGrid(User* user, int month, int year)
|
|||
int i, a;
|
||||
DEFAULT_FONT(font);
|
||||
|
||||
if (_accountsGrid->GetNumberRows())
|
||||
_accountsGrid->DeleteRows(0, _accountsGrid->GetNumberRows());
|
||||
|
||||
font.SetWeight(wxFONTWEIGHT_BOLD);
|
||||
|
||||
for (i=0, it = user->_accounts.begin(); it != user->_accounts.end(); i++, it++, curLine++)
|
||||
|
@ -725,3 +739,12 @@ void AccountPanel::OnAccountModified(wxGridEvent& event)
|
|||
_accountsGrid->GetCellValue(row, event.GetCol()).ToDouble(&amount);
|
||||
_kiss->SetAccountAmount(_curMonth, _curYear, user->GetAccountId(_accounts[row]), amount);
|
||||
}
|
||||
|
||||
void AccountPanel::OnTreeRightClick(wxTreeEvent& event)
|
||||
{
|
||||
ShowMonth(2010,4);
|
||||
}
|
||||
|
||||
void AccountPanel::OnTreeChange(wxTreeEvent& event)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -39,6 +39,8 @@ public:
|
|||
|
||||
void OnOperationModified(wxGridEvent& event);
|
||||
void OnAccountModified(wxGridEvent& event);
|
||||
void OnTreeRightClick(wxTreeEvent& event);
|
||||
void OnTreeChange(wxTreeEvent& event);
|
||||
|
||||
private:
|
||||
KissCount* _kiss;
|
||||
|
|
Loading…
Reference in New Issue
Block a user