private void Window_Loaded(object sender, RoutedEventArgs e) { //記帳本方面 // 開檔 string[] lines = System.IO.File.ReadAllLines(@"D:\temp\money.txt"); foreach (string line in lines) { // 用 | 符號拆開 string[] parts = line.Split('|'); // 建立 costbook costbook item = new costbook(); item.date.Text = parts[1]; item.thing.Text = parts[2]; item.number.Text = parts[3]; Todolist.Children.Add(item); } int sum = 0; foreach (costbook item in Todolist.Children) { sum += int.Parse(item.number.Text); SUMBOX.Text = sum.ToString(); } //日記方面 //開檔 string[] Lines = System.IO.File.ReadAllLines(@"D:\temp\dairy.txt"); foreach (string Line in Lines) { // 用 | 符號拆開 string[] parts = Line.Split('|'); // 建立 dairy dairy Item = new dairy(); Item.day.Text = parts[1]; Item.notebook.Text = parts[2]; word.Children.Add(Item); } }
// 增加新的記帳事項 private void plus_Click(object sender, RoutedEventArgs e) { costbook item = new costbook(); Todolist.Children.Add(item); }