Listing Program
Listing Program
NIM : 0811530120
File : Koneksi.vb
1. Imports System.Data
2. Imports System.Data.SqlClient
NIM : 0811530120
File : frmHome.vb
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
NIM : 0811530120
File : clsKamus.vb
1. Imports System.Data
2. Imports System.Data.SqlClient
3. Public Class clsKamus
32
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
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
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
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
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
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
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
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
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
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
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