private void Dg_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { if (e.ColumnIndex == Dg.GetColumnIndexByHeader("PILIH")) { int index = Dg.CurrentRow.Index; if (Dg.CurrentRow.Cells[Dg.GetColumnIndexByHeader("PILIH")].Value.ToString().Equals("SUDAH")) { if (MessageBox.Show("Hapus Kelas?", "Pertanyaan", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (A.ManipulasiData("DELETE FROM `tb_ruangan` " + "WHERE `kode_ruangan` = '" + Dg.CurrentRow.Cells[Dg.GetColumnIndexByHeader("KODE RUANGAN")].Value.ToString() + "'")) { Dg.LoadIndex(loaddb, 2); } } } else { string value = ""; A.InputRichTextBox("Keterangan", "Input", ref value); A.SetInsert("INSERT INTO `tb_ruangan` (`kode_ruangan`,`kode_kelas`,`kode_siswa`,`tahunajaran`,`keterangan`,`tanggal`,`id_user`) "); A.SetValues("VALUES ('" + A.GenerateKode("RG", "tb_ruangan", "kode_ruangan") + "', '" + KodeKelas[CbKelas.SelectedIndex] + "', " + "'" + Dg.Rows[e.RowIndex].Cells[0].Value.ToString() + "', '" + CbTahunAjaran.Text + "', '" + value + "', NOW(), '" + S.GetUserid() + "')"); A.SetQueri(A.GetInsert() + A.GetValues() + ";"); if (A.GetQueri().ManipulasiData()) { Dg.LoadIndex(loaddb, 2); } } } } }
private void Dg_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { if (e.ColumnIndex == Dg.GetColumnIndexByHeader("PILIH")) { if (Dg.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("BELUM")) { Dictionary <string, string> data = new Dictionary <string, string> { { "tahunajaran", CbTahunAjaran.Text }, { "kodekelas", kodekelas[CbKelas.SelectedIndex] }, { "kelas", CbKelas.Text }, { "kodepelajaran", Dg.Rows[e.RowIndex].Cells[Dg.GetColumnIndexByHeader("KODE PELAJARAN")].Value.ToString() }, { "kodemapel", Dg.Rows[e.RowIndex].Cells[Dg.GetColumnIndexByHeader("KODE MAPEL")].Value.ToString() }, { "pelajaran", Dg.Rows[e.RowIndex].Cells[Dg.GetColumnIndexByHeader("PELAJARAN")].Value.ToString() }, }; FKelolaPengajaran f = new FKelolaPengajaran(data); f.ShowDialog(); Loaddb(); } else { FKelolaPengajaran f = new FKelolaPengajaran(Dg.Rows[e.RowIndex].Cells[Dg.GetColumnIndexByHeader("KODE JADWAL")].Value); f.ShowDialog(); Dg.LoadIndex(Loaddb, e.ColumnIndex); } } } }
private void BSimpan_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(TbKodeMapel.Text)) { MessageBox.Show("Kode mapel kosong!", "Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (string.IsNullOrEmpty(TbMataPelajaran.Text)) { MessageBox.Show("Mata Pelajaran kosong!", "Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (CbStatus.SelectedIndex < 0) { MessageBox.Show("Status kosong!", "Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (Dg.Enabled) { if (MessageBox.Show("Simpan pelajaran baru?", "Pertanyaan", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { A.SetInsert("INSERT INTO `r_matapelajaran` (`kodepelajaran`, `kodemapel`, `namapelajaran`, `status`)"); A.SetValues("VALUES('" + A.GenerateKode("MP", "r_matapelajaran", "kodepelajaran") + "', '" + TbKodeMapel.Text + "', " + "'" + TbMataPelajaran.StrEscape() + "', '" + CbStatus.ToYN() + "')"); A.SetQueri(A.GetInsert() + A.GetValues() + ";"); if (A.GetQueri().ManipulasiData()) { MessageBox.Show("Data telah ditambahkan!", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information); TbKodeMapel.Clear(); TbMataPelajaran.Clear(); CbStatus.SelectedIndex = -1; Loaddb(); } } } else { if (MessageBox.Show("Simpan perubahan pelajaran?", "Pertanyaan", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { A.SetUpdate("UPDATE `r_matapelajaran` "); A.SetSet("SET `kodemapel` = '" + TbKodeMapel.Text + "', `namapelajaran` = '" + TbMataPelajaran.StrEscape() + "', `status` = '" + CbStatus.ToYN() + "' "); A.SetWhere("WHERE `kodepelajaran` = '" + Dg.CurrentRow.Cells[0].Value.ToString() + "' "); A.SetQueri(A.GetUpdate() + A.GetSet() + A.GetWhere() + ";"); if (A.GetQueri().ManipulasiData()) { MessageBox.Show("Data telah diubah!", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information); TbKodeMapel.Clear(); TbMataPelajaran.Clear(); CbStatus.SelectedIndex = -1; Dg.LoadIndex(Loaddb, 1); } } } } }
private void BSimpan_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(TbKelas.Text)) { MessageBox.Show("Nama kelas kosong!", "Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (string.IsNullOrEmpty(TbUrutan.Text)) { MessageBox.Show("Urutan kosong!", "Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (Dg.Enabled) { if (MessageBox.Show("Simpan kelas baru?", "Pertanyaan", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { A.SetInsert("INSERT INTO `r_kelas` (`kode_kelas`, `namakelas`, `urutan`, `keterangan`)"); A.SetValues("VALUES('" + A.GenerateKode("KL", "r_kelas", "kode_kelas") + "', '" + TbKelas.Text + "', '" + TbUrutan.Text + "', " + "'" + TbKeterangan.StrEscape() + "')"); A.SetQueri(A.GetInsert() + A.GetValues() + ";"); if (A.GetQueri().ManipulasiData()) { MessageBox.Show("Data telah ditambahkan!", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information); TbKelas.Clear(); TbUrutan.Clear(); TbKeterangan.Clear(); Loaddb(); } } } else { if (MessageBox.Show("Simpan perubahan kelas?", "Pertanyaan", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { A.SetUpdate("UPDATE `r_kelas` "); A.SetSet("SET `namakelas` = '" + TbKelas.Text + "', `keterangan` = '" + TbKeterangan.StrEscape() + "', '" + TbUrutan.Text + "' "); A.SetWhere("WHERE `kode_kelas` = '" + Dg.CurrentRow.Cells[0].Value.ToString() + "' "); A.SetQueri(A.GetUpdate() + A.GetSet() + A.GetWhere() + ";"); if (A.GetQueri().ManipulasiData()) { MessageBox.Show("Data telah diubah!", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information); TbKelas.Clear(); TbUrutan.Clear(); TbKeterangan.Clear(); Dg.LoadIndex(Loaddb, 1); } } } } }
private void BUbah_Click(object sender, EventArgs e) { if (Dg.Rows.Count >= 0) { if (Dg.SelectedRows.Count > 0) { FInputSiswa f = new FInputSiswa(Dg.CurrentRow.Cells[Dg.GetColumnIndexByHeader("KODE SISWA")].Value.ToString()); f.ShowDialog(); Dg.LoadIndex(Loaddb, 1); } } else { MessageBox.Show("Data Kosong!", "Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void Dg_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == Dg.GetColumnIndexByHeader("INPUT")) { if (Dg.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("INPUT")) { string nilai = Dg.CurrentRow.Cells[Dg.GetColumnIndexByHeader("NILAI")].Value.ToString(); if (A.InputTextBox("Input", "Nilai", ref nilai) == DialogResult.OK) { string keterangan = Dg.CurrentRow.Cells[Dg.GetColumnIndexByHeader("KETERANGAN")].Value.ToString(); A.InputRichTextBox("Keterangan", "Input", ref keterangan); A.SetQueri("INSERT INTO `tb_nilai` (`kode_nilai`, `kode_jenisnilai`, `kode_ruangan`, `kode_jadwal`, `tanggal`, `id_user`, `nilai`, `keterangan`) " + "VALUES ('" + A.GenerateKode("NL", "tb_nilai", "kode_nilai") + "', '" + KodeJenisNilai[CbJenisNilai.SelectedIndex] + "', " + "'" + Dg.Rows[e.RowIndex].Cells[Dg.GetColumnIndexByHeader("KODE RUANGAN")].Value.ToString() + "', " + "(SELECT `kode_jadwal` FROM `tb_jadwal` WHERE `kode_guru`='" + S.GetKodeGuru() + "' " + "AND `kode_kelas`='" + KodeKelas[CbKelas.SelectedIndex] + "' AND `kode_pelajaran`= '" + KodePelajaran[CbMataPelajaran.SelectedIndex] + "' " + "AND `tahunajaran`= '" + CbTahunAjaran.Text + "'), NOW(), '" + S.GetUserid() + "', '" + nilai + "', '" + keterangan + "');"); if (A.GetQueri().ManipulasiData()) { Dg.LoadIndex(Loaddb, e.ColumnIndex); } } } else { if (MessageBox.Show("Hapus data nilai?", "Pertanyaan", MessageBoxButtons.OK, MessageBoxIcon.Question) == DialogResult.Yes) { if (A.DBHapus("DELETE FROM `tb_nilai` WHERE `kode_nilai` = '" + Dg.Rows[e.RowIndex].Cells[Dg.GetColumnIndexByHeader("KODE NILAI")].Value.ToString() + "';")) { Loaddb(); } } } } else if (e.ColumnIndex == Dg.GetColumnIndexByHeader("NILAI")) { if (Dg.CurrentRow.Cells[Dg.GetColumnIndexByHeader("INPUT")].Value.ToString().Equals("INPUT")) { MessageBox.Show("Klik input!!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { string nilai = Dg.CurrentRow.Cells[Dg.GetColumnIndexByHeader("NILAI")].Value.ToString(); if (A.InputTextBox("Input", "Nilai", ref nilai) == DialogResult.OK) { if (A.ManipulasiData("UPDATE `tb_nilai` SET `nilai` = '" + nilai + "' " + "WHERE `kode_nilai` = '" + Dg.CurrentRow.Cells[Dg.GetColumnIndexByHeader("KODE NILAI")].Value.ToString() + "';")) { Dg.LoadIndex(Loaddb, e.ColumnIndex); } } } } else if (e.ColumnIndex == Dg.GetColumnIndexByHeader("KETERANGAN")) { if (Dg.CurrentRow.Cells[Dg.GetColumnIndexByHeader("INPUT")].Value.ToString().Equals("INPUT")) { MessageBox.Show("Klik input!!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { string nilai = Dg.CurrentRow.Cells[Dg.GetColumnIndexByHeader("KETERANGAN")].Value.ToString(); if (A.InputRichTextBox("Input", "Keterangan", ref nilai) == DialogResult.OK) { if (A.ManipulasiData("UPDATE `tb_nilai` SET `keterangan` = '" + nilai + "' " + "WHERE `kode_nilai` = '" + Dg.CurrentRow.Cells[Dg.GetColumnIndexByHeader("KODE NILAI")].Value.ToString() + "';")) { Dg.LoadIndex(Loaddb, e.ColumnIndex); } } } } }