private void buttonLogin_Click(object sender, EventArgs e) { bool admin = false; if (textBoxLogin.Text == "admin" || textBoxLogin.Text == "Admin") { admin = true; FormAdmin formAdmin = new FormAdmin(); this.Hide(); this.textBoxLogin.Text = ""; this.textBoxPassword.Text = ""; formAdmin.FormClosed += (send, args) => this.Show(); formAdmin.Show(); } else { admin = false; FormGeneral formGeneral = new FormGeneral(); this.Hide(); this.textBoxLogin.Text = ""; this.textBoxPassword.Text = ""; formGeneral.FormClosed += (send, args) => this.Show(); formGeneral.Show(); } }
private void buttonLogin_Click(object sender, EventArgs e) { bool correctUser = false; bool admin = false; string result = this.connector.CheckUser(textBoxLogin.Text, textBoxPassword.Text); if (result == "admin") { correctUser = true; admin = true; } else if (result == "general") { correctUser = true; admin = false; } if (correctUser && admin) { FormAdmin formAdmin = new FormAdmin(this.connector, true); this.Hide(); this.textBoxLogin.Text = ""; this.textBoxPassword.Text = ""; formAdmin.FormClosed += (send, args) => this.Show(); formAdmin.Show(); } else if (correctUser && !admin) { FormAdmin formGeneral = new FormAdmin(this.connector, false); this.Hide(); this.textBoxLogin.Text = ""; this.textBoxPassword.Text = ""; formGeneral.FormClosed += (send, args) => this.Show(); formGeneral.Show(); } else { MessageBox.Show("Incorrect Login or Password"); } }