Esempio n. 1
0
 private void btn_Login_Click(object sender, EventArgs e)
 {
     try
     {
         sqlConnect.Connect.Open();
         SqlCommand cmdDisplay = new SqlCommand("SELECT * FROM TBLOGIN WHERE USERNAME =@USERNAME AND PASSWORD =@PASSWORD", sqlConnect.Connect);
         cmdDisplay.Parameters.AddWithValue("@USERNAME", txtUsername.Text.Trim());
         cmdDisplay.Parameters.AddWithValue("@PASSWORD", txtPassword.Text.Trim());
         SqlDataReader dr;
         dr = cmdDisplay.ExecuteReader();
         if (dr.Read())
         {
             //jika valid
             MessageBox.Show("Welcome, " + txtUsername.Text);
             MenuAdmin obj = new MenuAdmin();
             obj.Show();
             this.Hide();
         }
         else
         {
             //jika invalid
             MessageBox.Show(" Invalid Username or Password");
         }
         sqlConnect.Connect.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            MenuAdmin obj = new MenuAdmin();

            obj.Show();
            this.Hide();
        }