Develop and Download Open Source Software

Browse Subversion Repository

Contents of /tags/FeliCa2Money-2.4/MainForm.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 150 - (show annotations) (download)
Sun Mar 16 10:36:07 2008 UTC (16 years ago) by tmurakam
File size: 5349 byte(s)
ver 2.4 tag

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 buttonCSV_Click(object sender, EventArgs e)
76 {
77 CsvCard csv = new CsvCard();
78 if (!csv.LoadAllRules()) return;
79
80 if (openFileDialog.ShowDialog() != DialogResult.OK) return;
81
82 try
83 {
84 if (csv.OpenFile(openFileDialog.FileName) == false) return;
85 }
86 catch (Exception ex)
87 {
88 MessageBox.Show(ex.Message, "���������");
89 return;
90 }
91
92 doConvert(csv);
93 csv.Close();
94 }
95
96 private void doConvert(Card c)
97 {
98 List<Transaction> list;
99
100 try
101 {
102 list = c.ReadCard();
103 }
104 catch (Exception ex)
105 {
106 MessageBox.Show(ex.Message, "���������");
107 return;
108 }
109
110 if (list == null)
111 {
112 MessageBox.Show("���������������������������������������������������", "���������");
113 return;
114 }
115
116 // ������������������������������
117 list.RemoveAll(Transaction.isInvalid);
118
119 // 0���������������������������
120 if (Properties.Settings.Default.IgnoreZeroTransaction)
121 {
122 list.RemoveAll(Transaction.isZeroTransaction);
123 }
124
125 if (list.Count == 0)
126 {
127 MessageBox.Show("���������������������������������", "���������");
128 return;
129 }
130
131 // OFX ������������������������
132 String ofxFilePath;
133 if (Properties.Settings.Default.ManualOfxPath)
134 {
135 if (saveFileDialog.ShowDialog() == DialogResult.OK)
136 {
137 ofxFilePath = saveFileDialog.FileName;
138 }
139 else
140 {
141 // do not save
142 return;
143 }
144 }
145 else
146 {
147 ofxFilePath = System.IO.Path.GetTempPath() + "FeliCa2Money.ofx";
148 }
149
150 // OFX ������������������
151 OfxFile ofx = new OfxFile();
152 ofx.SetOfxFilePath(ofxFilePath);
153 ofx.WriteFile(c, list);
154
155 // Money ������
156 if (Properties.Settings.Default.AutoKickOfxFile)
157 {
158 ofx.Execute();
159 }
160 }
161
162 // ���������������������
163 private void buttonOption_Click(object sender, EventArgs e)
164 {
165 OptionDialog dlg = new OptionDialog();
166
167 if (dlg.ShowDialog() == DialogResult.OK)
168 {
169 dlg.SaveProperties();
170 }
171 }
172
173 private void buttonManual_Click(object sender, EventArgs e)
174 {
175 try
176 {
177 String helpFile = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\Felica2Money.html";
178 System.Diagnostics.Process.Start(helpFile);
179 }
180 catch
181 {
182 // do nothing
183 }
184 }
185
186
187 }
188 }

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