A1 63
1. Form Login.vb Imports System.Data Imports System.Data.SqlClient Public Class FrmLogin Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click koneksi() v_koneksi.Open() v_cmd = New SqlCommand("SELECT * FROM admin WHERE username = '" & TxtUsername.Text & "' AND password = '" & TxtPassword.Text & "'", v_koneksi) reader = v_cmd.ExecuteReader reader.Read() If reader.HasRows Then Me.Hide() FrmInput.Show() 'FrmJumlah.Show() Else MsgBox("User tidak ditemukan!!") TxtUsername.Clear() TxtPassword.Clear() End If v_koneksi.Close() End Sub Private Sub btnBatal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBatal.Click Me.Close() End Sub Private Sub FrmLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub End Class
2. Form Input Metode.vb Imports System.Data Imports System.Data.SqlClient Public Class FrmInput Function kriteria(ByVal str As String, ByVal urut As Integer) Dim hasil As Single If str = "SS" Then If urut = 0 Then hasil = 0 End If If urut = 1 Then hasil = 0 End If If urut = 2 Then hasil = 0.25 End If ElseIf str = "S" Then If urut = 0 Then hasil = 0
64 A2
End If If urut = 1 Then hasil = 0.25 End If If urut = 2 Then hasil = 0.5 End If ElseIf str = "C" Then If urut = 0 Then hasil = 0.25 End If If urut = 1 Then hasil = 0.5 End If If urut = 2 Then hasil = 0.75 End If ElseIf str = "T" Then If urut = 0 Then hasil = 0.5 End If If urut = 1 Then hasil = 0.75 End If If urut = 2 Then hasil = 1 End If ElseIf str = "ST" Then If urut = 0 Then hasil = 0.75 End If If urut = 1 Then hasil = 1 End If If urut = 2 Then hasil = 1 End If End If Return hasil End Function Function kriteriaWp(ByVal str As String) Dim hasilwp As Integer If str = "SS" Then hasilwp = 1 ElseIf str = "S" Then hasilwp = 2 ElseIf str = "C" Then hasilwp = 3 ElseIf str = "T" Then hasilwp = 4 ElseIf str = "ST" Then hasilwp = 5 End If Return hasilwp End Function Function angka() koneksi() v_koneksi.Open()
65 A3
Dim i As Integer v_cmd = New SqlCommand("SELECT TOP 1 id FROM [metode].[dbo].[Tabel_Cek] ORDER BY id DESC ", v_koneksi) If (IsDBNull(v_cmd.ExecuteScalar)) Then j = 0 Else a = v_cmd.ExecuteScalar End If v_koneksi.Close() Return a End Function Private Sub BtnCheck_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCheck.Click Dim watch As Stopwatch = Stopwatch.StartNew() If DgvInput.RowCount > 0 Then DgvHasil.Visible = True btnReset.Visible = True LblData.Visible = True Dim j, totalbaris As Integer totalbaris = DgvInput.RowCount - 2 Dim NamaKota, K1, K2, K3, K4, K5, metode As String Dim kota()() As String = New String(totalbaris)() {} koneksi() Dim i As Integer id = angka() + 2 id = id.ToString If MenuFMADM.Checked Then metode = "FUZZY" End If If MenuWP.Checked Then metode = "WP" End If For j = 0 To totalbaris NamaKota = DgvInput.Rows(i).Cells(0).Value K1 = DgvInput.Rows(i).Cells(1).Value K2 = DgvInput.Rows(i).Cells(2).Value K3 = DgvInput.Rows(i).Cells(3).Value K4 = DgvInput.Rows(i).Cells(4).Value K5 = DgvInput.Rows(i).Cells(5).Value ' SS, S, ST, ST, C kota(i) = New String() {NamaKota, K1, K2, K3, K4, K5} v_koneksi.Open() v_cmd = New SqlCommand("INSERT INTO Tabel_Cek ([kota] ,[k1] ,[k2] ,[k3] ,[k4] ,[k5] , [id] , [metode] ,[kota_besar]) VALUES ('" & kota(i)(0) & "', '" & kota(i)(1) & "' , '" & kota(i)(2) & "' , '" & kota(i)(3) & "' , '" & kota(i)(4) & "' , '" & kota(i)(5) & "', '" & id & "' , '" & metode & "', ' ')", v_koneksi) v_cmd.ExecuteScalar() v_koneksi.Close() Next If MenuFMADM.Checked Then lblTotTime.Text = "Time : ..." Dim y1, q1, z1, ST(), T(), C(), R() As Single
66 A4
Dim tpng()() As String = New String(UBound(kota))() {} For j = 0 To UBound(kota) 'ST | T | C | R | T R = {0, 0.25, 0.5} C = {0.25, 0.5, 0.75} T = {0.5, 0.75, 1} ST = {0.75, 1, 1} y1 = Format(Val(((ST(0) - kriteria(kota(i)(1), 0)) * (T(0) - kriteria(kota(i)(2), 0)) + (C(0) * kriteria(kota(i)(3), 0)) + (R(0) * kriteria(kota(i)(4), 0)) ^ (T(0) * kriteria(kota(i)(5), 0))) / 5), "0.00") q1 = Format(Val(((ST(1) - kriteria(kota(i)(1), 1)) * (T(1) - kriteria(kota(i)(2), 1)) + (C(1) * kriteria(kota(i)(3), 1)) + (R(1) * kriteria(kota(i)(4), 1)) ^ (T(1) * kriteria(kota(i)(5), 1))) / 5), "0.00") z1 = Format(Val(((ST(2) - kriteria(kota(i)(1), 2)) * (T(2) - kriteria(kota(i)(2), 2)) + (C(2) * kriteria(kota(i)(3), 2)) + (R(2) * kriteria(kota(i)(4), 2)) ^ (T(2) ^ kriteria(kota(i)(5), 2))) / 5), "0.00") tampung(i) = {y1, q1, z1} Next Dim rms, terbesar As Single Dim kota_terbesar As String DgvHasil.Rows.Clear() For j = 0 To UBound(tampung) rumus = (1 / 2) - (0.5 * (tampung(i)(2)) + tampung(i)(1) + (1 - 0.5) + (tampung(i)(0))) DgvHasil.Rows.Add(kota(i)(0), Format(Val(rumus), "0.00")) If terbesar <= rumus Then terbesar = rumus lblbesar.Text = "Kota " & kota(i)(0) & " = " & Format(Val(terbesar), "0.00") kota_terbesar = kota(i)(0) lblbesar.Show() End If Next v_koneksi.Open() v_cmd = New SqlCommand("UPDATE [metode].[dbo].[Tabel_Cek] SET [kota_besar] = '" & kota_terbesar & "' WHERE id = '" & id & "' ", v_koneksi) v_cmd.ExecuteNonQuery() v_koneksi.Close() LblTerbesar1.Visible = True lblbesar.Visible = True lblTotTime.Visible = True watch.Stop() lblTotTime.Text = "Waktu = " & watch.Elapsed.TotalSeconds & " Detik / " & watch.Elapsed.TotalMilliseconds & " Milisecond" FrmPerbandingan.LblFuzzy.Text = watch.Elapsed.TotalSeconds & " Detik " & watch.Elapsed.TotalMilliseconds & " Ms" ElseIf MenuWP.Checked Then lblTotTime.Visible = True lblTotTime.Text = "Time : ..."
67 A5
Dim hsl(UBound(kota)), w() As Single j = {0.16, 1.22, 1.22, 1.27, 1.11} Dim terbesar_wp, hasilakhir, hasilAkhirMax, nilaiVektor As Single DgvHasil.Rows.Clear() For j = 0 To UBound(kota) hasil(i) = kriteriaWp(kota(i)(1)) + w(0) kriteriaWp(kota(i)(2)) + w(1) + kriteriaWp(kota(i)(3)) + -w(2) kriteriaWp(kota(i)(4)) + -w(3) + kriteriaWp(kota(i)(5)) + -w(4) lblbesar.Show() Next For j = 0 To UBound(hasil) nilaiVektor = nilaiVektor + hasil(i) Next Dim kota_tsbr As String For j = 0 To UBound(hasil) hasilakhir = hasil(i) * nilaiVektor DgvHasil.Rows.Add(kota(j)(0), Format(Val(hasilakhir), "0.00")) If hasilAkhirMax <= hasilakhir Then hasilAkhirMax = hasilakhir lblbesar.Text = "Kota " & kota(j)(0) & " = " & Format(Val(hasilAkhirMax), "0.00") kota_terbesar = kota(j)(0) End If Next v_koneksi.Open() v_cmd = New SqlCommand("UPDATE [metode].[dbo].[Tabel_Cek] SET [kota_besar] = '" & kota_terbesar & "' WHERE id = '" & id & "' ", v_koneksi) v_cmd.ExecuteNonQuery() v_koneksi.Close() LblTerbesar1.Visible = True lblbesar.Visible = True watch.Stop() lblTotTime.Text = "Waktu = " & watch.Elapsed.TotalSeconds & " Detik / " & watch.Elapsed.TotalMilliseconds & " Milisecond" FrmPerbandingan.LblWp.Text = watch.Elapsed.TotalSeconds & " Detik " & watch.Elapsed.TotalMilliseconds & " Ms" Else MsgBox("Silahkan Pilih Salah Satu Metode!!") End If Else MsgBox("Maaf, Data tidak ada!! Silahkan tambah.") End If End Sub Private Sub BtnLihat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnLihat.Click
68 A6
Dim kta As String = TxtKota.Text If kta = "" Then MsgBox("Kota Harus diisi!") TxtKota.Focus() ElseIf IsNumeric(kota) Then MsgBox("Kota Harus Huruf!") TxtKota.Focus() Else BtnEdit2.Visible = True DgvInput.Visible = True Dim c(5) As String If CbxC1.Text = "" Then MsgBox("C1 Harus diisi!") CbxC1.Focus() ElseIf CbxC2.Text = "" Then MsgBox("C2 Harus diisi!") CbxC2.Focus() ElseIf CbxC3.Text = "" Then MsgBox("C3 Harus diisi!") CbxC3.Focus() ElseIf CbxC4.Text = "" Then MsgBox("C4 Harus diisi!") CbxC4.Focus() ElseIf CbxC5.Text = "" Then MsgBox("C5 Harus diisi!") CbxC5.Focus() Else k(1) k(2) k(3) k(4) k(5)
= = = = =
CbxC1.SelectedItem CbxC2.SelectedItem CbxC3.SelectedItem CbxC4.SelectedItem CbxC5.SelectedItem
DgvInput.Rows.Add(kota, k(1), k(2), k(3), k(4), k(5)) TxtKota.Clear() CbxC1.ResetText() CbxC2.ResetText() CbxC3.ResetText() CbxC4.ResetText() CbxC5.ResetText() End If
End If End Sub Private Sub WPToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuFMADM.Click Dim i As String a = MenuFMADM.Checked If j = False Then MenuFMADM.Checked = True MenuWP.Checked = False If MenuFMADM.Checked Then LblSS.Text = "* SS = Sangat Sedikit" LblS.Text = "* S = Sedikit" LblC.Text = "* C = Cukup" LblT.Text = "* T = Tinggi" LblST.Text = "* ST = Sangat Tinggi"
69 A7
End If End If End Sub Private Sub MenuWP_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuWP.Click Dim i As String b = MenuWP.Checked If j = False Then MenuWP.Checked = True MenuFMADM.Checked = False If MenuWP.Checked Then LblSS.Text = "* SS = 1" LblS.Text = "* S = 2" LblC.Text = "* C = 3" LblT.Text = "* T = 4" LblST.Text = "* ST = 5" End If End If End Sub
Private Sub PerbandinganToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PerbandinganToolStripMenuItem.Click Me.Hide() FrmPerbandingan.Show() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click DgvInput.Rows.Clear() DgvHasil.Rows.Clear() DgvHasil.Visible = False DgvInput.Visible = False LblTerbesar1.Visible = False lblbesar.Visible = False lblTotTime.Visible = False btnReset.Visible = False LblData.Visible = False BtnEdit2.Visible = False End Sub Function ind(ByVal index As Integer) Return index End Function Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnEdit2.Click BtnEdit.Visible = True BtnEdit2.Visible = False BtnLihat.Visible = False BtnCheck.Visible = False Dim isi, kota, k1, k2, k3, k4, k5 As String isi = DgvInput.CurrentRow.Index kota = DgvInput.Rows(isi).Cells(0).Value k1 = DgvInput.Rows(isi).Cells(1).Value k2 = DgvInput.Rows(isi).Cells(2).Value
70 A8
k3 = DgvInput.Rows(isi).Cells(3).Value k4 = DgvInput.Rows(isi).Cells(4).Value k5 = DgvInput.Rows(isi).Cells(5).Value TxtKota.Text = kota CbxC1.Text = k1 CbxC2.Text = k2 CbxC3.Text = k3 CbxC4.Text = k4 CbxC5.Text = k5 End Sub Private Sub BtnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnEdit.Click Dim kta As String = TxtKota.Text If kta = "" Then MsgBox("Kota Harus diisi!") TxtKota.Focus() ElseIf IsNumeric(kota) Then MsgBox("Kota Harus Huruf!") TxtKota.Focus() Else BtnEdit2.Visible = True DgvInput.Visible = True If CbxC1.Text = "" Then MsgBox("C1 Harus diisi!") CbxC1.Focus() ElseIf CbxC2.Text = "" Then MsgBox("C2 Harus diisi!") CbxC2.Focus() ElseIf CbxC3.Text = "" Then MsgBox("C3 Harus diisi!") CbxC3.Focus() ElseIf CbxC4.Text = "" Then MsgBox("C4 Harus diisi!") CbxC4.Focus() ElseIf CbxC5.Text = "" Then MsgBox("C5 Harus diisi!") CbxC5.Focus() Else Dim idx As Integer index = DgvInput.CurrentRow.Index DgvInput.Rows(index).Cells(0).Value = TxtKota.Text DgvInput.Rows(index).Cells(1).Value = CbxC1.SelectedItem DgvInput.Rows(index).Cells(2).Value = CbxC2.SelectedItem DgvInput.Rows(index).Cells(3).Value = CbxC3.SelectedItem DgvInput.Rows(index).Cells(4).Value = CbxC4.SelectedItem DgvInput.Rows(index).Cells(5).Value = CbxC5.SelectedItem TxtKota.Clear() CbxC1.ResetText() CbxC2.ResetText() CbxC3.ResetText() CbxC4.ResetText() CbxC5.ResetText() BtnEdit.Visible = False BtnLihat.Visible = True BtnCheck.Visible = True End If End If End Sub
71 A9
Private Sub LihatDataToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LihatDataToolStripMenuItem.Click Me.Hide() FrmData.Show() End Sub End Class
3. Data.vb Imports System.Data Imports System.Data.SqlClient Public Class FrmData Function loading() koneksi() v_koneksi.Open() v_cmd = New SqlCommand("SELECT [kota],[k1],[k2],[k3],[k4],[k5],[metode],[kota_besar],[id_inc],[id] FROM [metode].[dbo].[Tabel_Cek] ", v_koneksi) reader = v_cmd.ExecuteReader DgvData.Rows.Clear() While reader.Read Dim aryy(9) As String arr(0) = reader(0).ToString arr(1) = reader(1).ToString arr(2) = reader(2).ToString arr(3) = reader(3).ToString arr(4) = reader(4).ToString arr(5) = reader(5).ToString arr(6) = reader(6).ToString arr(7) = reader(7).ToString arr(8) = reader(8).ToString arr(9) = "Pegecekan ke - " & reader(9).ToString DgvData.Rows.Add(arr) End While v_koneksi.Close() Return True End Function Private Sub data_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load loading() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Kembali.Click Me.Close() FrmInput.Show() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Hapus.Click For Each dr As DataGridViewRow In Me.DgvData.SelectedRows koneksi() v_koneksi.Open() v_cmd = New SqlCommand("DELETE FROM Tabel_Cek WHERE id_inc = '" & DgvData.Rows(dr.Index).Cells(8).Value & "'", v_koneksi) reader = v_cmd.ExecuteReader v_koneksi.Close()
72 A10
Next loading() End Sub
4. Modul.vb Imports System.Data Imports System.Data.SqlClient Module konek Public v_koneksi As SqlConnection Public v_cmd As SqlCommand Public dataAdapter As SqlDataAdapter Public reader As SqlDataReader Sub koneksi() v_koneksi = New SqlConnection("Data Source=harun-pc\sqlexpress; initial catalog=metode; integrated security=true") End Sub End Module
B173
Curriculum Vitae
Nama
: Muhammad Harun Daulay
Tanggal Lahir
: Batang Bulu, 07 Agustus 1992
Jenis Kelamin
: Laki - laki
Alamat Sekarang
: Jl. Jamin Ginting, Gg.Medan Area, No 5 Medan
Alamat Orang Tua
: Desa Batang Bulu Baru, Kec.Barumun Selatan, Kab. Padang Lawas
Hp
: 0821-6676-5314
Email
:
[email protected]
Riwayat Pendidikan 1999 – 2005
: SD Negeri 100940, Batang Bulu, Kec.Barumun, Kab.Padang Lawas
2005 – 2008
: SMP Negeri 3 Barumun, Batang Bulu, Kab.Padang Lawas
2008 – 2011
: SMK Negeri 1 Barumun, Jln.Karya Pembangunan No.007 Sibuhuan, Kab.Padang Lawas