• Tidak ada hasil yang ditemukan

Kemungkinan Pengembangan

Dalam dokumen APLIKASI PERKREDITAN FURNITURE (Halaman 53-111)

BAB VI KESIMPULAN DAN SARAN

6.3 Kemungkinan Pengembangan

Kemungkinan untuk mengembangkan aplikasi ini sangat besar. Contohnya, untuk metode pembayaran bisa ditambah menjadi menggunakan kartu kredit atau semacamnya. Kemudian dalam hal laporan, laporan tidak harus selalu dalam format kertas berukuran Legal, tetapi bisa juga dengan ukuran seperti struk belanja.

DAFTAR PUSTAKA

Jayan. (2006). Mudah dan Cepat Belajar VB. Palembang: Penerbit Maxikom.

VB Source Code. (2002, 15 Maret). Diakses 15 Juni, 2008, dari Planet Source Code: planet-source-code.com

LAMPIRAN-LAMPIRAN

Script

‘Form Pembayaran

Private Sub Command5_Click() With DataPmbayaran.Recordset .AddNew .Fields(0) = Text1.Text .Fields(1) = Combo1.Text .Fields(2) = lbltgl.Caption .Fields(3) = Text2.Text .Fields(4) = Label6.Caption .Update End With

MsgBox "Data berhasil disimpan", vbInformation, "Sukses!" End Sub

Private Sub Command6_Click() rptPembayaran.Show

End Sub

Private Sub Form_Load() With Me.DataPmbayaran

.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0;Data Source = " & App.Path & "\dbFBay.mdb"

.CommandType = adCmdText

.RecordSource = "Select * from pembayaran" .Refresh

End With

With Me.DataJual

.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0;Data Source = " & App.Path & "\dbFBay.mdb"

.CommandType = adCmdText

.RecordSource = "Select * from penjualan" .Refresh

End With

DataJual.RecordSource = "Select * from penjualan" If (DataJual.Recordset.RecordCount > 0) Then Do While Not DataJual.Recordset.EOF

Combo1.AddItem DataJual.Recordset!id_jual DataJual.Recordset.MoveNext

Loop End If Call AutoID

lbltgl.Caption = Format(Now, "dd/mm/yy hh:mm") Label6.Caption = frmUtama.sB1.Panels(2).Text End Sub

Private Function AutoID() With Me.DataPmbayaran

.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0;Data Source = " & App.Path & "\dbFBay.mdb"

.CommandType = adCmdText

.RecordSource = "Select * from pembayaran order by id_bayar DESC" .Refresh

End With

If DataPmbayaran.Recordset.RecordCount = 0 Then Text1.Text = "PY0000"

Else

Dim dataY As String

dataY = DataPmbayaran.Recordset.Fields(0)

Text1.Text = "PY" & Format(Right(dataY, 4) + 1, "0000") End If

End Function ‘Form Pembelian Dim tot As Double

Private Function AutoID() With Me.DataPmbelian

.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0;Data Source = " & App.Path & "\dbFBay.mdb"

.CommandType = adCmdText

.RecordSource = "Select * from pembelian order by id_beli DESC" .Refresh

End With

If DataPmbelian.Recordset.RecordCount = 0 Then Text1.Text = "PI0000"

Else

Dim dataY As String

dataY = DataPmbelian.Recordset.Fields(0)

Text1.Text = "PI" & Format(Right(dataY, 4) + 1, "0000") End If

DataPmbelian.Recordset.Close End Function

Private Sub Command1_Click() frmSupplier.Show

frmSupplier.Command4.SetFocus End Sub

Private Sub Command2_Click() frmBarang.Show

End Sub

Private Sub Command3_Click() Text1.Text = "" Combo1.Text = "" Combo2.Text = "" Text2.Text = "" Text3.Text = "" Label8.Caption = "" Call AutoID End Sub

Private Sub Command5_Click() With DataPmbelian.Recordset .Open .AddNew .Fields(0) = Text1.Text .Fields(1) = Combo1.Text .Fields(2) = Combo2.Text .Fields(3) = lbltgl.Caption .Fields(4) = Text2.Text .Fields(5) = Text3.Text .Fields(6) = tot .Update .Close End With

MsgBox "Data berhasil disimpan", vbInformation, "Sukses!" End Sub

Private Sub Command6_Click() rptPembelian.Show

End Sub

Private Sub Form_Click() Combo1.Clear

DataSupp.RecordSource = "Select id_supplier from supplier" DataSupp.Recordset.MoveFirst

DataSupp.Refresh

If (DataSupp.Recordset.RecordCount > 0) Then Do While Not DataSupp.Recordset.EOF

Combo1.AddItem DataSupp.Recordset.Fields(0) DataSupp.Recordset.MoveNext

Loop End If

Combo2.Clear

DataBrg.RecordSource = "Select id_barang from barang" DataBrg.Recordset.MoveFirst

DataBrg.Refresh

If (DataBrg.Recordset.RecordCount > 0) Then Do While Not DataBrg.Recordset.EOF

Combo2.AddItem DataBrg.Recordset.Fields(0) DataBrg.Recordset.MoveNext

Loop End If End Sub

Private Sub Form_Load() With Me.DataBrg

.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0;Data Source = " & App.Path & "\dbFBay.mdb"

.CommandType = adCmdText

.RecordSource = "Select * from barang" .Refresh

End With

With Me.DataSupp

.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0;Data Source = " & App.Path & "\dbFBay.mdb"

.CommandType = adCmdText

.RecordSource = "Select * from Supplier" .Refresh

End With

With Me.DataPmbelian

.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0;Data Source = " & App.Path & "\dbFBay.mdb"

.CommandType = adCmdText

.RecordSource = "Select * from Pembelian" .Refresh

End With

DataBrg.RecordSource = "Select * from barang" If (DataBrg.Recordset.RecordCount > 0) Then Do While Not DataBrg.Recordset.EOF

DataBrg.Recordset.MoveNext Loop

End If

DataSupp.RecordSource = "Select * from Supplier" If (DataSupp.Recordset.RecordCount > 0) Then Do While Not DataSupp.Recordset.EOF

Combo1.AddItem DataSupp.Recordset!id_supplier DataSupp.Recordset.MoveNext Loop End If Call AutoID Command5.Enabled = False

lbltgl.Caption = Format(Now, "dd/mm/yy hh:mm") End Sub

Private Sub Text3_Change()

Label8.Caption = Format(Val(Text2.Text) * Val(Text3.Text), "currency") If Label8.Caption = "" Then

Command5.Enabled = False Else

Command5.Enabled = True End If

tot = Val(Text2.Text) * Val(Text3.Text) End Sub

‘Form Penjualan

Dim strUserChoice As String Dim curPayment As Currency

Dim dblRate As Double, dblNper As Double, dblPv As Double, dblFv As Double, dblPer As Double

Dim dblIpay As Double, dblItotal As Double, dblIarray() As Double Dim dblPpay As Double, dblPtotal As Double, dblParray() As Double Dim dblPeriodComplete As Double 'period at which loan is paid in full Dim bolPaidOff As Boolean

Dim dblAdditionalPrinciple As Double Private Sub Kosong()

Combo2.Text = "" Label11.Caption = "" Option1.Value = False Option2.Value = False Combo4.ListIndex = 0 Text5.Text = "" Text6.Text = "" Text7.Text = "" Label16.Caption = ""

End Sub

Private Sub Combo2_Click() DataBrg.Recordset.Open

DataBrg.RecordSource = "select*from barang where id_barang like '%" & Combo2.Text & "%'"

DataBrg.Refresh

Label11.Caption = DataBrg.Recordset.Fields(9) DataBrg.Recordset.Close

End Sub

Private Sub Combo2_LostFocus() Combo2.Text = UCase(Combo2.Text) Combo2_Click

End Sub

Private Sub Command1_Click() frmCustomer.Show

End Sub

Private Sub Command3_Click() Combo1.Text = "" Call Kosong Call AutoID Command2.Enabled = False Command3.Enabled = False End Sub

Private Sub Command2_Click() Call Kosong

Command2.Enabled = False Command3.Enabled = False Combo1.SetFocus

End Sub

Private Sub Command5_Click() With DataPnjualan.Recordset .Open .AddNew .Fields(0) = Text1.Text .Fields(1) = Combo1.Text .Fields(2) = Combo2.Text .Fields(3) = lbltgl.Caption If Option1.Value = True Then .Fields(4) = "C"

Else

.Fields(4) = "R" End If

.Fields(5) = Label11.Caption If Option1.Value = True Then .Fields(6) = 0 .Fields(7) = 0 .Fields(8) = 0 .Fields(9) = "-" Else .Fields(6) = Text5.Text .Fields(7) = Text6.Text .Fields(8) = Text7.Text

If Combo4.Text = "Mingguan" Then .Fields(9) = "M"

ElseIf Combo4.Text = "Bulanan" Then .Fields(9) = "B" Else .Fields(9) = "T" End If End If .Fields(10) = Val(Label16.Caption) .Update .Close End With With DataBrg.Recordset .Open .Update .Fields(7) = Val(.Fields(7)) - 1 .Update .Close End With

MsgBox "Data berhasil disimpan", vbInformation, "Sukses!" Command2.Enabled = True

Command3.Enabled = True End Sub

Private Sub Command6_Click() rptPenjualan.Show

End Sub

Private Sub Command7_Click() If Option2.Value = True Then

If Text5.Text = "" Or Text6.Text = "" Or Text7.Text = "" Or Combo4.Text = "" Then

MsgBox "Data harus diisi semua", vbCritical, "Error" Option2.Value = False

Option1.SetFocus Else

'assign private datamembers

strUserChoice = Combo4.Text 'payment period (monthly, yearly, quarterly, etc.)

dblPv = Val(Label11.Caption) 'total loan

dblPv = dblPv - Val(Text5.Text) 'total loan minus downpayment dblFv = 0& 'future value of loan = $0.00

dblItotal = 0&: dblPtotal = 0& 'set total interest/principle paid to zero bolPaidOff = False

dblPeriodComplete = 0

'calculate total number of payment periods and assign appropriate Rate If strUserChoice = "Mingguan" Then

dblNper = Val(Text7.Text) * 52&

dblRate = (Val(Text6.Text) / 100&) / 52& End If

If strUserChoice = "Bulanan" Then dblNper = Val(Text7.Text) * 12&

dblRate = (Val(Text6.Text) / 100&) / 12& End If

If strUserChoice = "Tahunan" Then dblNper = Val(Text7.Text)

dblRate = (Val(Text6.Text) / 100&) End If

'calculate payment

curPayment = Pmt(dblRate, dblNper, -dblPv, dblFv, 0)

'Pmt is a VB function which returns the fixed payment for a loan

'based upon the rate(dblRate), number of periods(dblNper), amount of the loan(dblPv),

'future value of loan=0(dblFv), and type(0 indicates payment due at end of period) 'show appropriate term in label

If Combo4.Text = "Mingguan" Then Label15.Caption = "Biaya per minggu: " ElseIf Combo4.Text = "Bulanan" Then Label15.Caption = "Biaya per bulan: " ElseIf Combo4.Text = "Tahunan" Then Label15.Caption = "Biaya per tahun: "

Else

MsgBox ("Data harus di isi semuanya!!!"), vbCritical, "Ulangi Kembali" End If

Label16.Caption = curPayment

'Create array to contain Periodic interest due

ReDim dblIarray(dblNper - 1, 2) 'to contain the current period, current interest, total interest payment

ReDim dblParray(dblNper - 1, 2) 'to contain current period, current principal payment, total principle payment

dblPeriodComplete = dblNper 'set equal to number of periods calculated above For dblPer = 1 To dblNper

dblPpay = PPmt(dblRate, dblPer, dblNper, -dblPv, dblFv, 0) dblPtotal = dblPtotal + dblPpay + dblAdditionalPrinciple If dblPtotal > dblPv Then 'if loan paid off

If bolPaidOff = False Then

dblPeriodComplete = dblPer 'remember period when loan paid off End If

dblParray(dblPer - 1, 0) = dblPer dblParray(dblPer - 1, 1) = 0 If bolPaidOff = False Then

dblParray(dblPer - 1, 1) = dblPv - dblParray(dblPer - 2, 2) End If dblParray(dblPer - 1, 2) = dblPv bolPaidOff = True Else dblParray(dblPer - 1, 0) = dblPer dblParray(dblPer - 1, 1) = dblPpay dblParray(dblPer - 1, 2) = dblPtotal End If Next dblPer

For dblPer = 1 To dblNper

dblIpay = IPmt(dblRate, dblPer, dblNper, -dblPv, dblFv, 0) dblItotal = dblItotal + dblIpay

If dblPer > dblPeriodComplete Then dblItotal = dblItotal - dblIpay dblIarray(dblPer - 1, 0) = dblPer dblIarray(dblPer - 1, 1) = 0 dblIarray(dblPer - 1, 2) = dblItotal

Else dblIarray(dblPer - 1, 0) = dblPer dblIarray(dblPer - 1, 1) = dblIpay dblIarray(dblPer - 1, 2) = dblItotal End If Next dblPer 'Label25.Caption = _

' Format$((dblItotal + (Val(Labelharga.Caption)) - Val(Text10.Text)), "currency") 'Command4.Enabled = True End If Else Label16.Caption = Label11.Caption End If 'Command6.Enabled = True End Sub

Private Sub Form_Click() Combo1.Clear

DataCust.RecordSource = "Select id_customer from Customer" DataCust.Recordset.MoveFirst

DataCust.Refresh

If (DataCust.Recordset.RecordCount > 0) Then Do While Not DataCust.Recordset.EOF

Combo1.AddItem DataCust.Recordset!id_Customer DataCust.Recordset.MoveNext

Loop End If End Sub

Private Sub Form_Load() With Me.DataCust

.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0;Data Source = " & App.Path & "\dbFBay.mdb"

.CommandType = adCmdText

.RecordSource = "Select * from customer" .Refresh

End With

With Me.DataBrg

.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0;Data Source = " & App.Path & "\dbFBay.mdb"

.CommandType = adCmdText

.Refresh End With

DataCust.RecordSource = "Select id_customer from Customer" If (DataCust.Recordset.RecordCount > 0) Then

Do While Not DataCust.Recordset.EOF

Combo1.AddItem DataCust.Recordset!id_Customer DataCust.Recordset.MoveNext

Loop End If

'Set DataCust.Recordset = Nothing

DataBrg.RecordSource = "Select * from barang" If (DataBrg.Recordset.RecordCount > 0) Then Do While Not DataBrg.Recordset.EOF

Combo2.AddItem DataBrg.Recordset!id_barang DataBrg.Recordset.MoveNext Loop End If DataBrg.Recordset.Close Combo4.AddItem "Mingguan" Combo4.AddItem "Bulanan" Combo4.AddItem "Tahunan"

lbltgl.Caption = Format(Now, "dd/mm/yyyy") Call AutoID

Command2.Enabled = False Command3.Enabled = False End Sub

Private Function AutoID() With Me.DataPnjualan

.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0;Data Source = " & App.Path & "\dbFBay.mdb"

.CommandType = adCmdText

.RecordSource = "Select * from penjualan order by id_jual DESC" .Refresh

End With

If DataPnjualan.Recordset.RecordCount = 0 Then Text1.Text = "PO0000"

Else

Dim dataY As String

dataY = DataPnjualan.Recordset.Fields(0)

Text1.Text = "PO" & Format(Right(dataY, 4) + 1, "0000") End If

DataPnjualan.Recordset.Close End Function

Private Sub Option1_Click() Text5.Enabled = False Text6.Enabled = False Text7.Enabled = False Combo4.Enabled = False Text5.BackColor = &H8000000F Text6.BackColor = &H8000000F Text7.BackColor = &H8000000F Combo4.BackColor = &H8000000F End Sub

Private Sub Option2_Click() Text5.Enabled = True Text6.Enabled = True Text7.Enabled = True Combo4.Enabled = True Text5.BackColor = vbWhite Text6.BackColor = vbWhite Text7.BackColor = vbWhite Combo4.BackColor = vbWhite End Sub

Private Sub Text5_LostFocus()

If Val(Text5.Text) > Val(Label11.Caption) Then

MsgBox "Uang muka tidak bisa lebih besar daripada harga pokok!", vbCritical, App.Title Text5.Text = "" Text5.SetFocus End If End Sub ‘Form About Option Explicit

' Reg Key Security Options...

Const READ_CONTROL = &H20000 Const KEY_QUERY_VALUE = &H1 Const KEY_SET_VALUE = &H2

Const KEY_CREATE_SUB_KEY = &H4 Const KEY_ENUMERATE_SUB_KEYS = &H8 Const KEY_NOTIFY = &H10

Const KEY_CREATE_LINK = &H20

Const KEY_ALL_ACCESS = KEY_QUERY_VALUE + KEY_SET_VALUE + _

KEY_CREATE_SUB_KEY + KEY_ENUMERATE_SUB_KEYS + _

KEY_NOTIFY + KEY_CREATE_LINK + READ_CONTROL

' Reg Key ROOT Types...

Const HKEY_LOCAL_MACHINE = &H80000002 Const ERROR_SUCCESS = 0

Const REG_SZ = 1 ' Unicode nul terminated string Const REG_DWORD = 4 ' 32-bit number

Const gREGKEYSYSINFOLOC = "SOFTWARE\Microsoft\Shared Tools Location"

Const gREGVALSYSINFOLOC = "MSINFO"

Const gREGKEYSYSINFO = "SOFTWARE\Microsoft\Shared Tools\MSINFO" Const gREGVALSYSINFO = "PATH"

Private Declare Function RegOpenKeyEx Lib "advapi32" Alias

"RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, ByRef phkResult As Long) As Long

Private Declare Function RegQueryValueEx Lib "advapi32" Alias

"RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, ByRef lpType As Long, ByVal lpData As String, ByRef lpcbData As Long) As Long

Private Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As Long

Private Sub cmdSysInfo_Click() Call StartSysInfo

End Sub

Private Sub cmdOK_Click() Unload Me

End Sub

Private Sub Form_Load()

Me.Caption = "About " & App.Title

lblVersion.Caption = "Version " & App.Major & "." & App.Minor & "." & App.Revision

lblTitle.Caption = App.Title lblDescription = App.Comments End Sub

Public Sub StartSysInfo() On Error GoTo SysInfoErr

Dim rc As Long

Dim SysInfoPath As String

' Try To Get System Info Program Path\Name From Registry... If GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFO, gREGVALSYSINFO, SysInfoPath) Then

' Try To Get System Info Program Path Only From Registry...

ElseIf GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFOLOC, gREGVALSYSINFOLOC, SysInfoPath) Then

' Validate Existance Of Known 32 Bit File Version If (Dir(SysInfoPath & "\MSINFO32.EXE") <> "") Then SysInfoPath = SysInfoPath & "\MSINFO32.EXE"

' Error - File Can Not Be Found... Else

GoTo SysInfoErr End If

' Error - Registry Entry Can Not Be Found... Else

GoTo SysInfoErr End If

Call Shell(SysInfoPath, vbNormalFocus)

Exit Sub SysInfoErr:

MsgBox "System Information Is Unavailable At This Time", vbOKOnly End Sub

Public Function GetKeyValue(KeyRoot As Long, KeyName As String, SubKeyRef As String, ByRef KeyVal As String) As Boolean

Dim i As Long ' Loop Counter Dim rc As Long ' Return Code

Dim hKey As Long ' Handle To An Open Registry Key Dim hDepth As Long '

Dim KeyValType As Long ' Data Type Of A Registry Key Dim tmpVal As String ' Tempory Storage For A Registry Key Value

Dim KeyValSize As Long ' Size Of Registry Key Variable '---

' Open RegKey Under KeyRoot {HKEY_LOCAL_MACHINE...} '---

rc = RegOpenKeyEx(KeyRoot, KeyName, 0, KEY_ALL_ACCESS, hKey) ' Open Registry Key

If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError ' Handle Error...

tmpVal = String$(1024, 0) ' Allocate Variable Space KeyValSize = 1024 ' Mark Variable Size

'--- ' Retrieve Registry Key Value...

'--- rc = RegQueryValueEx(hKey, SubKeyRef, 0, _

KeyValType, tmpVal, KeyValSize) ' Get/Create Key Value

If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError ' Handle Errors

If (Asc(Mid(tmpVal, KeyValSize, 1)) = 0) Then ' Win95 Adds Null Terminated String...

tmpVal = Left(tmpVal, KeyValSize - 1) ' Null Found, Extract From String

Else ' WinNT Does NOT Null Terminate String...

tmpVal = Left(tmpVal, KeyValSize) ' Null Not Found, Extract String Only

End If

'--- ' Determine Key Value Type For Conversion... '---

Select Case KeyValType ' Search Data Types... Case REG_SZ ' String Registry Key Data Type KeyVal = tmpVal ' Copy String Value

Case REG_DWORD ' Double Word Registry Key Data Type

For i = Len(tmpVal) To 1 Step -1 ' Convert Each Bit

KeyVal = KeyVal + Hex(Asc(Mid(tmpVal, i, 1))) ' Build Value Char. By Char.

Next

KeyVal = Format$("&h" + KeyVal) ' Convert Double Word To String

End Select

GetKeyValue = True ' Return Success rc = RegCloseKey(hKey) ' Close Registry Key Exit Function ' Exit

GetKeyError: ' Cleanup After An Error Has Occured...

KeyVal = "" ' Set Return Val To Empty String GetKeyValue = False ' Return Failure

rc = RegCloseKey(hKey) ' Close Registry Key End Function

‘Form Data Barang

Private Sub Command1_Click()

If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or _ Text4.Text = "" Or Text5.Text = "" Or Text6.Text = "" Or _ Text7.Text = "" Or Combo2.Text = "" Or Combo1.Text = "" Then MsgBox "Data harus diisi semua", vbApplicationModal, "Error!" Text1.SetFocus

End If

With DataBarang.Recordset .AddNew

Select Case Combo1.Text Case "Meja": .Fields(2) = "M"

Case "Meja Belajar": .Fields(2) = "MB" Case "Meja Komputer": .Fields(2) = "MK" Case "Kursi": .Fields(2) = "K"

Case "Kursi Kantor": .Fields(2) = "KK" Case "Sofa": .Fields(2) = "S"

Case "Tempat Tidur": .Fields(2) = "T" Case "Lemari": .Fields(2) = "L" Case "Lemari Baju": .Fields(2) = "LB" End Select .Fields(0) = Text1.Text .Fields(1) = Text2.Text .Fields(3) = Text3.Text .Fields(4) = Text4.Text .Fields(5) = Text5.Text .Fields(6) = Text6.Text .Fields(7) = Text7.Text .Fields(8) = Combo2.Text .Fields(9) = Text8.Text .Update Call RefreshData

MsgBox "Data berhasil disimpan", vbInformation, "Sukses!" Command1.Enabled = False Command2.Enabled = True Command4.SetFocus Exit Sub End With End Sub

Private Sub Command2_Click()

Text4.Text = "" Or Text5.Text = "" Or Text6.Text = "" Or _ Text7.Text = "" Or Combo2.Text = "" Or Combo1.Text = "" Then MsgBox "Data harus diisi semua", vbApplicationModal, "Error!" Text1.SetFocus

End If

With DataBarang.Recordset .Update

Select Case Combo1.Text Case "Meja": .Fields(2) = "M"

Case "Meja Belajar": .Fields(2) = "MB" Case "Meja Komputer": .Fields(2) = "MK" Case "Kursi": .Fields(2) = "K"

Case "Kursi Kantor": .Fields(2) = "KK" Case "Sofa": .Fields(2) = "S"

Case "Tempat Tidur": .Fields(2) = "T" Case "Lemari": .Fields(2) = "L" Case "Lemari Baju": .Fields(2) = "LB" End Select .Fields(0) = Text1.Text .Fields(1) = Text2.Text .Fields(3) = Text3.Text .Fields(4) = Text4.Text .Fields(5) = Text5.Text .Fields(6) = Text6.Text .Fields(7) = Text7.Text .Fields(8) = Combo2.Text .Fields(9) = Text8.Text .Update Call RefreshData

MsgBox "Data berhasil diupdate", vbInformation, "Sukses!" Exit Sub

End With End Sub

Private Sub Command3_Click() On Error GoTo salah

Dim Konfirmasi, tanya As Integer

tanya = MsgBox("Anda yakin akan menghapusnya?", vbYesNo + vbQuestion, "Konfirmasi")

If tanya = vbYes Then Konfirmasi = 0

With DataBarang.Recordset If .RecordCount <> 0 Then .Delete

Call RefreshData

If .EOF Then .MovePrevious

If .BOF Then MsgBox "Data form kosong", vbInformation, "data" Else: MsgBox "Data masih kosong"

End If End With End If DataBarang.Refresh Call TampilData Exit Sub salah:

MsgBox "Data tidak dapat dihapus, terjadi kesalahan!!!", vbCritical, "error" End Sub

Private Sub Command4_Click() Command1.Enabled = True Command2.Enabled = False Call Baru Call AutoID Text2.SetFocus End Sub

Public Sub Baru() Text1.Text = "" Text2.Text = "" Text3.Text = "" Text4.Text = "" Text5.Text = "" Text6.Text = "" Text7.Text = "" Text8.Text = "" Combo1.Text = "" Combo2.Text = "" End Sub

Private Sub DataSupp_Validate(Action As Integer, Save As Integer) End Sub

Private Sub Form_Load() With Me.DataBarang

.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0;Data Source = " & App.Path & "\dbFBay.mdb"

.CommandType = adCmdText

.Refresh End With

With Me.DataSupp

.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0;Data Source = " & App.Path & "\dbFBay.mdb"

.CommandType = adCmdText

.RecordSource = "Select * from supplier" .Refresh

End With Call TampilData

Combo1.AddItem "Meja"

Combo1.AddItem "Meja Belajar" Combo1.AddItem "Meja Komputer" Combo1.AddItem "Kursi"

Combo1.AddItem "Kursi Kantor" Combo1.AddItem "Sofa"

Combo1.AddItem "Tempat Tidur" Combo1.AddItem "Lemari" Combo1.AddItem "Lemari Baju"

DataSupp.RecordSource = "Select id_supplier from Supplier" If (DataSupp.Recordset.RecordCount > 0) Then

Do While Not DataSupp.Recordset.EOF

Combo2.AddItem DataSupp.Recordset!id_supplier DataSupp.Recordset.MoveNext

Loop End If

'Set DataSupp.Recordset = Nothing cbKategori.AddItem "ID Barang" cbKategori.AddItem "Nama" cbKategori.AddItem "Jenis" cbKategori.AddItem "ID Supplier" Command1.Enabled = False End Sub

Private Sub txtKata_Click() txtKata.Text = ""

End Sub

Private Sub Form_Click() Call RefreshData

End Sub

Call TampilData End Sub

Private Sub RefreshData()

DataBarang.RecordSource = "select * from barang" DataBarang.Refresh

Call TampilData End Sub

Private Sub Command5_Click() If cbKategori.ListIndex = 0 Then

DataBarang.RecordSource = "select * from barang where id_barang like '%" & txtKata.Text & "%'"

DataBarang.Refresh

ElseIf cbKategori.ListIndex = 1 Then

DataBarang.RecordSource = "select * from barang where nama like '%" & txtKata.Text & "%'"

DataBarang.Refresh

ElseIf cbKategori.ListIndex = 2 Then

DataBarang.RecordSource = "select * from barang where jenis like '%" & txtKata.Text & "%'"

DataBarang.Refresh

ElseIf cbKategori.ListIndex = 3 Then

DataBarang.RecordSource = "select * from barang where id_supplier like '%" & txtKata.Text & "%'"

DataBarang.Refresh End If

End Sub

Private Sub TampilData()

LblRec.Caption = "Record: " & (DataBarang.Recordset.AbsolutePosition) & " dari " & _

CStr(DataBarang.Recordset.RecordCount) With DataBarang.Recordset

Text1.Text = .Fields(0) Text2.Text = .Fields(1) Select Case .Fields(2)

Case "M": Combo1.Text = "Meja"

Case "MB": Combo1.Text = "Meja Belajar" Case "MK": Combo1.Text = "Meja Komputer" Case "K": Combo1.Text = "Kursi"

Case "KK": Combo1.Text = "Kursi Kantor" Case "S": Combo1.Text = "Sofa"

Case "T": Combo1.Text = "Tempat Tidur" Case "L": Combo1.Text = "Lemari"

Case "LB": Combo1.Text = "Lemari Baju" End Select Text3.Text = .Fields(3) Text4.Text = .Fields(4) Text5.Text = .Fields(5) Text6.Text = .Fields(6) Text7.Text = .Fields(7) Combo2.Text = .Fields(8) Text8.Text = .Fields(9) End With End Sub

Private Function AutoID() With Me.DataBar

.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0;Data Source = " & App.Path & "\dbFBay.mdb"

.CommandType = adCmdText

.RecordSource = "select * from Barang Order By id_barang DESC" .Refresh

End With

If DataBar.Recordset.RecordCount = 0 Then Text1.Text = "PR0000"

Else

Dim dataY As String

dataY = DataBar.Recordset.Fields(0)

Text1.Text = "PR" & Format(Right(dataY, 4) + 1, "0000")

Dalam dokumen APLIKASI PERKREDITAN FURNITURE (Halaman 53-111)

Dokumen terkait