0% found this document useful (0 votes)
13 views

Listing Program

The documents describe code for connecting to a database and managing user authentication in a login form. The code includes classes for database connection and user management, and forms for login, home screen, and managing users.

Uploaded by

riyo romansyah
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Listing Program

The documents describe code for connecting to a database and managing user authentication in a login form. The code includes classes for database connection and user management, and forms for login, home screen, and managing users.

Uploaded by

riyo romansyah
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 50

1

Author : Riyo Romansyah

NIM : 0811530120

File : Koneksi.vb

1. Imports System.Data
2. Imports System.Data.SqlClient

3. Public Class Koneksi


4. Public Konek As New SqlConnection("Data Source=VOC-PC\SQLEXPRESS;Initial
Catalog=sispakkomp;Persist Security Info=True;User ID=sa;Password=admin")
5.
6. Public Function open() As SqlConnection
7. Try
8. Konek.Open()
9. Catch ex As Exception
10. MessageBox.Show(ex.Message)
11. End
12. End Try
13. Return Konek
14. End
15. End Function
16. Public Function Close() As SqlConnection
17. Konek.Close()
18. Return Konek
19. End Function
20. End Class

Author : Riyo Romansyah

NIM : 0811530120

File : frmHome.vb

1. Public Class Home


2. Private Sub Home_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Load
3. frmLogin.ShowDialog()
4. End Sub
5. Private Sub UserToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles UserToolStripMenuItem.Click
6. frmUser.Show()
7. End Sub
8. Private Sub KonsultasiToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles KonsultasiToolStripMenuItem1.Click
9. frmPilihKerusakan.ShowDialog()
2

10. End Sub


11. Private Sub IdentifikasiToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles IdentifikasiToolStripMenuItem1.Click
12. frmIdentifikasi.Show()
13. End Sub
14. Private Sub KesimpulanToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles KesimpulanToolStripMenuItem1.Click
15. frmKesimpulan.Show()
16. End Sub
17. Private Sub AturanToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles AturanToolStripMenuItem.Click
frmPengetahuan.Show()
18. End Sub
19. Private Sub IstilahToolStripMenuItem1_Click_1(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles IstilahToolStripMenuItem1.Click
20. frmKamus.Show()
21. End Sub
22. Private Sub AboutToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles AboutToolStripMenuItem1.Click
23. frmAbout.Show()
24. End Sub
25. Private Sub HelpToolStripMenuItem1_Click_1(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles HelpToolStripMenuItem1.Click
26. frmHelp.Show()
27. End Sub
28. Private Sub ExitToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As
System.EventArgs)
29. Dim Pesan As String
30. Pesan = MsgBox("Anda yakin keluar dari program", MsgBoxStyle.YesNo, "Information")
31. If Pesan = vbYes Then
32. Me.Close()
33. End If
34. End Sub
35. Private Sub LoginLogoffToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles LoginLogoffToolStripMenuItem1.Click
36. Me.KesimpulanToolStripMenuItem1.Enabled = False
37. Me.IdentifikasiToolStripMenuItem1.Enabled = False
38. Me.DataUserToolStripMenuItem.Enabled = False
39. Me.KonsultasiToolStripMenuItem1.Enabled = False
40. Me.PengetahuanToolStripMenuItem1.Enabled = False
41. Me.DiagnosisToolStripMenuItem.Enabled = False
42. frmLogin.Show()
43. frmLogin.txtUser.Clear()
44. frmLogin.txtPass.Clear()
45. End Sub
46. End Class
3

Author : Riyo Romansyah

NIM : 0811530120

File : frmLogin.vb

1. Imports System.Data
2. Imports System.Data.SqlClient Public Class frmLogin
3. Private Sub frmLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
4. IsiKombo()
5. End Sub
6. Private Sub btnMasuk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnMasuk.Click
7. If cbLevel.Text = "User" Then
8. txtPass.Text = "user"
9. txtUser.Text = "user"
10. Dim MyCmd As New SqlCommand
11. Dim MyConnection As New koneksi
12. Dim MyReader As SqlDataReader
13. MyCmd.CommandText = "SELECT * FROM user_list WHERE username = '" & txtUser.Text & "'
and pass = '" & txtPass.Text & "' and lev = '" & cbLevel.Text & "'" MyCmd.Connection =
MyConnection.Open
14. Try
15. MyReader = MyCmd.ExecuteReader
16. If MyReader.Read Then
17. Me.Hide()
18. Home.Show()
19. LoginUser()
20. FungsiKamus()
21. End If
22. MyReader.Close()
23. Catch ex As Exception
24. MsgBox(ex.Message)
25. End Try
26. ElseIf txtUser.Text = "" Then
27. MsgBox("Masukan Username Anda", MsgBoxStyle.Information)
28. ElseIf txtPass.Text = "" Then
29. MsgBox("Masukan Password Anda", MsgBoxStyle.Information)
30. ElseIf cbLevel.Text = "" Then
31. MsgBox("Masukan Level Anda", MsgBoxStyle.Information)
32. Else
33. Dim MyCmd As New SqlCommand
34. Dim MyConnection As New koneksi
4

35. Dim MyReader As SqlDataReader


36. MyCmd.CommandText = "SELECT * FROM user_list WHERE username = '" &
txtUser.Text & "' and pass = '" & txtPass.Text & "' and lev = '" & cbLevel.Text & "'"
37. MyCmd.Connection = MyConnection.Open
38. Try
39. MyReader = MyCmd.ExecuteReader
40. If MyReader.Read Then
41. LoginAdmin()
42. Me.Hide()
43. Else
44. MsgBox("Username atau Password Anda salah !!!",
MsgBoxStyle.Information)
45. txtUser.Focus()
46. End If
47. MyReader.Close()
48. Catch ex As Exception
49. MsgBox(ex.Message)
50. End Try
51. End If
52. End Sub
53. Private Sub IsiKombo()
54. cbLevel.Items.Add("User")
55. cbLevel.Items.Add("Administrator")
56. End Sub
57. Private Sub LoginUser()
58. Home.PengetahuanToolStripMenuItem1.Enabled = False
59. Home.KamusToolStripMenuItem1.Enabled = True
60. Home.IstilahToolStripMenuItem1.Enabled = True
61. Home.KesimpulanToolStripMenuItem1.Enabled = False
62. Home.IdentifikasiToolStripMenuItem1.Enabled = False
63. Home.AturanToolStripMenuItem.Enabled = False
64. Home.BasisDataToolStripMenuItem.Enabled = False
65. Home.KonsultasiToolStripMenuItem1.Enabled = True
66. Home.DiagnosisToolStripMenuItem.Enabled = True
67. Home.UserToolStripMenuItem.Enabled = False
68. End Sub
69. Private Sub LoginAdmin()
70. Home.PengetahuanToolStripMenuItem1.Enabled = True
71. Home.KamusToolStripMenuItem1.Enabled = True
72. Home.KesimpulanToolStripMenuItem1.Enabled = True
73. Home.IdentifikasiToolStripMenuItem1.Enabled = True
74. Home.AturanToolStripMenuItem.Enabled = True
75. Home.KonsultasiToolStripMenuItem1.Enabled = True
76. Home.DiagnosisToolStripMenuItem.Enabled = True
77. Home.DataUserToolStripMenuItem.Enabled = True
78. End Sub
Private Sub btnKeluar_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnKeluar.Click
5

79. Me.Hide()
80. FungsiKamus()
81. Home.BasisDataToolStripMenuItem.Enabled = False
82. Home.DiagnosisToolStripMenuItem.Enabled = False
83. Home.PengetahuanToolStripMenuItem1.Enabled = False
84. Home.DataUserToolStripMenuItem.Enabled = False
85. Home.UserToolStripMenuItem.Enabled = False
86. End Sub
87. Private Sub FungsiKamus()
88. frmKamus.btnTambah.Hide()
89. frmKamus.btnEdit.Hide()
90. frmKamus.btnSimpan.Hide()
91. frmKamus.btnHapus.Hide()
92. frmKamus.btnBatal.Hide()
93. End Sub
94. End Class

Author : Riyo Romansyah

NIM : 0811530120

File : frmUser.vb

1. Imports System.Data
2. Imports System.Data.SqlClient
3. Public Class frmUser
4. Dim clsUser As New clsUser
5. Dim MyCmd As New SqlCommand
6. Dim MyConnection As New koneksi
7. Dim MyReader As SqlDataReader
8. Private Sub frmUser_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Load
9. txtPass.Focus()
10. TampilData()
11. awal()
12. IsiKombo()
13. End Sub
14. #Region "Function"
15. Private Sub awal()
16. TampilDAta()
17. Bersih()
18. TextNonAktif()
19. btnTambah.Focus()
20. End Sub
21. Private Sub Bersih()
22. txtUser.Clear()
6

23. txtPass.Clear()
24. End Sub
25. Private Sub TextAktif()
26. txtUser.Enabled = True
27. txtPass.Enabled = True
28. cbLevel.Enabled = True
29. End Sub
30. Private Sub TextNonAktif()
31. txtUser.Enabled = False
32. txtPass.Enabled = False
33. cbLevel.Enabled = False
34. End Sub
35. Private Sub btnNew()
36. btnEdit.Enabled = False
37. btnHapus.Enabled = False
38. End Sub
39. Private Sub AmbilData()
40. clsUser.User_ = txtUser.Text()
41. clsUser.Pass_ = txtPass.Text()
42. clsUser.Level_ = cbLevel.Text()
43. End Sub
44. Private Sub IsiKombo()
45. cbLevel.Items.Add("User")
46. cbLevel.Items.Add("Administrator")
47. End Sub
48. Private Sub TampilData()
49. MyCmd.CommandText = "SELECT * FROM user_list ORDER BY username ASC"
50. MyCmd.Connection = MyConnection.Open()
51. Try
52. MyReader = MyCmd.ExecuteReader
53. lvUser.Items.Clear()
54. While MyReader.Read
55. With lvUser.Items.Add(MyReader.Item("username").ToString)
56. .SubItems.Add(MyReader.Item("pass").ToString)
57. .SubItems.Add(MyReader.Item("lev").ToString)
58. End With
59. End While
60. MyReader.Close()
61. Catch ex As Exception
62. MessageBox.Show(ex.Message)
63. End Try
64. MyConnection.Close()
65. End Sub
66. #End Region
67. #Region "Event"
68. Private Sub btnTambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnTambah.Click
69. TextAktif()
7

70. Bersih()
71. txtUser.Focus()
72. btnNew()
73. End Sub
74. Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnEdit.Click
75. If Len(txtUser.Text) = 0 Then
76. MsgBox("Pilih data dari tabel")
77. Else
78. AmbilData()
79. clsUser.Edit()
80. Bersih()
81. awal()
82. End If
83. End Sub
84. Private Sub btnSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnSimpan.Click
85. If Len(txtUser.Text) = 0 Then
86. MsgBox("Data Harus diisi semua !!")
87. Else
88. AmbilData()
89. clsUser.Simpan()
90. Bersih()
91. awal()
92. End If
93. End Sub
94. Private Sub btnHapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnHapus.Click
95. AmbilData()
96. clsUser.Hapus()
97. Bersih()
98. awal()
99. MsgBox("Data Berhasil Di Hapus", MsgBoxStyle.Information, "Information")
100. End Sub
101. Private Sub btnBatal_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnBatal.Click
102. TextNonAktif()
103. Bersih()
104. btnTambah.Enabled = True
105. btnEdit.Enabled = False
106. btnSimpan.Enabled = True
107. btnHapus.Enabled = False
108. End Sub
Private Sub lvUser_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs)
Handles lvUser.DoubleClick
109. btnSimpan.Enabled = False
110. btnTambah.Enabled = False
111. btnEdit.Enabled = True
8

112. btnHapus.Enabled = True


113. TextAktif()
114. Bersih()
115. txtUser.Text = lvUser.SelectedItems(0).SubItems(0).Text.ToString
116. txtPass.Text = lvUser.SelectedItems(0).SubItems(1).Text.ToString
117. cbLevel.Text = lvUser.SelectedItems(0).SubItems(2).Text.ToString
118. End Sub
119. #End Region
120. End Class

Author : Riyo Romansyah

NIM : 0811530120

File : clsUser.vb

1. Imports System.Data
2. Imports System.Data.SqlClient
3. Public Class clsUser
4. #Region "Property"
5. Dim User As String
6. Dim Pass As String
7. Dim Level As String
8.
9. Public Property User_ As String
10. Get
11. Return User
12. End Get
13. Set(ByVal value As String)
14. User = value
15. End Set
16. End Property
17. Public Property Pass_ As String
18. Get
19. Return Pass
20. End Get
21. Set(ByVal value As String)
22. Pass = value
23. End Set
24. End Property
25. Public Property Level_ As String
26. Get
27. Return Level
28. End Get
29. Set(ByVal value As String)
30. Level = value
31. End Set
9

32. End Property


33. #End Region
34. #Region "Event"
35. Dim MyCmd As New SqlCommand
36. Dim MyConnection As New koneksi
37. Public Sub Simpan()
38. MyCmd.CommandText = "INSERT INTO user_list (username, pass, lev) values ('" & User &
"','" & Pass & "', '" & Level & "');"
39. MyCmd.Connection = MyConnection.Open
40. MyCmd.ExecuteNonQuery()
41. MyConnection.Close()
42. MsgBox("Data User telah disimpan", MsgBoxStyle.Information, "Information")
43. End Sub
44. Public Sub Edit()
45. MyCmd.CommandText = "UPDATE user_list set pass = '" & Pass & "', lev = '" & Level & "'
WHERE username = '" & User & "'"
46. MyCmd.Connection = MyConnection.Open
47. MyCmd.ExecuteNonQuery()
48. MyConnection.Close()
49. MsgBox("Data User telah diupdate", MsgBoxStyle.Information, "Information")
50. End Sub
51. Public Sub Hapus()
52. MyCmd.CommandText = "DELETE FROM user_list WHERE username = '" & User & "'"
53. MyCmd.Connection = MyConnection.Open
54. MyCmd.ExecuteNonQuery()
55. MyConnection.Close()
56. MsgBox("Data User telah dihapus", MsgBoxStyle.Information, "Information")
57. End Sub
58. #End Region
59. End Class

Author : Riyo Romansyah

NIM : 0811530120

File : frmPilihKerusakan.vb

1. Imports System.Data
2. Imports System.Data.SqlClient
3. Public Class frmPilihKerusakan
4. Private Sub frmPilihKerusakan_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
5. IsiKombo()
6. End Sub
7. #Region "Event"
8. Private Sub cbKerusakan_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
cbKerusakan.Click
10

9. btnProses.Enabled = True
10. End Sub
11. Private Sub btnProses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnProses.Click
12. frmDiagnosis.HapusTemp()
13. If cbKerusakan.Text = "" Then
14. MsgBox("Pilih salah satu kemungkinan kerusakan", MsgBoxStyle.Information)
15. Else
16. frmDiagnosis.Showdialog()
17. End If
18. End Sub
19. Private Sub cbKerusakan_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cbKerusakan.SelectedIndexChanged
20. IsiKode()
21. End Sub
22. #End Region
23. #Region "Function"
24. Private Sub IsiKombo()
25. Dim MyCmd As New SqlCommand
26. Dim MyConnection As New koneksi
27. Dim MyReader As SqlDataReader
28. MyCmd.CommandText = "SELECT * FROM kesimpulan ORDER BY kd_kesimpulan ASC"
29. MyCmd.Connection = MyConnection.Open()
30. Try
31. MyReader = MyCmd.ExecuteReader
32. cbKerusakan.Items.Clear()
33. While MyReader.Read
34. With cbKerusakan.Items.Add(MyReader.Item("Kesimpulan").ToString)
35. End With
36. End While
37. Catch ex As Exception
38. MessageBox.Show(ex.Message)
39. End Try
40. MyConnection.Close()
41. End Sub
42. Private Sub IsiKode()
43. Dim MyCmd As New SqlCommand
44. Dim MyConnection As New koneksi
45. Dim MyReader As SqlDataReader
46. MyCmd.CommandText = "SELECT kd_kesimpulan FROM kesimpulan WHERE kesimpulan = '"
& cbKerusakan.Text & "'"
47. MyCmd.Connection = MyConnection.Open()
48. MyReader = MyCmd.ExecuteReader
49. While MyReader.Read
50. txtKd_Kerusakan.Text = MyReader.Item("kd_kesimpulan").ToString
51. End While
52. End Sub
53. #End Region
11

54. End Class

Author : Riyo Romansyah

NIM : 0811530120

File : frmDiagnosis.vb

1. Imports System.Data
2. Imports System.Data.SqlClient
3. Public Class frmDiagnosis
4. Dim koneksi As New koneksi
5. Dim clsKesimpulan As New clsKesimpulan
6. Dim MyCmd As New SqlCommand
7. Dim MyConnection As New koneksi
8. Dim MyReader As SqlDataReader
9. Private Sub frmDiagnosis_Activated(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Activated
10. On Error Resume Next
11. Dim nilai As String
12. Dim kode As String
13. nilai = frmPilihKerusakan.cbKerusakan.SelectedItem
14. txtDiagnosis.Text = nilai
15. kode = frmPilihKerusakan.txtKd_Kerusakan.Text
16. txtKode.Text = kode
17. HapusTemp()
18. End Sub
19. Private Sub frmDiagnosis_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Load
20. On Error Resume Next
21. Dim nilai As String
22. Dim kode As String
23. nilai = frmPilihKerusakan.cbKerusakan.SelectedItem
24. txtDiagnosis.Text = nilai
25. kode = frmPilihKerusakan.txtKd_Kerusakan.Text
26. txtKode.Text = kode
27. HapusTemp()
28. End Sub
29. #Region "Event"
30. Private Sub btnYa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnYa.Click
31. If txtKode.Text.Contains("A") Then
32. SimpanTemp()
33. frmHasilDiagnosis.ShowDialog()
34. ElseIf txtKode.Text.Contains("K") Then
35. SimpanTemp()
36. MyCmd.CommandText = ("SELECT identifikasi.kd_identifikasi, identifikasi.pertanyaan
12

FROM identifikasi, aturan " & _


37. "WHERE aturan.ya1 = '" & txtKode.Text & "' and identifikasi.kd_identifikasi =
aturan.ya2 ")
38. MyCmd.Connection = MyConnection.Open
39. Try
40. MyReader = MyCmd.ExecuteReader
41. txtDiagnosis.Clear()
42. txtKode.Clear()
43. If MyReader.Read Then
44. txtKode.Text = MyReader.Item("kd_identifikasi").ToString
45. txtDiagnosis.Text = MyReader.Item("pertanyaan").ToString
46. End If
47. MyReader.Close()
48. Catch ex As Exception
49. End Try
50. MyConnection.Close()
51. Else
52. SimpanTemp()
53. MyCmd.CommandText = ("SELECT identifikasi.kd_identifikasi, identifikasi.pertanyaan
FROM identifikasi, aturan " & _
54. "WHERE aturan.ya1 = '" & txtKode.Text & "' and identifikasi.kd_identifikasi =
aturan.ya2 ")
55. MyCmd.Connection = MyConnection.Open
56. Try
57. MyReader = MyCmd.ExecuteReader
58. txtDiagnosis.Clear()
59. txtKode.Clear()
60. If MyReader.Read Then
61. txtKode.Text = MyReader.Item("kd_identifikasi").ToString
62. txtDiagnosis.Text = MyReader.Item("pertanyaan").ToString
63. End If
64. MyReader.Close()
65. Catch ex As Exception
66. End Try
67. MyConnection.Close()
68. End If
69. End Sub
70. Private Sub btnTdk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnTdk.Click
71. If txtKode.Text.Contains("A") Then
72. SimpanTempTidak()
73. frmNextSolusi.ShowDialog()
74. ElseIf txtKode.Text.Contains("K") Then
75. SimpanTempTidak()
76. MyCmd.CommandText = ("SELECT kesimpulan.kd_kesimpulan, kesimpulan.kesimpulan
FROM kesimpulan, aturan " & _
77. "WHERE aturan.tdk1 = '" & txtKode.Text & "' AND
kesimpulan.kd_kesimpulan = aturan.tdk2")
13

78. MyCmd.Connection = MyConnection.Open


79. Try
80. MyReader = MyCmd.ExecuteReader
81. txtDiagnosis.Clear()
82. txtKode.Clear()
83. If MyReader.Read Then
84. txtKode.Text = MyReader.Item("kd_kesimpulan").ToString
85. txtDiagnosis.Text = MyReader.Item("kesimpulan").ToString
86. Else
87. MsgBox("Kerusakan tkdak teridentifikasi", MsgBoxStyle.Information)
88. End If
89. MyReader.Close()
90. Catch ex As Exception
91. MessageBox.Show(ex.Message)
92. End Try
93. MyConnection.Close()
94. Else
95. SimpanTempTidak()
96. MyCmd.CommandText = ("SELECT identifikasi.kd_identifikasi,identifikasi.pertanyaan
FROM identifikasi, aturan " & _
97. " WHERE aturan.tdk1 = '" & txtKode.Text & "' AND identifikasi. kd_identifikasi
= aturan.tdk2")
98. MyCmd.Connection = MyConnection.Open
99. Try
100. MyReader = MyCmd.ExecuteReader
101. txtDiagnosis.Clear()
102. txtKode.Clear()
103. If MyReader.Read Then
104. txtKode.Text = MyReader.Item("kd_identifikasi").ToString
105. txtDiagnosis.Text = MyReader.Item("pertanyaan").ToString
106. Else
107. frmNextSolusi.Show()
108. End If
109. MyReader.Close()
110. Catch ex As Exception
111. MessageBox.Show(ex.Message)
112. End Try
113. MyConnection.Close()
114. End If
115. End Sub
116. Private Sub btnBatal_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnBatal.Click
117. Me.Dispose()
118. End Sub
119. #End Region
120. #Region "Function"
121. Public Sub HapusTemp()
122. Dim MyCmd As New SqlCommand
14

123. Dim MyConnection As New koneksi


124. MyCmd.CommandText = "TRUNCATE TABLE temp"
125. MyCmd.Connection = MyConnection.Open()
126. MyCmd.ExecuteNonQuery()
127. MyConnection.Close()
128. End Sub
129. Public Sub SimpanTemp()
130. Dim MyCmd As New SqlCommand
131. Dim MyConnection As New koneksi
132. MyCmd.CommandText = "INSERT INTO temp (kd_identifikasi, pertanyaan,aturan)
values ('" & txtKode.Text & "','" & txtDiagnosis.Text & "','Ya')"
133. MyCmd.Connection = MyConnection.Open()
134. MyCmd.ExecuteNonQuery()
135. MyConnection.Close()
136. End Sub
137. Public Sub SimpanTempTidak()
138. Dim MyCmd As New SqlCommand
139. Dim MyConnection As New koneksi
140. MyCmd.CommandText = "INSERT INTO temp (kd_identifikasi, pertanyaan,aturan)
values ('" & txtKode.Text & "','" & txtDiagnosis.Text & "','Tidak')"
141. MyCmd.Connection = MyConnection.Open()
142. MyCmd.ExecuteNonQuery()
143. MyConnection.Close()
144. End Sub
145. Private Sub Buttonmati()
146. btnTdk.Enabled = False
147. btnTdk.Dispose()
148. End Sub
149. #End Region
150. End Class

Author : Riyo Romansyah

NIM : 0811530120

File : frmHasilDiagnosis.vb

1. Imports System.Data
2. Imports System.Data.SqlClient
3. Public Class frmHasilDiagnosis
4. Dim koneksi As New koneksi
5. Dim MyCmd As New SqlCommand
6. Dim MyConnection As New koneksi
7. Dim MyReader As SqlDataReader
8. Private Sub frmHasilDiagnosis_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
9. AmbilSolusi()
15

10. IsiLv()
11. End Sub
12. #Region "Event"
13. Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnExit.Click
14. Me.Hide()
15. frmDiagnosis.Hide()
16. End Sub
17. #End Region
18. #Region "Function"
19. Private Sub AmbilSolusi()
20. MyCmd.CommandText = ("SELECT top 1 kesimpulan.kd_kesimpulan,
kesimpulan.kesimpulan, kesimpulan.solusi, temp.kd_identifikasi FROM kesimpulan, temp,
arahan " & _
21. " WHERE temp.kd_identifikasi = arahan.kd_identifikasi and
arahan.kd_kesimpulan = kesimpulan.kd_kesimpulan ORDER by temp.kd_identifikasi desc")
22. MyCmd.Connection = MyConnection.Open
23. Try
24. MyReader = MyCmd.ExecuteReader
25. txtSolusi.Clear()
26. While MyReader.Read
27. txtIdKerusakan.Text = MyReader.Item("kd_kesimpulan").ToString
28. txtKesimpulan.Text = MyReader.Item("kesimpulan").ToString
29. txtSolusi.Text = MyReader.Item("Solusi").ToString
30. End While
31. MyReader.Close()
32. Catch ex As Exception
33. MessageBox.Show(ex.Message)
34. End Try
35. MyConnection.Close()
36. End Sub
37. Public Sub IsiLv()
38. MyCmd.CommandText = ("SELECT * FROM temp WHERE kd_identifikasi not like '%F%' and
aturan = 'ya' ORDER BY kd_identifikasi DESC")
39. MyCmd.Connection = MyConnection.Open
40. MyReader = MyCmd.ExecuteReader
41. lvAlasan.Items.Clear()
42. Try
43. While MyReader.Read
44. With lvAlasan.Items.Add(MyReader.Item("kd_identifikasi").ToString)
45. .SubItems.Add(MyReader.Item("pertanyaan").ToString)
46. End With
47. End While
48. MyReader.Close()
49. Catch ex As Exception
50. MessageBox.Show(ex.Message)
51. End Try
52. MyConnection.Close()
16

53. End Sub


54. #End Region
55. End Class

Author : Riyo Romansyah

NIM : 0811530120

File : frmNextSolusi.vb

1. Imports System.Data
2. Imports System.Data.SqlClient
3. Public Class frmNextSolusi
4. Dim Koneksi As New koneksi
5. Dim MyCmd As New SqlCommand
6. Dim MyConnection As New koneksi
7. Dim MyReader As SqlDataReader
8. Private Sub TampilDataSolusi()
9. MyCmd.CommandText = ("SELECT kesimpulan.kd_kesimpulan, kesimpulan.kesimpulan,
kesimpulan.solusi, temp.kd_identifikasi FROM kesimpulan, (select top 1 * from temp order by 1
asc) temp, arahan " & _
10. " WHERE temp.kd_identifikasi = arahan.kd_identifikasi and
arahan.kd_kesimpulan = kesimpulan.kd_kesimpulan ORDER by temp.kd_identifikasi desc")
11. MyCmd.Connection = MyConnection.Open()
12. Try
13. MyReader = MyCmd.ExecuteReader
14. lvKesimpulan.Items.Clear()
15. While MyReader.Read
16. With lvKesimpulan.Items.Add(MyReader.Item("kesimpulan").ToString)
17. .SubItems.Add(MyReader.Item("solusi").ToString)
18. End With
19. End While
20. MyReader.Close()
21. Catch ex As Exception
22. MessageBox.Show(ex.Message)
23. End Try
24. MyConnection.Close()
25. End Sub
26. Private Sub frmNextSolusi_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
27. TampilDataSolusi()
28. IsiLv()
29. IsiLvT()
30. End Sub
31. Public Sub IsiLv()
32. MyCmd.CommandText = ("SELECT * FROM temp WHERE aturan='Ya' ORDER BY
kd_identifikasi DESC")
17

33. MyCmd.Connection = MyConnection.Open


34. MyReader = MyCmd.ExecuteReader
35. lvAlasan.Items.Clear()
36. Try
37. While MyReader.Read
38. With lvAlasan.Items.Add(MyReader.Item("kd_identifikasi").ToString)
39. .SubItems.Add(MyReader.Item("pertanyaan").ToString)
40. End With
41. End While
42. MyReader.Close()
43. Catch ex As Exception
44. MessageBox.Show(ex.Message)
45. End Try
46. MyConnection.Close()
47. End Sub
48. Public Sub IsiLvT()
49. MyCmd.CommandText = ("SELECT * FROM temp WHERE aturan='Tidak' ORDER BY
kd_identifikasi DESC")
50. MyCmd.Connection = MyConnection.Open
51. MyReader = MyCmd.ExecuteReader
52. lvAlasanTidak.Items.Clear()
53. Try
54. While MyReader.Read
55. With lvAlasanTidak.Items.Add(MyReader.Item("kd_identifikasi").ToString)
56. .SubItems.Add(MyReader.Item("pertanyaan").ToString)
57. End With
58. End While
59. MyReader.Close()
60. Catch ex As Exception
61. MessageBox.Show(ex.Message)
62. End Try
63. MyConnection.Close()
64. End Sub
65. End Class

Author : Riyo Romansyah

NIM : 0811530120

File : frmIdentifikasi.vb

1. Imports System.Data
2. Imports System.Data.SqlClient
3. Public Class frmIdentifikasi
4. Dim clsidentifikasi As New clsIdentifikasi
5. Dim MyCmd As New SqlCommand
6. Dim MyConnection As New Koneksi
18

7. Dim MyReader As SqlDataReader


8. Private Sub frmIdentifikasi_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
9. Awal()
10. txtPertanyaan.Focus()
11. End Sub
12. #Region "Function"
13. Private Sub Awal()
14. TampilData()
15. Bersih()
16. TextNonAktif()
17. btnTambah.Focus()
18. End Sub
19. Private Sub Bersih()
20. txtPertanyaan.Clear()
21. txtKd_Identifikasi.Clear()
22. End Sub
23. Private Sub TextAktif()
24. txtKd_Identifikasi.Enabled = True
25. txtPertanyaan.Enabled = True
26. End Sub
27. Private Sub TextNonAktif()
28. txtKd_Identifikasi.Enabled = False
29. txtPertanyaan.Enabled = False
30. End Sub
31. Private Sub btnNew()
32. btnEdit.Enabled = False
33. btnHapus.Enabled = False
34. End Sub
35. Private Sub AmbilData()
36. clsidentifikasi.KdIdentifikasi_ = txtKd_Identifikasi.Text()
37. clsidentifikasi.pertanyaan_ = txtPertanyaan.Text()
38. End Sub
39. Private Sub TampilData()
40. MyCmd.CommandText = "SELECT * FROM identifikasi ORDER BY kd_identifikasi ASC"
41. MyCmd.Connection = MyConnection.Open()
42. Try
43. MyReader = MyCmd.ExecuteReader
44. lvIdentifikasi.Items.Clear()
45. While MyReader.Read
46. With lvIdentifikasi.Items.Add(MyReader.Item("kd_identifikasi").ToString)
47. .SubItems.Add(MyReader.Item("pertanyaan").ToString)
48. End With
49. End While
50. MyReader.Close()
51. Catch ex As Exception
52. MessageBox.Show(ex.Message)
53. End Try
19

54. MyConnection.Close()
55. End Sub
56. #End Region
57. #Region "Event"
58. Private Sub btnTambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnTambah.Click
59. TextAktif()
60. Bersih()
61. txtKd_Identifikasi.Enabled = True
62. txtKd_Identifikasi.Focus()
63. btnNew()
64. End Sub
65. Private Sub btnBatal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnBatal.Click
66. TextNonAktif()
67. Bersih()
68. btnTambah.Enabled = True
69. btnEdit.Enabled = False
70. btnSimpan.Enabled = True
71. btnHapus.Enabled = False
72. End Sub
73. Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnEdit.Click
74. If Len(txtPertanyaan.Text) = 0 Then
75. MsgBox("Pilih salah satu data dari Tabel")
76. Else
77. AmbilData()
78. clsidentifikasi.Ubah()
79. Bersih()
80. Awal()
81. End If
82. End Sub
83. Private Sub btnSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnSimpan.Click
84. If Len(txtPertanyaan.Text) = 0 Then
85. MsgBox("Data harus diisi semua...!")
86. Else
87. AmbilData()
88. clsidentifikasi.Simpan()
89. Bersih()
90. Awal()
91. End If
92. End Sub
93. Private Sub lvIdentifikasi_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs)
Handles lvIdentifikasi.DoubleClick
94. btnSimpan.Enabled = False
95. btnTambah.Enabled = False
96. btnEdit.Enabled = True
20

97. btnHapus.Enabled = True


98. TextAktif()
99. Bersih()
100. txtKd_Identifikasi.Text = lvIdentifikasi.SelectedItems(0).SubItems(0).Text.ToString
101. txtPertanyaan.Text = lvIdentifikasi.SelectedItems(0).SubItems(1).Text.ToString
102. End Sub
103. Private Sub btnHapus_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnHapus.Click
104. Dim pesan As String
105. pesan = MsgBox("Yakin data akan dihapus?", MsgBoxStyle.YesNo, "Information")
106. If pesan = vbYes Then
107. AmbilData()
108. clsidentifikasi.Hapus()
109. Bersih()
110. Awal()
111. Else
112. MsgBox("Data Tidak Jadi Di Hapus...!", MsgBoxStyle.Information, "Information")
113. Bersih()
114. Awal()
115. End If
116. Awal()
117. End Sub
118. Private Sub txtCari_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles txtCari.TextChanged
119. MyCmd.CommandText = "SELECT * FROM identifikasi WHERE pertanyaan like'%" &
Trim(txtCari.Text) & "%' ORDER BY kd_identifikasi ASC"
120. MyCmd.Connection = MyConnection.open()
121. Try
122. MyReader = MyCmd.ExecuteReader
123. lvIdentifikasi.Items.Clear()
124. While MyReader.Read
125. With lvIdentifikasi.Items.Add(MyReader.Item("kd_identifikasi").ToString)
126. .SubItems.Add(MyReader.Item("pertanyaan").ToString)
127. End With
128. End While
129. MyReader.Close()
130. Catch ex As Exception
131. MessageBox.Show(ex.Message)
132. End Try
133. MyConnection.Close()
134. End Sub
135. #End Region
136. End Class

Author : Riyo Romansyah


21

NIM : 0811530120

File : clsIdentifikasi.vb

1. Imports System.Data
2. Imports System.Data.SqlClient
3. Public Class clsIdentifikasi
4. #Region "Deklarasi Variabel"
5. Private KdIdentifikasi As String
6. Private pertanyaan As String
7. #End Region
8. #Region "Property"
9. Public Property KdIdentifikasi_() As String
10. Get
11. Return KdIdentifikasi
12. End Get
13. Set(ByVal value As String)
14. KdIdentifikasi = value
15. End Set
16. End Property
17. Public Property pertanyaan_() As String
18. Get
19. Return pertanyaan
20. End Get
21. Set(ByVal value As String)
22. pertanyaan = value
23. End Set
24. End Property
25. #End Region
26. #Region "Event"
27. Public Sub Simpan()
28. Dim MyCmd As New SqlCommand
29. Dim MyConnection As New Koneksi
30. MyCmd.CommandText = "INSERT INTO identifikasi (kd_identifikasi,pertanyaan) values ('" &
KdIdentifikasi & "','" & pertanyaan & "');"
31. MyCmd.Connection = MyConnection.open()
32. MyCmd.ExecuteNonQuery()
33. MyConnection.Close()
34. MsgBox("Data Telah di Simpan", MsgBoxStyle.Information, "Information")
35. End Sub
36. Public Sub Ubah()
37. Dim MyCmd As New SqlCommand
38. Dim MyConnection As New Koneksi
39. MyCmd.CommandText = "UPDATE identifikasi SET pertanyaan = '" & pertanyaan & "'
WHERE kd_identifikasi = '" & KdIdentifikasi & "'"
40. MyCmd.Connection = MyConnection.open()
41. MyCmd.ExecuteNonQuery()
42. MyConnection.Close()
22

43. MsgBox("Data Telah di Ubah", MsgBoxStyle.Information, "Information")


44. End Sub
45. Public Sub Hapus()
46. Dim MyCmd As New SqlCommand
47. Dim MyConnection As New Koneksi
48. MyCmd.CommandText = "DELETE FROM identifikasi WHERE kd_identifikasi = '" &
KdIdentifikasi & "'"
49. MyCmd.Connection = MyConnection.open()
50. MyCmd.ExecuteNonQuery()
51. MyConnection.Close()
52. MsgBox("Data Telah di Hapus", MsgBoxStyle.Information, "Information")
53. End Sub
54. #End Region
55. End Class

Author : Riyo Romansyah

NIM : 0811530120

File : frmKesimpulan.vb

1. Imports System.Data
2. Imports System.Data.SqlClient
3. Public Class frmKesimpulan
4. Dim clskesimpulan As New clskesimpulan
5. Dim MyCmd As New SqlCommand
6. Dim MyConnection As New koneksi
7. Dim MyReader As SqlDataReader
8. Private Sub frmKesimpulan_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
9. Awal()
10. End Sub
11. #Region "Function"
12. Private Sub Awal()
13. TampilData()
14. Bersih()
15. TextNonAktif()
16. btnTambah.Focus()
17. End Sub
18. Private Sub Bersih()
19. txtKesimpulan.Clear()
20. txtKd_Kesimpulan.Clear()
21. txtSolusi.Clear()
22. End Sub
23. Private Sub TextAktif()
24. txtKd_Kesimpulan.Enabled = True
25. txtKesimpulan.Enabled = True
23

26. txtSolusi.Enabled = True


27. End Sub
28. Private Sub TextNonAktif()
29. txtKd_Kesimpulan.Enabled = False
30. txtKesimpulan.Enabled = False
31. txtSolusi.Enabled = False
32. End Sub
33. Private Sub btnNew()
34. btnEdit.Enabled = False
35. btnHapus.Enabled = False
36. End Sub
37. Private Sub AmbilData()
38. clskesimpulan.kd_kesimpulan_ = txtKd_Kesimpulan.Text()
39. clskesimpulan.kesimpulan_ = txtKesimpulan.Text()
40. clskesimpulan.solusi_ = txtSolusi.Text()
41. End Sub
42. Private Sub TampilData()
43. MyCmd.CommandText = "SELECT * FROM kesimpulan ORDER BY kd_kesimpulan DESC"
44. MyCmd.Connection = MyConnection.Open()
45. Try
46. MyReader = MyCmd.ExecuteReader
47. lvKesimpulan.Items.Clear()
48. While MyReader.Read
49. With lvKesimpulan.Items.Add(MyReader.Item("kd_kesimpulan").ToString)
50. .SubItems.Add(MyReader.Item("kesimpulan").ToString)
51. .SubItems.Add(MyReader.Item("solusi").ToString)
52. End With
53. End While
54. MyReader.Close()
55. Catch ex As Exception
56. MessageBox.Show(ex.Message)
57. End Try
58. MyConnection.Close()
59. End Sub
60. #End Region
61. #Region "Event"
62. Private Sub btnTambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnTambah.Click
63. TextAktif()
64. Bersih()
65. txtKd_Kesimpulan.Enabled = True
66. txtKd_Kesimpulan.Focus()
67. End Sub
68. Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnEdit.Click
69. If Len(txtKesimpulan.Text) = 0 Then
70. MsgBox("Pilih data dari tabel")
71. Else
24

72. AmbilData()
73. clskesimpulan.Ubah()
74. Bersih()
75. Awal()
76. End If
77. End Sub
78. Private Sub btnSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnSimpan.Click
79. If Len(txtKesimpulan.Text) = 0 Then
80. MsgBox("Data harus diisi semua !")
81. Else
82. AmbilData()
83. clskesimpulan.Simpan()
84. Bersih()
85. Awal()
86. End If
87. End Sub
88. Private Sub btnHapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnHapus.Click
89. Dim Pesan As String
90. Pesan = MsgBox("Yakin data akan dihapus ?", MsgBoxStyle.YesNo, "Information")
91. If Pesan = vbYes Then
92. AmbilData()
93. clskesimpulan.Hapus()
94. Bersih()
95. Awal()
96. Else
97. MsgBox("Data Tidak Jadi Di Hapus", MsgBoxStyle.Information, "Information")
98. Bersih()
99. Awal()
100. End If
101. Awal()
102. End Sub
103. Private Sub btnBatal_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnBatal.Click
104. TextNonAktif()
105. Bersih()
106. btnTambah.Enabled = True
107. btnEdit.Enabled = False
108. btnSimpan.Enabled = True
109. btnHapus.Enabled = False
110. End Sub
111. Private Sub lvKesimpulan_DoubleClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles lvKesimpulan.DoubleClick
112. btnSimpan.Enabled = False
113. btnTambah.Enabled = False
114. btnEdit.Enabled = True
115. btnHapus.Enabled = True
25

116. TextAktif()
117. Bersih()
118. txtKd_Kesimpulan.Text = lvKesimpulan.SelectedItems(0).SubItems(0).Text.ToString
119. txtKesimpulan.Text = lvKesimpulan.SelectedItems(0).SubItems(1).Text.ToString
120. txtSolusi.Text = lvKesimpulan.SelectedItems(0).SubItems(2).Text.ToString
121. End Sub
122. Private Sub txtCari_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles txtCari.TextChanged
123. MyCmd.CommandText = "SELECT * FROM kesimpulan WHERE kesimpulan like '%" &
Trim(txtCari.Text) & "%' ORDER BY kd_kesimpulan DESC"
124. MyCmd.Connection = MyConnection.Open()
125. Try
126. MyReader = MyCmd.ExecuteReader
127. lvKesimpulan.Items.Clear()
128. While MyReader.Read
129. With lvKesimpulan.Items.Add(MyReader.Item("kd_kesimpulan").ToString)
130. .SubItems.Add(MyReader.Item("kesimpulan").ToString)
131. .SubItems.Add(MyReader.Item("solusi").ToString)
132. End With
133. End While
134. MyReader.Close()
135. Catch ex As Exception
136. MessageBox.Show(ex.Message)
137. End Try
138. MyConnection.Close()
139. End Sub
140. #End Region
141. End Class

Author : Riyo Romansyah

NIM : 0811530120

File : clsKesimpulan.vb

1. Imports System.Data
2. Imports System.Data.SqlClient
3. Public Class clskesimpulan
4. #Region "Deklarasi Variabel"
5. Private kd_kesimpulan As String
6. Private kesimpulan As String
7. Private solusi As String
8. #End Region
9. #Region "Property"
10. Public Property kd_kesimpulan_() As String
11. Get
12. Return kd_kesimpulan
26

13. End Get


14. Set(ByVal value As String)
15. kd_kesimpulan = value
16. End Set
17. End Property
18. Public Property kesimpulan_() As String
19. Get
20. Return kesimpulan
21. End Get
22. Set(ByVal value As String)
23. kesimpulan = value
24. End Set
25. End Property
26. Public Property solusi_() As String
27. Get
28. Return solusi
29. End Get
30. Set(ByVal value As String)
31. solusi = value
32. End Set
33. End Property
34. #End Region
35. #Region "Event"
36. Public Sub Simpan()
37. Dim MyCmd As New SqlCommand
38. Dim MyConnection As New koneksi
39. MyCmd.CommandText = "INSERT INTO kesimpulan (kd_kesimpulan,kesimpulan,solusi)
values ('" & kd_kesimpulan & "','" & kesimpulan & "','" & solusi & "');"
40. MyCmd.Connection = MyConnection.Open()
41. MyCmd.ExecuteNonQuery()
42. MyConnection.Close()
43. MsgBox("Data berhasil di simpan", MsgBoxStyle.Information, "Information")
44. End Sub
45. Public Sub Ubah()
46. Dim MyCmd As New SqlCommand
47. Dim MyConnection As New koneksi
48. MyCmd.CommandText = "UPDATE kesimpulan SET kesimpulan = '" & kesimpulan & "', solusi
= '" & solusi & "' WHERE kd_kesimpulan = '" & kd_kesimpulan & "'"
49. MyCmd.Connection = MyConnection.Open()
50. MyCmd.ExecuteNonQuery()
51. MyConnection.Close()
52. MsgBox("Data berhasil di ubah", MsgBoxStyle.Information, "Information")
53. End Sub
54. Public Sub Hapus()
55. Dim MyCmd As New SqlCommand
56. Dim MyConnection As New koneksi
57. MyCmd.CommandText = "DELETE FROM kesimpulan WHERE kd_kesimpulan = '" &
kd_kesimpulan & "'"
27

58. MyCmd.Connection = MyConnection.Open()


59. MyCmd.ExecuteNonQuery()
60. MyCmd.Connection.Close()
61. MsgBox("Data berhasil di hapus", MsgBoxStyle.Information, "Information")
62. End Sub
63. #End Region
64. End Class

Author : Riyo Romansyah

NIM : 0811530120

File : frmPengetahuan.vb

1. Imports System.Data
2. Imports System.Data.SqlClient
3. Public Class frmPengetahuan
4. Dim MyCmd As New SqlCommand
5. Dim MyConnection As New Koneksi
6. Dim MyReader As SqlDataReader
7. Private Sub frmPengetahuan_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
8. AmbilDataArahan()
9. AmbilAturan()
10. End Sub
11. #Region "Event"
12. Private Sub btnArahan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnArahan.Click
13. frmArahan.Show()
14. End Sub
15. Private Sub btnAturan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnAturan.Click
16. frmAturan.Show()
17. End Sub
18. #End Region
19. #Region "Function"
20. Private Sub AmbilDataArahan()
21. MyCmd.CommandText = "SELECT * FROM arahan ORDER BY no_arahan ASC"
22. MyCmd.Connection = MyConnection.open()
23. Try
24. MyReader = MyCmd.ExecuteReader
25. lvArahan.Items.Clear()
26. While MyReader.Read
27. With lvArahan.Items.Add(MyReader.Item("no_arahan").ToString)
28. .SubItems.Add(MyReader.Item("kd_Kesimpulan").ToString)
29. .SubItems.Add(MyReader.Item("kd_Identifikasi").ToString)
30. End With
28

31. End While


32. MyReader.Close()
33. Catch ex As Exception
34. MessageBox.Show(ex.Message)
35. End Try
36. MyConnection.Close()
37. End Sub
38. Private Sub AmbilAturan()
39. MyCmd.CommandText = "SELECT * FROM aturan ORDER BY no_aturan ASC"
40. MyCmd.Connection = MyConnection.Open()
41. Try
42. MyReader = MyCmd.ExecuteReader
43. lvAturan.Items.Clear()
44. While MyReader.Read
45. With lvAturan.Items.Add(MyReader.Item("no_aturan").ToString)
46. .SubItems.Add(MyReader.Item("ya1").ToString)
47. .SubItems.Add(MyReader.Item("ya2").ToString)
48. .SubItems.Add(MyReader.Item("tdk1").ToString)
49. .SubItems.Add(MyReader.Item("tdk2").ToString)
50. End With
51. End While
52. MyReader.Close()
53. Catch ex As Exception
54. MessageBox.Show(ex.Message)
55. End Try
56. MyConnection.Close()
57. End Sub
58. #End Region
59. End Class

Author : Riyo Romansyah

NIM : 0811530120

File : frmKamus.vb

1. Imports System.Data
2. Imports System.Data.SqlClient
3. Public Class frmKamus
4. Dim clsKamus As New clsKamus
5. Dim MyCmd As New SqlCommand
6. Dim MyConnection As New koneksi
7. Dim MyReader As SqlDataReader
8. Private Sub frmKamus_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Load
9. Awal()
10. End Sub
29

11. #Region "Function"


12. Private Sub Awal()
13. TampilData()
14. Bersih()
15. TextNonAktif()
16. txtId_Kamus.Enabled = False
17. btnTambah.Focus()
18. txtId_Kamus.Text = clsKamus.KodeOtomatis
19. End Sub
20. #Region "Function"
21. Private Sub Bersih()
22. txtKata.Clear()
23. txtKet.Clear()
24. End Sub
25. Private Sub TextAktif()
26. txtId_Kamus.Enabled = True
27. txtKata.Enabled = True
28. txtKet.Enabled = True
29. End Sub
30. Private Sub TextNonAktif()
31. txtId_Kamus.Enabled = False
32. txtKata.Enabled = False
33. txtKet.Enabled = False
34. End Sub
35. Private Sub btnNew()
36. btnEdit.Enabled = False
37. btnHapus.Enabled = False
38. End Sub
39. Private Sub AmbilData()
40. clsKamus.kd_kamus_ = txtId_Kamus.Text()
41. clsKamus.Kata_ = txtKata.Text()
42. clsKamus.Keterangan_ = txtKet.Text()
43. End Sub
44. Private Sub TampilData()
45. MyCmd.CommandText = "SELECT * FROM kamus ORDER BY kd_kamus ASC"
46. MyCmd.Connection = MyConnection.Open()
47. Try
48. MyReader = MyCmd.ExecuteReader
49. lvKamus.Items.Clear()
50. While MyReader.Read
51. With lvKamus.Items.Add(MyReader.Item("kd_kamus").ToString)
52. .SubItems.Add(MyReader.Item("kata").ToString)
53. .SubItems.Add(MyReader.Item("keterangan").ToString)
54. End With
55. End While
56. MyReader.Close()
57. Catch ex As Exception
58. MessageBox.Show(ex.Message)
30

59. End Try


60. MyConnection.Close()
61. End Sub
62. #End Region
63. #Region "Event"
64. Private Sub btnTambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnTambah.Click
65. TextAktif()
66. Bersih()
67. txtKata.Focus()
68. btnNew()
69. End Sub
70. Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnEdit.Click
71. If Len(txtKata.Text) = 0 Then
72. MsgBox("Pilih data dari Tabel")
73. Else
74. AmbilData()
75. clsKamus.Ubah()
76. Bersih()
77. Awal()
78. End If
79. End Sub
80. Private Sub btnSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnSimpan.Click
81. If Len(txtKata.Text) = 0 Then
82. MsgBox("Data harus diisi semua !")
83. Else
84. AmbilData()
85. clsKamus.Simpan()
86. Bersih()
87. Awal()
88. End If
89. End Sub
90. Private Sub btnHapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnHapus.Click
91. Dim Pesan As String
92. Pesan = MsgBox("Yakin data akan dihapus ?", MsgBoxStyle.YesNo, "Information")
93. If Pesan = vbYes Then
94. AmbilData()
95. clsKamus.Hapus()
96. Bersih()
97. Awal()
98. End If
99. End Sub
100. Private Sub btnBatal_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnBatal.Click
101. TextNonAktif()
31

102. Bersih()
103. End Sub
104. #End Region
105. Private Sub lvKamus_DoubleClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles lvKamus.DoubleClick
106. btnSimpan.Enabled = False
107. btnTambah.Enabled = False
108. btnEdit.Enabled = True
109. btnHapus.Enabled = True
110. TextAktif()
111. Bersih()
112. txtId_Kamus.Text = lvKamus.SelectedItems(0).SubItems(0).Text.ToString
113. txtKata.Text = lvKamus.SelectedItems(0).SubItems(1).Text.ToString
114. txtKet.Text = lvKamus.SelectedItems(0).SubItems(2).Text.ToString
115. End Sub
116. Private Sub txtCari_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles txtCari.TextChanged
117. MyCmd.CommandText = "SELCET * FROM kamus WHERE kata like '%" &
Trim(txtCari.Text) & "%' ORDER BY kd_kamus ASC"
118. MyCmd.Connection = MyConnection.Open()
119. Try
120. MyReader = MyCmd.ExecuteReader
121. lvKamus.Items.Clear()
122. While MyReader.Read()
123. With lvKamus.Items.Add(MyReader.Item("kd_kamus").ToString)
124. .SubItems.Add(MyReader.Item("kata").ToString)
125. .SubItems.Add(MyReader.Item("keterangan").ToString)
126. End With
127. End While
128. MyReader.Close()
129. Catch ex As Exception
130. MessageBox.Show(ex.Message)
131. End Try
132. MyConnection.Close()
133. End Sub
134. #End Region
135. End Class

Author : Riyo Romansyah

NIM : 0811530120

File : clsKamus.vb

1. Imports System.Data
2. Imports System.Data.SqlClient
3. Public Class clsKamus
32

4. #Region "Deklarasi Variabel"


5. Private kd_kamus As String
6. Private Kata As String
7. Private Keterangan As String
8. #End Region
9. #Region "Property"
10. Public Property kd_kamus_() As String
11. Get
12. Return kd_kamus
13. End Get
14. Set(ByVal value As String)
15. kd_kamus = value
16. End Set
17. End Property
18. Public Property Kata_() As String
19. Get
20. Return Kata
21. End Get
22. Set(ByVal value As String)
23. Kata = value
24. End Set
25. End Property
26. Public Property Keterangan_() As String
27. Get
28. Return Keterangan
29. End Get
30. Set(ByVal value As String)
31. Keterangan = value
32. End Set
33. End Property
34. #End Region
35. #Region "Kode Otomatis"
36. Public Function KodeOtomatis() As String
37. Dim StrTmp As String = ""
38. Dim StrValue As String = ""
39. Dim MyCmd As New SqlCommand
40. Dim MyConnection As New koneksi
41. Dim MyReader As SqlDataReader
42. MyCmd.CommandText = "SELECT * FROM kamus ORDER BY kd_kamus DESC"
43. MyCmd.Connection = MyConnection.Open()
44. MyReader = MyCmd.ExecuteReader()
45. If MyReader.HasRows Then
46. MyReader.Read()
47. Return Mid("000", 1, 3 - (Val(Trim(MyReader.Item(0).ToString)) + 1).ToString.Length) +
(Val(Trim(MyReader.Item(0).ToString)) + 1).ToString
48. Else
49. Return "001"
50. Return StrValue
33

51. End If
52. End Function
53. #End Region
54. #Region "Event"
55. Public Sub Simpan()
56. Dim MyCmd As New SqlCommand
57. Dim MyConnection As New koneksi
58. MyCmd.CommandText = "INSERT INTO kamus (kd_kamus, kata, keterangan) values ('" &
kd_kamus & "','" & Kata & "','" & Keterangan & "')"
59. MyCmd.Connection = MyConnection.Open()
60. MyCmd.ExecuteNonQuery()
61. MyConnection.Close()
62. MsgBox("Data berhasil di simpan", MsgBoxStyle.Information, "Information")
63. End Sub
64. Public Sub Ubah()
65. Dim MyCmd As New SqlCommand
66. Dim MyConnection As New koneksi
67. MyCmd.CommandText = "UPDATE kamus SET kata = '" & Kata & "', keterangan = '" &
Keterangan & "' WHERE kd_kamus = '" & kd_kamus & "'"
68. MyCmd.Connection = MyConnection.Open()
69. MyCmd.ExecuteNonQuery()
70. MyConnection.Close()
71. MsgBox("Data Telah di Ubah", MsgBoxStyle.Information, "Information")
72. End Sub
73. Public Sub Hapus()
74. Dim MyCmd As New SqlCommand
75. Dim MyConnection As New koneksi
76. MyCmd.CommandText = "DELETE FROM kamus WHERE kd_kamus = '" & kd_kamus & "'"
77. MyCmd.Connection = MyConnection.Open()
78. MyCmd.ExecuteNonQuery()
79. MyConnection.Close()
80. MsgBox("Data Telah di Hapus..!", MsgBoxStyle.Information, "Information")
81. End Sub
82. #End Region
83. End Class

Author : Riyo Romansyah

NIM : 0811530120

File : frmArahan.vb

1. Imports System.Data
2. Imports System.Data.SqlClient
3. Public Class frmArahan
4. Dim clsArahan As New clsArahan
5. Dim Myconnection As New koneksi
34

6. Dim MyCmd As New SqlCommand


7. Dim MyReader As SqlDataReader
8. Private Sub fmrArahan_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Me.Load
9. Awal()
10. End Sub
11. #Region "Function"
12. Private Sub Awal()
13. TampilData()
14. Bersih()
15. TextNonAktif()
16. btnTambah.Focus()
17. txtNo.Text = KodeOtomatis()
18. txtNo.Enabled = False
19. End Sub
20. Private Sub Bersih()
21. txtKdIdentifikasi.Clear()
22. txtKdKesimpulan.Clear()
23. End Sub
24. Private Sub TextAktif()
25. txtKdIdentifikasi.Enabled = False
26. txtKdKesimpulan.Enabled = False
27. End Sub
28. Private Sub TextNonAktif()
29. txtKdIdentifikasi.Enabled = False
30. txtKdKesimpulan.Enabled = False
31. End Sub
32. Private Sub BtnNew()
33. btnEdit.Enabled = False
34. btnHapus.Enabled = False
35. End Sub
36. Private Sub AmbilData()
37. clsArahan.No_ = txtNo.Text()
38. clsArahan.KdKesimpulan_ = txtKdKesimpulan.Text()
39. clsArahan.KdIdentifikasi_ = txtKdIdentifikasi.Text()
40. End Sub
41. Private Sub TampilData()
42. MyCmd.CommandText = "SELECT * FROM arahan ORDER BY no_arahan DESC"
43. MyCmd.Connection = Myconnection.Open()
44. Try
45. MyReader = MyCmd.ExecuteReader
46. lvArahan.Items.Clear()
47. While MyReader.Read
48. With lvArahan.Items.Add(MyReader.Item("no_arahan").ToString)
49. .SubItems.Add(MyReader.Item("kd_identifikasi").ToString)
50. .SubItems.Add(MyReader.Item("kd_kesimpulan").ToString)
51. End With
52. End While
35

53. MyReader.Close()
54. Catch ex As Exception
55. MessageBox.Show(ex.Message)
56. End Try
57. Myconnection.Close()
58. End Sub
59. Private Function KodeOtomatis() As String
60. Dim StrTmp As String = ""
61. Dim StrValue As String = ""
62. Dim MyCmd As New SqlCommand
63. Dim MyConnection As New koneksi
64. Dim MyReader As SqlDataReader
65. MyCmd.CommandText = "SELECT * FROM arahan ORDER BY no_arahan DESC"
66. MyCmd.Connection = MyConnection.Open()
67. MyReader = MyCmd.ExecuteReader()
68. If MyReader.HasRows Then
69. MyReader.Read()
70. Return Mid("000", 1, 3 - (Val(Trim(MyReader.Item(0).ToString)) + 1).ToString.Length) +
(Val(Trim(MyReader.Item(0).ToString)) + 1).ToString
71. Else
72. Return "001"
73. Return StrValue
74. End If
75. End Function
76. #End Region
77. #Region "Event"
78. Private Sub btnTambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnTambah.Click
79. TextAktif()
80. Bersih()
81. txtKdKesimpulan.Enabled = True
82. txtKdKesimpulan.Focus()
83. BtnNew()
84. End Sub
85. Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnEdit.Click
86. If Len(txtKdKesimpulan.Text) = 0 Then
87. MsgBox("Pilih salah satu dari data Tabel")
88. Else
89. AmbilData()
90. clsArahan.Ubah()
91. Bersih()
92. Awal()
93. End If
94. End Sub
95. Private Sub btnSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnSimpan.Click
96. If Len(txtKdKesimpulan.Text) = 0 Then
36

97. MsgBox("Data harus diisi semua !!")


98. Else
99. AmbilData()
100. clsArahan.Simpan()
101. Bersih()
102. Awal()
103. End If
104. End Sub
105. Private Sub btnHapus_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnHapus.Click
106. Dim Pesan As String
107. Pesan = MsgBox("Yakin data akan dihapus ?", MsgBoxStyle.YesNo, "Information")
108. If Pesan = vbYes Then
109. AmbilData()
110. clsArahan.Hapus()
111. Bersih()
112. Awal()
113. Else
114. MsgBox("Data Tidak Jadi Di Hapus", MsgBoxStyle.Information, "Information")
115. Bersih()
116. Awal()
117. End If
118. Awal()
119. End Sub
120. Private Sub btnBatal_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnBatal.Click
121. TextNonAktif()
122. Bersih()
123. btnTambah.Enabled = True
124. btnEdit.Enabled = False
125. btnSimpan.Enabled = True
126. btnHapus.Enabled = False
127. End Sub
128. Private Sub lvArahan_DoubleClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles lvArahan.DoubleClick
129. btnSimpan.Enabled = False
130. btnTambah.Enabled = False
131. btnEdit.Enabled = True
132. btnHapus.Enabled = True
133. TextAktif()
134. Bersih()
135. txtNo.Text = lvArahan.SelectedItems(0).SubItems(0).Text.ToString
136. txtKdKesimpulan.Text = lvArahan.SelectedItems(0).SubItems(1).Text.ToString
137. txtKdIdentifikasi.Text = lvArahan.SelectedItems(0).SubItems(2).Text.ToString
138. End Sub
139. Private Sub txtCari_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles txtCari.TextChanged
140. MyCmd.CommandText = "SELECT * FROM arahan WHERE kd_kesimpulan like '%" &
37

Trim(txtCari.Text) & "%' ORDER BY kd_kesimpulan ASC"


141. MyCmd.Connection = Myconnection.Open()
142. Try
143. MyReader = MyCmd.ExecuteReader
144. lvArahan.Items.Clear()
145. While MyReader.Read
146. With lvArahan.Items.Add(MyReader.Item("no_arahan").ToString)
147. .SubItems.Add(MyReader.Item("kd_identifikasi").Totstring)
148. .SubItems.Add(MyReader.Item("kd_kesimpulan").TotString)
149. End With
150. End While
151. MyReader.Close()
152. Catch ex As Exception
153. MessageBox.Show(ex.Message)
154. End Try
155. Myconnection.Close()
156. End Sub
157. #End Region
158. Private Sub btnCKes_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCKes.Click
159. Dim PopUpKesimpulan As New PopUpKesimpulan
160. PopUpKesimpulan.ShowDialog()
161. If PopUpKesimpulan.retNo <> "" Then
162. txtKdKesimpulan.Text = PopUpKesimpulan.retNo
163. TextAktif()
164. End If
165. End Sub
166. Private Sub btnCin_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCin.Click
167. Dim PopUpIdentifikasi As New PopUpIdentifikasi
168. PopUpIdentifikasi.ShowDialog()
169. If PopUpIdentifikasi.retKd <> "" Then
170. txtKdIdentifikasi.Text = PopUpIdentifikasi.retKd
171. TextAktif()
172. End If
173. End Sub
174. End Class

Author : Riyo Romansyah

NIM : 0811530120

File : clsArahan.vb

1. Imports System.Data
2. Imports System.Data.SqlClient
3. Public Class clsArahan
38

4. Private no As String
5. Private kdkesimpulan As String
6. Private kdidentifikasi As String
7. #Region "Property"
8. Public Property No_() As String
9. Get
10. Return no
11. End Get
12. Set(ByVal value As String)
13. no = value
14. End Set
15. End Property
16. Public Property KdKesimpulan_() As String
17. Get
18. Return KdKesimpulan
19. End Get
20. Set(ByVal value As String)
21. kdkesimpulan = value
22. End Set
23. End Property
24. Public Property KdIdentifikasi_() As String
25. Get
26. Return kdidentifikasi
27. End Get
28. Set(ByVal value As String)
29. kdidentifikasi = value
30. End Set
31. End Property
32. #End Region
33. #Region "Event"
34. Public Sub Simpan()
35. Dim MyCmd As New SqlCommand
36. Dim MyConnection As New Koneksi
37. MyCmd.CommandText = "INSERT INTO arahan (no_arahan,kd_kesimpulan,kd_identifikasi)
values ('" & no & "','" & kdkesimpulan & "','" & kdidentifikasi & "');"
38. MyCmd.Connection = MyConnection.open()
39. MyCmd.ExecuteNonQuery()
40. MyConnection.Close()
41. MsgBox("Data Telah di Simpan", MsgBoxStyle.Information, "Information")
42. End Sub
43. Public Sub Ubah()
44. Dim MyCmd As New SqlCommand
45. Dim MyConnection As New Koneksi
46. MyCmd.CommandText = "UPDATE arahan SET kd_kesimpulan = '" & kdkesimpulan & "',
kd_identifikasi = '" & kdidentifikasi & "' WHERE no_arahan = '" & no & "'"
47. MyCmd.Connection = MyConnection.open()
48. MyCmd.ExecuteNonQuery()
49. MyConnection.Close()
39

50. MsgBox("Data Telah di Ubah", MsgBoxStyle.Information, "Information")


51. End Sub
52. Public Sub Hapus()
53. Dim MyCmd As New SqlCommand
54. Dim MyConnection As New Koneksi
55. MyCmd.CommandText = "DELETE FROM arahan WHERE no_arahan = '" & no & "'"
56. MyCmd.Connection = MyConnection.open()
57. MyCmd.ExecuteNonQuery()
58. MyConnection.Close()
59. MsgBox("Data Telah di Hapus", MsgBoxStyle.Information, "Information")
60. End Sub
61. #End Region
62. End Class

Author : Riyo Romansyah

NIM : 0811530120

File : PopUpKesimpulan.vb

1. Imports System.Data
2. Imports System.Data.SqlClient
3. Public Class PopUpKesimpulan
4. Dim MyConnection As New Koneksi
5. Dim MyCmd As New SqlCommand
6. Dim MyReader As SqlDataReader
7. Public retNo, retKes As String
8. Private Sub TampilData()
9. MyCmd.CommandText = "SELECT * FROM kesimpulan ORDER BY kd_kesimpulan DESC"
10. MyCmd.Connection = MyConnection.open()
11. Try
12. MyReader = MyCmd.ExecuteReader
13. lvKesimpulan.Items.Clear()
14. While MyReader.Read
15. With lvKesimpulan.Items.Add(MyReader.Item("kd_kesimpulan").ToString)
16. .SubItems.Add(MyReader.Item("kesimpulan").ToString)
17. End With
18. End While
19. MyReader.Close()
20. Catch ex As Exception
21. MessageBox.Show(ex.Message)
22. End Try
23. MyConnection.Close()
24. End Sub
25. Private Sub txtCari_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles txtCari.TextChanged
26. MyCmd.CommandText = "SELECT * FROM kesimpulan WHERE kd_kesimpulan like'%" &
40

Trim(txtCari.Text) & "%' ORDER BY kd_kesimpulan ASC"


27. MyCmd.Connection = MyConnection.open()
28. Try
29. MyReader = MyCmd.ExecuteReader
30. lvKesimpulan.Items.Clear()
31. While MyReader.Read
32. With lvKesimpulan.Items.Add(MyReader.Item("kd_kesimpulan").ToString)
33. .SubItems.Add(MyReader.Item("kesimpulan").ToString)
34. End With
35. End While
36. MyReader.Close()
37. Catch ex As Exception
38. MessageBox.Show(ex.Message)
39. End Try
40. MyConnection.Close()
41. End Sub
42. Private Sub lvKesimpulan_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs)
Handles lvKesimpulan.DoubleClick
43. pilihlist()
44. End Sub
45. Private Sub PopUpKesimpulan_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
46. TampilData()
47. txtCari.Focus()
48. End Sub
49. Sub pilihlist()
50. Try
51. retNo = lvKesimpulan.SelectedItems(0).SubItems(0).Text.ToString
52. retKes = lvKesimpulan.SelectedItems(0).SubItems(1).Text.ToString
53. Me.Close()
54. Catch ex As Exception
55. MsgBox("Pilih salah satu data", MsgBoxStyle.Information)
56. End Try
57. End Sub
58. End Class

Author : Riyo Romansyah

NIM : 0811530120

File : PopUpIdentifikasi.vb

1. Imports System.Data
2. Imports System.Data.SqlClient
3. Public Class PopUpIdentifikasi
4. Dim MyConnection As New koneksi
5. Dim MyCmd As New SqlCommand
41

6. Dim MyReader As SqlDataReader


7. Public retKd, retPer As String
8. Private Sub TampilData()
9. MyCmd.CommandText = "SELECT * FROM identifikasi ORDER BY kd_identifikasi DESC"
10. MyCmd.Connection = MyConnection.Open()
11. Try
12. MyReader = MyCmd.ExecuteReader
13. lvKesimpulan.Items.Clear()
14. While MyReader.Read
15. With lvKesimpulan.Items.Add(MyReader.Item("kd_identifikasi").ToString)
16. .SubItems.Add(MyReader.Item("pertanyaan").ToString)
17. End With
18. End While
19. MyReader.Close()
20. Catch ex As Exception
21. MessageBox.Show(ex.Message)
22. End Try
23. MyConnection.Close()
24. End Sub
25. Private Sub txtCari_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles txtCari.TextChanged
26. MyCmd.CommandText = "SELECT * FROM identifikasi WHERE kd_identifikasi like'%" &
Trim(txtCari.Text) & "%' ORDER BY kd_identifikasi ASC"
27. MyCmd.Connection = MyConnection.Open()
28. Try
29. MyReader = MyCmd.ExecuteReader
30. lvKesimpulan.Items.Clear()
31. While MyReader.Read
32. With lvKesimpulan.Items.Add(MyReader.Item("kd_identifikasi").ToString)
33. .SubItems.Add(MyReader.Item("pertanyaan").ToString)
34. End With
35. End While
36. MyReader.Close()
37. Catch ex As Exception
38. MessageBox.Show(ex.Message)
39. End Try
40. MyConnection.Close()
41. End Sub
42. Private Sub lvKesimpulan_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs)
Handles lvKesimpulan.DoubleClick
43. pilihlist()
44. End Sub
45. Private Sub PopUpKesimpulan_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
46. TampilData()
47. txtCari.Focus()
48. End Sub
49. Sub pilihlist()
42

50. Try
51. retKd = lvKesimpulan.SelectedItems(0).SubItems(0).Text.ToString
52. retPer = lvKesimpulan.SelectedItems(0).SubItems(1).Text.ToString
53. Me.Close()
54. Catch ex As Exception
55. MsgBox("Pilih salah satu data", MsgBoxStyle.Information)
56. End Try
57. End Sub
58. End Class

Author : Riyo Romansyah

NIM : 0811530120

File : frmAturan.vb

1. Imports System.Data
2. Imports System.Data.SqlClient
3. Public Class frmAturan
4. Dim clsAturan As New clsAturan
5. Dim MyConnection As New koneksi
6. Dim MyCmd As New SqlCommand
7. Dim MyReader As SqlDataReader
8. Private Sub frmAturan_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Load
9. Awal()
10. End Sub
11. #Region "Function"
12. Private Sub Awal()
13. TampilData()
14. Bersih()
15. TextNonAktif()
16. btnTambah.Focus()
17. txtNoYa.Text = KodeOtomatis()
18. End Sub
19. Private Sub Bersih()
20. TxtIdentifikasiYa.Clear()
21. txtTujuanYa.Clear()
22. TxtIdentifikasiTdk.Clear()
23. TxtTujuanTdk.Clear()
24. End Sub
25. Private Sub TextAktif()
26. txtTujuanYa.Enabled = True
27. TxtTujuanTdk.Enabled = True
28. txtNoYa.Enabled = True
29. End Sub
30. Private Sub TextNonAktif()
43

31. txtTujuanYa.Enabled = False


32. TxtTujuanTdk.Enabled = False
33. txtNoYa.Enabled = False
34. End Sub
35. Private Sub btnNew()
36. btnEdit.Enabled = False
37. btnHapus.Enabled = False
38. End Sub
39. Private Sub AmbilData()
40. clsAturan.No_ = txtNoYa.Text()
41. clsAturan.Ya1_ = TxtIdentifikasiYa.Text()
42. clsAturan.Ya2_ = txtTujuanYa.Text()
43. clsAturan.Tdk1_ = TxtIdentifikasiTdk.Text()
44. clsAturan.Tdk2_ = TxtTujuanTdk.Text()
45. End Sub
46. Private Sub TampilData()
47. MyCmd.CommandText = "SELECT * FROM aturan ORDER BY no_aturan DESC"
48. MyCmd.Connection = MyConnection.Open()
49. Try
50. MyReader = MyCmd.ExecuteReader
51. lvAturan.Items.Clear()
52. While MyReader.Read
53. With lvAturan.Items.Add(MyReader.Item("no_aturan").ToString)
54. .SubItems.Add(MyReader.Item("ya1").ToString)
55. .SubItems.Add(MyReader.Item("ya2").ToString)
56. .SubItems.Add(MyReader.Item("tdk1").ToString)
57. .SubItems.Add(MyReader.Item("tdk2").ToString)
58. End With
59. End While
60. MyReader.Close()
61. Catch ex As Exception
62. MessageBox.Show(ex.Message)
63. End Try
64. MyConnection.Close()
65. End Sub
66. Private Function KodeOtomatis() As String
67. Dim StrTmp As String = ""
68. Dim StrValue As String = ""
69. Dim MyCmd As New SqlCommand
70. Dim MyConnection As New koneksi
71. Dim MyReader As SqlDataReader
72. MyCmd.CommandText = "SELECT * FROM aturan ORDER BY no_aturan DESC"
73. MyCmd.Connection = MyConnection.Open()
74. MyReader = MyCmd.ExecuteReader()
75. If MyReader.HasRows Then
76. MyReader.Read()
77. Return Mid("000", 1, 3 - (Val(Trim(MyReader.Item(0).ToString)) + 1).ToString.Length) +
(Val(Trim(MyReader.Item(0).ToString)) + 1).ToString
44

78. Else
79. Return "001"
80. Return StrValue
81. End If
82. End Function
83. #End Region
84. #Region "Event"
85. Private Sub btnTambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnTambah.Click
86. TextAktif()
87. Bersih()
88. txtNoYa.Enabled = True
89. TxtTujuanTdk.Focus()
90. txtTujuanYa.Focus()
91. btnNew()
92. End Sub
93. Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnEdit.Click
94. If Len(txtTujuanYa.Text) = 0 Then
95. MsgBox("Pilih salah satu data dari Tabel")
96. Else
97. AmbilData()
98. clsAturan.Ubah()
99. Bersih()
100. Awal()
101. End If
102. End Sub
103. Private Sub btnSimpan_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSimpan.Click
104. If Len(TxtIdentifikasiYa.Text) = 0 Then
105. MsgBox("Data harus diisi semua...!")
106. Else
107. AmbilData()
108. clsAturan.Simpan()
109. Bersih()
110. Awal()
111. End If
112. End Sub
113. Private Sub btnHapus_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnHapus.Click
114. Dim pesan As String
115. pesan = MsgBox("Yakin data akan dihapus?", MsgBoxStyle.YesNo, "Information")
116. If pesan = vbYes Then
117. AmbilData()
118. clsAturan.Hapus()
119. Bersih()
120. Awal()
121. Else
45

122. MsgBox("Data Tidak Jadi Di Hapus...!", MsgBoxStyle.Information, "Information")


123. Bersih()
124. Awal()
125. End If
126. Awal()
127. End Sub
128. Private Sub btnBatal_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnBatal.Click
129. TextNonAktif()
130. Bersih()
131. btnTambah.Enabled = True
132. btnEdit.Enabled = False
133. btnSimpan.Enabled = True
134. btnHapus.Enabled = False
135. End Sub
136. Private Sub lvArahan_DoubleClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles lvAturan.DoubleClick
137. btnSimpan.Enabled = False
138. btnTambah.Enabled = False
139. btnEdit.Enabled = True
140. btnHapus.Enabled = True
141. TextAktif()
142. Bersih()
143. txtNoYa.Text = lvAturan.SelectedItems(0).SubItems(0).Text.ToString
144. TxtIdentifikasiYa.Text = lvAturan.SelectedItems(0).SubItems(1).Text.ToString
145. txtTujuanYa.Text = lvAturan.SelectedItems(0).SubItems(2).Text.ToString
146. TxtIdentifikasiTdk.Text = lvAturan.SelectedItems(0).SubItems(3).Text.ToString
147. TxtTujuanTdk.Text = lvAturan.SelectedItems(0).SubItems(4).Text.ToString
148. End Sub
149. Private Sub txtCari_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles txtCari.TextChanged
150. MyCmd.CommandText = "SELECT * FROM aturan WHERE ya1 like'%" &
Trim(txtCari.Text) & "%' ORDER BY no_aturan ASC"
151. MyCmd.Connection = MyConnection.Open()
152. Try
153. MyReader = MyCmd.ExecuteReader
154. lvAturan.Items.Clear()
155. While MyReader.Read
156. With lvAturan.Items.Add(MyReader.Item("no_aturan").ToString)
157. .SubItems.Add(MyReader.Item("ya1").ToString)
158. .SubItems.Add(MyReader.Item("ya2").ToString)
159. .SubItems.Add(MyReader.Item("tdk1").ToString)
160. .SubItems.Add(MyReader.Item("tdk2").ToString)
161. End With
162. End While
163. MyReader.Close()
164. Catch ex As Exception
165. MessageBox.Show(ex.Message)
46

166. End Try


167. MyConnection.Close()
168. End Sub
169. Private Sub btnCinYa_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCinYa.Click
170. Dim PopUpIdentifikasi As New PopUpIdentifikasi
171. PopUpIdentifikasi.ShowDialog()
172. If PopUpIdentifikasi.retKd <> "" Then
173. TxtIdentifikasiYa.Text = PopUpIdentifikasi.retKd
174. TextAktif()
175. End If
176. End Sub
177. Private Sub btnCinTdk_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCinTdk.Click
178. Dim PopUpIdentifikasi As New PopUpIdentifikasi
179. PopUpIdentifikasi.ShowDialog()
180. If PopUpIdentifikasi.retKd <> "" Then
181. TxtIdentifikasiTdk.Text = PopUpIdentifikasi.retKd
182. TextAktif()
183. End If
184. End Sub
185. Private Sub btnYa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnYa.Click
186. Dim PopUpIdentifikasi As New PopUpIdentifikasi
187. PopUpIdentifikasi.ShowDialog()
188. If PopUpIdentifikasi.retKd <> "" Then
189. txtTujuanYa.Text = PopUpIdentifikasi.retKd
190. TextAktif()
191. End If
192. End Sub
193. Private Sub btnTdk_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnTdk.Click
194. Dim PopUpIdentifikasi As New PopUpIdentifikasi
195. PopUpIdentifikasi.ShowDialog()
196. If PopUpIdentifikasi.retKd <> "" Then
197. TxtTujuanTdk.Text = PopUpIdentifikasi.retKd
198. TextAktif()
199. End If
200. End Sub
201. #End Region
202. End Class

Author : Riyo Romansyah

NIM : 0811530120

File : PopUpAturan.vb
47

1. Imports System.Data
2. Imports System.Data.SqlClient
3. Public Class PopUpAturan
4. Dim MyConnection As New Koneksi
5. Dim MyCmd As New SqlCommand
6. Dim MyReader As SqlDataReader
7. Public retKd, retPer As String
8. Private Sub TampilData()
9. MyCmd.CommandText = "SELECT * FROM identifikasi ORDER BY identifikasi DESC"
10. MyCmd.Connection = MyConnection.open()
11. Try
12. MyReader = MyCmd.ExecuteReader
13. lvKesimpulan.Items.Clear()
14. While MyReader.Read
15. With lvKesimpulan.Items.Add(MyReader.Item("kd_identifikasi").ToString)
16. .SubItems.Add(MyReader.Item("pertanyaan").ToString)
17. End With
18. End While
19. MyReader.Close()
20. Catch ex As Exception
21. MessageBox.Show(ex.Message)
22. End Try
23. MyConnection.Close()
24. End Sub
25. Private Sub txtCari_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles txtCari.TextChanged
26. MyCmd.CommandText = "SELECT * FROM identifikasi WHERE kd_identifikasi like'%" &
Trim(txtCari.Text) & "%' ORDER BY kd_identifikasi ASC"
27. MyCmd.Connection = MyConnection.open()
28. Try
29. MyReader = MyCmd.ExecuteReader
30. lvKesimpulan.Items.Clear()
31. While MyReader.Read
32. With lvKesimpulan.Items.Add(MyReader.Item("kd_identifikasi").ToString)
33. .SubItems.Add(MyReader.Item("pertanyaan").ToString)
34. End With
35. End While
36. MyReader.Close()
37. Catch ex As Exception
38. MessageBox.Show(ex.Message)
39. End Try
40. MyConnection.Close()
41. End Sub
42. Private Sub lvKesimpulan_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs)
Handles lvKesimpulan.DoubleClick
43. pilihlist()
44. End Sub
45. Private Sub PopUpKesimpulan_Load(ByVal sender As Object, ByVal e As System.EventArgs)
48

Handles Me.Load
46. TampilData()
47. txtCari.Focus()
48. End Sub
49. Sub pilihlist()
50. Try
51. retKd = lvKesimpulan.SelectedItems(0).SubItems(0).Text.ToString
52. retPer = lvKesimpulan.SelectedItems(0).SubItems(1).Text.ToString
53. Me.Close()
54. Catch ex As Exception
55. MsgBox("Pilih salah satu data", MsgBoxStyle.Information)
56. End Try
57. End Sub
58. End Class

Author : Riyo Romansyah

NIM : 0811530120

File : clsAturan.vb

1. Imports System.Data
2. Imports System.Data.SqlClient
3. Public Class clsAturan
4. Private No As String
5. Private Ya1 As String
6. Private Ya2 As String
7. Private Tdk1 As String
8. Private Tdk2 As String
9. #Region "Property"
10. Public Property No_() As String
11. Get
12. Return No
13. End Get
14. Set(ByVal value As String)
15. No = value
16. End Set
17. End Property
18. Public Property Ya1_() As String
19. Get
20. Return Ya1
21. End Get
22. Set(ByVal value As String)
23. Ya1 = value
24. End Set
25. End Property
26. Public Property Ya2_() As String
49

27. Get
28. Return Ya2
29. End Get
30. Set(ByVal value As String)
31. Ya2 = value
32. End Set
33. End Property
34. Public Property Tdk1_() As String
35. Get
36. Return Tdk1
37. End Get
38. Set(ByVal value As String)
39. Tdk1 = value
40. End Set
41. End Property
42. Public Property Tdk2_() As String
43. Get
44. Return Tdk2
45. End Get
46. Set(ByVal value As String)
47. Tdk2 = value
48. End Set
49. End Property
50. #End Region
51. #Region "Event"
52. Public Sub Simpan()
53. Dim MyCmd As New SqlCommand
54. Dim MyConnection As New koneksi
55. MyCmd.CommandText = "INSERT INTO aturan (no_aturan, ya1, ya2, tdk1, tdk2) values ('" &
No & "','" & Ya1 & "','" & Ya2 & "','" & Tdk1 & "','" & Tdk2 & "');"
56. MyCmd.Connection = MyConnection.Open()
57. MyCmd.ExecuteNonQuery()
58. MyConnection.Close()
59. MsgBox("Data Telah di Simpan", MsgBoxStyle.Information, "Information")
60. End Sub
61. Public Sub Ubah()
62. Dim MyCmd As New SqlCommand
63. Dim MyConnection As New koneksi
64. MyCmd.CommandText = "UPDATE aturan SET ya1 = '" & Ya1 & "', ya2 = '" & Ya2 & "' , tdk1 =
'" & Tdk1 & "', tdk2 = '" & Tdk2 & "' WHERE no_aturan = '" & No & "'"
65. MyCmd.Connection = MyConnection.Open()
66. MyCmd.ExecuteNonQuery()
67. MyConnection.Close()
68. MsgBox("Data Telah di Ubah", MsgBoxStyle.Information, "Information")
69. End Sub
70. Public Sub Hapus()
71. Dim MyCmd As New SqlCommand
72. Dim MyConnection As New koneksi
50

73. MyCmd.CommandText = "DELETE FROM aturan WHERE no_aturan = '" & No & "'"
74. MyCmd.Connection = MyConnection.Open()
75. MyCmd.ExecuteNonQuery()
76. MyConnection.Close()
77. MsgBox("Data Telah di Hapus..!", MsgBoxStyle.Information, "Information")
78. End Sub
79. #End Region
80. End Class

You might also like