Sei sulla pagina 1di 9

Dim dbtoko As Database

Dim rsuplayer As Recordset


Dim tombol As Boolean

Private Sub Command1_Click()


If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Then
MsgBox "Data Harus Lengkap", vbExclamation + vbOKOnly, "info"
Exit Sub
End If

If tombol = False Then


rsuplayer.AddNew
rsuplayer!id_sr = Text1.Text
rsuplayer!namas = Text2.Text
rsuplayer!alamat = Text3.Text
rsuplayer!notelp = Text4.Text

Else
rsuplayer.Edit
rsuplayer!id_sr = Text1.Text
rsuplayer!namas = Text2.Text
rsuplayer!alamat = Text3.Text
rsuplayer!notelp = Text4.Text
End If
rsuplayer.Update
tombol = False
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""

Text1.SetFocus
End Sub

Private Sub Command2_Click()


tombol = True
rsuplayer.Edit
rsuplayer!id_sr = Text1.Text
rsuplayer!namas = Text2.Text
rsuplayer!alamat = Text3.Text
rsuplayer!notelp = Text4.Text
End Sub

Private Sub Command3_Click()


pesan = MsgBox("Yakin Data ini dihapus?", vbExclamation + vbYesNo, "Hapus")
If pesan = vbYes Then
rsuplayer.Delete
rsuplayer.MoveNext
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text1.SetFocus
End If
End Sub

Private Sub Command4_Click()


Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""

End Sub

Private Sub Command5_Click()


DataGrid1.Refresh
Adodc1.Refresh
End Sub

Private Sub Command6_Click()


Unload Me
End Sub

Private Sub Form_Load()


Set dbjualbeli = OpenDatabase(App.Path & "\\dbjualbeli.mdb")
Set rsuplayer = dbjualbeli.OpenRecordset("suplayer")
rsuplayer.Index = "id_sr"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""

End Sub

Private Sub Text1_Change()


rsuplayer.Index = "id_sr"
rsuplayer.Seek "=", Text1.Text
If rsuplayer.NoMatch Then

Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Exit Sub
End If
Text1.Text = rsuplayer!id_sr
Text2.Text = rsuplayer!namas
Text3.Text = rsuplayer!alamat
Text4.Text = rsuplayer!notelp
End Sub
Dim dbtoko As Database
Dim rbarang As Recordset
Dim rkaryawan As Recordset
Dim rtran As Recordset
Dim tombol As Boolean
Dim A As String

Private Sub Combo1_Click()


rkaryawan.Index = "id"
rkaryawan.Seek "=", Combo1.Text
If rkaryawan.NoMatch Then
Text2.Text = ""
Exit Sub
End If
Text2.Text = rkaryawan!nama
End Sub
Private Sub Combo1_Change()
rkaryawan.Index = "id"
rkaryawan.Seek "=", Combo1.Text
If rkaryawan.NoMatch Then
Text2.Text = ""
Exit Sub
End If
Text2.Text = rkaryawan!nama
End Sub

Private Sub Combo2_Change()


rbarang.Index = "kode"
rbarang.Seek "=", Combo2.Text
If rbarang.NoMatch Then
Text3.Text = ""
Text5.Text = ""
Exit Sub
End If
Text3.Text = rbarang!nama
Text5.Text = rbarang!harga
Text8.Text = rbarang!stok
End Sub
Private Sub Combo2_Click()
rbarang.Index = "kode"
rbarang.Seek "=", Combo2.Text
If rbarang.NoMatch Then
Text3.Text = ""
Text5.Text = ""
Exit Sub
End If
Text3.Text = rbarang!nama
Text5.Text = rbarang!harga
Text8.Text = rbarang!stok
Text4.SetFocus
End Sub

Private Sub Command1_Click()


If Text1.Text = "" Or Text4.Text = "" Or Text6.Text = "" Or Text7.Text = "" Or
Combo1.Text = "" Or Combo2.Text = "" Then
MsgBox "Data Harus Lengkap!!", vbExclamation + vbOKOnly, "info"
Exit Sub
End If
If tombol = False Then
rtran.AddNew
rtran!kbb = Text1.Text
rtran!id_brg = Combo2.Text
rtran!id = Combo1.Text
rtran!qty = Text4.Text
rtran!totalbayar = Text6.Text
rtran!noorder = Text7.Text
rtran!tgl = A
rbarang.Edit
rbarang!stok = Val(Text8.Text) - Val(Text4.Text)
rbarang.Update

Else
rtran.Edit
rtran!kbb = Text1.Text
rtran!id_brg = Combo2.Text
rtran!id = Combo1.Text
rtran!qty = Text4.Text
rtran!totalbayar = Text6.Text
rtran!noorder = Text7.Text
rtran!tgl = A

End If
rtran.Update
tombol = False
Text1.Text = Val(Text1.Text) + 1
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text8.Text = ""
Combo2.Text = ""
rkaryawan.Index = "id"
rkaryawan.Seek "=", Combo1.Text
If rkaryawan.NoMatch Then
Text2.Text = ""
Exit Sub
End If
Text2.Text = rkaryawan!nama
End Sub

Private Sub Command2_Click()


If Text1.Text = "" Or Text4.Text = "" Or Text6.Text = "" Or Text7.Text = "" Or
Combo1.Text = "" Or Combo2.Text = "" Then
MsgBox "Data Harus Lengkap!!", vbExclamation + vbOKOnly, "info"
Exit Sub
End If
If tombol = False Then
rtran.AddNew
rtran!kbb = Text1.Text
rtran!id_brg = Combo2.Text
rtran!id = Combo1.Text
rtran!qty = Text4.Text
rtran!totalbayar = Text6.Text
rtran!noorder = Text7.Text
rtran!tgl = A
rbarang.Edit
rbarang!stok = Val(Text8.Text) - Val(Text4.Text)
rbarang.Update

Else
rtran.Edit
rtran!kbb = Text1.Text
rtran!id_brg = Combo2.Text
rtran!id = Combo1.Text
rtran!qty = Text4.Text
rtran!totalbayar = Text6.Text
rtran!noorder = Text7.Text
rtran!tgl = A

End If
rtran.Update
tombol = False
Text1.Text = Val(Text1.Text) + 1
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = Val(Text7.Text) + 1
Combo2.Text = ""
Text8.Text = ""
rkaryawan.Index = "id"
rkaryawan.Seek "=", Combo1.Text
If rkaryawan.NoMatch Then
Text2.Text = ""
Exit Sub
End If
Text2.Text = rkaryawan!nama
End Sub

Private Sub Command3_Click()

rtran.Index = "tran"
rtran.MoveLast
Text1.Text = rtran!kbb
Text7.Text = rtran!noorder
Text1.Text = Val(Text1.Text) + 1
Text7.Text = Val(Text7.Text) + 1
rtran.MoveFirst
rkaryawan.Index = "id"
rkaryawan.MoveFirst
Combo1.Text = rkaryawan!id
Text2.Text = rkaryawan!nama
Text8.Text = ""
Text4.Text = ""
Text5.Text = ""
End Sub

Private Sub Command4_Click()


tombol = True
rtran.Edit
rtran!kbb = Text1.Text
rtran!id_brg = Combo2.Text
rtran!id = Combo1.Text
rtran!qty = Text4.Text
rtran!totalbayar = Text6.Text
rtran!noorder = Text7.Text
rtran!tgl = A
End Sub

Private Sub Command5_Click()


pesan = MsgBox("Yakin Data ini dihapus?", vbExclamation + vbYesNo, "Hapus")
If pesan = vbYes Then
rtran.Delete
rtran.MoveNext
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Combo1.Text = ""
Combo2.Text = ""
Text1.SetFocus
End If
End Sub

Private Sub Command6_Click()


Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Combo1.Text = ""
Combo2.Text = ""
End Sub
Private Sub Command7_Click()
DataGrid1.Refresh
Adodc1.Refresh
Adodc2.Refresh
Adodc3.Refresh
End Sub

Private Sub Command8_Click()


Unload Me
End Sub

Private Sub Form_Load()

DTPicker1.Value = Date
A = DTPicker1.Value

Set dbtoko = OpenDatabase(App.Path & "\\dbjualbeli.mdb")


Set rbarang = dbtoko.OpenRecordset("barang")
Set rkaryawan = dbtoko.OpenRecordset("karyawan")
Set rtran = dbtoko.OpenRecordset("transaksi")
rtran.Index = "tran"
tampilkasir
tampilbarang
End Sub
Sub tampilkasir()
If Not rkaryawan.BOF Then
rkaryawan.MoveFirst
End If
If Not rkaryawan.EOF Then rkaryawan.MoveFirst
Do While Not rkaryawan.EOF
Combo1.AddItem rkaryawan!id
rkaryawan.MoveNext
Loop
End Sub
Sub tampilbarang()
If Not rbarang.BOF Then
rbarang.MoveFirst
End If
If Not rbarang.EOF Then rbarang.MoveFirst
Do While Not rbarang.EOF
Combo2.AddItem rbarang!id_brg

rbarang.MoveNext
Loop
End Sub
Private Sub Text1_Change()
rtran.Index = "tran"
rtran.Seek "=", Text1.Text
If rtran.NoMatch Then

Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""

Combo2.Text = ""

Exit Sub
End If
Combo1.Text = rtran!id
Combo2.Text = rtran!id_brg
Text4.Text = rtran!qty
Text6.Text = rtran!totalbayar
Text7.Text = rtran!noorder
End Sub

Private Sub Text4_Change()


If Val(Text8.Text) < Val(Text4.Text) Then
Text4.Text = Text8.Text
End If

If Text4.Text = "" Then


Text4.Text = ""
Text6.Text = ""
Else
Text6.Text = Val(Text5.Text * Text4.Text)
End If

End Sub

Potrebbero piacerti anche