1 LISTING PROGRAM 1. Listing Flash Pembuka. Private Sub Timer1_Timer() ProgressBar1.Value = ProgressBar1.Value + 4 If ProgressBar1.Value = 100 Then TA.Show Unload Me 2. tugas_akhir.frm Private Sub nabout_click() About.Show Private Sub nadmin_click()
2 Admin.Show TA.Hide Private Sub nexit_click() exit1.show Private Sub ngizi_click() gizi.show Private Sub npms_click() Software.Show 3. Form2.frm Private Sub cmdhasil_click() Dim bulan As String Dim tanggal As Single bulan = cmbbln tanggal = cmbtgl hasil = Val(cmbtgl.Text + 14)
3 If bulan = 2 Then If tanggal < 17 Then - 28 If bulan = 4 Then If tanggal < 17 Then - 30 If bulan = 6 Then If tanggal < 17 Then - 30 If bulan = 9 Then If tanggal < 17 Then
4-30 If bulan = 11 Then If tanggal < 17 Then - 30 If bulan = 1 Or 3 Or 5 Or 7 Or 8 Or 10 Or 12 Then If tanggal < 17 Then - 31-30
5 Private Sub Form_Load() TA.Hide Dim I As Integer For I = 1 To 12 cmbbln.additem I Next For I = 1 To 31 cmbtgl.additem I Next Private Sub Form_Unload(Cancel As Integer) TA.Visible = True Private Sub nabout_click() About.Show Private Sub nadmin_click() Admin.Show Private Sub nexit_click()
6 exit1.show Private Sub ngizi_click() gizi.show Private Sub npms_click() Software.Show 4. gizi.frm Private Sub cmdreset_click() txtbb.text = "" Text1.Text = "" txtumur.text = "" txtbb.setfocus Private Sub cmdsearch1_click() Dim I As String Dim A As String Dim X As String
7 I = InputBox("Silahkan Masukkan Nama", "Search") A = "nama_makanan = '" & I & "'" Adodc1.Recordset.Find A If Adodc1.Recordset.EOF Then X = MsgBox("Data Not Found!", vbokonly, "Pencarian Nama Makanan!") Adodc1.Recordset.MoveFirst Private Sub cmdsubmit_click() Dim pria As Single Dim wanita As Single Dim tiber As Single Dim oring As Single Dim ose As Single Dim oin As Single Dim apro As Single pria = Option2 wanita = Option3 tiber = opt1 oring = opt2 ose = opt3 oin = opt4(0) apro = opt5
8 If pria Then If tiber Then hasil = Val((660 + (txtbb.text * 13.7) + (Text1.Text * 5) - (txtumur.text * 6.8)) * 1.2) If oring Then hasil = Val((660 + (txtbb.text * 13.7) + (Text1.Text * 5) - (txtumur.text * 6.8)) * 1.375) If ose Then hasil = Val((660 + (txtbb.text * 13.7) + (Text1.Text * 5) - (txtumur.text * 6.8)) * 1.55) If oin Then hasil = Val((660 + (txtbb.text * 13.7) + (Text1.Text * 5) - (txtumur.text * 6.8)) * 1.725)
9 hasil = Val((660 + (txtbb.text * 13.7) + (Text1.Text * 5) - (txtumur.text * 6.8)) * 1.9) If tiber Then hasil = Val((655 + (txtbb.text * 9.6) + (Text1.Text * 1.8) - (txtumur.text * 4.7)) * 1.2) If oring Then hasil = Val((655 + (txtbb.text * 9.6) + (Text1.Text * 1.8) - (txtumur.text * 4.7)) * 1.375) If ose Then hasil = Val((655 + (txtbb.text * 9.6) + (Text1.Text * 1.8) - (txtumur.text * 4.7)) * 1.55)
10 If oin Then hasil = Val((655 + (txtbb.text * 9.6) + (Text1.Text * 1.8) - (txtumur.text * 4.7)) * 1.725) hasil = Val((655 + (txtbb.text * 9.6) + (Text1.Text * 1.8) - (txtumur.text * 4.7)) * 1.9) Private Sub Form_Load() TA.Hide Private Sub Form_Unload(Cancel As Integer) TA.Visible = True Private Sub nabout_click()
11 About.Show Private Sub nadmin_click() Admin.Show Private Sub nexit_click() exit1.show Private Sub npms_click() Software.Show 5. Admin.frm Private Sub admin1_dragdrop(source As Control, X As Single, Y As Single) Private Sub cmdreset_click() txtusername.text = "" txtpassword.text = "" txtusername.setfocus
12 Private Sub Form_Load() Call BukaDb TA.Hide Private Sub cmdsubmit_click() If txtusername.text = "" Then MsgBox " Masukkan Username Anda!!", vbexclamation, "Alert" txtusername.setfocus Exit Sub If txtpassword.text = "" Then MsgBox "Masukkan Password Anda!!", vbexclamation, "Alert" txtpassword.setfocus Exit Sub Dim strsql2 As String Dim RSuser As ADODB.Recordset Dim intcounter2 As Integer
13 strsql2 = "Select* from admin where nama = '" & txtusername & "' AND password = '" & txtpassword & "'" Set rcs = conn.execute(strsql2) With rcs If Not.EOF Then MsgBox "Login sukses", vbexclamation, "Alert" isiadmin.show : MsgBox "Gagal Login!!", vbexclamation, "Alert" txtusername.setfocus End With txtusername.text = "" txtpassword.text = "" Admin.Hide Private Sub Form_Unload(Cancel As Integer) TA.Visible = True Private Sub ListView1_BeforeLabelEdit(Cancel As Integer) Private Sub nabout_click()
14 About.Show Private Sub nexit_click() exit1.show Private Sub ngizi_click() gizi.show Private Sub npms_click() Software.Show 6. form_kania.frm Private Sub nabout_click() About.Show Private Sub cmddelete_click() Dim delete As String
15 tanya = MsgBox("Are you sure to delete this data? : " & txtmakanan.text & "?", vbquestion + vbyesno, " Delete confirm") If tanya = vbyes Then delete = "Delete from daftar_makanan Where nama_makanan ='" & txtmakanan.text & "'" conn.execute (delete) txtno.text = "" txtmakanan.text = "" txtkdrgizi.text = "" Text1.Text = "" txtgol.text = "" MsgBox "Data telah berhasil dihapus! ", vbexclamation, "Alert" Adodc1.Refresh Exit Sub Private Sub cmdinsert_click() txtno.text = "" txtmakanan.text = "" txtkdrgizi.text = ""
16 Text1.Text = "" txtgol.text = "" txtno.locked = False txtmakanan.locked = False txtkdrgizi.locked = False Text1.Locked = False txtgol.locked = False txtno.setfocus cmdinsert.enabled = False cmdsave.enabled = True Private Sub cmdlogout_click() TA.Show isiadmin.hide Private Sub cmdsave_click() Dim strsql As String Dim RSuser As ADODB.Recordset If txtno.text = "" Then MsgBox "Masukkan No. ", vbexclamation, "Alert" Exit Sub
17 If txtmakanan.text = "" Then MsgBox "Masukkan Nama Makanan.", vbexclamation, "Alert" Exit Sub If txtkdrgizi.text = "" Then MsgBox " Masukkan Kadar Gizi.", vbexclamation, "Alert" Exit Sub If Text1.Text = "" Then MsgBox " Masukkan Jumlah Kalori.", vbexclamation, "Alert" Exit Sub If txtgol.text = "" Then MsgBox " Masukkan Berat.", vbexclamation, "Alert" Exit Sub strsql = "insert into daftar_makanan Values( '" & txtno.text & "', '" & txtmakanan.text & "','" & txtkdrgizi.text & "','" & Text1.Text & "','" & txtgol.text & "')" conn.execute (strsql)
18 txtno.text = "" txtmakanan.text = "" txtkdrgizi.text = "" Text1.Text = "" txtgol.text = "" MsgBox "Data Berhasil Disimpan Pada Database!!", vbexclamation, "Alert" txtno.locked = True txtmakanan.locked = True txtkdrgizi.locked = True Text1.Locked = True txtgol.locked = True cmdinsert.enabled = True cmdsave.enabled = False Adodc1.Refresh Private Sub cmdsearch_click() Dim I As String Dim A As String Dim X As String I = InputBox("Silahkan Masukkan Nama", "Search") X = "select * from daftar_makanan where nama_makanan='" & I & "'"
19 Set rcs = conn.execute(x) If Not rcs.eof Then txtno.text = rcs(0) txtmakanan.text = rcs(1) txtkdrgizi.text = rcs(2) Text1.Text = rcs(3) txtgol.text = rcs(4) MsgBox "Data Not Found ", vbcritical, "Pesan" Private Sub cmdupdate_click() Dim strupdate As String strupdate = "Update daftar_makanan Set No = '" & txtno.text & "',nama_makanan = '" & txtmakanan.text & "', kandungan_gizi = '" & txtkdrgizi.text & "', jumlah_kalori = '" & Text1.Text & "', Berat = '" & txtgol.text & "' where nama_makanan = '" & txtmakanan.text & "'" conn.execute (strupdate) txtno.text = "" txtmakanan.text = "" txtkdrgizi.text = "" Text1.Text = ""
20 txtgol.text = "" Adodc1.Refresh Exit Sub MsgBox " Data Berhasil di Update. ", vbexclamation, "Alert" Adodc1.Refresh cmdupdate.enabled = False txtno.locked = True txtmakanan.locked = True txtkdrgizi.locked = True Text1.Locked = True txtgol.locked = True Private Sub Form_Load() Call BukaDb Admin.Hide Me.Caption = App.Title Private Sub Form_Unload(Cancel As Integer) TA.Visible = True Private Sub nexit_click()
21 exit1.show Private Sub ngizi_click() gizi.show Private Sub npms_click() Software.Show 7. About.frm Private Sub cmdok_click() TA.Show Private Sub Form_Load() TA.Hide Private Sub Form_Unload(Cancel As Integer) TA.Visible = True
22 Private Sub nadmin_click() Admin.Show Private Sub nexit_click() exit1.show Private Sub ngizi_click() gizi.show Private Sub npms_click() Software.Show 8. Module Option Explicit Public nama, id As String Public conn As ADODB.Connection Public SqlSimpan, sql As String Public rcs As ADODB.Recordset
23 ' Prosedur untuk koneksi ke Server MySQL Sub BukaDb() Set conn = New ADODB.Connection conn.connectionstring = "" _ & "DRIVER={MySQL ODBC 3.51 Driver};" _ & "SERVER=localhost;" _ & "DATABASE=proyek_ta;" _ & "UID=root;" _ & "PWD=;" _ & "OPTION=" ' Melewatkan apabila ada error On Error Resume Next ' Membuka Koneksi dengan melihat status If conn.state = adstateopen Then conn.close Set conn = New ADODB.Connection conn.open conn.open 'Periksa koneksi apakah sudah berhasil If Err.Number <> 0 Then MsgBox "Gagal Membuka database", vbokonly, "Kesalahan" End
24 MsgBox "Koneksi Databaes Berhasil", vbokonly, "PESAN" 'PenjualanDb'Sukses..!!", _ vbinformation, "Pesan"