lampiran source code

33
LAMPIRAN SOURCE CODE Form Login Private Sub cmdcancel_Click() End End Sub Private Sub cmdlogin_Click() If conn.State = 1 Then conn.Close conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\kuliahku\itats\praktikum\praktikum bdl\bdl ku\program\TokoBuku.mdb;Persist Security Info=False" If RS.State = 1 Then RS.Close RS.Open "select * from pegawai where usern= '" & Text1.Text & "' And pass = '" & Text2.Text & "'", conn, 3, 3 If Not RS.EOF Then MsgBox "Berhasil, Selamat Datang Di Toko Buku Warna Warni" formloading.Show formlogin.Hide Else MsgBox "Username Atau Password Salah, Silahkan Ulangi Lagi", vbCritical, "L O G I N" Text1.Text = "" Text2.Text = "" Text1.SetFocus End If End Sub Private Sub Form_Activate() 68

Upload: adrian-allen-darmansyah

Post on 28-Jan-2016

236 views

Category:

Documents


0 download

DESCRIPTION

code

TRANSCRIPT

Page 1: Lampiran Source Code

LAMPIRAN SOURCE CODE

Form Login

Private Sub cmdcancel_Click()EndEnd Sub

Private Sub cmdlogin_Click()If conn.State = 1 Then conn.Closeconn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\kuliahku\itats\praktikum\praktikum bdl\bdl ku\program\TokoBuku.mdb;Persist Security Info=False"If RS.State = 1 Then RS.CloseRS.Open "select * from pegawai where usern= '" & Text1.Text & "' And pass = '" & Text2.Text & "'", conn, 3, 3If Not RS.EOF ThenMsgBox "Berhasil, Selamat Datang Di Toko Buku Warna Warni"formloading.Showformlogin.HideElseMsgBox "Username Atau Password Salah, Silahkan Ulangi Lagi", vbCritical, "L O G I N"Text1.Text = ""Text2.Text = ""Text1.SetFocusEnd IfEnd Sub

Private Sub Form_Activate() Text1.SetFocusEnd Sub

Private Sub Timer1_Timer()Label5.ForeColor = QBColor(Rnd * 10)Label6.ForeColor = QBColor(Rnd * 10)Label7.ForeColor = QBColor(Rnd * 10)Label8.ForeColor = QBColor(Rnd * 10)

68

Page 2: Lampiran Source Code

End Sub

Form LoadingPrivate Sub Form_Activate()ProgressBar1.Min = 0ProgressBar1.Max = 100Timer1.Enabled = TrueEnd Sub

Private Sub Timer1_Timer()ProgressBar1.Value = ProgressBar1.Value + 10If ProgressBar1.Value >= 100 ThenDoEventsTimer1.Enabled = Falseformmenu.Showformloading.HideEnd IfEnd Sub

Private Sub Timer2_Timer()Label4.ForeColor = QBColor(Rnd * 10)Label5.ForeColor = QBColor(Rnd * 10)Label6.ForeColor = QBColor(Rnd * 10)Label7.ForeColor = QBColor(Rnd * 10)End Sub

Form PegawaiPrivate Sub cmdsearch_Click()On Error GoTo pesanAdodc1.Refreshx = "id_peg ='" & Text1.Text & "'"Adodc1.Recordset.Find x If Not Adodc1.Recordset.EOF Then Text1.Text = Adodc1.Recordset.Fields("id_peg") Text2.Text = Adodc1.Recordset.Fields("nama_peg") Text3.Text = Adodc1.Recordset.Fields("alamat_peg") Text4.Text = Adodc1.Recordset.Fields("telp_peg") Text5.Text = Adodc1.Recordset.Fields("jabatan")

69

Page 3: Lampiran Source Code

Text6.Text = Adodc1.Recordset.Fields("email") Text7.Text = Adodc1.Recordset.Fields("usern") Text8.Text = Adodc1.Recordset.Fields("pass") yes putih Else MsgBox "Data Yang Anda Cari tidak ada !", vbCritical, "Pesan" Text1.Text = "" Text1.SetFocus End If Exit Subpesan:MsgBox "Database data yang kosong,Tolong Di Cek Ulang"End Sub

Private Sub cmdcancel_Click()Text1.Text = ""Text2.Text = ""Text3.Text = ""Text4.Text = ""Text5.Text = ""Text6.Text = ""Text7.Text = ""Text8.Text = ""HitamEnd Sub

Sub non()Text2.Enabled = FalseText3.Enabled = FalseText4.Enabled = FalseText5.Enabled = FalseText6.Enabled = FalseText7.Enabled = FalseText8.Enabled = FalseEnd Sub

Sub yes()Text2.Enabled = TrueText3.Enabled = True

70

Page 4: Lampiran Source Code

Text4.Enabled = TrueText5.Enabled = TrueText6.Enabled = TrueText7.Enabled = TrueText8.Enabled = TrueEnd Sub

Sub putih()Text1.BackColor = &H80000004Text2.BackColor = &H80000004Text3.BackColor = &H80000004Text4.BackColor = &H80000004Text5.BackColor = &H80000004Text6.BackColor = &H80000004Text7.BackColor = &H80000004Text8.BackColor = &H80000004End Sub

Sub Hitam()Text2.BackColor = &H80000000Text3.BackColor = &H80000000Text4.BackColor = &H80000000Text5.BackColor = &H80000000Text6.BackColor = &H80000000Text7.BackColor = &H80000000Text8.BackColor = &H80000000End Sub

Sub kosong() Text1.Text = "" Text2.Text = "" Text3.Text = "" Text4.Text = "" Text5.Text = "" Text6.Text = "" Text7.Text = "" Text8.Text = ""End Sub

Private Sub Form_Activate()

71

Page 5: Lampiran Source Code

Text1.SetFocusEnd Sub

Form Kategori

Private Sub cmdexit_Click()x = MsgBox("Anda Yakin Akan Keluar Ke Form Menu ??", 4 + 64, "PERINGATAN!!!") If x = vbYes Then formmenu.Show formkategori.Hide End IfEnd Sub

Private Sub cmdsave_Click()If Text1.Text = "" ThenMsgBox ("Data Masih Kosong")Elsex = "id_kategori='" & Text1.Text & "'"Adodc1.Recordset.Find x If Not Adodc1.Recordset.EOF Then MsgBox "Data Sudah Ada" Adodc1.Refresh Else Adodc1.Recordset.AddNew Adodc1.Recordset.Fields("id_kategori") = Text1.Text Adodc1.Recordset.Fields("nama_kategori") = Text2.Text Adodc1.Recordset.Update Text1.SetFocus End IfEnd If non kosong Hitam Text2.Enabled = FalseEnd Sub

Private Sub cmdedit_Click()yes

72

Page 6: Lampiran Source Code

x = "id_kategori='" & Text1.Text If Not Adodc1.Recordset.EOF Then Adodc1.Recordset.Fields("id_kategori") = Text1.Text Adodc1.Recordset.Fields("nama_kategori") = Text2.Text Adodc1.Recordset.Update Else MsgBox "Data form ada yang Kosong" End If DataGrid1.Refresh Text1.SetFocus kosong non HitamEnd Sub

Private Sub cmdcancel_Click() kosong HitamEnd Sub

Private Sub cmdsearch_Click()On Error GoTo pesanAdodc1.Refreshx = "id_kategori ='" & Text1.Text & "'"Adodc1.Recordset.Find x If Not Adodc1.Recordset.EOF Then Text1.Text = Adodc1.Recordset.Fields("id_kategori") Text2.Text = Adodc1.Recordset.Fields("nama_kategori") Text2.Enabled = True yes putih Else MsgBox "Data Yang Anda Cari tidak ada !", vbCritical, "Pesan" Text1.Text = "" Text1.SetFocus End If Exit Subpesan:MsgBox "Database data yang kosong,Tolong Di Cek Ulang"End Sub

73

Page 7: Lampiran Source Code

Private Sub cmddel_Click()If Text1.Text = "" Then x = MsgBox("Data kosong", vbInformation + vbOKOnly, "pesan") Text1.SetFocus Else vhapus = MsgBox("Anda yakin untuk menghapus data ini", vbYesNo, "peringatan") If vhapus = 6 Then Adodc1.Recordset.Delete Text1.Text = ("") Text2.Text = ("") Text1.SetFocus non Hitam End If End IfEnd Sub

Sub kosong() Text1.Text = "" Text2.Text = ""End Sub

Private Sub cmdadd_Click()Text1.SetFocusyeskosongputihEnd Sub

Sub putih()Text1.BackColor = &HFFFFFFText2.BackColor = &HFFFFFFEnd SubSub Hitam()Text2.BackColor = &H80000000End Sub

Sub non()

74

Page 8: Lampiran Source Code

Text2.Enabled = FalseEnd SubSub yes()Text1.Enabled = TrueText2.Enabled = TrueEnd Sub

Private Sub Form_Activate()Text1.SetFocusEnd Sub

Form BukuPrivate Sub cmdadd_Click()Text1.SetFocusyeskosongputihEnd SubPrivate Sub cmdcancel_Click() kosong HitamEnd SubPrivate Sub cmddel_Click()If Text1.Text = "" Then x = MsgBox("Data kosong", vbInformation + vbOKOnly, "pesan") Text1.SetFocus Else vhapus = MsgBox("Anda yakin untuk menghapus data ini", vbYesNo, "peringatan") If vhapus = 6 Then Adodc1.Recordset.Delete Text1.Text = ("") Text2.Text = ("") Text3.Text = ("") Text4.Text = ("") Text9.Text = ("") Text6.Text = ("") Text7.Text = ("") Text8.Text = ("") Text1.SetFocus

75

Page 9: Lampiran Source Code

non Hitam End If End IfEnd Sub

Private Sub cmdedit_Click()yesx = "id_buku='" & Text1.Text If Not Adodc1.Recordset.EOF Then Adodc1.Recordset.Fields("id_buku") = Text1.Text Adodc1.Recordset.Fields("judul") = Text2.Text Adodc1.Recordset.Fields("pengarang") = Text3.Text Adodc1.Recordset.Fields("penerbit") = Text4.Text Adodc1.Recordset.Fields("tahun_terbit") = Text9.Text Adodc1.Recordset.Fields("nama_kategori") = Text6.Text Adodc1.Recordset.Fields("stok_buku") = Text7.Text Adodc1.Recordset.Fields("harga_buku") = Text8.Text Adodc1.Recordset.Update Else MsgBox "Data form ada yang Kosong" End If DataGrid1.Refresh Text1.SetFocus kosong non HitamEnd Sub

Private Sub cmdexit_Click()x = MsgBox("Anda Yakin Akan Keluar Ke Form Menu ??", 4 + 64, "PERINGATAN!!!") If x = vbYes Then formmenu.Show formbuku.Hide End IfEnd Sub

Private Sub cmdsave_Click()If Text1.Text = "" Then

76

Page 10: Lampiran Source Code

MsgBox ("Data Masih Kosong")Elsex = "id_buku='" & Text1.Text & "'"Adodc1.Recordset.Find x If Not Adodc1.Recordset.EOF Then MsgBox "Data Sudah Ada" Adodc1.Refresh Else Adodc1.Recordset.AddNew Adodc1.Recordset.Fields("id_buku") = Text1.Text Adodc1.Recordset.Fields("judul") = Text2.Text Adodc1.Recordset.Fields("pengarang") = Text3.Text Adodc1.Recordset.Fields("penerbit") = Text4.Text Adodc1.Recordset.Fields("tahun_terbit") = Text9.Text Adodc1.Recordset.Fields("nama_kategori") = Text6.Text Adodc1.Recordset.Fields("stok_buku") = Text7.Text Adodc1.Recordset.Fields("harga_buku") = Text8.Text Adodc1.Recordset.Update Text1.SetFocus End IfEnd If non kosong HitamEnd Sub

Private Sub cmdsearch_Click()On Error GoTo pesanAdodc1.Refreshx = "id_buku ='" & Text1.Text & "'"Adodc1.Recordset.Find x If Not Adodc1.Recordset.EOF Then Text1.Text = Adodc1.Recordset.Fields("id_buku") Text2.Text = Adodc1.Recordset.Fields("judul") Text3.Text = Adodc1.Recordset.Fields("pengarang") Text4.Text = Adodc1.Recordset.Fields("penerbit") Text9.Text = Adodc1.Recordset.Fields("tahun_terbit") Text6.Text = Adodc1.Recordset.Fields("nama_kategori") Text7.Text = Adodc1.Recordset.Fields("stok_buku") Text8.Text = Adodc1.Recordset.Fields("harga_buku")

77

Page 11: Lampiran Source Code

yes putih Else MsgBox "Data Yang Anda Cari tidak ada !", vbCritical, "Pesan" Text1.Text = "" Text1.SetFocus End If Exit Subpesan:MsgBox "Database data yang kosong,Tolong Di Cek Ulang"End Sub

Private Sub Form_Activate()Text1.SetFocusEnd SubSub putih()Text1.BackColor = &HFFFFFFText2.BackColor = &HFFFFFFText3.BackColor = &HFFFFFFText4.BackColor = &HFFFFFFText9.BackColor = &HFFFFFFText5.BackColor = &HFFFFFFText6.BackColor = &HFFFFFFText7.BackColor = &HFFFFFFText8.BackColor = &HFFFFFF

End SubSub Hitam()Text2.BackColor = &H80000000Text3.BackColor = &H80000000Text4.BackColor = &H80000000Text9.BackColor = &H80000000Text5.BackColor = &H80000000Text6.BackColor = &H80000000Text7.BackColor = &H80000000Text8.BackColor = &H80000000End Sub

Sub kosong() Text1.Text = ""

78

Page 12: Lampiran Source Code

Text2.Text = "" Text3.Text = "" Text4.Text = "" Text9.Text = "" Text5.Text = "" Text6.Text = "" Text7.Text = "" Text8.Text = ""End Sub

Sub non()Text2.Enabled = FalseText3.Enabled = FalseText4.Enabled = FalseText9.Enabled = FalseText5.Enabled = FalseText6.Enabled = FalseText7.Enabled = FalseText8.Enabled = FalseEnd Sub

Sub yes()Text1.Enabled = TrueText2.Enabled = TrueText3.Enabled = TrueText4.Enabled = TrueText9.Enabled = TrueText5.Enabled = TrueText6.Enabled = TrueText7.Enabled = TrueText8.Enabled = TrueEnd Sub

Private Sub Text5_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenOn Error GoTo pesanAdodc2.Refreshx = "id_kategori ='" & Text5.Text & "'"Adodc2.Recordset.Find x If Not Adodc2.Recordset.EOF Then

79

Page 13: Lampiran Source Code

Text6.Text = Adodc2.Recordset.Fields("nama_kategori") Text7.SetFocus Else MsgBox "Data Yang Anda Cari tidak ada !", vbCritical, "Pesan" Text5.Text = "" Text5.SetFocus End If Exit Subpesan:MsgBox "Database data yang kosong,Tolong Di Cek Ulang"End IfEnd Sub

Form Aksesoris

Private Sub cmdadd_Click()Text1.SetFocusyeskosongputihEnd Sub

Private Sub cmdcancel_Click() kosong HitamEnd Sub

Private Sub cmddel_Click()If Text1.Text = "" Then x = MsgBox("Data kosong", vbInformation + vbOKOnly, "pesan") Text1.SetFocus Else vhapus = MsgBox("Anda yakin untuk menghapus data ini", vbYesNo, "peringatan") If vhapus = 6 Then Adodc1.Recordset.Delete Text1.Text = ("") Text2.Text = ("") Text3.Text = ("")

80

Page 14: Lampiran Source Code

Text4.Text = ("") Text1.SetFocus non Hitam End If End IfEnd SubPrivate Sub cmdedit_Click()yesx = "id_aks='" & Text1.Text If Not Adodc1.Recordset.EOF Then Adodc1.Recordset.Fields("id_aks") = Text1.Text Adodc1.Recordset.Fields("nama_aks") = Text2.Text Adodc1.Recordset.Fields("stok_aks") = Text3.Text Adodc1.Recordset.Fields("harga_aks") = Text4.Text Adodc1.Recordset.Update Else MsgBox "Data form ada yang Kosong" End If DataGrid1.Refresh Text1.SetFocus kosong non HitamEnd Sub

Private Sub cmdsave_Click()If Text1.Text = "" ThenMsgBox ("Data Masih Kosong")Elsex = "id_aks='" & Text1.Text & "'"Adodc1.Recordset.Find x If Not Adodc1.Recordset.EOF Then MsgBox "Data Sudah Ada" Adodc1.Refresh Else Adodc1.Recordset.AddNew Adodc1.Recordset.Fields("id_aks") = Text1.Text Adodc1.Recordset.Fields("nama_aks") = Text2.Text Adodc1.Recordset.Fields("stok_aks") = Text3.Text

81

Page 15: Lampiran Source Code

Adodc1.Recordset.Fields("harga_aks") = Text4.Text Adodc1.Recordset.Update Text1.SetFocus End IfEnd If non kosong HitamEnd Sub

Private Sub cmdsearch_Click()On Error GoTo pesanAdodc1.Refreshx = "id_aks ='" & Text1.Text & "'"Adodc1.Recordset.Find x If Not Adodc1.Recordset.EOF Then Text1.Text = Adodc1.Recordset.Fields("id_aks") Text2.Text = Adodc1.Recordset.Fields("nama_aks") Text3.Text = Adodc1.Recordset.Fields("stok_aks") Text4.Text = Adodc1.Recordset.Fields("harga_aks") yes putih Else MsgBox "Data Yang Anda Cari tidak ada !", vbCritical, "Pesan" Text1.Text = "" Text1.SetFocus End If Exit Subpesan:MsgBox "Database data yang kosong,Tolong Di Cek Ulang"End Sub

Private Sub cmdexit_Click()x = MsgBox("Anda Yakin Akan Keluar Ke Form Menu ??", 4 + 64, "PERINGATAN!!!") If x = vbYes Then formmenu.Show formaks.Hide End IfEnd Sub

82

Page 16: Lampiran Source Code

Sub kosong() Text1.Text = "" Text2.Text = "" Text3.Text = "" Text4.Text = ""End Sub

Sub Hitam()Text2.BackColor = &H80000000Text3.BackColor = &H80000000Text4.BackColor = &H80000000End SubSub putih()Text2.BackColor = &HFFFFFFText3.BackColor = &HFFFFFFText4.BackColor = &HFFFFFFEnd Sub

Sub non()Text2.Enabled = FalseText3.Enabled = FalseText4.Enabled = FalseEnd Sub

Sub yes()Text1.Enabled = TrueText2.Enabled = TrueText3.Enabled = TrueText4.Enabled = TrueEnd Sub

Form TransaksiSub non()Text3.Enabled = FalseText4.Enabled = FalseText5.Enabled = FalseText6.Enabled = FalseText7.Enabled = False

83

Page 17: Lampiran Source Code

Text8.Enabled = FalseText9.Enabled = FalseText10.Enabled = FalseText11.Enabled = FalseText12.Enabled = FalseText13.Enabled = FalseText14.Enabled = FalseText15.Enabled = FalseText16.Enabled = FalseText17.Enabled = FalseText18.Enabled = FalseText19.Enabled = FalseText20.Enabled = FalseText21.Enabled = FalseEnd Sub

Sub yes()Text3.Enabled = TrueText4.Enabled = TrueText5.Enabled = TrueText6.Enabled = TrueText7.Enabled = TrueText8.Enabled = TrueText9.Enabled = TrueText10.Enabled = TrueText11.Enabled = TrueText12.Enabled = TrueText13.Enabled = TrueText14.Enabled = TrueText15.Enabled = TrueText16.Enabled = TrueText17.Enabled = TrueText18.Enabled = TrueText19.Enabled = TrueText20.Enabled = TrueText21.Enabled = TrueEnd Sub

Sub kosong()Text1.Text = ""

84

Page 18: Lampiran Source Code

Text3.Text = ""Text4.Text = ""Text5.Text = ""Text6.Text = ""Text7.Text = ""Text8.Text = ""Text9.Text = ""Text10.Text = ""Text11.Text = ""Text12.Text = ""Text13.Text = ""Text14.Text = ""Text15.Text = ""Text16.Text = ""Text17.Text = ""Text18.Text = ""Text19.Text = ""Text20.Text = ""Text21.Text = ""End Sub

Sub putih()Text1.BackColor = &HFFFFFFText3.BackColor = &HFFFFFFText4.BackColor = &HFFFFFFText5.BackColor = &HFFFFFFText6.BackColor = &HFFFFFFText7.BackColor = &HFFFFFFText8.BackColor = &HFFFFFFText9.BackColor = &HFFFFFFText10.BackColor = &HFFFFFFText11.BackColor = &HFFFFFFText12.BackColor = &HFFFFFFText13.BackColor = &HFFFFFFText14.BackColor = &HFFFFFFText15.BackColor = &HFFFFFFText16.BackColor = &HFFFFFFText17.BackColor = &HFFFFFFText18.BackColor = &HFFFFFFText19.BackColor = &HFFFFFF

85

Page 19: Lampiran Source Code

Text20.BackColor = &HFFFFFFText21.BackColor = &HFFFFFFEnd Sub

Sub Hitam()Text1.BackColor = &H80000000Text3.BackColor = &H80000000Text4.BackColor = &H80000000Text5.BackColor = &H80000000Text6.BackColor = &H80000000Text7.BackColor = &H80000000Text8.BackColor = &H80000000Text9.BackColor = &H80000000Text10.BackColor = &H80000000Text11.BackColor = &H80000000Text12.BackColor = &H80000000Text13.BackColor = &H80000000Text14.BackColor = &H80000000Text15.BackColor = &H80000000Text16.BackColor = &H80000000Text17.BackColor = &H80000000Text18.BackColor = &H80000000Text19.BackColor = &H80000000Text20.BackColor = &H80000000Text21.BackColor = &H80000000End Sub

Private Sub cmdbuku_Click() adodetbuku.Recordset.AddNew adodetbuku.Recordset.Fields("id_buku") = Text5.Text adodetbuku.Recordset.Fields("judul") = Text6.Text adodetbuku.Recordset.Fields("pengarang") = Text7.Text adodetbuku.Recordset.Fields("penerbit") = Text8.Text adodetbuku.Recordset.Fields("stok_buku") = Text9.Text adodetbuku.Recordset.Fields("harga_buku") = Text10.Text adodetbuku.Recordset.Fields("jumlah_buku") = Text11.Text adodetbuku.Recordset.Fields("total_buku") = Text12.Text adodetbuku.Recordset.Update adodetbuku.Recordset.MoveFirst

86

Page 20: Lampiran Source Code

Do Until adodetbuku.Recordset.EOF Text19.Text = Str(Val(Text12.Text) + (Text18.Text) + (adodetbuku.Recordset.Fields!total_buku) + (adodetaks.Recordset.Fields!total_aks)) adodetbuku.Recordset.MoveNext Text12.SetFocus LoopEnd Sub

Private Sub cmdexit_Click()x = MsgBox("Anda Yakin Akan Keluar Ke Form Menu ??", 4 + 64, "PERINGATAN!!!") If x = vbYes Then formmenu.Show formtransaksi.Hide End IfEnd Sub

Private Sub cmdsave_Click() For i = 1 To ListView1.ListItems.Count ' adotransaksi.RecordSource = "select * from transaksi where id_transaksi=""" & Text1 & """ and id =""" & ListView1.ListItems(i) & """" ' adotransaksi.Refresh ' If adotransaksi.Recordset.RecordCount = 0 Then adotransaksi.Recordset.AddNew adotransaksi.Recordset.Fields("id_transaksi") = Text1 adotransaksi.Recordset.Fields("tgl_transaksi") = DTPicker1.Value adotransaksi.Recordset.Fields("id") = ListView1.ListItems(i) adotransaksi.Recordset.Fields("nama") = ListView1.ListItems(i).SubItems(1) adotransaksi.Recordset.Fields("harga") = ListView1.ListItems(i).SubItems(2) adotransaksi.Recordset.Fields("jumlah") = ListView1.ListItems(i).SubItems(3) adotransaksi.Recordset.Fields("total") = ListView1.ListItems(i).SubItems(4) adotransaksi.Recordset.Update ' End If Next i Unload Me

87

Page 21: Lampiran Source Code

Load Me ShowEnd Sub

Private Sub cmdtambah_Click() Dim l As ListItem Dim m As ListItem Set l = ListView1.FindItem(Text5, lvwText, , lvwPartial) Set m = ListView1.FindItem(Text13, lvwText, , lvwPartial) If l Is Nothing Then Set l = ListView1.ListItems.Add() l = Text5 l.SubItems(1) = Text6 l.SubItems(2) = Text10 l.SubItems(3) = Text11 l.SubItems(4) = Text12 Else Set m = ListView1.ListItems.Add() m = Text13 m.SubItems(1) = Text14 m.SubItems(2) = Text16 m.SubItems(3) = Text17 m.SubItems(4) = Text18 End If a = MsgBox("Apakah anda akan menambah lagi", vbInformation + vbYesNo, "Informasi") If a = vbYes Then Text5 = "" Text6 = "" Text7 = "" Text8 = "" Text9 = "" Text10 = "" Text11 = "" Text12 = "" Text13 = "" Text14 = "" Text15 = "" Text16 = "" Text17 = ""

88

Page 22: Lampiran Source Code

Text18 = "" Text5.SetFocus Else Text20.SetFocus End IfEnd Sub

Private Sub Text11_Change() If Not IsNumeric(Text11) Then Text11 = "0" Text12.Text = Val(Text10.Text) * Val(Text11.Text)End Sub

Private Sub Text11_KeyPress(KeyAscii As Integer)If Text9.Text = "0" Then MsgBox "Stok tidak ada !", _ vbInformation + vbOKOnly, "Information" Text11.Text = "" Text5.SetFocus ElseIf Val(Text11.Text) > Val(Text9.Text) Then MsgBox "Stok tidak memenuhi ! ", _ vbInformation + vbOKOnly, "Information" Text11.SetFocus Else On Error Resume Next If Text11.Text = "" Or Text10.Text = "" Then Text12.Text = "0" Exit Sub ElseIf Text11.Text = "0" _ Or Text10.Text = "0" Then Text12.Text = "0" Else Text12.Text = Text11.Text * Text10.Text End If End If 'Text19.Text = Str(Val(Text12.Text) + Val(Text18.Text)) Text13.SetFocusEnd Sub

Private Sub Text13_KeyPress(KeyAscii As Integer)If KeyAscii = 13 Then

89

Page 23: Lampiran Source Code

On Error GoTo pesanadoaks.Refreshx = "id_aks ='" & Text13.Text & "'"adoaks.Recordset.Find x If Not adoaks.Recordset.EOF Then Text14.Text = adoaks.Recordset.Fields("nama_aks") Text15.Text = adoaks.Recordset.Fields("stok_aks") Text16.Text = adoaks.Recordset.Fields("harga_aks") Text17.SetFocus Else MsgBox "Data Yang Anda Cari tidak ada !", vbCritical, "Pesan" Text13.Text = "" Text13.SetFocus End If Exit Subpesan:MsgBox "Database data yang kosong,Tolong Di Cek Ulang"End IfEnd Sub

Private Sub Text17_Change() If Not IsNumeric(Text17) Then Text17 = "0" Text18.Text = Val(Text16.Text) * Val(Text17.Text)End Sub

Private Sub Text17_KeyPress(KeyAscii As Integer)If Text15.Text = "0" Then MsgBox "Stok tidak ada !", _ vbInformation + vbOKOnly, "Information" Text17.Text = "" Text13.SetFocus ElseIf Val(Text17.Text) > Val(Text15.Text) Then MsgBox "Stok tidak memenuhi ! ", _ vbInformation + vbOKOnly, "Information" Text17.SetFocus Else On Error Resume Next If Text17.Text = "" Or Text16.Text = "" Then Text18.Text = "0" Exit Sub

90

Page 24: Lampiran Source Code

ElseIf Text17.Text = "0" _ Or Text16.Text = "0" Then Text18.Text = "0" Else Text18.Text = Text17.Text * Text16.Text End If End If 'Text19.Text = Str(Val(Text12.Text) + Val(Text18.Text)) Text20.SetFocusEnd Sub

Private Sub Text20_GotFocus() Dim i, Tot, a For i = 1 To ListView1.ListItems.Count Tot = Val(Tot) + Val(ListView1.ListItems(i).SubItems(4)) Next i Text19.Text = TotEnd Sub

Private Sub Text20_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenText21.Text = Str(Val(Text20.Text) - Val(Text19.Text))If Text21 < 0 Then MsgBox ("Uang Pembayaran Kurang") Text20.SetFocus Text21.Text = "" Exit SubEnd IfEnd IfEnd Sub

Private Sub Text3_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenOn Error GoTo pesanadopeg.Refreshx = "id_peg ='" & Text3.Text & "'"adopeg.Recordset.Find x If Not adopeg.Recordset.EOF Then

91

Page 25: Lampiran Source Code

Text4.Text = adopeg.Recordset.Fields("nama_peg") Text5.SetFocus Else MsgBox "Data Yang Anda Cari tidak ada !", vbCritical, "Pesan" Text3.Text = "" Text3.SetFocus End If Exit Subpesan:MsgBox "Database data yang kosong,Tolong Di Cek Ulang"End IfEnd Sub

Private Sub Text5_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenOn Error GoTo pesanadobuku.Refreshx = "id_buku ='" & Text5.Text & "'"adobuku.Recordset.Find x If Not adobuku.Recordset.EOF Then Text6.Text = adobuku.Recordset.Fields("judul") Text7.Text = adobuku.Recordset.Fields("pengarang") Text8.Text = adobuku.Recordset.Fields("penerbit") Text9.Text = adobuku.Recordset.Fields("stok_buku") Text10.Text = adobuku.Recordset.Fields("harga_buku") Text11.SetFocus Else MsgBox "Data Yang Anda Cari tidak ada !", vbCritical, "Pesan" Text6.Text = "" Text6.SetFocus End If Exit Subpesan:MsgBox "Database data yang kosong,Tolong Di Cek Ulang"End IfEnd Sub

Private Sub Timer1_Timer()If jam.Text <> CStr(Timer) Then

92

Page 26: Lampiran Source Code

jam.Text = Time End IfEnd Sub

Private Sub cmdnew_Click()DTPicker1.Value = Format(Date, "DD-MM-YYYY")yeskosongnotaputihText3.SetFocusEnd SubSub nota()If adotransaksi.Recordset.RecordCount <> 0 Then adotransaksi.Recordset.MoveLast tekno = adotransaksi.Recordset.Fields("id_transaksi") noku = Val(tekno) + 1 Select Case noku Case 0 To 9 Text1.Text = "000000" & Trim(Str(noku)) Case 10 To 99 Text1.Text = "00000" & Trim(Str(noku)) Case 100 To 999 Text1.Text = "0000" & Trim(Str(noku)) Case 1000 To 9999 Text1.Text = "000" & Trim(Str(noku)) Case 10000 To 99999 Text1.Text = "00" & Trim(Str(noku)) Case 100000 To 999999 Text1.Text = "0" & Trim(Str(noku)) Case 1000000 To 9999999 Text1.Text = Trim(Str(noku)) End SelectElse Text1.Text = "0000001"End IfEnd Sub

Module1

93

Page 27: Lampiran Source Code

Public conn As New ADODB.ConnectionPublic RS As New ADODB.Recordset

94