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.Windows.Forms;
- namespace projekt2
- {
- public partial class Main : Form
- {
- public Main()
- {
- InitializeComponent();
- CreateUsers();
- }
- AdminPanel _AdminPanel;
- string[,] userdata = new string[3, 2];
- private void CreateUsers()
- {
- userdata[0, 0] = "jan";
- userdata[0, 1] = "abc123";
- userdata[1, 0] = "adm";
- userdata[1, 1] = "123456";
- userdata[2, 0] = "admin";
- userdata[2, 1] = "12345";
- }
- private void Main_Load(object sender, EventArgs e)
- {
- }
- private void textBox2_TextChanged(object sender, EventArgs e)
- {
- }
- private void label2_Click(object sender, EventArgs e)
- {
- }
- private void button1_Click(object sender, EventArgs e)
- {
- if (textBox1.Text.Length == 0)
- {
- textBox1.Focus();
- return;
- }
- if (textBox2.Text.Length == 0)
- {
- textBox2.Focus();
- return;
- }
- auth(textBox1.Text, textBox2.Text);
- }
- private void button2_Click(object sender, EventArgs e)
- {
- Close();
- }
- private void auth(string user, string password)
- {
- for (int i = 0; i < userdata.GetLength(0); i++)
- {
- //trzecie okno, rozszerzenie tablicy, warunek (5 uzytkownikow, 2 administratorow)
- if(user == userdata[i, 0] && password == userdata[i,1])
- if ((_AdminPanel =
- (AdminPanel)checkifwinopen(typeof(AdminPanel))) == null)
- {
- _AdminPanel = new AdminPanel();
- _AdminPanel.Show();
- }
- else _AdminPanel.BringToFront();
- break;
- }
- }
- private Form checkifwinopen(Type FormType)
- {
- foreach (Form OpenForm in Application.OpenForms)
- {
- if (OpenForm.GetType() == FormType) return OpenForm;
- }
- return null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement