Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk/FeliCa2Money.net/MainForm.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 177 - (show annotations) (download)
Fri Mar 21 09:21:26 2008 UTC (16 years, 2 months ago) by tmurakam
File size: 5774 byte(s)
use string resources
1 /*
2 * FeliCa2Money
3 *
4 * Copyright (C) 2001-2008 Takuya Murakami
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21 using System;
22 using System.Collections.Generic;
23 using System.ComponentModel;
24 using System.Data;
25 using System.Drawing;
26 using System.Text;
27 using System.Windows.Forms;
28
29 namespace FeliCa2Money
30 {
31 public partial class MainForm : Form
32 {
33 public MainForm()
34 {
35 InitializeComponent();
36
37 Properties.Settings s = Properties.Settings.Default;
38 if (s.IsFirstRun)
39 {
40 s.Upgrade();
41 s.IsFirstRun = false;
42 s.Save();
43 }
44 }
45
46 private void buttonQuit_Click(object sender, EventArgs e)
47 {
48 Application.Exit();
49 }
50
51 private void buttonEdy_Click(object sender, EventArgs e)
52 {
53 using (Edy edy = new Edy())
54 {
55 doConvert(edy);
56 }
57 }
58
59 private void buttonSuica_Click(object sender, EventArgs e)
60 {
61 using (Suica suica = new Suica())
62 {
63 doConvert(suica);
64 }
65 }
66
67 private void buttonNanaco_Click(object sender, EventArgs e)
68 {
69 using(Nanaco nanaco = new Nanaco())
70 {
71 doConvert(nanaco);
72 }
73 }
74
75 private void buttonWaon_Click(object sender, EventArgs e)
76 {
77 using (Waon waon = new Waon())
78 {
79 doConvert(waon);
80 }
81 }
82
83 private void buttonCSV_Click(object sender, EventArgs e)
84 {
85 CsvCard csv = new CsvCard();
86 if (!csv.LoadAllRules()) return;
87
88 if (openFileDialog.ShowDialog() != DialogResult.OK) return;
89
90 try
91 {
92 if (csv.OpenFile(openFileDialog.FileName) == false) return;
93 }
94 catch (Exception ex)
95 {
96 MessageBox.Show(ex.Message, Properties.Resources.Error);
97 return;
98 }
99
100 doConvert(csv);
101 csv.Close();
102 }
103
104 private void doConvert(Card c)
105 {
106 List<Transaction> list;
107
108 try
109 {
110 list = c.ReadCard();
111 }
112 catch (Exception ex)
113 {
114 MessageBox.Show(ex.Message, Properties.Resources.Error);
115 return;
116 }
117
118 if (list == null)
119 {
120 MessageBox.Show(Properties.Resources.CardReadError, Properties.Resources.Error);
121 return;
122 }
123
124 // ������������������������������
125 list.RemoveAll(Transaction.isInvalid);
126
127 // 0���������������������������
128 if (Properties.Settings.Default.IgnoreZeroTransaction)
129 {
130 list.RemoveAll(Transaction.isZeroTransaction);
131 }
132
133 if (list.Count == 0)
134 {
135 MessageBox.Show(Properties.Resources.NoHistory, Properties.Resources.Error);
136 return;
137 }
138
139 // OFX ������������������������
140 String ofxFilePath;
141 if (Properties.Settings.Default.ManualOfxPath)
142 {
143 if (saveFileDialog.ShowDialog() == DialogResult.OK)
144 {
145 ofxFilePath = saveFileDialog.FileName;
146 }
147 else
148 {
149 // do not save
150 return;
151 }
152 }
153 else
154 {
155 ofxFilePath = System.IO.Path.GetTempPath() + "FeliCa2Money.ofx";
156 }
157
158 // OFX ������������������
159 OfxFile ofx;
160 if (Properties.Settings.Default.OfxVer2)
161 {
162 ofx = new OfxFile2();
163 }
164 else
165 {
166 ofx = new OfxFile();
167 }
168
169 ofx.SetOfxFilePath(ofxFilePath);
170 ofx.WriteFile(c, list);
171
172 // Money ������
173 if (Properties.Settings.Default.AutoKickOfxFile)
174 {
175 ofx.Execute();
176 }
177 }
178
179 // ���������������������
180 private void buttonOption_Click(object sender, EventArgs e)
181 {
182 OptionDialog dlg = new OptionDialog();
183
184 if (dlg.ShowDialog() == DialogResult.OK)
185 {
186 dlg.SaveProperties();
187 }
188 }
189
190 private void buttonManual_Click(object sender, EventArgs e)
191 {
192 try
193 {
194 String helpFile = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\Felica2Money.html";
195 System.Diagnostics.Process.Start(helpFile);
196 }
197 catch
198 {
199 // do nothing
200 }
201 }
202 }
203 }

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