Ejemplo n.º 1
0
 private void BoxUser_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         BoxPass.Focus();
     }
 }
Ejemplo n.º 2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (BoxUser.Text == "")
            {
                MessageBox.Show("username harus diisi!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                BoxUser.Focus();
                return;
            }
            if (BoxPass.Text == "")
            {
                MessageBox.Show("password harus diisi!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                BoxPass.Focus();
                return;
            }

            try
            {
                SqlConnection con = new SqlConnection();
                con.ConnectionString = "Data Source=ASUS-X555U-TDC;Initial Catalog=Rental-sound;User ID=sa;Password=1976";
                con.Open();
                string         query = ("select * from Register where username = '******' and password = '******'");
                SqlDataAdapter sda   = new SqlDataAdapter(query, con);
                DataTable      dtbl  = new DataTable();
                sda.Fill(dtbl);

                string         queryadmin = ("select * from LoginAdmin where username = '******' and password = '******'");
                SqlDataAdapter admin      = new SqlDataAdapter(queryadmin, con);
                DataTable      dataadmin  = new DataTable();
                admin.Fill(dataadmin);

                if (dtbl.Rows.Count == 1)
                {
                    MessageBox.Show("Login Sukses");
                    MENU go = new MENU();
                    this.Hide();
                    go.ShowDialog();
                    this.Close();
                }
                else if (dataadmin.Rows.Count == 1)
                {
                    MessageBox.Show("Login Admin Sukses");
                    Menu_Admin go = new Menu_Admin();
                    this.Hide();
                    go.ShowDialog();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Username atau password salah!");
                }
            }
            catch (SqlException f)
            {
                Console.WriteLine(f.Message);
            }
        }
Ejemplo n.º 3
0
        private bool ValidarTexBox()
        {
            if (BoxUser.Text.Trim().Length == 0)
            {
                MessageBox.Show("ingresa Usuario", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); BoxUser.Focus(); return(false);
            }
            if (BoxPass.Text.Trim().Length == 0)
            {
                MessageBox.Show("ingresa Contraseña", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); BoxPass.Focus(); return(false);
            }

            return(true);
        }