added "UserPermissionTesting_CS_WinForms" project
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace UserPermissionTest_CS_WinForms
|
||||
{
|
||||
public partial class LoginDialog : Form
|
||||
{
|
||||
public LoginDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void btnLogin_Click(object sender, EventArgs e)
|
||||
{
|
||||
lblError.Visible = false;
|
||||
string username = txtUsername.Text.Trim();
|
||||
string password = txtPassword.Text;
|
||||
|
||||
if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
|
||||
{
|
||||
lblError.Text = "Please fill in all fields.";
|
||||
lblError.Visible = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (SessionManager.Login(username, password))
|
||||
{
|
||||
this.DialogResult = DialogResult.OK;
|
||||
this.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
lblError.Text = "Invalid username or password!";
|
||||
lblError.Visible = true;
|
||||
txtPassword.Clear();
|
||||
txtPassword.Focus();
|
||||
}
|
||||
}
|
||||
|
||||
private void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void btnTogglePassword_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (txtPassword.PasswordChar == '•')
|
||||
{
|
||||
txtPassword.PasswordChar = '\0'; // Show password
|
||||
btnTogglePassword.Text = "🙈";
|
||||
}
|
||||
else
|
||||
{
|
||||
txtPassword.PasswordChar = '•'; // Mask password
|
||||
btnTogglePassword.Text = "👁";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user