LAMPIRAN A : Listing Program
1.
Form Login
Imports MySql.Data.MySqlClient Public Class formLogin
Dim adapter As MySqlDataAdapter Dim bc As MySqlDataReader
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Then MsgBox("Masukkan username dan password anda.", MsgBoxStyle.Exclamation, "Perhatian")
TextBox1.Text = "" TextBox2.Text = "" TextBox1.Focus() Else
Call konek()
Dim cmd As New MySqlCommand
cmd.CommandType = CommandType.Text
cmd.CommandText = "Select * from tbl_user where username = '" & TextBox1.Text & "' and password = '" & TextBox2.Text & "'" cmd.Connection = conn
cmd = New MySqlCommand(cmd.CommandText, conn) bc = cmd.ExecuteReader()
If Not bc.HasRows Then
MsgBox("Username atau password salah. Isi kembali.", MsgBoxStyle.Exclamation, "Error")
bc.Close()
TextBox1.Text = "" TextBox2.Text = "" TextBox1.Focus() Else
bc.Close()
TextBox1.Clear() TextBox2.Clear() Me.Visible = False menuUtama.Show() End If
End If End Sub End Class
2.
Form Menu Utama
Public Class menuUtama
Private Sub menuUtama_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TabControl1.Width = Me.Width End Sub
53
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
inputNilai.Show() End Sub
Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
konversi.Show() End Sub
Private Sub PictureBox3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox3.Click
TabControl1.TabPages(0).Focus() Me.Close()
formLogin.Show() End Sub
Private Sub PictureBox4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox4.Click
informasiSistem.Show() End Sub
Private Sub PictureBox5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox5.Click
profil.Show() End Sub
End Class
3.
Form Input Nilai Kriteria
Imports MySql.Data.MySqlClient Public Class inputNilai
Dim adapter As MySqlDataAdapter Dim table As DataTable
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Focus()
DataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect DataGridView1.EditMode =
DataGridViewEditMode.EditProgrammatically tampilDG()
ComboBox1.SelectedIndex = 0 ComboBox2.SelectedIndex = 0 ComboBox3.SelectedIndex = 0 End Sub
Private Sub tampilDG()
adapter = New MySqlDataAdapter("SELECT * FROM tbl_tanah Order By id", "server=localhost; user id=root; password=; database=db_spk") table = New DataTable
adapter.Fill(table)
DataGridView1.DataSource = table End Sub
Private Sub bersih() TextBox1.Clear() TextBox2.Clear()
54
TextBox3.Clear() TextBox6.Clear()
ComboBox1.SelectedIndex = 0 ComboBox2.SelectedIndex = 0 ComboBox3.SelectedIndex = 0 End Sub
Private Sub btn_simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_simpan.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Then
MsgBox("Kriteria belum terisi lengkap. Isi kembali!", MsgBoxStyle.Information, "Perhatian")
Else Try
Call konek()
Dim cmd As New MySqlCommand
cmd.CommandType = CommandType.Text cmd.CommandText = "Insert into
tbl_tanah(namaPemilik,luasTanah,NJOP,harga_jual,tata_ruang_kota,akses Jalan,fasilitasUmum) values ('" & TextBox1.Text & "','" &
TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox6.Text & "','" & ComboBox1.Text & "','" & ComboBox2.Text & "','" & ComboBox3.Text & "')"
cmd.Connection = conn cmd.ExecuteNonQuery()
MsgBox("Data Telah Tersimpan.", MsgBoxStyle.Information, "Berhasil")
tampilDG() Call bersih() Catch ex As Exception
MsgBox("Gagal menyimpan data.", MsgBoxStyle.Exclamation, "Error")
Call bersih() TextBox1.Focus() End Try
End If End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_batal.Click
Call bersih() End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_keluar.Click
Me.Close() End Sub
Private Sub btn_hapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_hapus.Click
If DataGridView1.RowCount = 0 Then
MsgBox("Data tidak ada.", MsgBoxStyle.Exclamation, "Warning")
ElseIf DataGridView1.SelectedRows.Count = 0 Then
MsgBox("Anda belum memilih data yang akan dihapus.", MsgBoxStyle.Exclamation, "Warning")
Else
55
If MsgBox("Anda akan menghapus data ini?", MsgBoxStyle.YesNo, "Anda Yakin?") = MsgBoxResult.Yes Then Try
Call konek()
Dim cmd As New MySqlCommand
cmd.CommandType = CommandType.Text
cmd.CommandText = "Delete FROM tbl_tanah where id = '" & DataGridView1.SelectedCells(0).Value & "'"
cmd.Connection = conn cmd.ExecuteNonQuery()
MsgBox("Data Telah Dihapus.", MsgBoxStyle.Information, "Berhasil")
TextBox1.Clear() tampilDG()
Catch ex As Exception
MsgBox("Gagal Dihapus.", MsgBoxStyle.Exclamation, "Gagal")
End Try Else
End If End If End Sub End Class
4.
Modul Koneksi
Imports MySql.Data.MySqlClient Module koneksi
Public conn As New MySqlConnection Public Sub konek()
If conn.State = ConnectionState.Closed Then
Dim myString As String = "server=localhost; user id=root; password=; database=db_spk"
Try
conn.ConnectionString = myString conn.Open()
Catch ex As Exception MsgBox(ex.Message) End Try
End If End Sub
Public Sub disconnect() Try
conn.Open()
Catch ex As Exception
End Try End Sub End Module