Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace WindowsFormsApp1
- {
- public partial class Form1 : Form
- {
- List<user> u = new List<user>();
- user User = new user();
- public Form1()
- {
- InitializeComponent();
- u.Add(new user("admin", "abc123", true));
- u.Add(new user("mg", "xyz123", true));
- u.Add(new user("pwsip", "informatyka", false));
- }
- private void button_Zaloguj_Click(object sender, EventArgs e)
- {
- string maskPassword = User.encryptPassword(textBox_PASSWORD.Text);
- //zmienna w której przechowujemy wprowadzone hasło i przekazujemy haslo do porownywacza
- foreach (user us in u)
- {
- if (us.UserName == textBox_LOGIN.Text && us.checkPassword(maskPassword))
- {
- Form2 okno = new Form2(this, us.UserName, us.isAdmin);
- okno.Show();
- this.Hide();
- }
- else if (us.UserName != textBox_LOGIN.Text && us.checkPassword(maskPassword))
- {
- //MessageBox.Show("Sprawdź login lub hasło i spróbuj jeszcze raz.", "Błąd logowania");
- textBox_LOGIN.Clear();
- textBox_PASSWORD.Clear();
- }
- }
- if (textBox_LOGIN.Text != "admin" && textBox_LOGIN.Text != "mg" && textBox_LOGIN.Text != "pwsip")
- {
- MessageBox.Show("Sprawdź login lub hasło i spróbuj jeszcze raz.", "Błąd logowania");
- textBox_LOGIN.Clear();
- textBox_PASSWORD.Clear();
- }
- }
- private void button_Zamknij_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void textBox_LOGIN_TextChanged(object sender, EventArgs e)
- {
- }
- private void textBox_PASSWORD_TextChanged(object sender, EventArgs e)
- {
- textBox_PASSWORD.PasswordChar = '*';
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement