Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            DataPendaftaran mDataPendaftaran = new DataPendaftaran();

            this.Hide();
            mDataPendaftaran.Show();
        }
Exemple #2
0
        private void editData()
        {
            String jk = "";

            if (FormEdit.jkLaki)
            {
                jk = "Laki Laki";
            }
            else if (FormEdit.jkPerem)
            {
                jk = "Perempuan";
            }

            MySqlConnection connection = new MySqlConnection("Server=localhost;Database=data_siswa;Uid=root;pwd=''");

            connection.Open();

            String       updateQuery = "UPDATE data_pendaftaran SET nama_lengkap = '" + FormEdit.namaLengkap + "', tempat_tanggal_lahir = '" + FormEdit.tempatTanggalLahir + "', jenis_kelamin = '" + jk + "', agama = '" + FormEdit.Agama + "', kewarganegaraan = '" + FormEdit.kewargaNegaraan + "', banyak_saudara_kandung = '" + FormEdit.banyakSaudaraKandung + "', usia = '" + FormEdit.Usia + "', banyak_saudara_angkat= '" + FormEdit.banyakSaudaraAngkat + "', bahasa_sehari_hari= '" + FormEdit.BahasaSehariHari + "', berat_badan = '" + FormEdit.beratBadan + "', tinggi_badan = '" + FormEdit.tinggiBadan + "', golongan_darah = '" + FormEdit.golonganDarah + "', penyakit = '" + FormEdit.Penyakit + "', alamat = '" + FormEdit.Alamat + "', nama_ayah_kandung = '" + nama_ayah_kandung.Text + "', nama_ibu_kandung = '" + nama_ibu_kandung.Text + "', ttl_ayah = '" + ttl_ayah_kandung.Text + "', ttl_ibu = '" + ttl_ibu_kandung.Text + "', pekerjaan_ayah = '" + pekerjaan_ayah_kandung.Text + "', pekerjaan_ibu = '" + pekerjaan_ibu_kandung.Text + "', alamat_ortu = '" + alamat_orangtua.Text + "', nama_wali = '" + nama_wali.Text + "', ttl_wali = '" + ttl_wali.Text + "', pendidikan_terakhir_wali = '" + pendidikan_terakhir_wali.Text + "', hubungan_terhadap_anak = '" + hubungan_anak.Text + "', pekerjaan_wali = '" + pekerjaan_wali.Text + "' WHERE id_pendaftaran = " + FormEdit.id;
            MySqlCommand command     = new MySqlCommand(updateQuery, connection);

            // execute the query
            if (command.ExecuteNonQuery() == 1)
            {
                DataPendaftaran dataPendaftaran = new DataPendaftaran();
                MessageBox.Show("Berhasil!", "Data Berhasil di update", MessageBoxButtons.OK, MessageBoxIcon.Information);
                dataPendaftaran.Show();
                this.Hide();
            }
        }
Exemple #3
0
        private void addData()
        {
            MySqlConnection connection = new MySqlConnection("Server=localhost;Database=data_siswa;Uid=root;pwd=''");
            MySqlCommand    comand;

            connection.Open();

            comand             = connection.CreateCommand();
            comand.CommandText = "INSERT INTO  admin (username, password) VALUES (@username, @password)";
            comand.Parameters.AddWithValue("@username", tbUsername.Text);
            comand.Parameters.AddWithValue("@password", tbPassword.Text);

            if (checkUsername())
            {
                MessageBox.Show("This Username Already Exists, Select A Different One", "Duplicate Username", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
            }
            else
            {
                // execute the query
                if (comand.ExecuteNonQuery() == 1)
                {
                    MessageBox.Show("Register Sucsessful", "Hi, New Admin :)", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    DataPendaftaran datapendaftaran = new DataPendaftaran();
                    this.Hide();
                    datapendaftaran.Show();
                }
                else
                {
                    MessageBox.Show("ERROR");
                }
            }
        }
Exemple #4
0
        private void button2_Click_1(object sender, EventArgs e)
        {
            ClassDB db = new ClassDB();

            String username = uname.Text;
            String password = pass.Text;

            DataTable table = new DataTable();

            MySqlDataAdapter adapter = new MySqlDataAdapter();

            MySqlCommand command = new MySqlCommand("SELECT * FROM admin WHERE username = @uname and password= @pass", db.getConnection());

            command.Parameters.Add("@uname", MySqlDbType.VarChar).Value = username;
            command.Parameters.Add("@pass", MySqlDbType.VarChar).Value  = password;

            adapter.SelectCommand = command;

            adapter.Fill(table);

            // check if the user exists or not
            if (table.Rows.Count > 0)
            {
                MessageBox.Show("Login Berhasil", "Selamat Datang", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Hide();
                DataPendaftaran datapendaftaran = new DataPendaftaran();
                datapendaftaran.Show();
            }

            else
            {
                // check if the username field is empty
                if (username.Trim().Equals(""))
                {
                    MessageBox.Show("Enter Your Username To Login", "Empty Username", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                // check if the password field is empty
                else if (password.Trim().Equals(""))
                {
                    MessageBox.Show("Enter Your password To Login", "Empty password", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                // check if the username or the password don't exist
                else
                {
                    MessageBox.Show("Wrong username or password", "Wrong Data", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }