-
Notifications
You must be signed in to change notification settings - Fork 0
/
FormCreateBudget.cs
71 lines (58 loc) · 1.5 KB
/
FormCreateBudget.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using System.Windows.Forms;
using Trip_Budget_Tracker.Models.Services;
using Trip_Expense_Tracker;
using Trip_Expense_Tracker.Models.Dto;
using Trip_Expense_Tracker.Models.Interfaces;
using Trip_Expense_Tracker.Models.Repositories;
namespace Trip_Budget_Tracker
{
public partial class FormCreateBudget : Form,IDataContainer
{
public FormCreateBudget()
{
InitializeComponent();
this.Load += FormCreateBudget_Load;
this.buttonSave.Click += ButtonSave_Click;
}
private void FormCreateBudget_Load(object sender, EventArgs e)
{
this.Text = "新增預算項目";
this.FormBorderStyle = FormBorderStyle.Fixed3D;
this.MaximizeBox = false;
}
private IBudgetRepository GetRepo()
{
return new BudgetEFRepo();
}
private void ButtonSave_Click(object sender, EventArgs e)
{
BudgetDto dto = new BudgetDto()
{
Name = textBox1.Text,
Budgno = int.TryParse(textBox2.Text, out int value) ? value : 0
};
int newData = new BudgetService(GetRepo()).Create(dto);
MessageBox.Show($"預算項目已更新!");
var container = this.Owner as IDataContainer;
if (container != null)
{
container.Display();
this.DialogResult = DialogResult.OK;
}
else
{
MessageBox.Show("Owner 表單沒有實作IDateContainerur介面");
this.DialogResult = DialogResult.OK;
}
}
public void Display()
{
throw new NotImplementedException();
}
public void Balance(decimal totalAmount)
{
throw new NotImplementedException();
}
}
}