Mercurial > pub > bltoolkit
comparison Demo/WinForms/Forms/MainForm.cs @ 0:f990fcb411a9
Копия текущей версии из github
author | cin |
---|---|
date | Thu, 27 Mar 2014 21:46:09 +0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f990fcb411a9 |
---|---|
1 using System; | |
2 using System.Windows.Forms; | |
3 | |
4 using BLToolkit.Demo.ObjectModel; | |
5 using BLToolkit.Demo.BusinessLogic; | |
6 | |
7 namespace BLToolkit.Demo.Forms | |
8 { | |
9 public partial class MainForm : Form | |
10 { | |
11 public MainForm() | |
12 { | |
13 InitializeComponent(); | |
14 | |
15 personBinder.List = new PersonManager().SelectAll(); | |
16 } | |
17 | |
18 private void Edit(Person person) | |
19 { | |
20 EditPersonForm.Edit(person, delegate(Person p) | |
21 { | |
22 new PersonManager().Update(p); | |
23 }); | |
24 } | |
25 | |
26 private void personGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e) | |
27 { | |
28 DataGridViewRow row = personGridView.Rows[e.RowIndex]; | |
29 | |
30 Edit((Person)row.DataBoundItem); | |
31 } | |
32 | |
33 private void edit_Click(object sender, EventArgs e) | |
34 { | |
35 if (personGridView.CurrentRow != null) | |
36 Edit((Person)personGridView.CurrentRow.DataBoundItem); | |
37 } | |
38 | |
39 private void new_Click(object sender, EventArgs e) | |
40 { | |
41 Person person = EditPersonForm.EditNew(delegate(Person p) | |
42 { | |
43 new PersonManager().Insert(p); | |
44 }); | |
45 | |
46 if (person != null) | |
47 personBinder.List.Add(person); | |
48 } | |
49 | |
50 private void delete_Click(object sender, EventArgs e) | |
51 { | |
52 if (personGridView.CurrentRow != null) | |
53 { | |
54 Person person = (Person)personGridView.CurrentRow.DataBoundItem; | |
55 | |
56 try | |
57 { | |
58 UseWaitCursor = true; | |
59 new PersonManager().Delete(person); | |
60 UseWaitCursor = false; | |
61 | |
62 personBinder.List.Remove(person); | |
63 } | |
64 catch (Exception ex) | |
65 { | |
66 UseWaitCursor = false; | |
67 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); | |
68 } | |
69 } | |
70 } | |
71 | |
72 private void exit_Click(object sender, EventArgs e) | |
73 { | |
74 Close(); | |
75 } | |
76 } | |
77 } |