Develop and Download Open Source Software

Browse Subversion Repository

Contents of /branches/MoneyImport/MainForm.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 205 - (show annotations) (download) (as text)
Sun May 18 04:21:59 2008 UTC (15 years, 10 months ago) by tmurakam
File MIME type: text/x-c++src
File size: 5932 byte(s)
move older MoneyImport

1 /*
2 * MoneyImport : Convert Bank transaction csv file to MS Money OFX file.
3 *
4 * Copyright (c) 2001-2003 Takuya Murakami. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
21 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * $Id$
30 */
31 //---------------------------------------------------------------------------
32
33 #include <vcl.h>
34 #pragma hdrstop
35 #include <Registry.hpp>
36 #include <ShellApi.h>
37
38 #include "MainForm.h"
39 #include "Convert.h"
40 #include "Account.h"
41
42 #include "JNB.h"
43 #include "SonyBank.h"
44 #include "Ebank.h"
45
46 //---------------------------------------------------------------------------
47 #pragma package(smart_init)
48 #pragma resource "*.dfm"
49 TMForm *MForm;
50 //---------------------------------------------------------------------------
51 __fastcall TMForm::TMForm(TComponent* Owner)
52 : TForm(Owner)
53 {
54 }
55 //---------------------------------------------------------------------------
56 void __fastcall TMForm::FormShow(TObject *Sender)
57 {
58 accounts.AddAcount(new JNBAccount);
59 accounts.AddAcount(new SBAccount);
60 accounts.AddAcount(new EbankAccount);
61
62 LoadRegistry();
63
64 if (ParamCount() == 1) {
65 Convert(ParamStr(1));
66 Application->Terminate();
67 }
68 }
69 //---------------------------------------------------------------------------
70 void __fastcall TMForm::ButtonConvertClick(TObject *Sender)
71 {
72 if (OpenDialog->Execute()) {
73 Convert(OpenDialog->FileName);
74 }
75 }
76 //---------------------------------------------------------------------------
77 void TMForm::Convert(AnsiString csvfile)
78 {
79 AnsiString ofxfile = ExtractFilePath(Application->ExeName) +
80 "ImportMoney.ofx";
81
82 #if 0
83 JNBAccount jnb;
84 jnb.SetAccount(EditJNBBranch->Text, EditJNBAccount->Text);
85
86 SBAccount sb;
87 sb.SetAccount(EditSBBranch->Text, EditSBAccount->Text);
88
89 Accounts acs;
90 acs.AddAcount(&jnb);
91 acs.AddAcount(&sb);
92 #endif
93
94 int n = accounts.NumAccount();
95 for (int i = 0; i < n; i++) {
96 Account *ac = accounts.GetAccount(i);
97 ac->SetAccount(
98 AcGrid->Cells[2][i+1], // branch
99 AcGrid->Cells[3][i+1] // account
100 );
101 }
102
103
104 ::Convert(csvfile, ofxfile, &accounts);
105 }
106 //---------------------------------------------------------------------------
107 void __fastcall TMForm::EditJNBAccountExit(TObject *Sender)
108 {
109 SaveRegistry();
110 }
111
112 //---------------------------------------------------------------------------
113
114 void __fastcall TMForm::ButtonQuitClick(TObject *Sender)
115 {
116 Application->Terminate();
117 }
118 //---------------------------------------------------------------------------
119 void TMForm::LoadRegistry(void)
120 {
121 // ���W�X�g������������������������
122 TRegistry *reg = new TRegistry();
123
124 reg->RootKey = HKEY_CURRENT_USER;
125 reg->OpenKey("\\Software\\Takuya Murakami\\ImportMoney", true);
126
127 #if 0
128 EditJNBBranch->Text = reg->ReadString("JNBBranchId");
129 EditJNBAccount->Text = reg->ReadString("JNBAccountId");
130
131 EditSBBranch->Text = reg->ReadString("SBBranchId");
132 EditSBAccount->Text = reg->ReadString("SBAccountId");
133 #endif
134
135 AcGrid->Cells[0][0] = "���s��";
136 AcGrid->Cells[1][0] = "���sID";
137 AcGrid->Cells[2][0] = "�x�X����";
138 AcGrid->Cells[3][0] = "��������";
139
140 int n = accounts.NumAccount();
141 for (int i = 0; i < n; i++) {
142 Account *ac = accounts.GetAccount(i);
143 AcGrid->Cells[0][i+1] = ac->getBankName();
144 AcGrid->Cells[1][i+1] = ac->getBankId();
145
146 AnsiString bid, aid;
147 bid = aid = ac->getIdent();
148 bid += "BranchId";
149 aid += "AccountId";
150
151 AcGrid->Cells[2][i+1] = reg->ReadString(bid);
152 AcGrid->Cells[3][i+1] = reg->ReadString(aid);
153 }
154 }
155 //---------------------------------------------------------------------------
156 void TMForm::SaveRegistry(void)
157 {
158 TRegIniFile *ini;
159
160 // ���W�X�g������������������
161 TRegistry *reg = new TRegistry();
162
163 reg->RootKey = HKEY_CURRENT_USER;
164 reg->OpenKey("\\Software\\Takuya Murakami\\ImportMoney", true);
165
166 #if 0
167 reg->WriteString("JNBBranchId", EditJNBBranch->Text);
168 reg->WriteString("JNBAccountId", EditJNBAccount->Text);
169
170 reg->WriteString("SBBranchId", EditSBBranch->Text);
171 reg->WriteString("SBAccountId", EditSBAccount->Text);
172 #endif
173
174 int n = accounts.NumAccount();
175 for (int i = 0; i < n; i++) {
176 Account *ac = accounts.GetAccount(i);
177
178 AnsiString bid, aid;
179 bid = aid = ac->getIdent();
180 bid += "BranchId";
181 aid += "AccountId";
182
183 reg->WriteString(bid, AcGrid->Cells[2][i+1]);
184 reg->WriteString(aid, AcGrid->Cells[3][i+1]);
185 }
186 }
187
188 //---------------------------------------------------------------------------
189 void __fastcall TMForm::ButtonHelpClick(TObject *Sender)
190 {
191 ShellExecute(NULL, "open", "MoneyImport.chm",
192 NULL, NULL, SW_SHOWDEFAULT);
193 }
194 //---------------------------------------------------------------------------
195
196 void __fastcall TMForm::AcGridExit(TObject *Sender)
197 {
198 SaveRegistry();
199 }
200 //---------------------------------------------------------------------------
201

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26