Advertisement
Guest User

panel

a guest
Mar 28th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.38 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11.  
  12. namespace WindowsFormsApp1
  13. {
  14.     public partial class Form1 : Form
  15.     {
  16.         List<user> u = new List<user>();
  17.         user User = new user();
  18.  
  19.         public Form1()
  20.         {
  21.             InitializeComponent();
  22.  
  23.             u.Add(new user("admin", "abc123", true));
  24.             u.Add(new user("mg", "xyz123", true));
  25.             u.Add(new user("pwsip", "informatyka", false));
  26.         }
  27.  
  28.         private void button_Zaloguj_Click(object sender, EventArgs e)
  29.         {
  30.             string maskPassword = User.encryptPassword(textBox_PASSWORD.Text);
  31.             //zmienna w której przechowujemy wprowadzone hasło i przekazujemy haslo do porownywacza
  32.             foreach (user us in u)
  33.             {
  34.                 if (us.UserName == textBox_LOGIN.Text && us.checkPassword(maskPassword))
  35.                 {
  36.                     Form2 okno = new Form2(this, us.UserName, us.isAdmin);
  37.                     okno.Show();
  38.                     this.Hide();
  39.                 }
  40.                 else if (us.UserName != textBox_LOGIN.Text && us.checkPassword(maskPassword))
  41.                 {
  42.                     //MessageBox.Show("Sprawdź login lub hasło i spróbuj jeszcze raz.", "Błąd logowania");
  43.                     textBox_LOGIN.Clear();
  44.                     textBox_PASSWORD.Clear();
  45.                 }
  46.  
  47.             }
  48.             if (textBox_LOGIN.Text != "admin" && textBox_LOGIN.Text != "mg" && textBox_LOGIN.Text != "pwsip")
  49.             {
  50.                 MessageBox.Show("Sprawdź login lub hasło i spróbuj jeszcze raz.", "Błąd logowania");
  51.                 textBox_LOGIN.Clear();
  52.                 textBox_PASSWORD.Clear();
  53.             }
  54.  
  55.         }
  56.  
  57.         private void button_Zamknij_Click(object sender, EventArgs e)
  58.         {
  59.             this.Close();
  60.         }
  61.  
  62.         private void Form1_Load(object sender, EventArgs e)
  63.         {
  64.  
  65.         }
  66.  
  67.         private void textBox_LOGIN_TextChanged(object sender, EventArgs e)
  68.         {
  69.  
  70.         }
  71.        
  72.         private void textBox_PASSWORD_TextChanged(object sender, EventArgs e)
  73.         {
  74.             textBox_PASSWORD.PasswordChar = '*';
  75.         }
  76.  
  77.        
  78.     }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement