-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainForm.cs
82 lines (69 loc) · 2.24 KB
/
MainForm.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
71
72
73
74
75
76
77
78
79
80
81
82
using System;
using System.Windows.Forms;
using System.Data.Objects;
namespace Finance
{
public partial class MainForm : Form
{
FinanceEntities db;
FinanceBrowser fb;
public MainForm()
{
InitializeComponent();
}
private void MainForm_Load(object sender, EventArgs e)
{
txtUsername.Text = "ttester414@yahoo.com";
txtPassword.Text = "123456";
lblCookies.Text = string.Empty;
db = new FinanceEntities();
fb = new FinanceBrowser(db);
fb.DataDownloaded += new FinanceBrowser.EventHandler(fb_DataDownloaded);
fb.Authenticated += new FinanceBrowser.EventHandler(fb_Authenticated);
ObjectSet<Symbol> symbols = db.Symbols;
symbolBindingSource.DataSource = symbols;
SetDatumSource();
}
void fb_Authenticated(object sender, EventArgs args)
{
lblCookies.Text = "Authenticated";
}
void fb_DataDownloaded(object sender, EventArgs args)
{
SetDatumSource();
}
private void SetDatumSource()
{
FinanceEntities datumDb = new FinanceEntities();
ObjectSet<Datum> datum = datumDb.Data;
datumBindingSource.DataSource = datum;
datumBindingSource.ResetBindings(false);
}
private void btnUpdate_Click(object sender, EventArgs e)
{
try
{
db.SaveChanges();
MessageBox.Show("Changes Saved", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void btnAuthenticate_Click(object sender, EventArgs e)
{
fb.Login = txtUsername.Text;
fb.Password = txtPassword.Text;
fb.Authenticate();
}
private void btnGetData_Click(object sender, EventArgs e)
{
fb.DownloadData();
}
private void btnRefresh_Click(object sender, EventArgs e)
{
fb.StopDownloading();
}
}
}