Exemplo n.º 1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(AddConnection.ConnectionString);

            con.Open();
            SqlCommand    cmd        = new SqlCommand("Select idKaryawan, pass, idJabatan from tableKaryawan", con);
            SqlDataReader dataReader = cmd.ExecuteReader();

            while (dataReader.Read())
            {
                if (dataReader.GetInt32(0).ToString() == id.Text && dataReader.GetString(1) == pass.Text)
                {
                    success = true;
                    if (dataReader.GetInt32(2) == 1)
                    {
                        Menu2 form = new Menu2();
                        form.Show();
                        this.Hide();
                    }
                    else if (dataReader.GetInt32(2) == 2)
                    {
                        Menu1 form = new Menu1();
                        form.Show();
                        this.Hide();
                    }
                    break;
                }
            }
            if (!success)
            {
                MessageBox.Show("Login gagal. Id atau Password salah.");
            }
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            Menu2 form = new Menu2();

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