private void Button_LogIn_Click(object sender, EventArgs e) { this.errorProvider1.Clear(); Admin adm = new Admin(); Form_Lekar lkr = new Form_Lekar(); if (this.textBox1.Text == "Admin" && this.textBox2.Text == "ABCD") { MessageBox.Show("Přihlášení proběhlo uspěšně"); adm.ShowDialog(); } else { MessageBox.Show("Špatně zadané heslo nebo email"); } if (this.textBox1.Text == "Lekar" && this.textBox2.Text == "123456") { MessageBox.Show("Přihlášení proběhlo uspěšně"); lkr.ShowDialog(); } else { MessageBox.Show("Špatně zadané heslo nebo email"); } }
private void btnlogin_Click(object sender, EventArgs e) { try { newcon.dbcon(); cm.CommandText = ("Select * from adminpass where Username = '******' and Password = '******'"); cm.Connection = Connectionclass.con; SqlDataReader dr; dr = cm.ExecuteReader(); int count = 0; while (dr.Read()) { count = count + 1; } if (count == 1) { MessageBox.Show("Successfully Log In", "Welcome"); this.Hide(); Admin display = new Admin(); display.ShowDialog(); } else { MessageBox.Show("Failed to Login. Please Check your Username and Password", "Error"); return; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { newcon.Closecon(); } }