//button for login private void btnLogIn_Click(object sender, EventArgs e) { MY_DB db = new MY_DB(); MySqlDataAdapter adapter = new MySqlDataAdapter(); DataTable table = new DataTable(); MySqlCommand command = new MySqlCommand("SELECT * FROM `ex2` WHERE `username`=@anju AND `pass`=@pass", db.getConnection); command.Parameters.Add("@anju", MySqlDbType.VarChar).Value = textBoxUsername.Text; command.Parameters.Add("@pass", MySqlDbType.VarChar).Value = textBoxPassword.Text; adapter.SelectCommand = command; adapter.Fill(table); try { if (table.Rows.Count > 0) { MessageBox.Show("You are Logged In."); this.Hide(); ManageSystem ms = new ManageSystem(); ms.ShowDialog(); } else { MessageBox.Show("Inavalid Username and a Password", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message, "login", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnBack_Click(object sender, EventArgs e) { this.Hide(); ManageSystem ms = new ManageSystem(); ms.ShowDialog(); }
private void pictureBox16_Click(object sender, EventArgs e) { this.Hide(); ManageSystem Ms = new ManageSystem(); Ms.Show(); }