private void pictureBox2_Click(object sender, EventArgs e) { this.Hide(); TrainerBD tt = new TrainerBD(); tt.Show(); }
private void tLogin_Click(object sender, EventArgs e) { try { SqlConnection con = new SqlConnection(); con.ConnectionString = "data source = AIRONY-LAPTOP;database = GymManagementSystem;integrated security = SSPI"; SqlCommand cmd = new SqlCommand( cmdText: "Select * from trainerinfo where username='******'and password='******'", connection: con); con.Open(); SqlDataAdapter adapt = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); adapt.Fill(ds); con.Close(); int count = ds.Tables[0].Rows.Count; if (count == 1) { MessageBox.Show("Login Successful!"); this.Hide(); TrainerBD fq = new TrainerBD(); fq.Show(); } else { MessageBox.Show("Login Failed!"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }