Skocz do zawartości

Piootrek

Użytkownicy
  • Postów

    1
  • Dołączył

  • Ostatnia wizyta

Osiągnięcia Piootrek

Chicken

Chicken (1/13)

0

Reputacja

  1. Witam, dopiero zaczynam z programowaniem i mam problem.. Muszę zrobić logowanie 10 użytkowników z tabeli z tego co znalazłem to mam na pętli if.. Ma wyświtlać okienka z rangami np admin ze "zalogował sie admin' i drugie wtedy okienko witamy adminie np. a jak zwykly uz to jedno okienko Ktoś potrafi pomóc? using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace logowanie { public partial class Form1 : Form { private object stRole; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { string uzytkownik = textBox1.Text; string haslo = textBox2.Text; if (SprawdzNazweiHaslo(uzytkownik, haslo)) { MessageBox.Show("Poprawne zalogowanie", "Zalogowano"); } else { MessageBox.Show("Niepoprawna nazwa użytkownika lub hasło", "Błąd logowania"); return; } } public bool SprawdzNazweiHaslo(string uzytkownik, string haslo) { if (uzytkownik == "Admin" & haslo == "admin") { MessageBox.Show("Administrator zalogowany"); return true; } if (uzytkownik == "Michal" & haslo == "michal") return true; if (uzytkownik == "Anna" & haslo == "anna") return true; if (uzytkownik == "Barbara" & haslo == "barbara") return true; if (uzytkownik == "Maria" & haslo == "maria") return true; if (uzytkownik == "Agata" & haslo == "agata") return true; if (uzytkownik == "Justyna" & haslo == "justyna") return true; if (uzytkownik == "Wojtek" & haslo == "wojtek") return true; if (uzytkownik == "Krzysztof" & haslo == "krzysztof") return true; if (uzytkownik == "Karol" & haslo == "karol") return true; else return false; } private void button2_Click(object sender, EventArgs e) { Application.Exit(); } } } \ I wiem że tak to ma mniej wiecej wygladac: public Form1() { InitializeComponent(); CreateUsers(); } AdminPanel _AdminPanel; NormalUser _NormalUser; string[,] tableuser = new string[4, 2]; private void CreateUsers() { tableuser[0, 0] = "admin"; tableuser[0, 1] = "12345"; tableuser[1, 0] = "user"; tableuser[1, 1] = "12345"; tableuser[2, 0] = "user"; tableuser[2, 1] = "12345"; }
×
×
  • Dodaj nową pozycję...