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.Tasks;
- using System.Windows.Forms;
- using System.IO;
- namespace Shell
- {
- public partial class Form1 : Form
- {
- bool insystem, error;
- string login, password, state, access;
- string[] rights;
- string[][] tabrights = new string [10][];
- string[] a;
- int user, cursor;
- int x, t;
- public void verify()
- {
- errorlabel.Visible = false;
- textBox1.Visible = true;
- button1.Visible = true;
- label1.Visible = true;
- x = (new Random()).Next(10);
- label1.Text = x.ToString();
- }
- public void show()
- {
- }
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- state = "unsigned";
- a = Directory.GetDirectories(@"D:\TZI");
- for (int i = 0; i < a.Length; i++)
- {
- a[i] = a[i].Substring(7);
- }
- rights = File.ReadAllLines(@"D:\TZI\S\users.txt");
- for (int i=0 ; i< rights.Length ; i++)
- {
- tabrights[i] = rights[i].Split(' ');
- }
- }
- private void textBox2_TextChanged(object sender, EventArgs e)
- {
- }
- private void button1_Click(object sender, EventArgs e)
- {
- login = Loginfield.Text;
- password = Passwordfield.Text;
- for (int i=0; i<rights.Length; i++)
- {
- if (tabrights[i][0] == login)
- {
- if (tabrights[i][1] == password)
- {
- /*state = login;
- Statelabel.Text = state; */
- error = false;
- errorlabel.Visible = error;
- textBox1.Visible = true;
- button1.Visible = true;
- label1.Visible = true;
- x = (new Random()).Next(10);
- label1.Text = x.ToString();
- user = i;
- break;
- }
- else
- {
- errorlabel.Text = "Wrong password";
- error = true;
- errorlabel.Visible = error;
- Loginfield.Text = null;
- Passwordfield.Text = null;
- //func();
- break;
- }
- }
- else
- {
- errorlabel.Text = "Login not found";
- error = true;
- errorlabel.Visible = error;
- Loginfield.Text = null;
- Passwordfield.Text = null;
- }
- }
- loginbutton.Visible = (state == "unsigned");
- Loginlabel.Visible = (state == "unsigned");
- Loginfield.Visible = (state == "unsigned");
- Passwordfield.Visible = (state == "unsigned");
- Passwordlabel.Visible = (state == "unsigned");
- logoutbutton.Visible = !(state == "unsigned");
- }
- private void button2_Click(object sender, EventArgs e)
- {
- state = "unsigned";
- Loginfield.Text = null;
- Passwordfield.Text = null;
- Statelabel.Text = state;
- folderlist.Items.Clear();
- loginbutton.Visible = (state == "unsigned");
- Loginlabel.Visible = (state == "unsigned");
- Loginfield.Visible = (state == "unsigned");
- Passwordfield.Visible = (state == "unsigned");
- Passwordlabel.Visible = (state == "unsigned");
- logoutbutton.Visible = !(state == "unsigned");
- accesslabel.Visible = false;
- folderlist.Visible = false;
- Folderslabel.Visible = false;
- }
- private void button3_Click(object sender, EventArgs e)
- {
- }
- private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
- cursor = folderlist.SelectedIndex;
- if (access.Contains(a[cursor]))
- {
- accesslabel.Text = "access granted";
- accesslabel.ForeColor = System.Drawing.Color.Green;
- accesslabel.Visible = true;
- }
- else
- {
- accesslabel.Text = "access denied";
- accesslabel.ForeColor = System.Drawing.Color.Red;
- accesslabel.Visible = true;
- }
- }
- private void button1_Click_1(object sender, EventArgs e)
- {
- int f = 2 * x + 3;
- if (textBox1.Text == f.ToString())
- {
- state = tabrights[user][0];
- access = tabrights[user][2];
- folderlist.Items.AddRange(a);
- folderlist.Visible = true;
- Folderslabel.Visible = true;
- textBox1.Visible = false;
- button1.Visible = false;
- label1.Visible = false;
- loginbutton.Visible = (state == "unsigned");
- Loginlabel.Visible = (state == "unsigned");
- Loginfield.Visible = (state == "unsigned");
- Passwordfield.Visible = (state == "unsigned");
- Passwordlabel.Visible = (state == "unsigned");
- logoutbutton.Visible = !(state == "unsigned");
- Statelabel.Text = state;
- insystem = true;
- t = 10;
- }
- else
- {
- errorlabel.Text = "wrong function";
- textBox1.Visible = false;
- button1.Visible = false;
- label1.Visible = false;
- }
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- if (insystem && t>0)
- {
- t -= 1;
- }
- else
- {
- insystem = false;
- verify();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement