private void BBatal_Click(object sender, EventArgs e) { if (Dg.Enabled) { Close(); } else { Dg.Enabled = !Dg.Enabled; TbJenisNilai.Clear(); TbKeterangan.Clear(); } }
private void BSimpan_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(TbJenisNilai.Text)) { MessageBox.Show("Jenis nilai kosong!", "Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (Dg.Enabled) { if (MessageBox.Show("Simpan jenis nilai baru?", "Pertanyaan", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { A.SetInsert("INSERT INTO `r_jenisnilai` (`kode_jenisnilai`, `namajenisnilai`, `keterangan`)"); A.SetValues("VALUES('" + A.GenerateKode("JN", "r_jenisnilai", "kode_jenisnilai") + "', '" + TbJenisNilai.Text + "', " + "'" + TbKeterangan.StrEscape() + "')"); A.SetQueri(A.GetInsert() + A.GetValues() + ";"); if (A.GetQueri().ManipulasiData()) { MessageBox.Show("Data telah ditambahkan!", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information); TbJenisNilai.Clear(); TbKeterangan.Clear(); Loaddb(); } } } else { if (MessageBox.Show("Simpan perubahan jenis nilai?", "Pertanyaan", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { A.SetUpdate("UPDATE `r_jenisnilai` "); A.SetSet("SET `namajenisnilai` = '" + TbJenisNilai.Text + "', `keterangan` = '" + TbKeterangan.StrEscape() + "' "); A.SetWhere("WHERE `kode_jenisnilai` = '" + 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); TbJenisNilai.Clear(); TbKeterangan.Clear(); Dg.LoadIndex(Loaddb, 1); } } } } }