private void LoginCheck() { bool success = false; string line; bool admin = false; StreamReader file = new StreamReader("users.txt"); while ((line = file.ReadLine()) != null) { string[] podaci = line.Split(','); if ((username == podaci[0]) && (password == podaci[1])) { if (podaci[2] == "admin") { admin = true; } MessageBox.Show("Uspesan login!"); success = true; id = int.Parse(podaci[8]); } } file.Close(); if (success) { if (admin) { k = new Administrator(username, password); Form frm = new AdministratorForm(); frm.Show(); this.Hide(); //Otvara se forma za administratora. } else { k = new Kupac(username, password); UserForm frm = new UserForm(); frm.LoadUsernamePassword(username, password, id); frm.Show(); this.Hide(); //Otvara se forma za korisnika. } } else { MessageBox.Show("Neuspesan login. Pokusajte ponovo."); } textBox1.Clear(); textBox2.Clear(); }
private void CheckLogin() { bool success = false; string line; bool admin = false; StreamReader file = new StreamReader("users.txt"); while ((line = file.ReadLine()) != null) { string[] podaci = line.Split(','); if ((username == podaci[0]) && (password == podaci[1])) { if (podaci[2].Equals("admin")) { admin = true; MessageBox.Show("Admin"); } MessageBox.Show("Uspesno"); success = true; } } file.Close(); if (success) { if (admin) { k = new Administrator(username, password); Form frm = new AdministratorForm(); frm.Show(); this.Hide(); //FORMA ADMIN } } else { MessageBox.Show(username, password); k = new Kupac(username, password); Form frm = new UserForm(); frm.Show(); this.Hide(); //FORMA KORISNIK } }