Pr
ogra
m P
embe
lian
dan
Penj
uala
n Ba
rang
2
2010
Kel
ompo
k 3
Visu
al B
asic
Nurul Hasanah Okta Maulida Ocsa Cadayani Paulus Ari heryono Ricky Afrian Riyatno Shera Heni Pertiwi Siti Marhammah Syahrul Reza Tri Puji Atmaja
STMIK Pringsewu 2010
Jl. Wisma Rini No. 09 (0729) 22240
Visual Basic 2 Page 2
KELOMPOK 3 VISUAL BASIC
Private Sub mnBarang_Click()
Frm_Barang.Show
End Sub
Private Sub mnBayar_Click()
Frm_Bayar.Show
End Sub
Private Sub mnDafBarang_Click()
DR_Barang.Show
End Sub
Private Sub mnDafBeli_Click()
DR_Pembelian.Show
End Sub
Visual Basic 2 Page 3
Private Sub mnDafSuppliers_Click()
DR_Suppliers.Show
End Sub
Private Sub mnDBeli_Click()
Frm_DBeli.Show
End Sub
Private Sub mnFakBeli_Click()
Frm_FakBeli.Show
End Sub
Private Sub mnKeluar_Click()
Unload Me
End Sub
Private Sub mnRekapBeli_Click()
Frm_RekapBeli.Show
End Sub
Private Sub mnSuppliers_Click()
Frm_Suppliers.Show
End Sub
Visual Basic 2 Page 4
Private Sub Ado_Barang_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
'menampilkan nomor record aktif
'menampilkan jumlah record keseluruhan
Ado_Barang.Caption = "Record:" & CStr(Ado_Barang.Recordset.AbsolutePosition) & "/" & Ado_Barang.Recordset.RecordCount
End Sub
Private Sub Cmd_Hapus_Click()
Dim Hapus As Byte
Hapus = MsgBox("Anda Yakin Data Akan Dihapus?", vbSystemModal + vbYesNo + vbQuestion, "Menghapus Data")
If Hapus = vbYes Then
Ado_Barang.Recordset.Delete
Ado_Barang.Recordset.MoveFirst
Else
Visual Basic 2 Page 5
MsgBox "Data Tidak Jadi Dihapus!", vbSystemModal, "Batal Menghapus Data"
Exit Sub
End If
End Sub
Private Sub Cmd_Keluar_Click()
Unload Me
End Sub
Private Sub Opt_Kode_Click()
Ado_Barang.RecordSource = "Select Barang.Kd_Brg, Barang.Nama_Brg, Barang.Harga From Barang Order by Barang.Kd_Brg"
Ado_Barang.Refresh
End Sub
Private Sub Opt_Nama_Click()
Ado_Barang.RecordSource = "Select Barang.Kd_Brg, Barang.Nama_Brg, Barang.Harga From Barang Order by Barang.Nama_Brg"
End Sub
Visual Basic 2 Page 6
Private Sub Ado_Suppliers_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
'menampilkan nomor record aktif dan
'menampilkan jumlah record keseluruhan
Ado_Suppliers.Caption = "Record:" & CStr(Ado_Suppliers.Recordset.AbsolutePosition) & "/" & Ado_Suppliers.Recordset.RecordCount
End Sub
Private Sub Cmd_Hapus_Click()
Dim Hapus As Byte
Hapus = MsgBox("Anda Yakin Data Akan Dihapus?", vbSystemModal + vbYesNo + vbQuestion, "Menghapus Data")
If Hapus = vbYes Then
Ado_Suppliers.Recordset.Delete
Ado_Suppliers.Recordset.MoveFirst
Else
MsgBox "Data Tidak Jadi Dihapus!", vbSystemModal, "Batal Menghapus Data"
Exit Sub
Visual Basic 2 Page 7
End If
End Sub
Private Sub Cmd_Keluar_Click()
Unload Me
End Sub
Private Sub Opt_Kode_Click()
'mengurutkan data by kode suppliers
Ado_Suppliers.RecordSource = "Select Suppliers.Kd_Spl, Suppliers.Nama_Spl, Suppliers.Alamat_Spl, Suppliers.Telepon From Suppliers Order by Suppliers.Kd_Spl"
Ado_Suppliers.Refresh
End Sub
Private Sub Opt_Nama_Click()
'mengurutkan data by nama suppliers
Ado_Suppliers.RecordSource = "Select Suppliers.Kd_Spl, Suppliers.Nama_Spl, Suppliers.Alamat_Spl, Suppliers.Telepon From Suppliers Order by Suppliers.Nama_Spl"
Ado_Suppliers.Refresh
End Sub
Visual Basic 2 Page 8
Private Sub Form_Load()
Set grdDataGrid.DataSource = datPrimaryRS.Recordset("ChildCMD").UnderlyingValue
End Sub
Private Sub Form_Resize()
On Error Resume Next
'This will resize the grid when the form is resized
grdDataGrid.Width = Me.ScaleWidth
grdDataGrid.Height = Me.ScaleHeight - grdDataGrid.Top - datPrimaryRS.Height - 30 - picButtons.Height
End Sub
Private Sub Form_Unload(Cancel As Integer)
Screen.MousePointer = vbDefault
End Sub
Visual Basic 2 Page 9
Private Sub datPrimaryRS_Error(ByVal ErrorNumber As Long, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, fCancelDisplay As Boolean)
'This is where you would put error handling code
'If you want to ignore errors, comment out the next line
'If you want to trap them, add code here to handle them
MsgBox "Data error event hit err:" & Description
End Sub
Private Sub datPrimaryRS_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
'This will display the current record position for this recordset
datPrimaryRS.Caption = "Record: " & CStr(datPrimaryRS.Recordset.AbsolutePosition)
End Sub
Private Sub datPrimaryRS_WillChangeRecord(ByVal adReason As ADODB.EventReasonEnum, ByVal cRecords As Long, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
'This is where you put validation code
'This event gets called when the following actions occur
Dim bCancel As Boolean
Select Case adReason
Case adRsnAddNew
Case adRsnClose
Case adRsnDelete
Case adRsnFirstChange
Case adRsnMove
Case adRsnRequery
Visual Basic 2 Page 10
Case adRsnResynch
Case adRsnUndoAddNew
Case adRsnUndoDelete
Case adRsnUndoUpdate
Case adRsnUpdate
End Select
If bCancel Then adStatus = adStatusCancel
End Sub
Private Sub cmdAdd_Click()
On Error GoTo AddErr
datPrimaryRS.Recordset.AddNew
Exit Sub
AddErr:
MsgBox Err.Description
End Sub
Private Sub cmdDelete_Click()
On Error GoTo DeleteErr
With datPrimaryRS.Recordset
.Delete
.MoveNext
If .EOF Then .MoveLast
End With
Exit Sub
Visual Basic 2 Page 11
DeleteErr:
MsgBox Err.Description
End Sub
Private Sub cmdRefresh_Click()
'This is only needed for multi user apps
On Error GoTo RefreshErr
datPrimaryRS.Refresh
Set grdDataGrid.DataSource = datPrimaryRS.Recordset("ChildCMD").UnderlyingValue
Exit Sub
RefreshErr:
MsgBox Err.Description
End Sub
Private Sub cmdUpdate_Click()
On Error GoTo UpdateErr
datPrimaryRS.Recordset.UpdateBatch adAffectAll
Exit Sub
UpdateErr:
MsgBox Err.Description
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Visual Basic 2 Page 12
Private Sub Form_Load()
Set grdDataGrid.DataSource = datPrimaryRS.Recordset("ChildCMD").UnderlyingValue
End Sub
Private Sub Form_Resize()
On Error Resume Next
'This will resize the grid when the form is resized
grdDataGrid.Width = Me.ScaleWidth
grdDataGrid.Height = Me.ScaleHeight - grdDataGrid.Top - datPrimaryRS.Height - 30 - picButtons.Height
End Sub
Private Sub Form_Unload(Cancel As Integer)
Screen.MousePointer = vbDefault
End Sub
Private Sub datPrimaryRS_Error(ByVal ErrorNumber As Long, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, fCancelDisplay As Boolean)
Visual Basic 2 Page 13
'This is where you would put error handling code
'If you want to ignore errors, comment out the next line
'If you want to trap them, add code here to handle them
MsgBox "Data error event hit err:" & Description
End Sub
Private Sub datPrimaryRS_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
'This will display the current record position for this recordset
datPrimaryRS.Caption = "Record: " & CStr(datPrimaryRS.Recordset.AbsolutePosition)
End Sub
Private Sub datPrimaryRS_WillChangeRecord(ByVal adReason As ADODB.EventReasonEnum, ByVal cRecords As Long, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
'This is where you put validation code
'This event gets called when the following actions occur
Dim bCancel As Boolean
Select Case adReason
Case adRsnAddNew
Case adRsnClose
Case adRsnDelete
Case adRsnFirstChange
Case adRsnMove
Case adRsnRequery
Case adRsnResynch
Case adRsnUndoAddNew
Case adRsnUndoDelete
Visual Basic 2 Page 14
Case adRsnUndoUpdate
Case adRsnUpdate
End Select
If bCancel Then adStatus = adStatusCancel
End Sub
Private Sub cmdAdd_Click()
On Error GoTo AddErr
datPrimaryRS.Recordset.AddNew
Exit Sub
AddErr:
MsgBox Err.Description
End Sub
Private Sub cmdDelete_Click()
On Error GoTo DeleteErr
With datPrimaryRS.Recordset
.Delete
.MoveNext
If .EOF Then .MoveLast
End With
Exit Sub
DeleteErr:
MsgBox Err.Description
End Sub
Visual Basic 2 Page 15
Private Sub cmdRefresh_Click()
'This is only needed for multi user apps
On Error GoTo RefreshErr
datPrimaryRS.Refresh
Set grdDataGrid.DataSource = datPrimaryRS.Recordset("ChildCMD").UnderlyingValue
Exit Sub
RefreshErr:
MsgBox Err.Description
End Sub
Private Sub cmdUpdate_Click()
On Error GoTo UpdateErr
datPrimaryRS.Recordset.UpdateBatch adAffectAll
Exit Sub
UpdateErr:
MsgBox Err.Description
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Top Related