Вы находитесь на странице: 1из 13

FORM SPLASH Private Sub Form_KeyPress(KeyAscii As Integer) Unload Me End Sub Private Sub Timer1_Timer() PB.Value = PB.Value + 10 If PB.

Value = 100 Then Timer1.Enabled = False Unload Me FrmPasswd.Show End If End Sub FORM LOGIN Option Explicit Private Sub cmdGanti_Click() End Sub Private Sub cmdLogin_Click() If Me.optPilihan(0).Value = True Then FrmKonsultasi1.Show Me.Hide Else If (Me.txtNama.Text = TbPakar!nama) And (Me.txtPasswd.Text = TbPakar!sandi) Then FrmMenuUtama.Show Me.Hide Else MsgBox "Sandi Anda Salah !", vbOKOnly + vbCritical, "Konfirmasi" Me.txtNama.Text = "" Me.txtPasswd.Text = "" Me.txtNama.SetFocus Exit Sub End If End If End Sub Private Sub Form_Load() Call koneksi.koneksi End Sub Private Sub FrmTutup_Click() End End Sub Private Sub optPilihan_Click(Index As Integer) If Index = 1 Then txtNama.SetFocus End If End Sub Private Sub txtNama_Change() Me.txtNama.SelStart = Len(Me.txtNama.Text) End Sub Private Sub txtNama_GotFocus() Me.optPilihan(1).Value = True

End Sub Private Sub txtNama_KeyPress(KeyAscii As Integer) Dim strValid As String 'mendefinisikan validitas inputan strValid = "abcdefghijklmnopqrstuvwxyz" strValid = strValid & "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 'Jika tombol Enter ditekan maka pindahkan fokus ke txtPasswd If KeyAscii = vbKeyReturn Then Me.txtPasswd.SetFocus Else If InStr(strValid, Chr(KeyAscii)) = 0 Then KeyAscii = 0 End If End If End Sub Private Sub txtPasswd_Change() If Len(Me.txtPasswd.Text) = 8 Then Me.cmdLogin.SetFocus End If End Sub Private Sub txtPasswd_KeyPress(KeyAscii As Integer) Dim strValid As String 'mendefinisikan validitas inputan strValid = "0123456789abcdefghijklmnopqrstuvwxyz" If InStr(strValid, Chr(KeyAscii)) = 0 Then KeyAscii = 0 End If End Sub FORM KONSULTASI 1 Private Sub Command1_Click() FrmKonsultasi2.Show FrmKonsultasi1.Hide End Sub Private Sub Command2_Click() Unload Me End Sub Private Sub Command3_Click() Pepeng1.Show End Sub Private Sub Command4_Click() InfoProgram.Show End Sub Private Sub Command5_Click() Unload Me End Sub Sub refreshDG() Set rsGejala = New ADODB.Recordset rsGejala.LockType = adLockOptimistic rsGejala.CursorType = adOpenDynamic rsGejala.Open "SELECT * FROM TbGejala", conn, , , adCmdText

Set DataGrid1.DataSource = rsGejala DataGrid1.Columns(0).Width = 1000 DataGrid1.Columns(1).Width = 8000 DataGrid1.Refresh End Sub Private Sub DataGrid1_Click() txtkdgejala.Text = DataGrid1.Columns(0).Text Txtgejala.Text = DataGrid1.Columns(1).Text End Sub Private Sub Form_Load() refreshDG End Sub Private Sub Label4_Click() End Sub Private Sub Label1_Click() End Sub FORM KONSULTASI 2 Private Sub Command1_Click() FrmKonsultasi3.Show FrmKonsultasi2.Hide End Sub Private Sub Command2_Click() Unload Me FrmKonsultasi1.Show End Sub Private Sub Command3_Click() Pepeng2.Show End Sub Private Sub Command4_Click() InfoProgram.Show End Sub Private Sub Command5_Click() End End Sub Private Sub Form_Load() Text4.Text = FrmKonsultasi1.Txtgejala.Text refreshDG If rsQSolusi.RecordCount <> 0 Then rsQSolusi.MoveFirst For i = 1 To rsQSolusi.RecordCount Me.List1.AddItem rsQSolusi!KdPenyakit & " " & rsQSolusi!Penyakit rsQSolusi.MoveNext Next i End If End Sub Sub refreshDG() Set rsQSolusi = New ADODB.Recordset rsQSolusi.LockType = adLockOptimistic

rsQSolusi.CursorType = adOpenDynamic rsQSolusi.Open "SELECT * FROM QSolusi where kdgejala ='" & FrmKons ultasi1.txtkdgejala.Text & "'", conn, , , adCmdText Set List1.DataSource = rsQSolusi End Sub FORM KONSULTASI 3 Private Sub Command1_Click() FrmKonsultasi1.Show End Sub Private Sub Command2_Click() End End Sub Private Sub Command3_Click() Pepeng3.Show End Sub Private Sub Command4_Click() InfoProgram.Show End Sub Private Sub Command5_Click() End End Sub Private Sub Form_Load() Text4.Text = FrmKonsultasi1.Txtgejala.Text refreshDG If rsQSolusi.RecordCount <> 0 Then rsQSolusi.MoveFirst For i = 1 To rsQSolusi.RecordCount Me.List1.AddItem rsQSolusi!KdSolusi & " " & rsQSolusi!Solusi rsQSolusi.MoveNext Next i End If End Sub Sub refreshDG() Set rsQSolusi = New ADODB.Recordset rsQSolusi.LockType = adLockOptimistic rsQSolusi.CursorType = adOpenDynamic rsQSolusi.Open "SELECT * FROM QSolusi where kdgejala ='" & FrmKons ultasi1.txtkdgejala.Text & "'", conn, , , adCmdText Set List1.DataSource = rsQSolusi End Sub FORM MENU UTAMA Private Sub Form_Load() End Sub Private Sub mnAbout_Click() InfoProgram.Show End Sub Private Sub mnDapak_Click() DataPakar.Show FrmMenuUtama.Hide

End Sub Private Sub mnKeluar_Click() Unload Me End End Sub Private Sub mnMasalah_Click() FrmPengetahuanM.Show FrmMenuUtama.Hide End Sub Private Sub mnPenyebab_Click() FrmPengetahuanS.Show FrmMenuUtama.Hide End Sub Private Sub mnRelasi_Click() FrmAturan.Show FrmMenuUtama.Hide End Sub Private Sub mnSolusi_Click() FrmSolusi.Show FrmMenuUtama.Hide End Sub Private Sub mnUjicoba_Click() FrmKonsultasi1.Show FrmMenuUtama.Hide End Sub FORM GEJALA 'Tombol Simpan Private Sub Command1_Click() Dim a As Long If MsgBox("Yakin Data Akan Disimpan ?", vbYesNo + vbQuestion, "Simpan Data") = v bYes Then With rsGejala .AddNew !KdGejala = Text1.Text !Gejala = Text2.Text .Update End With MsgBox "Data Telah Berhasil Dimasukkan!!!", vbInformation, "Penyimpanan Data" Command6.Value = True Else MsgBox "Data Telah Ada!!! Masukkan Data Lain!!!", vbInformation, "Duplikasi Data " Command6.Value = True End If End Sub 'Tombol Ubah Private Sub Command2_Click() If MsgBox("Yakin Data Akan Diubah ?", vbYesNo + vbQuestion, "Simpan Data") = vbY es Then With rsGejala .Update !KdGejala = Text1.Text

!Gejala = Text2.Text .Update End With Command6.Value = True Else Command6.Value = True End If End Sub 'Tombol Hapus Private Sub Command3_Click() If MsgBox("Yakin Data Berikut Akan Dihapus ?", vbYesNo + vbQuestion, "Hapus Data ") = vbYes Then rsGejala.Delete Command6.Value = True Else Command6.Value = True End If End Sub Private Sub Command4_Click() FrmPengetahuanS.Show Unload Me End Sub Private Sub Command5_Click() Unload Me FrmMenuUtama.Show End Sub Private Sub Command6_Click() Pepak1.Show End Sub Private Sub DataGrid1_Click() Text1.Text = DataGrid1.Columns(0).Text Text2.Text = DataGrid1.Columns(1).Text End Sub Private Sub Form_Load() refreshDG End Sub Sub refreshDG() Set rsMasalah = New ADODB.Recordset rsGejala.LockType = adLockOptimistic rsGejala.CursorType = adOpenDynamic rsGejala.Open "SELECT * FROM TbGejala", conn, , , adCmdText Set DataGrid1.DataSource = rsGejala DataGrid1.Columns(0).Width = 1000 DataGrid1.Columns(1).Width = 8000 DataGrid1.Refresh End Sub FORM PENGETAHUAN 'Tombol Simpan Private Sub Command1_Click() Dim a As Long If MsgBox("Yakin Data Akan Disimpan ?", vbYesNo + vbQuestion, "Simpan Data") = v bYes Then

With rsPenyakit .AddNew !KdPenyakit = Text1.Text !Penyakit = Text2.Text .Update End With MsgBox "Data Telah Berhasil Dimasukkan!!!", vbInformation, "Penyimpanan Data" Command6.Value = True Else MsgBox "Data Telah Ada!!! Masukkan Data Lain!!!", vbInformation, "Duplikasi Data " Command6.Value = True End If End Sub 'Tombol Ubah Private Sub Command2_Click() If MsgBox("Yakin Data Akan Diubah ?", vbYesNo + vbQuestion, "Simpan Data") = vbY es Then With rsPenyakit .Update !KdPenyakit = Text1.Text !Penyakit = Text2.Text .Update End With Command6.Value = True Else Command6.Value = True End If End Sub 'Tombol Hapus Private Sub Command3_Click() If MsgBox("Yakin Data Berikut Akan Dihapus ?", vbYesNo + vbQuestion, "Hapus Data ") = vbYes Then rsPenyakit.Delete Command6.Value = True Else Command6.Value = True End If End Sub Private Sub Command4_Click() FrmSolusi.Show Unload Me End Sub Private Sub Command5_Click() Unload Me FrmMenuUtama.Show End Sub Private Sub Command6_Click() Pepak2.Show End Sub Private Sub DataGrid1_Click() Text1.Text = DataGrid1.Columns(0).Text

Text2.Text = DataGrid1.Columns(1).Text End Sub Private Sub Form_Load() refreshDG End Sub Sub refreshDG() Set rsPenyakit = New ADODB.Recordset rsPenyakit.LockType = adLockOptimistic rsPenyakit.CursorType = adOpenDynamic rsPenyakit.Open "SELECT * FROM TbPenyakit", conn, , , adCmdText Set DataGrid1.DataSource = rsPenyakit DataGrid1.Columns(0).Width = 1000 DataGrid1.Columns(1).Width = 8000 DataGrid1.Refresh End Sub FORM SOLUSI 'Tombol Simpan Private Sub Command1_Click() Dim a As Long If MsgBox("Yakin Data Akan Disimpan ?", vbYesNo + vbQuestion, "Simpan Data") = v bYes Then With rsSolusi .AddNew !KdSolusi = Text1.Text !Solusi = Text2.Text .Update End With MsgBox "Data Telah Berhasil Dimasukkan!!!", vbInformation, "Penyimpanan Data" Command6.Value = True Else MsgBox "Data Telah Ada!!! Masukkan Data Lain!!!", vbInformation, "Duplikasi Data " Command6.Value = True End If End Sub 'Tombol Ubah Private Sub Command2_Click() If MsgBox("Yakin Data Akan Diubah ?", vbYesNo + vbQuestion, "Simpan Data") = vbY es Then With rsSolusi .Update !KdSolusi = Text1.Text !Solusi = Text2.Text .Update End With 'Command6.Value = True Else 'Command6.Value = True End If End Sub 'Tombol Hapus Private Sub Command3_Click() With rsSolusi If MsgBox("Yakin Data Berikut Akan Dihapus ?", vbYesNo + vbQuestion, "Hapus Data ") = vbYes Then rsSolusi.Delete

'Command6.Value = True Else 'Command6.Value = True End If End With End Sub Private Sub Command4_Click() FrmAturan.Show Unload Me End Sub Private Sub Command5_Click() Unload Me FrmMenuUtama.Show End Sub Private Sub Command6_Click() Pepak3.Show End Sub Private Sub DataGrid1_Click() Text1.Text = DataGrid1.Columns(0).Text Text2.Text = DataGrid1.Columns(1).Text End Sub Private Sub Form_Load() refreshDG End Sub Sub refreshDG() Set rsSolusi = New ADODB.Recordset rsSolusi.LockType = adLockOptimistic rsSolusi.CursorType = adOpenDynamic rsSolusi.Open "SELECT * FROM TbSolusi", conn, , , adCmdText Set DataGrid1.DataSource = rsSolusi DataGrid1.Columns(0).Width = 1000 DataGrid1.Columns(1).Width = 8000 DataGrid1.Refresh End Sub FORM RELASI Private Sub DataGrid1_Click() txtKdRelasi.Text = DataGrid1.Columns(0).Text txtkdgejala.Text = DataGrid1.Columns(1).Text txtKdPenyakit.Text = DataGrid1.Columns(2).Text txtKdSolusi.Text = DataGrid1.Columns(3).Text End Sub Private Sub Form_Load() refreshDG End Sub Sub refreshDG() Set rsRelasi = New ADODB.Recordset rsRelasi.LockType = adLockOptimistic rsRelasi.CursorType = adOpenDynamic rsRelasi.Open "SELECT * FROM TbRelasi", conn, , , adCmdText Set DataGrid1.DataSource = rsRelasi DataGrid1.Refresh End Sub 'Tombol Simpan

Private Sub Command1_Click() Dim a As Long If MsgBox("Yakin Data Akan Disimpan ?", vbYesNo + vbQuestion, "Simpan Data") = v bYes Then With rsRelasi .AddNew !KdRelasi = txtKdRelasi.Text !KdGejala = txtkdgejala.Text !KdPenyakit = txtKdPenyakit.Text !KdSolusi = txtKdSolusi.Text .Update End With MsgBox "Data Telah Berhasil Dimasukkan!!!", vbInformation, "Penyimpanan Data" Command6.Value = True refreshDG Else MsgBox "Data Telah Ada!!! Masukkan Data Lain!!!", vbInformation, "Duplikasi Data " Command6.Value = True End If End Sub 'Tombol Ubah Private Sub Command2_Click() If MsgBox("Yakin Data Akan Diubah ?", vbYesNo + vbQuestion, "Simpan Data") = vbY es Then With rsRelasi .Update !KdRelasi = txtKdRelasi.Text !KdGejala = txtkdgejala.Text !KdPenyakit = txtKdPenyakit.Text !KdSolusi = txtKdSolusi.Text .Update End With Command6.Value = True refreshDG Else Command6.Value = True End If End Sub 'Tombol Hapus Private Sub Command3_Click() If MsgBox("Yakin Data Berikut Akan Dihapus ?", vbYesNo + vbQuestion, "Hapus Data ") = vbYes Then rsRelasi.Delete Command6.Value = True Else Command6.Value = True End If End Sub Private Sub Command4_Click() txtKdRelasi.Text = "" txtkdgejala.Text = "" txtKdPenyakit.Text = "" txtKdSolusi.Text = "" End Sub Private Sub Command5_Click()

Unload Me FrmMenuUtama.Show End Sub FORM DATA PAKAR Private Sub Command4_Click() Unload Me FrmMenuUtama.Show End Sub Private Sub Command5_Click() Unload Me FrmMenuUtama.Show End Sub Private Sub Command6_Click() txtNama.Text = "" txtSandi.Text = "" txtNama.SetFocus End Sub Private Sub DataGrid1_Click() txtNama.Text = DataGrid1.Columns(0).Text txtSandi.Text = DataGrid1.Columns(1).Text End Sub Private Sub Form_Load() refreshDG End Sub Sub refreshDG() Set rsPakar = New ADODB.Recordset rsPakar.LockType = adLockOptimistic rsPakar.CursorType = adOpenDynamic rsPakar.Open "SELECT * FROM TbPakar", conn, , , adCmdText Set DataGrid1.DataSource = rsPakar DataGrid1.Refresh End Sub 'Tombol Simpan Private Sub Command1_Click() Dim a As Long If MsgBox("Yakin Data Akan Disimpan ?", vbYesNo + vbQuestion, "Simpan Data") = v bYes Then With rsPakar .AddNew !nama = txtNama.Text !sandi = txtSandi.Text .Update End With refreshDG MsgBox "Data Telah Berhasil Dimasukkan!!!", vbInformation, "Penyimpanan Data" Command6.Value = True End If End Sub 'Tombol Ubah Private Sub Command2_Click() If MsgBox("Yakin Data Akan Diubah ?", vbYesNo + vbQuestion, "Simpan Data") = vbY es Then Set rsPakar = New ADODB.Recordset

rsPakar.LockType = adLockOptimistic rsPakar.CursorType = adOpenDynamic rsPakar.Open "SELECT * FROM TbPakar where nama ='" & txtNama.Text & "'", conn, , , adCmdText With rsPakar .Update !nama = txtNama.Text !sandi = txtSandi.Text .Update End With refreshDG Command6.Value = True Else Command6.Value = True End If End Sub 'Tombol Hapus Private Sub Command3_Click() If MsgBox("Yakin Data Berikut Akan Dihapus ?", vbYesNo + vbQuestion, "Hapus Data ") = vbYes Then Set rsPakar = New ADODB.Recordset rsPakar.LockType = adLockOptimistic rsPakar.CursorType = adOpenDynamic rsPakar.Open "SELECT * FROM TbPakar where nama ='" & txtNama.Text & "'", conn, , , adCmdText With rsPakar .Delete Command6.Value = True refreshDG End With Else Command6.Value = True End If End Sub KONEKSI DATA BASE Global Global Global Global Global Global Global Global Public Public Public Public Public Public Public Public conn As ADODB.Connection rsGejala As ADODB.Recordset rsPakar As ADODB.Recordset rsPenyakit As ADODB.Recordset rsPetunjuk As ADODB.Recordset rsRelasi As ADODB.Recordset rsSolusi As ADODB.Recordset rsQSolusi As ADODB.Recordset rsquery As String dbSapi As Database TbGejala As Recordset TbPakar As Recordset TbPenyakit As Recordset TbPetunjuk As Recordset TbRelasi As Recordset TbSolusi As Recordset

Sub koneksi()

Set conn = New ADODB.Connection conn.Provider = "microsoft.jet.oledb.4.0" conn.CursorLocation = adUseClient conn.Open App.Path & "\dbSapi.mdb" Set rsPakar = New ADODB.Recordset rsPakar.Open "TbPakar", conn, adOpenDynamic, adLockOptimistic Set Set Set Set Set Set rsGejala = New ADODB.Recordset rsPenyakit = New ADODB.Recordset rsPetunjuk = New ADODB.Recordset rsRelasi = New ADODB.Recordset rsQSolusi = New ADODB.Recordset rsSolusi = New ADODB.Recordset

Set dbSapi = DBEngine.Workspaces(0).OpenDatabase(App.Path & "\dbSapi.mdb") Set TbGejala = dbSapi.OpenRecordset("tbGejala", dbOpenTable) Set TbPakar = dbSapi.OpenRecordset("TbPakar", dbOpenTable) Set TbPenyakit = dbSapi.OpenRecordset("TbPenyakit", dbOpenTable) Set TbPetunjuk = dbSapi.OpenRecordset("TbPetunjuk", dbOpenTable) Set TbRelasi = dbSapi.OpenRecordset("TbRelasi", dbOpenTable) Set TbSolusi = dbSapi.OpenRecordset("TbSolusi", dbOpenTable) End Sub Public Sub SetFormCenter(frm As Form) frm.Move (MDIForm1.ScaleWidth \ 2) - (frm.Width \ 2), (MDIForm1.ScaleHeight / 2) - (frm.Height / 2) End Sub