Exemplo n.º 1
0
        private void siswa_menu_Click(object sender, EventArgs e)
        {
            FormSiswa fSiswa = new FormSiswa();

            fSiswa.tahun_ajaran = tahuj_combo.Text.ToString();
            fSiswa.ShowDialog();
        }
Exemplo n.º 2
0
 private void siswa_menu_Click(object sender, EventArgs e)
 {
     FormSiswa fSiswa = new FormSiswa();
     fSiswa.tahun_ajaran = tahuj_combo.Text.ToString();
     fSiswa.ShowDialog();
 }
Exemplo n.º 3
0
        private void updateData()
        {
            try
            {
                //update ke tabel siswa
                this.table = "siswa";
                this.field = "nis_siswa ='" + this.nis_txt.Text +
                             "', nama_siswa ='" + this.namaSiswa_txt.Text.Replace("'", "''") +
                             "', nisn_siswa ='" + this.nisn_txt.Text +
                             "', tempat_lahir ='" + this.tempatLahir_txt.Text.Replace("'", "''") +
                             "', tanggal_lahir ='" + this.ttl_date.Text +
                             "', jenis_kelamin ='" + this.kelamin_combo.Text +
                             "', agama ='" + this.agama_combo.Text +
                             "', status_keluarga ='" + this.status_combo.Text +
                             "', anak_ke ='" + this.anakke_combo.Text +
                             "', alamat ='" + this.alamatSiswa_txt.Text.Replace("'", "''") +
                             "', no_telp ='" + this.telpSiswa_txt.Text +
                             "', asal_sekolah ='" + this.asalSekolah_txt.Text.Replace("'", "''") +
                             "', tanggal_masuk ='" + this.diterima_date.Text + "'";
                this.cond = "nis_siswa = '" + nis_lbl.Text + "'";
                db.updateData(table, field, cond);

                //update ke tabel orangtua
                string table2 = "orangtua";
                string field2 = "nama_ayah = '" + this.namaAyah_txt.Text.Replace("'", "''") +
                                "', nama_ibu = '" + this.namaIbu_txt.Text.Replace("'", "''") +
                                "', alamat_ortu = '" + this.alamatOrtu_txt.Text.Replace("'", "''") +
                                "', no_telp = '" + this.telpOrtu_txt.Text +
                                "', pekerjaan_ayah = '" + this.pekerjaanAyah_txt.Text.Replace("'", "''") +
                                "', pekerjaan_ibu ='" + this.pekerjaanIbu_txt.Text.Replace("'", "''") +
                                "', nama_wali = '" + this.namaWali_txt.Text.Replace("'", "''") +
                                "', alamat_wali = '" + this.alamatWali_txt.Text.Replace("'", "''") +
                                "', pekerjaan_wali = '" + this.pekerjaanWali_txt.Text.Replace("'", "''") + "'";
                string cond2 = "nis_siswa = '" + nis_txt.Text + "'";
                db.updateData(table2, field2, cond2);

                //update ke tabel detailkelassiswa
                string dikelas = this.dikelas_combo.SelectedValue.ToString();
                string table3  = "detailkelassiswa";
                string field3  = "kode_kelas = '" + dikelas + "'";
                string cond3   = "id_detail = '" + id_lbl.Text + "'";
                db.updateData(table3, field3, cond3);
                FormSiswa fSiswa = new FormSiswa();
                fSiswa.loadData();
                MessageBox.Show("Edit Data Siswa Berhasil \n Data Tersimpan");
                this.Close();
            }
            catch (MySqlException myex)
            {
                switch (myex.Number)
                {
                case 0: MessageBox.Show("Tidak bisa terkkoneksi ke Server."); break;

                case 1042: MessageBox.Show("Koneksi ke Database atau Server tidak ditemukan."); break;

                case 1045: MessageBox.Show("username/password salah."); break;

                default: MessageBox.Show("Terjadi kesalahan data atau duplikasi data."); break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 4
0
        private void insertData()
        {
            try
            {
                //insert ke tabel siswa
                string dikelas = this.dikelas_combo.SelectedValue.ToString();
                this.table = "siswa";
                this.field = "'" + this.nis_txt.Text +
                             "', '" + this.namaSiswa_txt.Text.Replace("'", "''") +
                             "', '" + this.nisn_txt.Text +
                             "', '" + this.tempatLahir_txt.Text.Replace("'", "''") +
                             "', '" + this.ttl_date.Text +
                             "', '" + this.kelamin_combo.Text +
                             "', '" + this.agama_combo.Text +
                             "', '" + this.status_combo.Text +
                             "', '" + this.anakke_combo.Text +
                             "', '" + this.alamatSiswa_txt.Text.Replace("'", "''") +
                             "', '" + this.telpSiswa_txt.Text +
                             "', '" + this.asalSekolah_txt.Text.Replace("'", "''") +
                             "', '" + this.diterima_date.Text + "', DEFAULT";
                db.insertData(table, field);

                //insert ke tabel orangtua
                string table2 = "orangtua";
                string field2 = "DEFAULT, '" + this.nis_txt.Text +
                                "', '" + this.namaAyah_txt.Text.Replace("'", "''") +
                                "', '" + this.namaIbu_txt.Text.Replace("'", "''") +
                                "', '" + this.alamatOrtu_txt.Text.Replace("'", "''") +
                                "', '" + this.telpOrtu_txt.Text +
                                "', '" + this.pekerjaanAyah_txt.Text.Replace("'", "''") +
                                "', '" + this.pekerjaanIbu_txt.Text.Replace("'", "''") +
                                "', '" + this.namaWali_txt.Text.Replace("'", "''") +
                                "', '" + this.alamatWali_txt.Text.Replace("'", "''") +
                                "', '" + this.pekerjaanWali_txt.Text.Replace("'", "''") + "'";
                db.insertData(table2, field2);

                //insert ke tabel detailkelassiswa
                string table3 = "detailkelassiswa";
                string field3 = "DEFAULT, '" + dikelas +
                                "', '" + this.nis_txt.Text + "', 'Data Siswa'";
                db.insertData(table3, field3);
                FormSiswa fSiswa = new FormSiswa();
                fSiswa.loadData();
                MessageBox.Show("Data Siswa '" + this.namaSiswa_txt.Text + "' disimpan");
                this.Close();
            }
            catch (MySqlException myex)
            {
                switch (myex.Number)
                {
                case 0: MessageBox.Show("Tidak bisa terkkoneksi ke Server."); break;

                case 1042: MessageBox.Show("Koneksi ke Database atau Server tidak ditemukan."); break;

                case 1045: MessageBox.Show("username/password salah."); break;

                default: MessageBox.Show("Terjadi kesalahan data atau duplikasi data."); break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 5
0
        private void save_btn_Click(object sender, EventArgs e)
        {
            try
            {
                foreach (DataGridViewRow row in data_grid.Rows)
                {
                    this.table = "siswa";
                    this.field = "'" + row.Cells[0].Value.ToString().Replace("'", "''") +
                                 "', '" + row.Cells[1].Value.ToString().Replace("'", "''") +
                                 "', '" + row.Cells[2].Value.ToString().Replace("'", "''") +
                                 "', '" + row.Cells[3].Value.ToString().Replace("'", "''") +
                                 "', '" + row.Cells[4].Value.ToString().Replace("'", "''") +
                                 "', '" + row.Cells[5].Value.ToString().Replace("'", "''") +
                                 "', '" + row.Cells[6].Value.ToString().Replace("'", "''") +
                                 "', '" + row.Cells[7].Value.ToString().Replace("'", "''") +
                                 "', '" + row.Cells[8].Value.ToString().Replace("'", "''") +
                                 "', '" + row.Cells[9].Value.ToString().Replace("'", "''") +
                                 "', '" + row.Cells[10].Value.ToString().Replace("'", "''") +
                                 "', '" + row.Cells[11].Value.ToString().Replace("'", "''") +
                                 "', '" + row.Cells[13].Value.ToString().Replace("'", "''") + "', DEFAULT";
                    db.insertData(table, field);

                    //insert ke tabel orangtua
                    string table2 = "orangtua";
                    string field2 = "DEFAULT, '" + row.Cells[0].Value.ToString().Replace("'", "''") +
                                    "', '" + row.Cells[14].Value.ToString().Replace("'", "''") +
                                    "', '" + row.Cells[15].Value.ToString().Replace("'", "''") +
                                    "', '" + row.Cells[16].Value.ToString().Replace("'", "''") +
                                    "', '" + row.Cells[17].Value.ToString().Replace("'", "''") +
                                    "', '" + row.Cells[18].Value.ToString().Replace("'", "''") +
                                    "', '" + row.Cells[19].Value.ToString().Replace("'", "''") +
                                    "', '" + row.Cells[20].Value.ToString().Replace("'", "''") +
                                    "', '" + row.Cells[21].Value.ToString().Replace("'", "''") +
                                    "', '" + row.Cells[22].Value.ToString().Replace("'", "''") + "'";
                    db.insertData(table2, field2);

                    //insert ke tabel detailkelassiswa
                    string table3 = "detailkelassiswa";
                    string field3 = "DEFAULT, '" + row.Cells[12].Value.ToString() +
                                    "', '" + row.Cells[0].Value.ToString() + "', 'Data Siswa'";
                    db.insertData(table3, field3);
                    FormSiswa fSiswa = new FormSiswa();
                    fSiswa.loadData();
                    this.Close();
                }
            }
            catch (MySqlException myex)
            {
                save_btn.Enabled = false;
                switch (myex.Number)
                {
                case 0: MessageBox.Show("Tidak bisa terkkoneksi ke Server."); break;

                case 1042: MessageBox.Show("Koneksi ke Database atau Server tidak ditemukan."); break;

                case 1045: MessageBox.Show("username/password salah."); break;

                default: MessageBox.Show("Terjadi kesalahan data atau duplikasi data."); break;
                }
            }
            catch (Exception ex)
            {
                save_btn.Enabled = false;
                MessageBox.Show("Terjadi kesalahan atau ada duplikasi data");
            }
        }
Exemplo n.º 6
0
        private void save_btn_Click(object sender, EventArgs e)
        {
            try
            {
                foreach (DataGridViewRow row in data_grid.Rows)
                {
                    this.table = "siswa";
                    this.field = "'" + row.Cells[0].Value.ToString().Replace("'", "''") +
                                "', '" + row.Cells[1].Value.ToString().Replace("'", "''") +
                                "', '" + row.Cells[2].Value.ToString().Replace("'", "''") +
                                "', '" + row.Cells[3].Value.ToString().Replace("'", "''") +
                                "', '" + row.Cells[4].Value.ToString().Replace("'", "''") +
                                "', '" + row.Cells[5].Value.ToString().Replace("'", "''") +
                                "', '" + row.Cells[6].Value.ToString().Replace("'", "''") +
                                "', '" + row.Cells[7].Value.ToString().Replace("'", "''") +
                                "', '" + row.Cells[8].Value.ToString().Replace("'", "''") +
                                "', '" + row.Cells[9].Value.ToString().Replace("'", "''") +
                                "', '" + row.Cells[10].Value.ToString().Replace("'", "''") +
                                "', '" + row.Cells[11].Value.ToString().Replace("'", "''") +
                                "', '" + row.Cells[13].Value.ToString().Replace("'", "''") + "', DEFAULT";
                    db.insertData(table, field);

                    //insert ke tabel orangtua
                    string table2 = "orangtua";
                    string field2 = "DEFAULT, '" + row.Cells[0].Value.ToString().Replace("'", "''") +
                                    "', '" + row.Cells[14].Value.ToString().Replace("'", "''") +
                                    "', '" + row.Cells[15].Value.ToString().Replace("'", "''") +
                                    "', '" + row.Cells[16].Value.ToString().Replace("'", "''") +
                                    "', '" + row.Cells[17].Value.ToString().Replace("'", "''") +
                                    "', '" + row.Cells[18].Value.ToString().Replace("'", "''") +
                                    "', '" + row.Cells[19].Value.ToString().Replace("'", "''") +
                                    "', '" + row.Cells[20].Value.ToString().Replace("'", "''") +
                                    "', '" + row.Cells[21].Value.ToString().Replace("'", "''") +
                                    "', '" + row.Cells[22].Value.ToString().Replace("'", "''") + "'";
                    db.insertData(table2, field2);

                    //insert ke tabel detailkelassiswa
                    string table3 = "detailkelassiswa";
                    string field3 = "DEFAULT, '" + row.Cells[12].Value.ToString() +
                                    "', '" + row.Cells[0].Value.ToString() + "', 'Data Siswa'";
                    db.insertData(table3, field3);
                    FormSiswa fSiswa = new FormSiswa();
                    fSiswa.loadData();
                    this.Close();
                }
            }
            catch (MySqlException myex)
            {
                save_btn.Enabled = false;
                switch (myex.Number)
                {
                    case 0: MessageBox.Show("Tidak bisa terkkoneksi ke Server."); break;
                    case 1042: MessageBox.Show("Koneksi ke Database atau Server tidak ditemukan."); break;
                    case 1045: MessageBox.Show("username/password salah."); break;
                    default: MessageBox.Show("Terjadi kesalahan data atau duplikasi data."); break;
                }
            }
            catch (Exception ex)
            {
                save_btn.Enabled = false;
                MessageBox.Show("Terjadi kesalahan atau ada duplikasi data");
            }
        }