private void goBackButton_Click(object sender, EventArgs e) { AdminStartForm form = new AdminStartForm(); form.Show(); this.Hide(); }
private void LoginButton_Click(object sender, EventArgs e) { progressBar1.Visible = true; progressBar1.Value = 0; authorisationErrorLabel.Visible = false; progressBar1.Visible = true; for (int i = 0; i < 100; i++) { progressBar1.Value++; Thread.Sleep(10); } using (MyDbContext db = new MyDbContext()) { string login = LoginTextBox.Text; string password = PasswordTextBox.Text; // Authorization procession. Is user registered? User authorising = db.Users.SingleOrDefault(u => u.Login == login); // Error processing. Wrong password or login if (authorising == null || !PasswordHasher.Verify(password, authorising.PassWord)) { authorisationErrorLabel.Visible = true; progressBar1.Visible = false; return; } // Authorization processing if (authorising.Status == "admin") { CurrentUser.Set(authorising); AdminStartForm form = new AdminStartForm(); form.Show(); progressBar1.Visible = false; Hide(); } // Authorization processing if (authorising.Status == "user") { CurrentUser.Set(authorising); UserStartForm form = new UserStartForm(); form.Show(); progressBar1.Visible = false; Hide(); } } return; }