質問編集履歴
5
意図的に内容を抹消する行為にあたるため
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,3 +1,327 @@
|
|
1
|
+
```C#
|
2
|
+
|
3
|
+
using System;
|
4
|
+
|
5
|
+
using System.Collections.Generic;
|
6
|
+
|
7
|
+
using System.ComponentModel;
|
8
|
+
|
9
|
+
using System.Data;
|
10
|
+
|
11
|
+
using System.Drawing;
|
12
|
+
|
13
|
+
using System.Linq;
|
14
|
+
|
15
|
+
using System.Text;
|
16
|
+
|
17
|
+
using System.Threading.Tasks;
|
18
|
+
|
19
|
+
using System.Windows.Forms;
|
20
|
+
|
21
|
+
namespace MyHouseKeepingBook
|
22
|
+
|
23
|
+
{
|
24
|
+
|
25
|
+
public partial class Form1 : Form
|
26
|
+
|
27
|
+
{
|
28
|
+
|
29
|
+
public Form1()
|
30
|
+
|
31
|
+
{
|
32
|
+
|
33
|
+
InitializeComponent();
|
34
|
+
|
35
|
+
}
|
36
|
+
|
37
|
+
private void buttonAdd_Click(object sender, EventArgs e)
|
38
|
+
|
39
|
+
{
|
40
|
+
|
41
|
+
AddData();
|
42
|
+
|
43
|
+
}
|
44
|
+
|
45
|
+
private void 追加AToolStripMenuItem_Click(object sender, EventArgs e)
|
46
|
+
|
47
|
+
{
|
48
|
+
|
49
|
+
AddData();
|
50
|
+
|
51
|
+
}
|
52
|
+
|
53
|
+
private void AddData()
|
54
|
+
|
55
|
+
{
|
56
|
+
|
57
|
+
ItemForm frmItem = new ItemForm(CategoryDataSet1);
|
58
|
+
|
59
|
+
DialogResult drRet = frmItem.ShowDialog();
|
60
|
+
|
61
|
+
if (drRet == DialogResult.OK)
|
62
|
+
|
63
|
+
{
|
64
|
+
|
65
|
+
moneyDataSet.moneyDataTable.AddmoneyDataTableRow(
|
66
|
+
|
67
|
+
frmItem.monCalendar.SelectionRange.Start,
|
68
|
+
|
69
|
+
frmItem.cmbCategory.Text,
|
70
|
+
|
71
|
+
frmItem.txtItem.Text,
|
72
|
+
|
73
|
+
int.Parse(frmItem.mtxtMoney.Text),
|
74
|
+
|
75
|
+
frmItem.txtRemarks.Text);
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
private void Form1_Load(object sender, EventArgs e)
|
82
|
+
|
83
|
+
{
|
84
|
+
|
85
|
+
LoadData();
|
86
|
+
|
87
|
+
categoryDataSet1.CategoryDataTable.AddCategoryDataTableRow("給料", "入金");
|
88
|
+
|
89
|
+
categoryDataSet1.CategoryDataTable.AddCategoryDataTableRow("食費", "出金");
|
90
|
+
|
91
|
+
categoryDataSet1.CategoryDataTable.AddCategoryDataTableRow("雑費", "出金");
|
92
|
+
|
93
|
+
categoryDataSet1.CategoryDataTable.AddCategoryDataTableRow("住居", "出金");
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
private void buttonEnd_Click(object sender, EventArgs e)
|
98
|
+
|
99
|
+
{
|
100
|
+
|
101
|
+
this.Close();
|
102
|
+
|
103
|
+
}
|
104
|
+
|
105
|
+
private void 終了XToolStripMenuItem_Click(object sender, EventArgs e)
|
106
|
+
|
107
|
+
{
|
108
|
+
|
109
|
+
this.Close();
|
110
|
+
|
111
|
+
}
|
112
|
+
|
113
|
+
private void SaveData()
|
114
|
+
|
115
|
+
{
|
116
|
+
|
117
|
+
string path = "MoneyData.csv"; //出力ファイル名
|
118
|
+
|
119
|
+
string strData = ""; //一行分のデータ
|
120
|
+
|
121
|
+
System.IO.StreamWriter sw = new System.IO.StreamWriter(
|
122
|
+
|
123
|
+
path,
|
124
|
+
|
125
|
+
false,
|
126
|
+
|
127
|
+
System.Text.Encoding.Default);
|
128
|
+
|
129
|
+
foreach (MoneyDataSet.moneyDataTableRow drMoney
|
130
|
+
|
131
|
+
in moneyDataSet.moneyDataTable)
|
132
|
+
|
133
|
+
{
|
134
|
+
|
135
|
+
strData = drMoney.日付.ToShortDataString() + ","
|
136
|
+
|
137
|
+
+ drMoney.分類 + ","
|
138
|
+
|
139
|
+
+ drMoney.品目 + ","
|
140
|
+
|
141
|
+
+ drMoney.金額.ToString() + ","
|
142
|
+
|
143
|
+
+ drMoney.備考;
|
144
|
+
|
145
|
+
sw.WriteLine(strData);
|
146
|
+
|
147
|
+
}
|
148
|
+
|
149
|
+
sw.Close();
|
150
|
+
|
151
|
+
}
|
152
|
+
|
153
|
+
private void 保存SToolStripMenuItem_Click(object sender, EditorArgs e)
|
154
|
+
|
155
|
+
{
|
156
|
+
|
157
|
+
SaveData();
|
158
|
+
|
159
|
+
}
|
160
|
+
|
161
|
+
private void form1_FormClosing(object sender, FormClosingEditorArgs e)
|
162
|
+
|
163
|
+
{
|
164
|
+
|
165
|
+
SaveData();
|
166
|
+
|
167
|
+
}
|
168
|
+
|
169
|
+
private void LoadData()
|
170
|
+
|
171
|
+
{
|
172
|
+
|
173
|
+
string path = "MoneyData.csv"; //入力ファイル名
|
174
|
+
|
175
|
+
string delimStr = ","; // 区切り文字
|
176
|
+
|
177
|
+
char[] delimiter = delimStr.ToCharArray(); // 区切り文字をまとめる
|
178
|
+
|
179
|
+
string[] strLine; // 分解後の文字の入れ物
|
180
|
+
|
181
|
+
string strLine; // 一行分のデータ
|
182
|
+
|
183
|
+
bool fileExists = System.IO.File.Exists(path);
|
184
|
+
|
185
|
+
if (fileExists)
|
186
|
+
|
187
|
+
{
|
188
|
+
|
189
|
+
System.IO.StreamReader sr = new System.IO.StreamReader(
|
190
|
+
|
191
|
+
path,
|
192
|
+
|
193
|
+
System.Text.Encoding.Default);
|
194
|
+
|
195
|
+
while (sr.Peek() >= 0)
|
196
|
+
|
197
|
+
{
|
198
|
+
|
199
|
+
strLine = sr.ReadLine();
|
200
|
+
|
201
|
+
strData = strLine.Splite(delimiter);
|
202
|
+
|
203
|
+
moneyDataSet.moneyDataTable.AddmoneyDataTableRow(
|
204
|
+
|
205
|
+
DateTime.Parse(strData[0]),
|
206
|
+
|
207
|
+
strData[1],
|
208
|
+
|
209
|
+
strData[2],
|
210
|
+
|
211
|
+
int, Parse(strData[3]),
|
212
|
+
|
213
|
+
strData[4];
|
214
|
+
|
215
|
+
}
|
216
|
+
|
217
|
+
sr.Close;
|
218
|
+
|
219
|
+
}
|
220
|
+
|
221
|
+
}
|
222
|
+
|
223
|
+
private void UpdateData()
|
224
|
+
|
225
|
+
{
|
226
|
+
|
227
|
+
int nowRow = dgv.CurrentRow, Index;
|
228
|
+
|
229
|
+
DateTime oldDate
|
230
|
+
|
231
|
+
= DateTime.Parse(dgv.Rows[nowRow].Cell[0].Value.ToString());
|
232
|
+
|
233
|
+
string oldCategory = dgv.Rows[nowRow].Cell[1].Value.ToString();
|
234
|
+
|
235
|
+
string oldItem = dgv.Rows[nowRow].Cell[2].Value.ToString();
|
236
|
+
|
1
|
-
|
237
|
+
int oldMoney
|
238
|
+
|
2
|
-
|
239
|
+
= int.Parse(dgv.Rows[nowRow].Cells[3].Value.ToString());
|
240
|
+
|
241
|
+
string oldRemarks = dgv.Rows[nowRow].Cells[4].Value.ToString();
|
242
|
+
|
243
|
+
ItemForm frmItem = newItemForm(categoryDataSet1,
|
244
|
+
|
245
|
+
oldDate,
|
246
|
+
|
3
|
-
|
247
|
+
oldCategory,
|
248
|
+
|
249
|
+
oldItem,
|
250
|
+
|
251
|
+
oldMoney,
|
252
|
+
|
253
|
+
oldRemarks);
|
254
|
+
|
255
|
+
DialogResult draRet = frmItem.ShowDialog();
|
256
|
+
|
257
|
+
if (draRet == DialogResult.OK)
|
258
|
+
|
259
|
+
{
|
260
|
+
|
261
|
+
dgv.Rows[nowRow].Cells[0].Value
|
262
|
+
|
263
|
+
= frmItem.monCalendar.SelectionRangr.Start;
|
264
|
+
|
265
|
+
dgv.Rows[nowRow].Cells[1].Value = frmItem.cmbCategory.Text;
|
266
|
+
|
267
|
+
dgv.Rows[nowRow].Cells[2].Value = frmItem.txtItem.Text;
|
268
|
+
|
269
|
+
dgv.Rows[nowRow].Cells[3].Value = int.Parse.(frmItem.mtxtMoney.Text);
|
270
|
+
|
271
|
+
dgv.Rows[nowRow].Cells[4].Value = frmItem.txtRemarks.Text;
|
272
|
+
|
273
|
+
}
|
274
|
+
|
275
|
+
}
|
276
|
+
|
277
|
+
private void buttonChange_Click(object sender, EditorArgs e)
|
278
|
+
|
279
|
+
{
|
280
|
+
|
281
|
+
UpdateData();
|
282
|
+
|
283
|
+
}
|
284
|
+
|
285
|
+
private void 変更CToolStripMenuItem_Click(object sender, EditorArgs e)
|
286
|
+
|
287
|
+
{
|
288
|
+
|
289
|
+
UpdateData();
|
290
|
+
|
291
|
+
}
|
292
|
+
|
293
|
+
private void DeleteData()
|
294
|
+
|
295
|
+
{
|
296
|
+
|
297
|
+
int nowRow = DataGridView.CurrentRow.Index;
|
298
|
+
|
299
|
+
DataGridView.Rows.RemoveAt(nowRow); // 現在行を削除
|
300
|
+
|
301
|
+
}
|
302
|
+
|
303
|
+
private void buttonDelete_Click(object sender, EditorArgs e)
|
304
|
+
|
305
|
+
{
|
306
|
+
|
307
|
+
DeleteData();
|
308
|
+
|
309
|
+
}
|
310
|
+
|
311
|
+
private void buttonChange_Click(object sender, EditorArgs e)
|
312
|
+
|
313
|
+
{
|
314
|
+
|
315
|
+
DeleteData();
|
316
|
+
|
317
|
+
}
|
318
|
+
|
319
|
+
}
|
320
|
+
|
321
|
+
}
|
322
|
+
|
323
|
+
```家計簿アプリの作成をVisual StudioのC#で行なっております。
|
324
|
+
|
325
|
+
Month Calendar でCSVに既に登録されている日付を選択できなくし、既に登録されている日付を選択するとメッセージボックスが表示されるようにしたいです。
|
326
|
+
|
327
|
+
説明が不自由かも知れませんが、ご教示いただければと存じます。
|
4
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,371 +1,3 @@
|
|
1
|
-
|
1
|
+
Month Calendarについて
|
2
2
|
|
3
|
-
using System;
|
4
|
-
|
5
|
-
using System.Collections.Generic;
|
6
|
-
|
7
|
-
using System.ComponentModel;
|
8
|
-
|
9
|
-
using System.Data;
|
10
|
-
|
11
|
-
using System.Drawing;
|
12
|
-
|
13
|
-
using System.Linq;
|
14
|
-
|
15
|
-
using System.Text;
|
16
|
-
|
17
|
-
using System.Threading.Tasks;
|
18
|
-
|
19
|
-
using System.Windows.Forms;
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
namespace MyHouseKeepingBook
|
24
|
-
|
25
|
-
{
|
26
|
-
|
27
|
-
public partial class Form1 : Form
|
28
|
-
|
29
|
-
{
|
30
|
-
|
31
|
-
public Form1()
|
32
|
-
|
33
|
-
{
|
34
|
-
|
35
|
-
InitializeComponent();
|
36
|
-
|
37
|
-
}
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
private void buttonAdd_Click(object sender, EventArgs e)
|
42
|
-
|
43
|
-
{
|
44
|
-
|
45
|
-
AddData();
|
46
|
-
|
47
|
-
}
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
private void 追加AToolStripMenuItem_Click(object sender, EventArgs e)
|
52
|
-
|
53
|
-
{
|
54
|
-
|
55
|
-
AddData();
|
56
|
-
|
57
|
-
}
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
private void AddData()
|
62
|
-
|
63
|
-
{
|
64
|
-
|
65
|
-
ItemForm frmItem = new ItemForm(CategoryDataSet1);
|
66
|
-
|
67
|
-
DialogResult drRet = frmItem.ShowDialog();
|
68
|
-
|
69
|
-
if (drRet == DialogResult.OK)
|
70
|
-
|
71
|
-
{
|
72
|
-
|
73
|
-
moneyDataSet.moneyDataTable.AddmoneyDataTableRow(
|
74
|
-
|
75
|
-
frmItem.monCalendar.SelectionRange.Start,
|
76
|
-
|
77
|
-
frmItem.cmbCategory.Text,
|
78
|
-
|
79
|
-
frmItem.txtItem.Text,
|
80
|
-
|
81
|
-
int.Parse(frmItem.mtxtMoney.Text),
|
82
|
-
|
83
|
-
frmItem.txtRemarks.Text);
|
84
|
-
|
85
|
-
}
|
86
|
-
|
87
|
-
}
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
private void Form1_Load(object sender, EventArgs e)
|
92
|
-
|
93
|
-
{
|
94
|
-
|
95
|
-
LoadData();
|
96
|
-
|
97
|
-
categoryDataSet1.CategoryDataTable.AddCategoryDataTableRow("給料", "入金");
|
98
|
-
|
99
|
-
categoryDataSet1.CategoryDataTable.AddCategoryDataTableRow("食費", "出金");
|
100
|
-
|
101
|
-
categoryDataSet1.CategoryDataTable.AddCategoryDataTableRow("雑費", "出金");
|
102
|
-
|
103
|
-
categoryDataSet1.CategoryDataTable.AddCategoryDataTableRow("住居", "出金");
|
104
|
-
|
105
|
-
}
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
private void buttonEnd_Click(object sender, EventArgs e)
|
110
|
-
|
111
|
-
{
|
112
|
-
|
113
|
-
this.Close();
|
114
|
-
|
115
|
-
}
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
private void 終了XToolStripMenuItem_Click(object sender, EventArgs e)
|
120
|
-
|
121
|
-
{
|
122
|
-
|
123
|
-
this.Close();
|
124
|
-
|
125
|
-
}
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
private void SaveData()
|
130
|
-
|
131
|
-
{
|
132
|
-
|
133
|
-
string path = "MoneyData.csv"; //出力ファイル名
|
134
|
-
|
135
|
-
string strData = ""; //一行分のデータ
|
136
|
-
|
137
|
-
System.IO.StreamWriter sw = new System.IO.StreamWriter(
|
138
|
-
|
139
|
-
path,
|
140
|
-
|
141
|
-
false,
|
142
|
-
|
143
|
-
System.Text.Encoding.Default);
|
144
|
-
|
145
|
-
foreach (MoneyDataSet.moneyDataTableRow drMoney
|
146
|
-
|
147
|
-
in moneyDataSet.moneyDataTable)
|
148
|
-
|
149
|
-
{
|
150
|
-
|
151
|
-
strData = drMoney.日付.ToShortDataString() + ","
|
152
|
-
|
153
|
-
+ drMoney.分類 + ","
|
154
|
-
|
155
|
-
+ drMoney.品目 + ","
|
156
|
-
|
157
|
-
+ drMoney.金額.ToString() + ","
|
158
|
-
|
159
|
-
+ drMoney.備考;
|
160
|
-
|
161
|
-
sw.WriteLine(strData);
|
162
|
-
|
163
|
-
}
|
164
|
-
|
165
|
-
sw.Close();
|
166
|
-
|
167
|
-
}
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
private void 保存SToolStripMenuItem_Click(object sender, EditorArgs e)
|
172
|
-
|
173
|
-
{
|
174
|
-
|
175
|
-
SaveData();
|
176
|
-
|
177
|
-
}
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
private void form1_FormClosing(object sender, FormClosingEditorArgs e)
|
182
|
-
|
183
|
-
{
|
184
|
-
|
185
|
-
SaveData();
|
186
|
-
|
187
|
-
}
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
private void LoadData()
|
192
|
-
|
193
|
-
{
|
194
|
-
|
195
|
-
string path = "MoneyData.csv"; //入力ファイル名
|
196
|
-
|
197
|
-
string delimStr = ","; // 区切り文字
|
198
|
-
|
199
|
-
char[] delimiter = delimStr.ToCharArray(); // 区切り文字をまとめる
|
200
|
-
|
201
|
-
string[] strLine; // 分解後の文字の入れ物
|
202
|
-
|
203
|
-
string strLine; // 一行分のデータ
|
204
|
-
|
205
|
-
bool fileExists = System.IO.File.Exists(path);
|
206
|
-
|
207
|
-
if (fileExists)
|
208
|
-
|
209
|
-
{
|
210
|
-
|
211
|
-
System.IO.StreamReader sr = new System.IO.StreamReader(
|
212
|
-
|
213
|
-
path,
|
214
|
-
|
215
|
-
System.Text.Encoding.Default);
|
216
|
-
|
217
|
-
while (sr.Peek() >= 0)
|
218
|
-
|
219
|
-
{
|
220
|
-
|
221
|
-
strLine = sr.ReadLine();
|
222
|
-
|
223
|
-
strData = strLine.Splite(delimiter);
|
224
|
-
|
225
|
-
moneyDataSet.moneyDataTable.AddmoneyDataTableRow(
|
226
|
-
|
227
|
-
DateTime.Parse(strData[0]),
|
228
|
-
|
229
|
-
strData[1],
|
230
|
-
|
231
|
-
strData[2],
|
232
|
-
|
233
|
-
int, Parse(strData[3]),
|
234
|
-
|
235
|
-
strData[4];
|
236
|
-
|
237
|
-
}
|
238
|
-
|
239
|
-
sr.Close;
|
240
|
-
|
241
|
-
}
|
242
|
-
|
243
|
-
}
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
private void UpdateData()
|
248
|
-
|
249
|
-
{
|
250
|
-
|
251
|
-
int nowRow = dgv.CurrentRow, Index;
|
252
|
-
|
253
|
-
DateTime oldDate
|
254
|
-
|
255
|
-
= DateTime.Parse(dgv.Rows[nowRow].Cell[0].Value.ToString());
|
256
|
-
|
257
|
-
string oldCategory = dgv.Rows[nowRow].Cell[1].Value.ToString();
|
258
|
-
|
259
|
-
string oldItem = dgv.Rows[nowRow].Cell[2].Value.ToString();
|
260
|
-
|
261
|
-
|
3
|
+
Month Calendarについて
|
262
|
-
|
263
|
-
= int.Parse(dgv.Rows[nowRow].Cells[3].Value.ToString());
|
264
|
-
|
265
|
-
string oldRemarks = dgv.Rows[nowRow].Cells[4].Value.ToString();
|
266
|
-
|
267
|
-
ItemForm frmItem = newItemForm(categoryDataSet1,
|
268
|
-
|
269
|
-
oldDate,
|
270
|
-
|
271
|
-
oldCategory,
|
272
|
-
|
273
|
-
oldItem,
|
274
|
-
|
275
|
-
oldMoney,
|
276
|
-
|
277
|
-
oldRemarks);
|
278
|
-
|
279
|
-
DialogResult draRet = frmItem.ShowDialog();
|
280
|
-
|
281
|
-
if (draRet == DialogResult.OK)
|
282
|
-
|
283
|
-
{
|
284
|
-
|
285
|
-
dgv.Rows[nowRow].Cells[0].Value
|
286
|
-
|
287
|
-
= frmItem.monCalendar.SelectionRangr.Start;
|
288
|
-
|
289
|
-
dgv.Rows[nowRow].Cells[1].Value = frmItem.cmbCategory.Text;
|
290
|
-
|
291
|
-
dgv.Rows[nowRow].Cells[2].Value = frmItem.txtItem.Text;
|
292
|
-
|
293
|
-
dgv.Rows[nowRow].Cells[3].Value = int.Parse.(frmItem.mtxtMoney.Text);
|
294
|
-
|
295
|
-
dgv.Rows[nowRow].Cells[4].Value = frmItem.txtRemarks.Text;
|
296
|
-
|
297
|
-
}
|
298
|
-
|
299
|
-
}
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
private void buttonChange_Click(object sender, EditorArgs e)
|
304
|
-
|
305
|
-
{
|
306
|
-
|
307
|
-
UpdateData();
|
308
|
-
|
309
|
-
}
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
private void 変更CToolStripMenuItem_Click(object sender, EditorArgs e)
|
314
|
-
|
315
|
-
{
|
316
|
-
|
317
|
-
UpdateData();
|
318
|
-
|
319
|
-
}
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
private void DeleteData()
|
324
|
-
|
325
|
-
{
|
326
|
-
|
327
|
-
int nowRow = DataGridView.CurrentRow.Index;
|
328
|
-
|
329
|
-
DataGridView.Rows.RemoveAt(nowRow); // 現在行を削除
|
330
|
-
|
331
|
-
}
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
private void buttonDelete_Click(object sender, EditorArgs e)
|
336
|
-
|
337
|
-
{
|
338
|
-
|
339
|
-
DeleteData();
|
340
|
-
|
341
|
-
}
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
private void buttonChange_Click(object sender, EditorArgs e)
|
346
|
-
|
347
|
-
{
|
348
|
-
|
349
|
-
DeleteData();
|
350
|
-
|
351
|
-
}
|
352
|
-
|
353
|
-
}
|
354
|
-
|
355
|
-
}
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
```家計簿アプリの作成をVisual StudioのC#で行なっております。
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
Month Calendar でCSVに既に登録されている日付を選択できなくし、既に登録されている日付を選択するとメッセージボックスが表示されるようにしたいです。
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
説明が不自由かも知れませんが、ご教示いただければと存じます。
|
3
現時点でのコードです。
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,362 @@
|
|
1
|
+
```C#
|
2
|
+
|
3
|
+
using System;
|
4
|
+
|
5
|
+
using System.Collections.Generic;
|
6
|
+
|
7
|
+
using System.ComponentModel;
|
8
|
+
|
9
|
+
using System.Data;
|
10
|
+
|
11
|
+
using System.Drawing;
|
12
|
+
|
13
|
+
using System.Linq;
|
14
|
+
|
15
|
+
using System.Text;
|
16
|
+
|
17
|
+
using System.Threading.Tasks;
|
18
|
+
|
19
|
+
using System.Windows.Forms;
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
namespace MyHouseKeepingBook
|
24
|
+
|
25
|
+
{
|
26
|
+
|
27
|
+
public partial class Form1 : Form
|
28
|
+
|
29
|
+
{
|
30
|
+
|
31
|
+
public Form1()
|
32
|
+
|
33
|
+
{
|
34
|
+
|
35
|
+
InitializeComponent();
|
36
|
+
|
37
|
+
}
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
private void buttonAdd_Click(object sender, EventArgs e)
|
42
|
+
|
43
|
+
{
|
44
|
+
|
45
|
+
AddData();
|
46
|
+
|
47
|
+
}
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
private void 追加AToolStripMenuItem_Click(object sender, EventArgs e)
|
52
|
+
|
53
|
+
{
|
54
|
+
|
55
|
+
AddData();
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
private void AddData()
|
62
|
+
|
63
|
+
{
|
64
|
+
|
65
|
+
ItemForm frmItem = new ItemForm(CategoryDataSet1);
|
66
|
+
|
67
|
+
DialogResult drRet = frmItem.ShowDialog();
|
68
|
+
|
69
|
+
if (drRet == DialogResult.OK)
|
70
|
+
|
71
|
+
{
|
72
|
+
|
73
|
+
moneyDataSet.moneyDataTable.AddmoneyDataTableRow(
|
74
|
+
|
75
|
+
frmItem.monCalendar.SelectionRange.Start,
|
76
|
+
|
77
|
+
frmItem.cmbCategory.Text,
|
78
|
+
|
79
|
+
frmItem.txtItem.Text,
|
80
|
+
|
81
|
+
int.Parse(frmItem.mtxtMoney.Text),
|
82
|
+
|
83
|
+
frmItem.txtRemarks.Text);
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
}
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
private void Form1_Load(object sender, EventArgs e)
|
92
|
+
|
93
|
+
{
|
94
|
+
|
95
|
+
LoadData();
|
96
|
+
|
97
|
+
categoryDataSet1.CategoryDataTable.AddCategoryDataTableRow("給料", "入金");
|
98
|
+
|
99
|
+
categoryDataSet1.CategoryDataTable.AddCategoryDataTableRow("食費", "出金");
|
100
|
+
|
101
|
+
categoryDataSet1.CategoryDataTable.AddCategoryDataTableRow("雑費", "出金");
|
102
|
+
|
103
|
+
categoryDataSet1.CategoryDataTable.AddCategoryDataTableRow("住居", "出金");
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
private void buttonEnd_Click(object sender, EventArgs e)
|
110
|
+
|
111
|
+
{
|
112
|
+
|
113
|
+
this.Close();
|
114
|
+
|
115
|
+
}
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
private void 終了XToolStripMenuItem_Click(object sender, EventArgs e)
|
120
|
+
|
121
|
+
{
|
122
|
+
|
123
|
+
this.Close();
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
private void SaveData()
|
130
|
+
|
131
|
+
{
|
132
|
+
|
133
|
+
string path = "MoneyData.csv"; //出力ファイル名
|
134
|
+
|
135
|
+
string strData = ""; //一行分のデータ
|
136
|
+
|
137
|
+
System.IO.StreamWriter sw = new System.IO.StreamWriter(
|
138
|
+
|
139
|
+
path,
|
140
|
+
|
141
|
+
false,
|
142
|
+
|
143
|
+
System.Text.Encoding.Default);
|
144
|
+
|
145
|
+
foreach (MoneyDataSet.moneyDataTableRow drMoney
|
146
|
+
|
147
|
+
in moneyDataSet.moneyDataTable)
|
148
|
+
|
149
|
+
{
|
150
|
+
|
151
|
+
strData = drMoney.日付.ToShortDataString() + ","
|
152
|
+
|
153
|
+
+ drMoney.分類 + ","
|
154
|
+
|
155
|
+
+ drMoney.品目 + ","
|
156
|
+
|
157
|
+
+ drMoney.金額.ToString() + ","
|
158
|
+
|
159
|
+
+ drMoney.備考;
|
160
|
+
|
161
|
+
sw.WriteLine(strData);
|
162
|
+
|
163
|
+
}
|
164
|
+
|
165
|
+
sw.Close();
|
166
|
+
|
167
|
+
}
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
private void 保存SToolStripMenuItem_Click(object sender, EditorArgs e)
|
172
|
+
|
173
|
+
{
|
174
|
+
|
175
|
+
SaveData();
|
176
|
+
|
177
|
+
}
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
private void form1_FormClosing(object sender, FormClosingEditorArgs e)
|
182
|
+
|
183
|
+
{
|
184
|
+
|
185
|
+
SaveData();
|
186
|
+
|
187
|
+
}
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
private void LoadData()
|
192
|
+
|
193
|
+
{
|
194
|
+
|
195
|
+
string path = "MoneyData.csv"; //入力ファイル名
|
196
|
+
|
197
|
+
string delimStr = ","; // 区切り文字
|
198
|
+
|
199
|
+
char[] delimiter = delimStr.ToCharArray(); // 区切り文字をまとめる
|
200
|
+
|
201
|
+
string[] strLine; // 分解後の文字の入れ物
|
202
|
+
|
203
|
+
string strLine; // 一行分のデータ
|
204
|
+
|
205
|
+
bool fileExists = System.IO.File.Exists(path);
|
206
|
+
|
207
|
+
if (fileExists)
|
208
|
+
|
209
|
+
{
|
210
|
+
|
211
|
+
System.IO.StreamReader sr = new System.IO.StreamReader(
|
212
|
+
|
213
|
+
path,
|
214
|
+
|
215
|
+
System.Text.Encoding.Default);
|
216
|
+
|
217
|
+
while (sr.Peek() >= 0)
|
218
|
+
|
219
|
+
{
|
220
|
+
|
221
|
+
strLine = sr.ReadLine();
|
222
|
+
|
223
|
+
strData = strLine.Splite(delimiter);
|
224
|
+
|
225
|
+
moneyDataSet.moneyDataTable.AddmoneyDataTableRow(
|
226
|
+
|
227
|
+
DateTime.Parse(strData[0]),
|
228
|
+
|
229
|
+
strData[1],
|
230
|
+
|
231
|
+
strData[2],
|
232
|
+
|
233
|
+
int, Parse(strData[3]),
|
234
|
+
|
235
|
+
strData[4];
|
236
|
+
|
237
|
+
}
|
238
|
+
|
239
|
+
sr.Close;
|
240
|
+
|
241
|
+
}
|
242
|
+
|
243
|
+
}
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
private void UpdateData()
|
248
|
+
|
249
|
+
{
|
250
|
+
|
251
|
+
int nowRow = dgv.CurrentRow, Index;
|
252
|
+
|
253
|
+
DateTime oldDate
|
254
|
+
|
255
|
+
= DateTime.Parse(dgv.Rows[nowRow].Cell[0].Value.ToString());
|
256
|
+
|
257
|
+
string oldCategory = dgv.Rows[nowRow].Cell[1].Value.ToString();
|
258
|
+
|
259
|
+
string oldItem = dgv.Rows[nowRow].Cell[2].Value.ToString();
|
260
|
+
|
261
|
+
int oldMoney
|
262
|
+
|
263
|
+
= int.Parse(dgv.Rows[nowRow].Cells[3].Value.ToString());
|
264
|
+
|
265
|
+
string oldRemarks = dgv.Rows[nowRow].Cells[4].Value.ToString();
|
266
|
+
|
267
|
+
ItemForm frmItem = newItemForm(categoryDataSet1,
|
268
|
+
|
269
|
+
oldDate,
|
270
|
+
|
271
|
+
oldCategory,
|
272
|
+
|
273
|
+
oldItem,
|
274
|
+
|
275
|
+
oldMoney,
|
276
|
+
|
277
|
+
oldRemarks);
|
278
|
+
|
279
|
+
DialogResult draRet = frmItem.ShowDialog();
|
280
|
+
|
281
|
+
if (draRet == DialogResult.OK)
|
282
|
+
|
283
|
+
{
|
284
|
+
|
285
|
+
dgv.Rows[nowRow].Cells[0].Value
|
286
|
+
|
287
|
+
= frmItem.monCalendar.SelectionRangr.Start;
|
288
|
+
|
289
|
+
dgv.Rows[nowRow].Cells[1].Value = frmItem.cmbCategory.Text;
|
290
|
+
|
291
|
+
dgv.Rows[nowRow].Cells[2].Value = frmItem.txtItem.Text;
|
292
|
+
|
293
|
+
dgv.Rows[nowRow].Cells[3].Value = int.Parse.(frmItem.mtxtMoney.Text);
|
294
|
+
|
295
|
+
dgv.Rows[nowRow].Cells[4].Value = frmItem.txtRemarks.Text;
|
296
|
+
|
297
|
+
}
|
298
|
+
|
299
|
+
}
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
private void buttonChange_Click(object sender, EditorArgs e)
|
304
|
+
|
305
|
+
{
|
306
|
+
|
307
|
+
UpdateData();
|
308
|
+
|
309
|
+
}
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
private void 変更CToolStripMenuItem_Click(object sender, EditorArgs e)
|
314
|
+
|
315
|
+
{
|
316
|
+
|
317
|
+
UpdateData();
|
318
|
+
|
319
|
+
}
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
private void DeleteData()
|
324
|
+
|
325
|
+
{
|
326
|
+
|
327
|
+
int nowRow = DataGridView.CurrentRow.Index;
|
328
|
+
|
329
|
+
DataGridView.Rows.RemoveAt(nowRow); // 現在行を削除
|
330
|
+
|
331
|
+
}
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
private void buttonDelete_Click(object sender, EditorArgs e)
|
336
|
+
|
337
|
+
{
|
338
|
+
|
339
|
+
DeleteData();
|
340
|
+
|
341
|
+
}
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
private void buttonChange_Click(object sender, EditorArgs e)
|
346
|
+
|
347
|
+
{
|
348
|
+
|
349
|
+
DeleteData();
|
350
|
+
|
351
|
+
}
|
352
|
+
|
353
|
+
}
|
354
|
+
|
355
|
+
}
|
356
|
+
|
357
|
+
|
358
|
+
|
1
|
-
家計簿アプリの作成をVisual StudioのC#で行なっております。
|
359
|
+
```家計簿アプリの作成をVisual StudioのC#で行なっております。
|
2
360
|
|
3
361
|
|
4
362
|
|
2
test
CHANGED
File without changes
|
test
CHANGED
@@ -8,4 +8,6 @@
|
|
8
8
|
|
9
9
|
|
10
10
|
|
11
|
+
|
12
|
+
|
11
13
|
説明が不自由かも知れませんが、ご教示いただければと存じます。
|
1
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
Visual Studio
|
1
|
+
家計簿アプリの作成をVisual StudioのC#で行なっております。
|
2
|
+
|
3
|
+
|
2
4
|
|
3
5
|
|
4
6
|
|