Halaman Proses Kriteria Imports MySql.Data.MySqlClient

2. Halaman Proses Kriteria Imports MySql.Data.MySqlClient

Imports MySql.Data Public Class frmkriteria Dim blnaddcus As Boolean = True Dim blnubahcus As Boolean = False Dim blnhapuscus As Boolean = False Sub bersih txtnama_kriteria.Text = txtid_kriteria.Text = End Sub Sub isisDgv Dim dt As New DataTable GetDatadt, select from kriteria dgkriteria.DataSource = dt dgkriteria.Columns0.HeaderText = ID Kriteria dgkriteria.Columns1.HeaderText = Nama Kriteria dgkriteria.Columns0.Width = 50 dgkriteria.Columns1.Width = 200 End Sub Sub enabFalse txtnama_kriteria.Enabled = False txtid_kriteria.Enabled = False End Sub Sub enabTrue txtnama_kriteria.Enabled = True txtid_kriteria.Enabled = True End Sub Function validasi As Boolean If txtnama_kriteria.Text.Length = 0 Then MessageBox.ShowKriteria tidak boleh kosong, Validasi, MessageBoxButtons.OK, MessageBoxIcon.Information txtnama_kriteria.Focus Return False End If If txtnama_kriteria.Text.Length 0 0 Then Return True End If End Function Private Sub frmkriteria_LoadByVal sender As System.Object, ByVal e As System.EventArgs Handles MyBase.Load getConnString isisDgv Universitas Sumatera Utara End Sub Private Sub cmdtambah_ClickByVal sender As System.Object, ByVal e As System.EventArgs Handles cmdtambah.Click Try If cmdtambah.Text = Tambah Then Me.bersih enabTrue txtnama_kriteria.Focus cmdtambah.Text = Simpan cmdubah.Text = Batal cmdhapus.Enabled = False blnaddcus = True blnubahcus = True Else If validasi Then cmdtambah.Text = Tambah cmdubah.Text = Ubah cmdhapus.Enabled = True If blnaddcus = True Then If EksekusiString.Formatinsert into kriteria nama_kriteria values txtnama_kriteria.Text 0 Then MessageBox.ShowBerhasil tersimpan, Informasi, MessageBoxButtons.OK, MessageBoxIcon.Information isisDgv bersih enabFalse Else MessageBox.ShowGagal tersimpan, Informasi, MessageBoxButtons.OK, MessageBoxIcon.Information End If blnubahcus = False blnhapuscus = False Else If MessageBox.ShowString.FormatApakah anda yakin akan mengubah menjadi{0}, txtnama_kriteria.Text, Konfirmasi, MessageBoxButtons.YesNo, MessageBoxIcon.Question = Windows.Forms.DialogResult.Yes Then If EksekusiString.Formatupdate kriteria set nama_kriteria={0} where id_kriteria={2}, txtnama_kriteria.Text, txtid_kriteria.Text 0 Then MessageBox.ShowBerhasil diubah, Sukses, MessageBoxButtons.OK, MessageBoxIcon.Information isisDgv bersih enabFalse Else MessageBox.ShowBerhasil diubah, Sukses, MessageBoxButtons.OK, MessageBoxIcon.Information Universitas Sumatera Utara End If blnubahcus = False blnhapuscus = False End If End If End If End If Catch ex As Exception MessageBox.ShowFailed : ex.Message End Try End Sub Private Sub cmdubah_ClickByVal sender As System.Object, ByVal e As System.EventArgs Handles cmdubah.Click If blnubahcus Then If blnaddcus = True Then batal add cmdtambah.Text = Tambah cmdubah.Text = Ubah cmdhapus.Enabled = True blnaddcus = False enabFalse bersih blnubahcus = False blnhapuscus = False Else If cmdubah.Text = Ubah Then Tambah cmdtambah.Text = Simpan cmdubah.Text = Batal cmdhapus.Enabled = False blnaddcus = False cmdubah.Enabled = True cmdhapus.Enabled = False cmdtambah.Enabled = True enabTrue txtid_kriteria.Enabled = False blnubahcus = True blnhapuscus = True Else batal ubah cmdtambah.Text = Tambah cmdubah.Text = Ubah cmdhapus.Enabled = True enabFalse bersih blnubahcus = False blnhapuscus = False End If Universitas Sumatera Utara End If Else MessageBox.ShowPilih dahulu data yang akan diubah, Pilih, MessageBoxButtons.OK, MessageBoxIcon.Information End If End Sub Private Sub cmdhapus_ClickByVal sender As System.Object, ByVal e As System.EventArgs Handles cmdhapus.Click If blnhapuscus Then If MessageBox.ShowString.FormatApakah anda yakin akan menghapus {0} dari daftar, txtnama_kriteria.Text, Konfirmasi, MessageBoxButtons.YesNo, MessageBoxIcon.Question = Windows.Forms.DialogResult.Yes Then make sure there is a selected item to delete Try If EksekusiString.FormatDelete from kriteria Where id_kriteria ={0}, txtid_kriteria.Text 0 Then MessageBox.ShowBerhasil dihapus, Sukses, MessageBoxButtons.OK, MessageBoxIcon.Information isisDgv bersih txtnama_kriteria.Enabled = False txtid_kriteria.Enabled = False blnhapuscus = False Else MessageBox.ShowGagal dihapus, Kesalahan, MessageBoxButtons.OK, MessageBoxIcon.Error End If Catch ex As Exception MessageBox.ShowFailed : ex.Message End Try End If Else MessageBox.ShowPilih dahulu data yang akan dihapus, Pilih, MessageBoxButtons.OK, MessageBoxIcon.Information End If End Sub Private Sub dgkriteria_DoubleClickByVal sender As Object, ByVal e As System.EventArgs Handles dgkriteria.DoubleClick txtid_kriteria.Text = dgkriteria.Item0, dgkriteria.CurrentRow.Index.Value txtnama_kriteria.Text = dgkriteria.Item1, dgkriteria.CurrentRow.Index.Value blnaddcus = False txtid_kriteria.Enabled = False blnubahcus = True blnhapuscus = True End Sub End Class Universitas Sumatera Utara

3. Halaman Proses Penilaian Imports System.Data.Odbc