-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAccountDlg.cpp
138 lines (114 loc) · 3.54 KB
/
AccountDlg.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/******************************************************************************
** (C) Chris Oldwood
**
** MODULE: ACCOUNTDLG.CPP
** COMPONENT: The Application.
** DESCRIPTION: CAccountDlg class definition.
**
*******************************************************************************
*/
#include "Common.hpp"
#include "AccountDlg.hpp"
#include "Accounts.hpp"
/******************************************************************************
** Method: Constructor.
**
** Description: .
**
** Parameters: None.
**
** Returns: Nothing.
**
*******************************************************************************
*/
CAccountDlg::CAccountDlg(CFCMDB& oDB, CRow& oRow, bool bEditing)
: CPropertySheet()
, m_oRow(oRow)
, m_bEditing(bEditing)
, m_oDB(oDB)
, m_nItemID(oRow[CAccounts::ID])
// , m_oTmpSubs(oDB, oDB.m_oMembers, false)
// , m_oMembers(oDB.m_oMembers)
// , m_oTmpExps(oDB, oDB.m_oExpenseTypes)
// , m_oExpTypes(oDB.m_oExpenseTypes)
, m_oAccountPage(oRow)
, m_oNotesPage(oRow, CAccounts::NOTES, CAccounts::NOTES_LEN)
{
// Set the title.
m_strTitle = (m_bEditing == true) ? TXT("Edit Account") : TXT("Add An Account");
DEFINE_PAGE_TABLE
PAGE(&m_oAccountPage, TXT("Name && Transactions"))
PAGE(&m_oNotesPage, TXT("Notes") )
END_PAGE_TABLE
// Editing existing item?
if (m_bEditing)
{
/* CTable& oSubsTable = m_oDB.m_oSubs;
// Fetch the current subs for the item.
CResultSet oSubsRS = oSubsTable.Select(CWhereEqual(CSubs::ITEM_ID, m_nItemID));
// Copy to temporary table.
for (int i = 0; i < oSubsRS.Count(); i++)
{
CRow& oOrig = oSubsRS[i];
CRow& oCopy = m_oTmpSubs.CreateRow();
ASSERT(oOrig[CSubs::ITEM_ID] == m_nItemID);
oCopy[CSubs::ITEM_ID] = m_nItemID;
oCopy[CSubs::MEMBER_ID] = oOrig[CSubs::MEMBER_ID];
oCopy[CSubs::FEE] = oOrig[CSubs::FEE];
oCopy[CSubs::PAID] = oOrig[CSubs::PAID];
m_oTmpSubs.InsertRow(oCopy, false);
}
CTable& oExpsTable = m_oDB.m_oExpenses;
// Fetch the current expenses for the item.
CResultSet oExpsRS = oExpsTable.Select(CWhereEqual(CExpenses::ITEM_ID, m_nItemID));
// Copy to temporary table.
for (i = 0; i < oExpsRS.Count(); i++)
{
CRow& oOrig = oExpsRS[i];
CRow& oCopy = m_oTmpExps.CreateRow();
ASSERT(oOrig[CExpenses::ITEM_ID] == m_nItemID);
oCopy[CExpenses::ITEM_ID] = m_nItemID;
oCopy[CExpenses::TYPE_ID] = oOrig[CExpenses::TYPE_ID];
oCopy[CExpenses::PAID] = oOrig[CExpenses::PAID];
m_oTmpExps.InsertRow(oCopy, false);
}
*/ }
}
/******************************************************************************
** Method: UpdateTransTable()
**
** Description: Updates the account transactions table.
**
** Parameters: None.
**
** Returns: Nothing.
**
*******************************************************************************
*/
void CAccountDlg::UpdateTransTable()
{
/* // Debits table untouched?
if (!m_oTmpExps.Modified())
return;
CTable& oExps = m_oDB.m_oExpenses;
int nItemID = m_oRow[CAccounts::ID];
// Was editing item?
if (m_bEditing)
{
// Fetch the current expenses for the item.
CResultSet oRS = oExps.Select(CWhereEqual(CExpenses::ITEM_ID, nItemID));
// Delete all rows for the item.
for (int i = 0; i < oRS.Count(); i++)
oExps.DeleteRow(oRS[i]);
}
// Copy from temporary table to real table.
for (int i = 0; i < m_oTmpExps.RowCount(); i++)
{
CRow& oTmp = m_oTmpExps[i];
CRow& oNew = oExps.CreateRow();
oNew[CExpenses::ITEM_ID] = nItemID;
oNew[CExpenses::TYPE_ID] = oTmp[CExpenses::TYPE_ID];
oNew[CExpenses::PAID] = oTmp[CExpenses::PAID];
oExps.InsertRow(oNew);
}*/
}