Beispiel #1
0
        private void txtPw_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
                if (koneksi.OpenConnection())
                {
                    string query = String.Concat("SELECT * FROM tbladmin WHERE kode_admin='", txtKduser.Text, "' AND password='******'");
                    koneksi.cmd = new MySqlCommand(query, koneksi.connection);
                    koneksi.dr  = koneksi.cmd.ExecuteReader();


                    if (koneksi.dr.Read())
                    {
                        string x = koneksi.dr["nama_admin"].ToString();
                        MessageBox.Show(("Selamat Datang Admin " + x), "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Hide();
                        var frmUtama = new FrmUtama();
                        frmUtama.Closed += (s, args) => this.Close();
                        frmUtama.Show();
                    }
                    else
                    {
                        MessageBox.Show("Username dan Password tidak cocok", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        txtKduser.Clear();
                        txtPw.Clear();
                        txtKduser.Focus();
                    }
                    koneksi.CloseConnection();
                }
            }
        }
        private void btnBack_Click(object sender, EventArgs e)
        {
            this.Hide();
            var frmUtama = new FrmUtama();

            frmUtama.Closed += (s, args) => this.Close();
            frmUtama.Show();
        }