Punya Account Blogger?
Posted by Sofyan SOX on Sabtu, 26 Juni 2010 in















'Koneksi Database

Private Sub Form_Load()
 Me.dbunga.DatabaseName = App.Path + "\Type_B.mdb"
 Me.djual.DatabaseName = App.Path + "\Type_B.mdb"
End Sub

'Membuat Prosedur

Sub kosong()
  Me.tid = ""
  Me.tnama = ""
  Me.tharga = ""
  Me.tjml = ""
  Me.op1.Value = False
  Me.op2.Value = False
  Me.tpot = ""
  Me.ttotal = ""
  Me.tbayar = ""
  Me.tkem = ""
End Sub

Sub mati()
  Me.tnota.Enabled = False
  Me.ttgl.Enabled = False
  Me.tid.Enabled = False
  Me.tnama.Enabled = False
  Me.tharga.Enabled = False
  Me.tjml.Enabled = False
  Me.op1.Enabled = False
  Me.op2.Enabled = False
  Me.tpot.Enabled = False
  Me.ttotal.Enabled = False
  Me.tbayar.Enabled = False
  Me.tkem.Enabled = False
End Sub

Sub hidup()
  Me.tid.Enabled = True
  Me.tjml.Enabled = True
  Me.op1.Enabled = True
  Me.op2.Enabled = True
  Me.tbayar.Enabled = True
End Sub

Sub simpan()
  With djual.Recordset
    !nota = Me.tnota.Text
    !tgl = Me.ttgl.Text
    !id = Me.tid.Text
    !nama = Me.tnama.Text
    !harga = Val(Me.tharga.Text)
    !jml = Val(Me.tjml.Text)
    !pot = Val(Me.tpot.Text)
    !total = Val(Me.ttotal.Text)
  End With
End Sub

Sub tombol(a, b, c, d As Boolean)
  Me.cadd.Enabled = a
  Me.csave.Enabled = b
  Me.ccancel.Enabled = c
  Me.cexit.Enabled = d
End Sub

Sub nomor()
  With Me.djual.Recordset
     bentuk = "FJ" & Format(Date, "YYMM")
     If .RecordCount > 0 Then
       .MoveLast
       Me.tnota.Text = bentuk & Right((Val(Right(!nota, 4)) + 10001), 4)
     Else
       Me.tnota.Text = bentuk & "0001"
     End If
  End With
End Sub

'Ketika Form Aktif

Private Sub Form_Activate()
  tombol 1, 0, 0, 1
  Call kosong
  Call mati
  Me.cadd.SetFocus
  Me.ttgl.Text = Date
End Sub

'ketika tombol add di klik

Private Sub cadd_Click()
  tombol 0, 1, 1, 0
  Call kosong
  Call hidup
  Call nomor
  Me.tid.SetFocus
End Sub



'Munculin Nama & harga bunga

Private Sub tid_KeyPress(KeyAscii As Integer)
On Error Resume Next
  If KeyAscii = 13 Then
    With Me.dbunga.Recordset
       .FindFirst "id='" + Me.tid.Text + "'"
       If .NoMatch = False Then
          Me.tnama.Text = !nama
          Me.tharga.Text = !harga
          Me.tjml.SetFocus
       Else
          MsgBox "ID bunga tidak ada", vbYesNo + vbInformation, , "Informasi"
          Me.tid = ""
          Me.tid.SetFocus
       End If
    End With
  End If
End Sub

Private Sub DBList2_Click()
    With Me.dbunga.Recordset
       .FindFirst "id='" + Me.DBList2.Text + "'"
       If .NoMatch = False Then
          Call hidup
          Me.tid.Text = !id
          Me.tnama.Text = !nama
          Me.tharga.Text = !harga
          Me.tjml.SetFocus
       Else
          MsgBox "ID bunga tidak ada", vbYesNo + vbInformation, , "Informasi"
       End If
    End With
End Sub

Private Sub DBList1_Click()
    With Me.dbunga.Recordset
       .FindFirst "nama='" + Me.DBList1.Text + "'"
       If .NoMatch = False Then
          Call hidup
          Me.tid.Text = !id
          Me.tnama.Text = !nama
          Me.tharga.Text = !harga
          Me.tjml.SetFocus
       Else
          MsgBox "ID bunga tidak ada", vbYesNo + vbInformation, , "Informasi"
       End If
    End With
End Sub

'Menghitung potongan & Subtotal

Private Sub op1_Click()
  Me.tpot.Text = 0.05 * (Val(Me.tharga.Text) * Val(Me.tjml.Text))
  Me.ttotal.Text = (Val(Me.tharga.Text) * Val(Me.tjml.Text)) - Val(Me.tpot.Text)
  Me.tbayar.SetFocus
End Sub

Private Sub op2_Click()
  Me.tpot.Text = 0
  Me.ttotal.Text = (Val(Me.tharga.Text) * Val(Me.tjml.Text))
  Me.tbayar.SetFocus
End Sub

'Menampilkan uang kembalian

Private Sub tbayar_KeyPress(KeyAscii As Integer)
  If KeyAscii = 13 Then
    Me.tkem.Text = Val(Me.tbayar.Text) - Val(Me.ttotal.Text)
    Me.csave.SetFocus
  End If
End Sub

'Proses Penyimpanan
Private Sub csave_Click()
  Me.djual.Recordset.AddNew
    Call simpan
  Me.djual.Recordset.Update
    MsgBox "Data Tersimpan", vbOKOnly + vbInformation, "Informasi"
    tombol 1, 0, 0, 1
    Call kosong
    Call mati
End Sub

'Membatalkan Penyimpanan

Private Sub ccancel_Click()
  Call kosong
  Call mati
  tombol 1, 0, 0, 1
  Me.cadd.SetFocus
End Sub

'Menutup Form

Private Sub cexit_Click()
  x = MsgBox("keluar ?", vbOKOnly + vbInformation, "Tutup Form")
  If x = vbYes Then Unload Me
End Sub



vbuasB -







0 Responses to “Review Uas Kelas B”:

Posting Komentar