-
Notifications
You must be signed in to change notification settings - Fork 80
/
MainForm.cs
44 lines (43 loc) · 1.68 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
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Security;
namespace WindowsFormsApplication {
public partial class MainForm : DevExpress.XtraBars.Ribbon.RibbonForm {
public SecurityStrategyComplex Security { get; set; }
public IObjectSpaceProvider ObjectSpaceProvider { get; set; }
public MainForm(SecurityStrategyComplex security, IObjectSpaceProvider objectSpaceProvider) {
InitializeComponent();
Security = security;
ObjectSpaceProvider = objectSpaceProvider;
}
private void MainForm_Load(object sender, EventArgs e) {
ShowLoginForm();
}
private void LogoutButtonItem_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) {
foreach(Form form in MdiChildren) {
form.Close();
}
string userName = Security.UserName;
Security.Logoff();
Hide();
ShowLoginForm(userName);
}
private void ShowLoginForm(string userName = "User") {
using(LoginForm loginForm = new LoginForm(Security, ObjectSpaceProvider, userName)) {
DialogResult dialogResult = loginForm.ShowDialog();
if(dialogResult == DialogResult.OK) {
CreateListForm();
Show();
}
else {
Close();
}
}
}
private void CreateListForm() {
EmployeeListForm employeeForm = new EmployeeListForm();
employeeForm.MdiParent = this;
employeeForm.WindowState = FormWindowState.Maximized;
employeeForm.Show();
}
}
}