added "UserPermissionTesting_CS_WinForms" project

This commit is contained in:
Atakan Kayman
2026-05-31 15:08:26 +03:00
parent 1ea9de0042
commit 374067dd2e
26 changed files with 2213 additions and 427 deletions
@@ -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 = "👁";
}
}
}
}