You are on page 1of 12

LAMPIRAN

Sourcecode Modul
Option Explicit
Public Const angka = "0123456789"
PublicConstHuruf=
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
PublicConstHuruftitikkoma=
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ .,"
PublicConstangkahuruf=
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW
XYZ"
Public Const Karakter = "~`!@#$%^&*()_-+=\}]{[:;?/>.<, "
Public Const titik = "."
Public con As New ADODB.Connection
Public rec As New ADODB.Recordset
Sub Main()
If con.State = 1 Then con.Close
con.ConnectionString = "Provider=SQLOLEDB.1; " & _
"Integrated Security=SSPI; " & _
"Persist Security Info=False; " & _
"Initial Catalog=handphone"
con.Open
Load Formmenu1: Formmenu1.Show
End Sub
Sub inputType(text As String, KeyAscii As Integer)
If KeyAscii > 26 Then If InStr(text, Chr(KeyAscii)) = 0 Then Beep: KeyAscii =
0
End Sub
Sub Query(Perintah As String)
If rec.State = 1 Then rec.Close
rec.Open Perintah, con, adOpenDynamic, adLockOptimistic
End Sub

Sourcecode Basis Aturan

Private Sub cmdexit_Click()


Unload Me
End Sub

Private Sub cmdtambah_Click()


Formtambahaturan.Show
End Sub

Private Sub Combo1_Click()


Dim Ambil As String
Dim Cari As String
Dim i As Integer
Query "select * from macam_kerusakan where no_macam = '" & Combo1.text &
"'"
If Not rec.EOF = True Then
Combo1.text = rec!no_macam
End If
List1.Clear
Query "select * from relasi1, jenis_kerusakan where relasi1.no_macam = '" &
Combo1.text & "' and relasi1.no_jenis = jenis_kerusakan.no_jenis"
While Not rec.EOF
List1.AddItem (rec!no_jenis & " " & rec!nama_jenis)
rec.MoveNext
Wend
Query "select * from jenis_kerusakan "
List1.Clear
While Not rec.EOF
List1.AddItem (rec!no_jenis & " " & rec!nama_jenis)
rec.MoveNext
Wend
Call List1_Click
End Sub

Private Sub Form_Activate()


Formmenu.Enabled = False
Query "select * from macam_kerusakan"
While Not rec.EOF
Combo1.AddItem (rec!no_macam & " " & rec!macam)
rec.MoveNext
Wend
End Sub

Private Sub Form_Load()


Call List1_Click
End Sub

Private Sub Form_Unload(Cancel As Integer)


Formmenu.Enabled = True
End Sub

Private Sub List1_Click()


Dim i As Integer

Query "select * from relasi1, jenis_kerusakan where relasi1.no_macam = '" &


Combo1.text & "' and relasi1.no_jenis = jenis_kerusakan.no_jenis"
List2.Clear
Text2.text = ""
Query "select * from relasi2, ciri_kerusakan where relasi2.no_jenis = '" &
(Mid(List1.text, 1, 4)) & "' and relasi2.no_ciri = ciri_kerusakan.no_ciri"
While Not rec.EOF
List2.AddItem (rec!no_ciri & " " & rec!ciri)
rec.MoveNext
Wend
Query "select * from relasi2, ciri_kerusakan where relasi2.no_jenis = '" &
(Mid(List1.text, 1, 4)) & "' and relasi2.no_ciri = ciri_kerusakan.no_ciri"
If Not rec.EOF Then
Text2.text = rec!solusi
End If
End Sub

Sourcecode Input Jenis Kerusakan

Sub kodebaru()
Dim urutan As String * 4
Dim hitUrut As Double
Query "select no_jenis from jenis_kerusakan ORDER BY no_jenis DESC"
If rec.EOF = True Then
urutan = "J" & "001"
Else
hitUrut = Val(Right(rec!no_jenis, 3) + 1)
urutan = "J" & Right("000" & hitUrut, 3)
End If
Textnomor.text = urutan
End Sub

Sub BARU()
Call kodebaru
Call Grid
Query "select count(*) from jenis_kerusakan"
If rec(0) >= 9999 Then
Textnomor.text = Empty
MsgBox "jumlah data dibatasi sampai 9999 record", _
vbCritical, "PERHATIAN"
End If
End Sub

Sub simpan()
If Textjenis.text = Empty Then
MsgBox "Jenis Kerusakan harus diisi", vbCritical, "PERHATIAN"
Textjenis.SetFocus
Else
con.Execute "insert into jenis_kerusakan " & _
"VALUES('" & Textnomor.text & "','" & Textjenis.text & "')"
MsgBox "penyimpanan jenis kerusakan handphone sukses", vbInformation,
"INFORMASI"
Call kosong
End If
End Sub

Sub perbaiki()
Textnomor.text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 1)
Textjenis.text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 2)
cmdhapus.Enabled = True
cmdedit.Enabled = True
Textjenis.SetFocus
End Sub

Sub hapus()
If MsgBox("Anda yakin record data ini mau menghapus..?", vbQuestion +
vbYesNo, _
"PERHATIAN") = vbYes Then
con.Execute "delete from jenis_kerusakan where no_jenis = '" &
MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 1) & "'"
MsgBox "record jenis kerusakan Telah Berhasil DIHAPUS dari Tabel",
vbInformation, _
"PERHATIAN"
Call kosong
End If
cmdedit.Enabled = True
cmdhapus.Enabled = True
End Sub

Sub batal()
Call kosong
End Sub

Sub kosong()
Call kodebaru
Textjenis.text = Empty
cmdsimpan.Enabled = True
cmdedit.Enabled = True
cmdhapus.Enabled = True
Textjenis.SetFocus
Call Grid
End Sub

Sub KELUAR()
x = MsgBox("Yakin Anda akan Keluar..?", vbYesNo + vbQuestion,
"Konfirmasi")
If x = 6 Then
Unload Me
End If
Formmenu.Enabled = False
Formmenu2.Enabled = True
End Sub

Sub ok()
If MsgBox("Yakin Mau diperbaiki..?", vbQuestion + vbYesNo, "PERHATIAN")
= vbYes Then

'''proses perbaikan record


con.Execute "UPDATE jenis_kerusakan set nama_jenis='" & Textjenis.text & "', "
&_
"' where no_jenis ='" & Textnomor.text & "'"
MsgBox "Data Jenis Kerusakan Telah Berhasil Diperbaiki", vbInformation,
"PERHATIAN"
Call kosong
Call Grid
End If
End Sub

Sub Grid()
Dim i As Single
tampilkan_data "no_jenis", ""
MSFlexGrid1.Refresh
End Sub

Function tampilkan_data(field_aktif, patokkan)


Dim No As Single, i As Single
MSFlexGrid1.Clear
On Error Resume Next
Query "SELECT count(no_jenis) FROM jenis_kerusakan WHERE [" &
field_aktif & "] like '%" & patokkan & "%'"
If Err.Number <> 0 Then MsgBox Err.Description, 16, "Error": Exit Function
If rec(0) > 0 Then MSFlexGrid1.Rows = rec(0) + 1 Else MSFlexGrid1.Rows = 2
Query "SELECT * FROM jenis_kerusakan where [" & field_aktif & "] like '%"
& patokkan & "%'"
MSFlexGrid1.Cols = rec.Fields.Count + 1: No = 1
MSFlexGrid1.Row = 0:
MSFlexGrid1.Col = 0: MSFlexGrid1.text = "NO"
MSFlexGrid1.Col = 1: MSFlexGrid1.text = "NO JENIS"
MSFlexGrid1.Col = 2: MSFlexGrid1.text = "JENIS KERUSAKAN"
For i = 0 To rec.Fields.Count - 1
MSFlexGrid1.Col = i + 1
MSFlexGrid1.ColWidth(0) = 700
MSFlexGrid1.ColWidth(1) = 1000
MSFlexGrid1.ColWidth(2) = 5000
Next
If Not rec.EOF Then
While Not rec.EOF
MSFlexGrid1.Row = No: MSFlexGrid1.Col = 0: MSFlexGrid1.text = No
For i = 0 To rec.Fields.Count - 1
MSFlexGrid1.Col = i + 1
MSFlexGrid1.text = IIf(IsNull(rec(i)), "", rec(i))
Next
No = No + 1
DoEvents
rec.MoveNext
Wend
End If
End Function

Private Sub cmdbatal_Click()


Call batal
End Sub

Private Sub cmdhapus_Click()


Call hapus
End Sub
Private Sub cmdkeluar_Click()
Call KELUAR
End Sub

Private Sub cmdedit_Click()


Call perbaiki
End Sub

Private Sub cmdsimpan_Click()


Call simpan
End Sub

Private Sub Form_Activate()


Call kodebaru
Call Grid
Formmenu2.Hide
End Sub

Private Sub Form_Unload(Cancel As Integer)


Formmenu2.Show
End Sub

Private Sub MSFlexGrid1_Click()


cmdedit.Enabled = True
cmdhapus.Enabled = True
End Sub
Private Sub MSFlexGrid1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF2 Then Call perbaiki
If KeyCode = vbKeyDelete Then Call hapus
If KeyCode = vbKeyF5 Then Call batal
If KeyCode = vbKeyEscape Then Call KELUAR
End Sub

Private Sub textjenis_Change()


tampilkan_data "nama_jenis", ""
MSFlexGrid1.Refresh
If Textjenis.text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 2) Then
MSFlexGrid1.Col = 2: MSFlexGrid1.SetFocus
End Sub

Private Sub textjenis_GotFocus()


cmdedit.Enabled = True
cmdhapus.Enabled = True

End Sub

Private Sub textjenis_KeyDown(KeyCode As Integer, Shift As Integer)

If KeyCode = vbKeyF2 Then Call perbaiki


If KeyCode = vbKeyDelete Then Call hapus
If KeyCode = vbKeyF5 Then Call batal
If KeyCode = vbKeyEscape Then Call KELUAR
End Sub
Private Sub textjenis_KeyPress(KeyAscii As Integer)
If KeyAscii = 8 Then SendKeys "{home}+{end}"
If KeyAscii = 13 Then Textgejala.SetFocus
If KeyAscii = 27 Then Call batal

End Sub

You might also like