| 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.Default.Upgrade(); |
| 38 |
} |
| 39 |
|
| 40 |
private void buttonQuit_Click(object sender, EventArgs e) |
| 41 |
{ |
| 42 |
Application.Exit(); |
| 43 |
} |
| 44 |
|
| 45 |
private void buttonEdy_Click(object sender, EventArgs e) |
| 46 |
{ |
| 47 |
using (Edy edy = new Edy()) |
| 48 |
{ |
| 49 |
doConvert(edy); |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
private void buttonSuica_Click(object sender, EventArgs e) |
| 54 |
{ |
| 55 |
using (Suica suica = new Suica()) |
| 56 |
{ |
| 57 |
doConvert(suica); |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
private void buttonNanaco_Click(object sender, EventArgs e) |
| 62 |
{ |
| 63 |
using(Nanaco nanaco = new Nanaco()) |
| 64 |
{ |
| 65 |
doConvert(nanaco); |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
private void doConvert(Card c) |
| 70 |
{ |
| 71 |
List<Transaction> list; |
| 72 |
|
| 73 |
try |
| 74 |
{ |
| 75 |
list = c.ReadCard(); |
| 76 |
} |
| 77 |
catch (Exception ex) |
| 78 |
{ |
| 79 |
MessageBox.Show(ex.Message, "���������"); |
| 80 |
return; |
| 81 |
} |
| 82 |
|
| 83 |
if (list == null) |
| 84 |
{ |
| 85 |
MessageBox.Show("���������������������������������������������������", "���������"); |
| 86 |
return; |
| 87 |
} |
| 88 |
|
| 89 |
// 0��������������������������� |
| 90 |
if (Properties.Settings.Default.IgnoreZeroTransaction) |
| 91 |
{ |
| 92 |
list.RemoveAll(Transaction.isZeroTransaction); |
| 93 |
} |
| 94 |
|
| 95 |
if (list.Count == 0) |
| 96 |
{ |
| 97 |
MessageBox.Show("���������������������������������", "���������"); |
| 98 |
return; |
| 99 |
} |
| 100 |
|
| 101 |
// OFX ������������������������ |
| 102 |
String ofxFilePath; |
| 103 |
if (Properties.Settings.Default.ManualOfxPath) |
| 104 |
{ |
| 105 |
if (saveFileDialog.ShowDialog() == DialogResult.OK) |
| 106 |
{ |
| 107 |
ofxFilePath = saveFileDialog.FileName; |
| 108 |
} |
| 109 |
else |
| 110 |
{ |
| 111 |
// do not save |
| 112 |
return; |
| 113 |
} |
| 114 |
} |
| 115 |
else |
| 116 |
{ |
| 117 |
ofxFilePath = System.IO.Path.GetTempPath() + "FeliCa2Money.ofx"; |
| 118 |
} |
| 119 |
|
| 120 |
// OFX ������������������ |
| 121 |
OfxFile ofx = new OfxFile(); |
| 122 |
ofx.SetOfxFilePath(ofxFilePath); |
| 123 |
ofx.WriteFile(c, list); |
| 124 |
|
| 125 |
// Money ������ |
| 126 |
if (Properties.Settings.Default.AutoKickOfxFile) |
| 127 |
{ |
| 128 |
ofx.Execute(); |
| 129 |
} |
| 130 |
} |
| 131 |
|
| 132 |
// ��������������������� |
| 133 |
private void buttonOption_Click(object sender, EventArgs e) |
| 134 |
{ |
| 135 |
OptionDialog dlg = new OptionDialog(); |
| 136 |
|
| 137 |
if (dlg.ShowDialog() == DialogResult.OK) |
| 138 |
{ |
| 139 |
dlg.SaveProperties(); |
| 140 |
} |
| 141 |
} |
| 142 |
|
| 143 |
private void buttonManual_Click(object sender, EventArgs e) |
| 144 |
{ |
| 145 |
try |
| 146 |
{ |
| 147 |
String helpFile = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\Felica2Money.html"; |
| 148 |
System.Diagnostics.Process.Start(helpFile); |
| 149 |
} |
| 150 |
catch |
| 151 |
{ |
| 152 |
// do nothing |
| 153 |
} |
| 154 |
} |
| 155 |
|
| 156 |
} |
| 157 |
} |