This repository has been archived by the owner on May 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
frmLogin.cs
62 lines (56 loc) · 1.8 KB
/
frmLogin.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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using foi.pi;
namespace PutniNalozi.NET
{
public partial class frmLogin : Form
{
// set piLoginInstance property to frmLogin class
Login piLogin;
public frmLogin(Login piLoginInstance)
{
InitializeComponent();
this.piLogin = piLoginInstance;
}
private void btnLogin_Click(object sender, EventArgs e)
{
// fetch user information from text fields
string username = txtUsername.Text;
string password = txtPassword.Text;
// run authentication against database
iUser tmpUser = piLogin.Authenticate(username, password);
// check authentication result
if (tmpUser == null)
{
// notify user that login failed
((frmMain)this.ParentForm).writeToStatus("Login failed!", 3000);
// focus text input on username
txtUsername.Focus();
txtUsername.SelectAll();
}
else
{
// notify user that login failed
((frmMain)this.ParentForm).writeToStatus("Login suceed!", 3000);
// set this user as current_user
((frmMain)this.ParentForm).setLoggedUser(tmpUser);
// unload form
this.Close();
}
}
private void txtPassword_Enter(object sender, EventArgs e)
{
txtPassword.SelectAll();
}
private void txtUsername_Enter(object sender, EventArgs e)
{
txtUsername.SelectAll();
}
}
}