-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathLoginForm.cs
More file actions
37 lines (35 loc) · 1.67 KB
/
Copy pathLoginForm.cs
File metadata and controls
37 lines (35 loc) · 1.67 KB
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
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Security;
using DevExpress.XtraEditors;
namespace WindowsFormsApplication {
public partial class LoginForm : DevExpress.XtraEditors.XtraForm {
private SecurityStrategyComplex security;
private IObjectSpaceProvider objectSpaceProvider;
public LoginForm(SecurityStrategyComplex security, IObjectSpaceProvider objectSpaceProvider, string userName) {
InitializeComponent();
this.security = security;
this.objectSpaceProvider = objectSpaceProvider;
this.userNameEdit.Text = userName;
}
private void Login_Click(object sender, EventArgs e) {
IObjectSpace logonObjectSpace = objectSpaceProvider.CreateObjectSpace();
string userName = userNameEdit.Text;
string password = passwordEdit.Text;
security.Authentication.SetLogonParameters(new AuthenticationStandardLogonParameters(userName, password));
try {
security.Logon(logonObjectSpace);
DialogResult = DialogResult.OK;
}
catch(Exception ex) {
XtraMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void Cancel_Click(object sender, EventArgs e) {
Application.Exit();
}
private void UserNameEdit_Validating(object sender, System.ComponentModel.CancelEventArgs e) {
string message = string.IsNullOrEmpty(userNameEdit.Text) ? "The user name must not be empty. Try Admin or User." : string.Empty;
dxErrorProvider1.SetError(userNameEdit, message);
}
}
}