pertama yang harus dilakukan adalah membuat data base di micrososft acces disini saya beri nama penjualankue disave ke 2003
kemudian membuat program di VB dengan cara new project
Lalu saya membuat form login, form menu form, form barang, form customer, form salesman, form penjualan dan laporan.
berikut adalah tampilan dari dua form dan listing yang akan saya jelaskan.....
form login |
'----------------- Login
'----------------- Inisialisasi
Dim dbConn As ADODB.Connection
Dim rsUser As ADODB.Recordset
Dim rsQuery As StringDim Pilih As Integer
Dim Jawab As String
'------------------ Koneksi ke Database
Private Sub Koneksi()
Set dbConn = New ADODB.Connection
'-----------------Koneksi VB ke Ms SQL Server
'dbConn.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Penggajian"
'-----------------Koneksi VB ke Ms Access
dbConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Penjualankue.mdb;Persist Security Info=False"
Set rsUser = New ADODB.Recordset
rsUser.Open "Barang", dbConn, adOpenKeyset, adLockOptimistic
End Sub
Private Sub cboLevel_Click()
If cboLevel.Text = "User" Then
txtlogin.Enabled = False
txtpass.Enabled = False
cmdMasuk.Enabled = True
cmdMasuk.SetFocus
ElseIf cboLevel.Text = "Staf" Then
txtlogin.Enabled = True
txtpass.Enabled = True
txtlogin.Text = ""
txtpass.Text = ""
txtlogin.SetFocus
cmdMasuk.Enabled = True
ElseIf cboLevel.Text = "Administrator" Then
txtlogin.Enabled = True
txtpass.Enabled = True
txtlogin.Text = ""
txtpass.Text = ""
txtlogin.SetFocus
cmdMasuk.Enabled = True
End If
End Sub
Private Sub cmdKeluar_Click()
Unload Me
End Sub
Private Sub cmdMasuk_Click()
'On Error GoTo login_err
If cboLevel.Text = "User" Then
userid = "User"
levelid = "User"
MDIForm1.Show
Unload Me
Exit Sub
Else
If txtlogin.Text = "" Then
MsgBox "Masukkan User ID !", vbCritical
txtlogin.SetFocus
Exit Sub
End If
If Not validity(txtlogin, "User ID") Then
txtlogin.SetFocus
Exit Sub
End If
If txtpass.Text = "" Then
MsgBox "Masukkan Password !", vbCritical
txtpass.SetFocus
Exit Sub
End If
If Not validity(txtpass, "Password") Then
txtpass.SetFocus
Exit Sub
End If
Koneksi
Dim sql As String
Set rsUser = New ADODB.Recordset
'sql = "select * from list_user where id_user= '" & txtLogin.Text & "' and pass = '" & Crypt(txtpass.text) & "'"
sql = "select * from list_user where id_user= '" & txtlogin.Text & "' and pass = '" & txtpass.Text & "'"
rsUser.Open sql, dbConn, adOpenDynamic, adLockOptimistic
If (rsUser.EOF) Then
MsgBox "User ID dan Password salah! Coba Lagi !", vbCritical, "Peringatan"
txtlogin.Text = ""
txtpass.Text = ""
txtlogin.SetFocus
Call closeconn
Exit Sub
End If
levelid = rsUser!Level
Call closeconn
userid = txtlogin.Text
Unload Me
MDIForm1.Show
End If
Exit Sub
login_err:
MsgBox Err.Description
End Sub
Private Sub Form_Load()
cboLevel.AddItem "User"
cboLevel.AddItem "Staf"
cboLevel.AddItem "Administrator"
cmdMasuk.Enabled = False
End Sub
Private Sub txtlogin_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtpass.SetFocus
End If
End Sub
Private Sub txtpass_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cmdMasuk.SetFocus
End If
End Sub
form penjualan |
'----------------- penjualan
'----------------- Inisialisasi
Dim dbConn As ADODB.Connection
Dim rsCustomer As ADODB.Recordset
Dim rsPenjualan As ADODB.Recordset
Dim rsBarang As ADODB.Recordset
Dim rsSalesman As ADODB.Recordset
Dim rsQuery As String
Dim Pilih As Integer
Dim Jawab As String
'------------------ Koneksi ke Database
Private Sub Koneksi()
Set dbConn = New ADODB.Connection
'-----------------Koneksi VB ke Ms SQL Server
'dbConn.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Penggajian"
'-----------------Koneksi VB ke Ms Access
dbConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\penjualankue.mdb;Persist Security Info=False"
Set rsCustomer = New ADODB.Recordset
rsCustomer.Open "customer", dbConn, adOpenKeyset, adLockOptimistic
Set rsPenjualan = New ADODB.Recordset
rsPenjualan.Open "penjualan", dbConn, adOpenKeyset, adLockOptimistic
Set rsBarang = New ADODB.Recordset
rsBarang.Open "Barang", dbConn, adOpenKeyset, adLockOptimistic
Set rsSalesman = New ADODB.Recordset
rsSalesman.Open "salesman", dbConn, adOpenKeyset, adLockOptimistic
End Sub
Private Sub cmdAdd_Click()
Pilih = 0
Clear2
auto
Tombol (False)
txtNomorFaktur.Enabled = True
txtNomorFaktur.SetFocus
Proteksi (False)
End Sub
'-------------------- Membatalkan proses
Private Sub cmdCancel_Click()
Pilih = 0
Clear
Tombol (False)
txtNomorFaktur.Enabled = True
txtNomorFaktur.SetFocus
Proteksi (False)
End Sub
'-------------------- Menghapus data
Private Sub cmdDelete_Click()
'On Error GoTo label
Set rsPenjualan = New ADODB.Recordset
rsQuery = "SELECT * from penjualan where Nomorfaktur= '" & txtNomorFaktur.Text & "'"
rsPenjualan.Open rsQuery, dbConn, adOpenStatic, adLockOptimistic
Jawab = MsgBox("Are you sure?", vbYesNo + bCritical)
If Jawab = vbYes Then
rsPenjualan.Delete
rsPenjualan.MoveNext
MsgBox "Delete succeed"
Gridpenjualan
Clear
Proteksi (False)
Tombol (False)
txtNomorFaktur.Enabled = True
txtNomorFaktur.SetFocus
Exit Sub
Else
Call cmdCancel_Click
Exit Sub
End If
DeleteErr:
MsgBox Err.Description
End Sub
'-------------- Exit
Private Sub cmdExit_Click()
Unload Me
End Sub
'-------------- Insert
Private Sub cmdInsert_Click()
'On Error GoTo label
Tombol (False)
Set rsPenjualan = New ADODB.Recordset
rsQuery = "SELECT * from penjualan where Nomorfaktur = '" & txtNomorFaktur.Text & "'"
rsPenjualan.Open rsQuery, dbConn, adOpenStatic, adLockOptimistic
rsPenjualan.AddNew
rsPenjualan!NomorFaktur = txtNomorFaktur.Text
If DTPicker1 = 0 Then
rsPenjualan!TanggalFaktur = 0
Else
rsPenjualan!TanggalFaktur = DTPicker1
End If
If DTPicker2 = 0 Then
rsPenjualan!TanggalJatuhTempo = 0
Else
rsPenjualan!TanggalJatuhTempo = DTPicker2
End If
If txtHalaman.Text = "" Then
rsPenjualan!Halaman = ""
Else
rsPenjualan!Halaman = txtHalaman.Text
End If
If txtNomorPO.Text = "" Then
rsPenjualan!NomorPO = ""
Else
rsPenjualan!NomorPO = txtNomorPO.Text
End If
If txtNomorOrder.Text = "" Then
rsPenjualan!NomorOrder = ""
Else
rsPenjualan!NomorOrder = txtNomorOrder.Text
End If
If txtNomorCustomer.Text = "" Then
rsPenjualan!nomorCustomer = ""
Else
rsPenjualan!nomorCustomer = txtNomorCustomer.Text
End If
If txtNamaCustomer.Text = "" Then
rsPenjualan!NamaCustomer = ""
Else
rsPenjualan!NamaCustomer = txtNamaCustomer.Text
End If
If txtPerusahaan.Text = "" Then
rsPenjualan!Perusahaan = ""
Else
rsPenjualan!Perusahaan = txtPerusahaan.Text
End If
If txtPcode.Text = "" Then
rsPenjualan!Pcode = ""
Else
rsPenjualan!Pcode = txtPcode.Text
End If
If txtNamaBarang.Text = "" Then
rsPenjualan!NamaBarang = ""
Else
rsPenjualan!NamaBarang = txtNamaBarang.Text
End If
If txtKuantitas.Text = "" Then
rsPenjualan!kuantitas = ""
Else
rsPenjualan!kuantitas = txtKuantitas.Text
End If
If txtSatuanatauIsi.Text = "" Then
rsPenjualan!SatuanatauIsi = ""
Else
rsPenjualan!SatuanatauIsi = txtSatuanatauIsi.Text
End If
If txtJumlahBarang.Text = "" Then
rsPenjualan!JumlahBarang = ""
Else
rsPenjualan!JumlahBarang = txtJumlahBarang.Text
End If
If txtTanggalDaluwarsa.Text = "" Then
rsPenjualan!TanggalDaluwarsa = ""
Else
rsPenjualan!TanggalDaluwarsa = txtTanggalDaluwarsa.Text
End If
If txtHarga1TambahPPN.Text = "" Then
rsPenjualan!Harga1TambahPPN = 0
Else
rsPenjualan!Harga1TambahPPN = txtHarga1TambahPPN.Text
End If
If txtHarga1KurangPPN.Text = "" Then
rsPenjualan!Harga1KurangPPN = 0
Else
rsPenjualan!Harga1KurangPPN = txtHarga1KurangPPN.Text
End If
If txtJumlahRp.Text = "" Then
rsPenjualan!JumlahRp = 0
Else
rsPenjualan!JumlahRp = txtJumlahRp.Text
End If
If txtKeterangan.Text = "" Then
rsPenjualan!Keterangan = ""
Else
rsPenjualan!Keterangan = txtKeterangan.Text
End If
If txtRpDisc.Text = "" Then
rsPenjualan!RpDisc = 0
Else
rsPenjualan!RpDisc = txtRpDisc.Text
End If
If txtJumlah.Text = "" Then
rsPenjualan!Jumlah = 0
Else
rsPenjualan!Jumlah = txtJumlah.Text
End If
If txtTotalDiscount.Text = "" Then
rsPenjualan!TotalDiscount = 0
Else
rsPenjualan!TotalDiscount = txtTotalDiscount.Text
End If
If txtPPN.Text = "" Then
rsPenjualan!PPN = 0
Else
rsPenjualan!PPN = txtPPN.Text
End If
If txtNilaiFaktur.Text = "" Then
rsPenjualan!NilaiFaktur = 0
Else
rsPenjualan!NilaiFaktur = txtNilaiFaktur.Text
End If
If txtNomorIndukSalesman.Text = "" Then
rsPenjualan!nomorIndukSalesman = ""
Else
rsPenjualan!nomorIndukSalesman = txtNomorIndukSalesman.Text
End If
If txtNamaSalesman.Text = "" Then
rsPenjualan!NamaSalesman = ""
Else
rsPenjualan!NamaSalesman = txtNamaSalesman.Text
End If
If Combo1.Text = "" Then
rsPenjualan!bulan = ""
Else
rsPenjualan!bulan = Combo1.Text
End If
If Combo2.Text = "" Then
rsPenjualan!tahun = ""
Else
rsPenjualan!tahun = Combo2.Text
End If
rsPenjualan.Update
MsgBox "Insert succeed"
Gridpenjualan
Clear
Tombol (False)
Proteksi (False)
txtNomorFaktur.SetFocus
Exit Sub
label:
Select Case Err.Number
Case 3197
Jawab = MsgBox(" Record in used", vbOKCancel + vbQuestion, "update")
If Jawab = vbOK Then
Call cmdCancel_Click
Call TampilkanData
'Call cmdEdit_Click
Exit Sub
Else
Call cmdCancel_Click
Call TampilkanData
Exit Sub
End If
Case 3167
Jawab = MsgBox(" Record has deleted", vbInformation + vbOKOnly, "update")
Err = 0
Call cmdCancel_Click
Exit Sub
Case Else
MsgBox "Error :" & Err.Description
End Select
MsgBox "Save does not succeed"
Call Clear
Proteksi (False)
txtNomorFaktur.SetFocus
End Sub
'--------------- Update
Private Sub cmdUpdate_Click()
'On Error GoTo label
Tombol (False)
Set rsPenjualan = New ADODB.Recordset
rsQuery = "SELECT * from penjualan where Nomorfaktur = '" & txtNomorFaktur.Text & "'"
rsPenjualan.Open rsQuery, dbConn, adOpenStatic, adLockOptimistic
rsPenjualan.Update
rsPenjualan!NomorFaktur = txtNomorFaktur.Text
If DTPicker1 = 0 Then
rsPenjualan!TanggalFaktur = 0
Else
rsPenjualan!TanggalFaktur = DTPicker1
End If
If DTPicker2 = 0 Then
rsPenjualan!TanggalJatuhTempo = 0
Else
rsPenjualan!TanggalJatuhTempo = DTPicker2
End If
If txtHalaman.Text = "" Then
rsPenjualan!Halaman = ""
Else
rsPenjualan!Halaman = txtHalaman.Text
End If
If txtNomorPO.Text = "" Then
rsPenjualan!NomorPO = ""
Else
rsPenjualan!NomorPO = txtNomorPO.Text
End If
If txtNomorOrder.Text = "" Then
rsPenjualan!NomorOrder = ""
Else
rsPenjualan!NomorOrder = txtNomorOrder.Text
End If
If txtNomorCustomer.Text = "" Then
rsPenjualan!nomorCustomer = ""
Else
rsPenjualan!nomorCustomer = txtNomorCustomer.Text
End If
If txtNamaCustomer.Text = "" Then
rsPenjualan!NamaCustomer = ""
Else
rsPenjualan!NamaCustomer = txtNamaCustomer.Text
End If
If txtPerusahaan.Text = "" Then
rsPenjualan!Perusahaan = ""
Else
rsPenjualan!Perusahaan = txtPerusahaan.Text
End If
If txtPcode.Text = "" Then
rsPenjualan!Pcode = ""
Else
rsPenjualan!Pcode = txtPcode.Text
End If
If txtNamaBarang.Text = "" Then
rsPenjualan!NamaBarang = ""
Else
rsPenjualan!NamaBarang = txtNamaBarang.Text
End If
If txtKuantitas.Text = "" Then
rsPenjualan!kuantitas = ""
Else
rsPenjualan!kuantitas = txtKuantitas.Text
End If
If txtSatuanatauIsi.Text = "" Then
rsPenjualan!SatuanatauIsi = ""
Else
rsPenjualan!SatuanatauIsi = txtSatuanatauIsi.Text
End If
If txtJumlahBarang.Text = "" Then
rsPenjualan!JumlahBarang = ""
Else
rsPenjualan!JumlahBarang = txtJumlahBarang.Text
End If
If txtTanggalDaluwarsa.Text = "" Then
rsPenjualan!TanggalDaluwarsa = ""
Else
rsPenjualan!TanggalDaluwarsa = txtTanggalDaluwarsa.Text
End If
If txtHarga1TambahPPN.Text = "" Then
rsPenjualan!Harga1TambahPPN = 0
Else
rsPenjualan!Harga1TambahPPN = txtHarga1TambahPPN.Text
End If
If txtHarga1KurangPPN.Text = "" Then
rsPenjualan!Harga1KurangPPN = 0
Else
rsPenjualan!Harga1KurangPPN = txtHarga1KurangPPN.Text
End If
If txtJumlahRp.Text = "" Then
rsPenjualan!JumlahRp = 0
Else
rsPenjualan!JumlahRp = txtJumlahRp.Text
End If
If txtKeterangan.Text = "" Then
rsPenjualan!Keterangan = ""
Else
rsPenjualan!Keterangan = txtKeterangan.Text
End If
If txtRpDisc.Text = "" Then
rsPenjualan!RpDisc = 0
Else
rsPenjualan!RpDisc = txtRpDisc.Text
End If
If txtJumlah.Text = "" Then
rsPenjualan!Jumlah = 0
Else
rsPenjualan!Jumlah = txtJumlah.Text
End If
If txtTotalDiscount.Text = "" Then
rsPenjualan!TotalDiscount = 0
Else
rsPenjualan!TotalDiscount = txtTotalDiscount.Text
End If
If txtPPN.Text = "" Then
rsPenjualan!PPN = 0
Else
rsPenjualan!PPN = txtPPN.Text
End If
If txtNilaiFaktur.Text = "" Then
rsPenjualan!NilaiFaktur = 0
Else
rsPenjualan!NilaiFaktur = txtNilaiFaktur.Text
End If
If txtNomorIndukSalesman.Text = "" Then
rsPenjualan!nomorIndukSalesman = ""
Else
rsPenjualan!nomorIndukSalesman = txtNomorIndukSalesman.Text
End If
If txtNamaSalesman.Text = "" Then
rsPenjualan!NamaSalesman = ""
Else
rsPenjualan!NamaSalesman = txtNamaSalesman.Text
End If
If Combo1.Text = "" Then
rsPenjualan!bulan = ""
Else
rsPenjualan!bulan = Combo1.Text
End If
If Combo2.Text = "" Then
rsPenjualan!tahun = ""
Else
rsPenjualan!tahun = Combo2.Text
End If
rsPenjualan.Update
MsgBox "Update succeed"
Gridpenjualan
Clear
Tombol (False)
Proteksi (False)
txtNomorFaktur.Enabled = True
txtNomorFaktur.SetFocus
Exit Sub
End Sub
'--------------- View
Private Sub cmdView_Click()
Pilih = 0
Clear
Tombol (False)
txtNomorFaktur.Enabled = True
txtNomorFaktur.SetFocus
Proteksi (False)
End Sub
Private Sub DTPicker1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
DTPicker2.SetFocus
End If
End Sub
Private Sub DTPicker2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtHalaman.SetFocus
End If
End Sub
'---------------- Form Load
Private Sub Form_Load()
Clear
Tombol (False)
MaxData
Proteksi (False)
Koneksi
'TampilkanData
Gridpenjualan
cbo1
cbo2
cbo3
TampilGridPenjualan1
'----------- Bulan
Combo1.AddItem "Januari"
Combo1.AddItem "Pebruari"
Combo1.AddItem "Maret"
Combo1.AddItem "April"
Combo1.AddItem "Mei"
Combo1.AddItem "Juni"
Combo1.AddItem "Juli"
Combo1.AddItem "Agustus"
Combo1.AddItem "September"
Combo1.AddItem "Oktober"
Combo1.AddItem "November"
Combo1.AddItem "Desember"
'----------- Tahun
Combo2.AddItem "2010"
Combo2.AddItem "2011"
Combo2.AddItem "2012"
Combo2.AddItem "2013"
Combo2.AddItem "2014"
Combo2.AddItem "2015"
Combo2.AddItem "2016"
Combo2.AddItem "2011"
Combo2.AddItem "2012"
Combo2.AddItem "2013"
Combo2.AddItem "2014"
Combo2.AddItem "2015"
End Sub
Private Sub Combo1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Combo2.SetFocus
End If
End Sub
Private Sub Gridpenjualan1_DblClick()
txtNomorFaktur.SetFocus
GridBaris = Gridpenjualan1.Row
Set rsPenjualan = New ADODB.Recordset
rsPenjualan.Open "SELECT NomorFaktur from penjualan where NomorFaktur = '" & Gridpenjualan1.TextMatrix(GridBaris, 1) & " ' ", _
dbConn, adOpenDynamic, adLockOptimistic
If rsPenjualan.BOF Then
MsgBox "TABEL MASIH KOSONG", _
vbOKOnly + vbInformation, "Error"
Exit Sub
Else
rsPenjualan.MoveFirst
Do While Not rsPenjualan.EOF
On Error Resume Next
txtNomorFaktur.Text = rsPenjualan!NomorFaktur
DTPicker1 = rsPenjualan!TanggalFaktur
DTPicker2 = rsPenjualan!TanggalJatuhTempo
txtHalaman.Text = rsPenjualan!Halaman
txtNomorPO.Text = rsPenjualan!NomorPO
txtNomorOrder.Text = rsPenjualan!NomorOrder
txtNomorCustomer.Text = rsPenjualan!nomorCustomer
txtNamaCustomer.Text = rsPenjualan!NamaCustomer
txtPerusahaan.Text = rsPenjualan!Perusahaan
txtPcode.Text = rsPenjualan!Pcode
txtNamaBarang.Text = rsPenjualan!NamaBarang
txtKuantitas.Text = rsPenjualan!kuantitas
txtSatuanatauIsi.Text = rsPenjualan!SatuanatauIsi
txtJumlahBarang.Text = rsPenjualan!JumlahBarang
txtTanggalDaluwarsa.Text = rsPenjualan!TanggalDaluwarsa
txtHarga1TambahPPN.Text = rsPenjualan!Harga1TambahPPN
txtHarga1KurangPPN.Text = rsPenjualan!Harga1KurangPPN
txtJumlahRp.Text = rsPenjualan!JumlahRp
txtKeterangan.Text = rsPenjualan!Keterangan
txtRpDisc.Text = rsPenjualan!RpDisc
txtJumlah.Text = rsPenjualan!Jumlah
txtTotalDiscount.Text = rsPenjualan!TotalDiscount
txtPPN.Text = rsPenjualan!PPN
txtNilaiFaktur.Text = rsPenjualan!NilaiFaktur
txtNomorIndukSalesman.Text = rsPenjualan!nomorIndukSalesman
txtNamaSalesman.Text = rsPenjualan!NamaSalesman
Combo1.Text = rsPenjualan!bulan
Combo2.Text = rsPenjualan!tahun
rsPenjualan.MoveNext
Loop
End If
End Sub
Private Sub txtHarga1KurangPPN_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtJumlahRp.SetFocus
End If
End Sub
Private Sub txtHarga1TambahPPN_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtHarga1KurangPPN.SetFocus
End If
End Sub
Private Sub txtJumlah_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtTotalDiscount.SetFocus
txtTotalDiscount.Text = Val(txtJumlah.Text) / 100
End If
End Sub
Private Sub txtJumlahRp_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtKeterangan.SetFocus
End If
End Sub
Private Sub txtKeterangan_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtRpDisc.SetFocus
End If
txtRpDisc.Text = Val(txtJumlahRp.Text) / 100
End Sub
Private Sub txtKuantitas_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtSatuanatauIsi.SetFocus
End If
End Sub
Private Sub txtNamaSalesman_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Combo1.SetFocus
End If
End Sub
Private Sub txtNilaiFaktur_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtNomorIndukSalesman.SetFocus
End If
End Sub
Private Sub txtPcode_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Len(txtPcode.Text) < 6 Then
MsgBox "Pcode harus diisi sebanyak 6 digit, tidak boleh kosong"
txtPcode.SetFocus
Else
Set rsBarang = New ADODB.Recordset
rsQuery = "SELECT * from barang where Pcode = '" & txtPcode.Text & "'"
rsBarang.Open rsQuery, dbConn, adOpenDynamic, adLockOptimistic
If rsBarang.EOF Then
'Pilih = 0
MsgBox ("Kode barang belum terdaftar")
Proteksi (True)
txtPcode.SetFocus
cmdInsert.Enabled = True
Else
'Pilih = 1
Proteksi (True)
caribarang
'txtjumlahbarang.Enabled = True
'txtjumlahbarang.SetFocus
End If
rsBarang.Close
End If
End If
End Sub
Private Sub caribarang()
'------------------ Tampilkan Data
'On Error Resume Next
Set rsBarang = New ADODB.Recordset
rsQuery = "SELECT * from Barang where pcode= '" & txtPcode.Text & "'"
rsBarang.Open rsQuery, dbConn, adOpenStatic, adLockOptimistic
txtNamaBarang.Text = rsBarang!NamaBarang
txtKuantitas.Text = rsBarang!kuantitas
txtSatuanatauIsi.Text = rsBarang!SatuanatauIsi
txtJumlahBarang.Text = rsBarang!JumlahBarang
txtTanggalDaluwarsa.Text = rsBarang!TanggalDaluwarsa
txtHarga1TambahPPN.Text = rsBarang!Harga1TambahPPN
txtHarga1KurangPPN.Text = rsBarang!Harga1KurangPPN
txtJumlahRp.Text = rsBarang!JumlahRp
txtKeterangan.Text = rsBarang!Keterangan
txtJumlahBarang.Enabled = True
txtJumlahBarang.SetFocus
End Sub
Private Sub Caripenjualan()
Set rsPenjualan = New ADODB.Recordset
rsQuery = "SELECT * from penjualan where Nomorfaktur = '" & txtNomorFaktur.Text & "'"
rsPenjualan.Open rsQuery, dbConn, adOpenStatic, adLockOptimistic
If rsPenjualan.EOF Then
'Pilih = 0
MsgBox ("Nomor faktur tersebut belum terdaftar di Tabel penjualan")
Proteksi (True)
txtNomorFaktur.Enabled = True
txtNomorFaktur.SetFocus
Else
'Pilih = 1
Proteksi (True)
DTPicker1.Enabled = True
DTPicker1.SetFocus
End If
End Sub
'--------------- Clear Kolom
Public Sub Clear()
txtNomorFaktur.Text = ""
'DTPicker1.Value = 0
'DTPicker2.Value = 0
txtHalaman.Text = ""
txtNomorPO.Text = ""
txtNomorOrder.Text = ""
txtNomorCustomer.Text = ""
txtNamaCustomer.Text = ""
txtPerusahaan.Text = ""
txtPcode.Text = ""
txtNamaBarang.Text = ""
txtKuantitas.Text = ""
txtSatuanatauIsi.Text = ""
txtJumlahBarang.Text = ""
txtTanggalDaluwarsa.Text = ""
txtHarga1TambahPPN.Text = 0
txtHarga1KurangPPN.Text = 0
txtJumlahRp.Text = 0
txtKeterangan.Text = ""
txtRpDisc.Text = 0
txtJumlah.Text = 0
txtTotalDiscount.Text = 0
txtPPN.Text = 0
txtNilaiFaktur.Text = 0
txtNomorIndukSalesman.Text = ""
txtNamaSalesman.Text = ""
Combo1.Text = ""
Combo2.Text = ""
End Sub
Public Sub Clear2()
txtNomorFaktur.Text = ""
'DTPicker1.Value = ""
'DTPicker2.Value = ""
txtHalaman.Text = ""
txtNomorPO.Text = ""
txtNomorOrder.Text = ""
txtNomorCustomer.Text = ""
txtNamaCustomer.Text = ""
txtPerusahaan.Text = ""
txtPcode.Text = ""
txtNamaBarang.Text = ""
txtKuantitas.Text = ""
txtSatuanatauIsi.Text = ""
txtJumlahBarang.Text = ""
txtTanggalDaluwarsa.Text = ""
txtHarga1TambahPPN.Text = ""
txtHarga1KurangPPN.Text = ""
txtJumlahRp.Text = ""
txtKeterangan.Text = ""
txtRpDisc.Text = ""
txtJumlah.Text = ""
txtTotalDiscount.Text = ""
txtPPN.Text = ""
txtNilaiFaktur.Text = ""
txtNomorIndukSalesman.Text = ""
txtNamaSalesman.Text = ""
Combo1.Text = ""
Combo2.Text = ""
End Sub
Public Sub MaxData()
txtNomorFaktur.MaxLength = 8
'DTPicker1.Value = 0
'DTPicker2.Value = 0
txtHalaman.MaxLength = 8
txtNomorPO.MaxLength = 5
txtNomorOrder.MaxLength = 8
'txtNomorCustomer.MaxLength = 6
txtNamaCustomer.MaxLength = 25
'txtPcode.MaxLength = 6
txtNamaBarang.MaxLength = 25
txtKuantitas.MaxLength = 8
txtPerusahaan.MaxLength = 25
txtSatuanatauIsi.MaxLength = 15
txtJumlahBarang.MaxLength = 8
txtTanggalDaluwarsa.MaxLength = 8
txtHarga1TambahPPN.MaxLength = 8
txtHarga1KurangPPN.MaxLength = 8
txtJumlahRp.MaxLength = 8
txtKeterangan.MaxLength = 20
txtRpDisc.MaxLength = 8
txtJumlah.MaxLength = 8
txtTotalDiscount.MaxLength = 8
txtPPN.MaxLength = 8
txtNilaiFaktur.MaxLength = 8
'txtNomorIndukSalesman.MaxLength = 6
txtNamaSalesman.MaxLength = 25
'Combo1.MaxLength = 15
'Combo2.MaxLength = 4
End Sub
Private Sub TampilkanData()
'------------------ Tampilkan Data
'On Error Resume Next
Set rsPenjualan = New ADODB.Recordset
rsQuery = "SELECT * from penjualan where Nomorfaktur = '" & txtNomorFaktur.Text & "'"
rsPenjualan.Open rsQuery, dbConn, adOpenStatic, adLockOptimistic
txtNomorFaktur.Text = rsPenjualan!NomorFaktur
If IsNull(rsPenjualan!TanggalFaktur) Then
DTPicker1 = 0
Else
DTPicker1 = rsPenjualan!TanggalFaktur
End If
If IsNull(rsPenjualan!TanggalJatuhTempo) Then
DTPicker2 = 0
Else
DTPicker2 = rsPenjualan!TanggalJatuhTempo
End If
If IsNull(rsPenjualan!Halaman) Then
txtHalaman.Text = ""
Else
txtHalaman.Text = rsPenjualan!Halaman
End If
If IsNull(rsPenjualan!NomorPO) Then
txtNomorPO.Text = ""
Else
txtNomorPO.Text = rsPenjualan!NomorPO
End If
If IsNull(rsPenjualan!NomorOrder) Then
txtNomorOrder.Text = ""
Else
txtNomorOrder.Text = rsPenjualan!NomorOrder
End If
If IsNull(rsPenjualan!nomorCustomer) Then
txtNomorCustomer.Text = ""
Else
txtNomorCustomer.Text = rsPenjualan!nomorCustomer
End If
If IsNull(rsPenjualan!NamaCustomer) Then
txtNamaCustomer.Text = ""
Else
txtNamaCustomer.Text = rsPenjualan!NamaCustomer
End If
If IsNull(rsPenjualan!Perusahaan) Then
txtPerusahaan.Text = ""
Else
txtPerusahaan.Text = rsPenjualan!Perusahaan
End If
If IsNull(rsPenjualan!Pcode) Then
txtPcode.Text = ""
Else
txtPcode.Text = rsPenjualan!Pcode
End If
If IsNull(rsPenjualan!NamaBarang) Then
txtNamaBarang.Text = ""
Else
txtNamaBarang.Text = rsPenjualan!NamaBarang
End If
If IsNull(rsPenjualan!kuantitas) Then
txtKuantitas.Text = ""
Else
txtKuantitas.Text = rsPenjualan!kuantitas
End If
If IsNull(rsPenjualan!SatuanatauIsi) Then
txtSatuanatauIsi.Text = ""
Else
txtSatuanatauIsi.Text = rsPenjualan!SatuanatauIsi
End If
If IsNull(rsPenjualan!JumlahBarang) Then
txtJumlahBarang.Text = ""
Else
txtJumlahBarang.Text = rsPenjualan!JumlahBarang
End If
If IsNull(rsPenjualan!TanggalDaluwarsa) Then
txtTanggalDaluwarsa.Text = ""
Else
txtTanggalDaluwarsa.Text = rsPenjualan!TanggalDaluwarsa
End If
If IsNull(rsPenjualan!Harga1TambahPPN) Then
txtHarga1TambahPPN.Text = ""
Else
txtHarga1TambahPPN.Text = rsPenjualan!Harga1TambahPPN
End If
If IsNull(rsPenjualan!Harga1KurangPPN) Then
txtHarga1KurangPPN.Text = ""
Else
txtHarga1KurangPPN.Text = rsPenjualan!Harga1KurangPPN
End If
If IsNull(rsPenjualan!JumlahRp) Then
txtJumlahRp.Text = ""
Else
txtJumlahRp.Text = rsPenjualan!JumlahRp
End If
If IsNull(rsPenjualan!Keterangan) Then
txtKeterangan.Text = ""
Else
txtKeterangan.Text = rsPenjualan!Keterangan
End If
If IsNull(rsPenjualan!RpDisc) Then
txtRpDisc.Text = ""
Else
txtRpDisc.Text = rsPenjualan!RpDisc
End If
If IsNull(rsPenjualan!Jumlah) Then
txtJumlah.Text = ""
Else
txtJumlah.Text = rsPenjualan!Jumlah
End If
If IsNull(rsPenjualan!TotalDiscount) Then
txtTotalDiscount.Text = ""
Else
txtTotalDiscount.Text = rsPenjualan!TotalDiscount
End If
If IsNull(rsPenjualan!PPN) Then
txtPPN.Text = ""
Else
txtPPN.Text = rsPenjualan!PPN
End If
If IsNull(rsPenjualan!NilaiFaktur) Then
txtNilaiFaktur.Text = ""
Else
txtNilaiFaktur.Text = rsPenjualan!NilaiFaktur
End If
If IsNull(rsPenjualan!nomorIndukSalesman) Then
txtNomorIndukSalesman.Text = ""
Else
txtNomorIndukSalesman.Text = rsPenjualan!nomorIndukSalesman
End If
If IsNull(rsPenjualan!NamaSalesman) Then
txtNamaSalesman.Text = ""
Else
txtNamaSalesman.Text = rsPenjualan!NamaSalesman
End If
If IsNull(rsPenjualan!bulan) Then
Combo1.Text = ""
Else
Combo1.Text = rsPenjualan!bulan
End If
If IsNull(rsPenjualan!tahun) Then
Combo2.Text = ""
Else
Combo2.Text = rsPenjualan!tahun
End If
End Sub
'--------------- Tombol Status
Public Sub Tombol(Status As Boolean)
cmdInsert.Enabled = Status
cmdUpdate.Enabled = Status
cmdDelete.Enabled = Status
cmdCancel.Enabled = Not Status
cmdExit.Enabled = Not Status
End Sub
'--------------- Proteksi Kolom
Public Sub Proteksi(Status As Boolean)
'txtNomorFaktur(0).Enabled = Status
DTPicker1.Enabled = Status
DTPicker2.Enabled = Status
txtHalaman.Enabled = Status
txtNomorPO.Enabled = Status
txtNomorOrder.Enabled = Status
txtNomorCustomer.Enabled = Status
txtNamaCustomer.Enabled = Status
txtPerusahaan.Enabled = Status
txtPcode.Enabled = Status
txtNamaBarang.Enabled = Status
txtKuantitas.Enabled = Status
txtSatuanatauIsi.Enabled = Status
txtJumlahBarang.Enabled = Status
txtTanggalDaluwarsa.Enabled = Status
txtHarga1TambahPPN.Enabled = Status
txtHarga1KurangPPN.Enabled = Status
txtJumlahRp.Enabled = Status
txtKeterangan.Enabled = Status
txtRpDisc.Enabled = Status
txtJumlah.Enabled = Status
txtTotalDiscount.Enabled = Status
txtPPN.Enabled = Status
txtNilaiFaktur.Enabled = Status
txtNomorIndukSalesman.Enabled = Status
txtNamaSalesman.Enabled = Status
Combo1.Enabled = Status
Combo2.Enabled = Status
End Sub
'--------------------- Grid Data
Sub Gridpenjualan()
If rsPenjualan.State = 1 Then rsPenjualan.Close
rsQuery = "select * from penjualan " 'where txtNomorFaktur = '" & txtNomorFaktur(0).text & "'"
rsPenjualan.Open (rsQuery), dbConn, adOpenDynamic, adLockOptimistic
Set Gridpenjualan1.DataSource = rsPenjualan
End Sub
Private Sub txtHalaman_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtNomorPO.SetFocus
End If
End Sub
Private Sub txtJumlahBarang_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtTanggalDaluwarsa.SetFocus
End If
End Sub
Private Sub txtNamaBarang_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtKuantitas.SetFocus
End If
End Sub
Private Sub txtNamaCustomer_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtPerusahaan.SetFocus
End If
End Sub
Private Sub txtNomorCustomer_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Len(txtNomorCustomer.Text) < 6 Then
MsgBox "NomorCustomer harus diisi sebanyak 6 digit, tidak boleh kosong"
txtNomorCustomer.SetFocus
Else
Set rsCustomer = New ADODB.Recordset
rsQuery = "SELECT * from Customer where NomorCustomer = '" & txtNomorCustomer.Text & "'"
rsCustomer.Open rsQuery, dbConn, adOpenDynamic, adLockOptimistic
If rsCustomer.EOF Then
'Pilih = 0
MsgBox ("Nomor Customer belum terdaftar")
Proteksi (True)
txtNomorCustomer.SetFocus
cmdInsert.Enabled = True
Else
'Pilih = 1
Proteksi (True)
caricustomer
txtNamaCustomer.Enabled = True
txtNamaCustomer.SetFocus
End If
rsCustomer.Close
End If
End If
End Sub
Private Sub caricustomer()
'------------------ Tampilkan Data
'On Error Resume Next
Set rsCustomer = New ADODB.Recordset
rsQuery = "SELECT * from Customer where NomorCustomer= '" & txtNomorCustomer.Text & "'"
rsCustomer.Open rsQuery, dbConn, adOpenStatic, adLockOptimistic
txtNamaCustomer.Text = rsCustomer!NamaCustomer
txtPerusahaan.Text = rsCustomer!Perusahaan
txtNamaCustomer.Enabled = True
txtNamaCustomer.SetFocus
End Sub
Sub auto()
Dim urutan As String
Dim hitung As Byte
Set rsPenjualan = New ADODB.Recordset
rsQuery = "select NomorFaktur from Penjualan"
rsPenjualan.Open (rsQuery), dbConn, adOpenKeyset, adLockPessimistic
If rsPenjualan.EOF Then
urutan = "FM" & "000001"
txtNomorFaktur = urutan
Else
rsPenjualan.MoveLast
txtNomorFaktur = rsPenjualan!NomorFaktur
hitung = Val(Right((txtNomorFaktur), 6)) + 1
urutan = "FM" & Right("00000" & hitung, 6)
txtNomorFaktur = urutan
End If
End Sub
Private Sub txtNomorFaktur_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Len(txtNomorFaktur.Text) < 8 Then
MsgBox "Nomorfaktur harus diisi sebanyak 8 digit, tidak boleh kosong"
txtNomorFaktur.SetFocus
Else
Set rsPenjualan = New ADODB.Recordset
rsQuery = "SELECT Nomorfaktur from penjualan where Nomorfaktur = '" & txtNomorFaktur.Text & "'"
rsPenjualan.Open rsQuery, dbConn, adOpenDynamic, adLockOptimistic
If rsPenjualan.EOF Then
Pilih = 0
'MsgBox ("Data does not exist")
Proteksi (True)
DTPicker1.Enabled = True
DTPicker1.SetFocus
cmdInsert.Enabled = True
cmdUpdate.Enabled = False
cmdDelete.Enabled = False
Else
Pilih = 1
Proteksi (True)
TampilkanData
DTPicker1.Enabled = True
DTPicker1.SetFocus
cmdUpdate.Enabled = True
cmdDelete.Enabled = True
End If
'rsPenjualan.Close
End If
End If
End Sub
Private Sub txtNomorInduksalesman_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Len(txtNomorIndukSalesman.Text) < 6 Then
MsgBox "NomorInduksalesman harus diisi sebanyak 6 digit, tidak boleh kosong"
txtNomorIndukSalesman.SetFocus
Else
Set rsSalesman = New ADODB.Recordset
rsQuery = "SELECT * from salesman where NomorInduksalesman = '" & txtNomorIndukSalesman.Text & "'"
rsSalesman.Open rsQuery, dbConn, adOpenDynamic, adLockOptimistic
If rsSalesman.EOF Then
'Pilih = 0
MsgBox ("Nomor Induk salesman belum terdaftar")
Proteksi (True)
txtNomorIndukSalesman.SetFocus
cmdInsert.Enabled = True
Else
'Pilih = 1
Proteksi (True)
Carisalesman
txtNamaSalesman.Enabled = True
txtNamaSalesman.SetFocus
End If
rsSalesman.Close
End If
End If
End Sub
Private Sub Carisalesman()
'------------------ Tampilkan Data
'On Error Resume Next
Set rsSalesman = New ADODB.Recordset
rsQuery = "SELECT * from salesman where NomorInduksalesman = '" & txtNomorIndukSalesman.Text & "'"
rsSalesman.Open rsQuery, dbConn, adOpenStatic, adLockOptimistic
txtNamaSalesman.Text = rsSalesman!NamaSalesman
Combo1.Enabled = True
Combo1.SetFocus
End Sub
Private Sub Combo2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Pilih = 1 Then
cmdUpdate.Enabled = True
cmdCancel.Enabled = True
cmdDelete.Enabled = True
cmdUpdate.SetFocus
Else
cmdInsert.Enabled = True
cmdInsert.SetFocus
End If
End If
End Sub
Private Sub txtNomorOrder_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtNomorCustomer.SetFocus
End If
End Sub
Private Sub txtNomorPO_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtNomorOrder.SetFocus
End If
End Sub
Private Sub txtPerusahaan_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtPcode.SetFocus
End If
End Sub
Private Sub txtPPN_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtNilaiFaktur.Text = Val(txtJumlah.Text) + (txtTotalDiscount.Text) + Val(txtPPN.Text)
txtNilaiFaktur.SetFocus
End If
End Sub
Private Sub txtRpDisc_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtJumlah.SetFocus
txtJumlah.Text = txtJumlahRp.Text
End If
End Sub
Private Sub txtSatuanatauIsi_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtJumlahBarang.SetFocus
End If
End Sub
Private Sub txtTanggalDaluwarsa_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtHarga1TambahPPN.SetFocus
End If
End Sub
Private Sub Form_Activate()
cmdAdd.SetFocus
End Sub
Sub AturGridPenjualan1()
'----------------------------------------
'PENGATURAN GridPenjualan1
'----------------------------------------
With Gridpenjualan1
.Cols = 29 'Jumlah Kolom Seluruhnya
.RowHeightMin = 300
.Col = 0 'Kolom Pertama
.Row = 0
.Text = "No." 'Nama kolom
.CellFontBold = True
.ColWidth(0) = 400 'Lebar Kolom
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
.Col = 1 'Kolom Kedua
.Row = 0
.Text = "Nomor Faktur" 'Nama kolom
.CellFontBold = True
.ColWidth(1) = 1500 'Lebar Kolom
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
.Col = 2
.Row = 0
.Text = "Tanggal Faktur"
.CellFontBold = True
.ColWidth(2) = 1500
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
.Col = 3
.Row = 0
.Text = "Tanggal JTempo"
.CellFontBold = True
.ColWidth(3) = 1500
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
.Col = 4
.Row = 0
.Text = "Halaman"
.CellFontBold = True
.ColWidth(4) = 1500
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
.Col = 5
.Row = 0
.Text = "Nomor PO"
.CellFontBold = True
.ColWidth(5) = 1500
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
.Col = 6
.Row = 0
.Text = "Nomor Order"
.CellFontBold = True
.ColWidth(6) = 1500
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
.Col = 7
.Row = 0
.Text = "No. Customer"
.CellFontBold = True
.ColWidth(7) = 2500
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
.Col = 8
.Row = 0
.Text = "Nama Customer"
.CellFontBold = True
.ColWidth(8) = 2500
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
.Col = 9
.Row = 0
.Text = "Nama Perusahaan"
.CellFontBold = True
.ColWidth(9) = 2500
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
.Col = 10
.Row = 0
.Text = "Kode Barang"
.CellFontBold = True
.ColWidth(10) = 1500
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
.Col = 11
.Row = 0
.Text = "Nama Barang"
.CellFontBold = True
.ColWidth(11) = 3000
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
.Col = 12
.Row = 0
.Text = "Berat Bersih"
.CellFontBold = True
.ColWidth(12) = 1500
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
.Col = 13
.Row = 0
.Text = "Satuan/Isi"
.CellFontBold = True
.ColWidth(13) = 1500
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
.Col = 14
.Row = 0
.Text = "Jumlah Barang"
.CellFontBold = True
.ColWidth(14) = 1500
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
.Col = 15
.Row = 0
.Text = "Tanggal Daluwarsa"
.CellFontBold = True
.ColWidth(15) = 1500
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
.Col = 16
.Row = 0
.Text = "Harga1 + PPN"
.CellFontBold = True
.ColWidth(16) = 1500
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
.Col = 17
.Row = 0
.Text = "Harga1 - PPN"
.CellFontBold = True
.ColWidth(17) = 1500
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
.Col = 18
.Row = 0
.Text = "Harga1 - PPN"
.CellFontBold = True
.ColWidth(18) = 1500
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
.Col = 19
.Row = 0
.Text = "Keterangan"
.CellFontBold = True
.ColWidth(19) = 1500
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
.Col = 20
.Row = 0
.Text = "Rp. Discount"
.CellFontBold = True
.ColWidth(20) = 1500
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
.Col = 21
.Row = 0
.Text = "Jumlah"
.CellFontBold = True
.ColWidth(21) = 1500
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
.Col = 22
.Row = 0
.Text = "Total Discount"
.CellFontBold = True
.ColWidth(22) = 1500
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
.Col = 23
.Row = 0
.Text = "PPN"
.CellFontBold = True
.ColWidth(23) = 1500
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
.Col = 24
.Row = 0
.Text = "Total Harga"
.CellFontBold = True
.ColWidth(24) = 1500
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
.Col = 25
.Row = 0
.Text = "NIS"
.CellFontBold = True
.ColWidth(25) = 1500
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
.Col = 26
.Row = 0
.Text = "Nama Salesman"
.CellFontBold = True
.ColWidth(26) = 1500
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
.Col = 27
.Row = 0
.Text = "Bulan"
.CellFontBold = True
.ColWidth(27) = 1500
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
.Col = 28
.Row = 0
.Text = "Tahun"
.CellFontBold = True
.ColWidth(28) = 1500
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
End With
End Sub
Sub TampilGridPenjualan1()
Dim Baris As Integer
Gridpenjualan1.Clear
Call AturGridPenjualan1
Gridpenjualan1.Rows = 5
Baris = 0
Set rsPenjualan = New ADODB.Recordset
rsPenjualan.Open "SELECT * FROM Penjualan", _
dbConn, adOpenDynamic, adLockOptimistic
If rsPenjualan.BOF Then
Exit Sub
Else
With rsPenjualan
.MoveFirst
Do While Not .EOF
On Error Resume Next
Baris = Baris + 1
Gridpenjualan1.Rows = Baris + 1
Gridpenjualan1.TextMatrix(Baris, 0) = Baris
Gridpenjualan1.TextMatrix(Baris, 1) = !NomorFaktur
Gridpenjualan1.TextMatrix(Baris, 2) = !TanggalFaktur
Gridpenjualan1.TextMatrix(Baris, 3) = !TanggalJatuhTempo
Gridpenjualan1.TextMatrix(Baris, 4) = !Halaman
Gridpenjualan1.TextMatrix(Baris, 5) = !NomorPO
Gridpenjualan1.TextMatrix(Baris, 6) = !NomorOrder
Gridpenjualan1.TextMatrix(Baris, 7) = !nomorCustomer
Gridpenjualan1.TextMatrix(Baris, 8) = !NamaCustomer
Gridpenjualan1.TextMatrix(Baris, 9) = !Perusahaan
Gridpenjualan1.TextMatrix(Baris, 10) = !Pcode
Gridpenjualan1.TextMatrix(Baris, 11) = !NamaBarang
Gridpenjualan1.TextMatrix(Baris, 12) = !kuantitas
Gridpenjualan1.TextMatrix(Baris, 13) = !SatuanatauIsi
Gridpenjualan1.TextMatrix(Baris, 14) = !JumlahBarang
Gridpenjualan1.TextMatrix(Baris, 15) = !TanggalDaluwarsa
Gridpenjualan1.TextMatrix(Baris, 16) = !Harga1TambahPPN
Gridpenjualan1.TextMatrix(Baris, 17) = !Harga1KurangPPN
Gridpenjualan1.TextMatrix(Baris, 18) = !JumlahRp
Gridpenjualan1.TextMatrix(Baris, 19) = !Keterangan
Gridpenjualan1.TextMatrix(Baris, 20) = !RpDisc
Gridpenjualan1.TextMatrix(Baris, 21) = !Jumlah
Gridpenjualan1.TextMatrix(Baris, 22) = !TotalDiscount
Gridpenjualan1.TextMatrix(Baris, 23) = !PPN
Gridpenjualan1.TextMatrix(Baris, 24) = !NilaiFaktur
Gridpenjualan1.TextMatrix(Baris, 25) = !nomorIndukSalesman
Gridpenjualan1.TextMatrix(Baris, 26) = !NamaSalesman
Gridpenjualan1.TextMatrix(Baris, 27) = !bulan
Gridpenjualan1.TextMatrix(Baris, 28) = !tahun
.MoveNext
Loop
End With
End If
End Sub
Private Sub txtTotalDiscount_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtPPN.SetFocus
txtPPN.Text = txtRpDisc.Text
End If
End Sub
Sub cbo3()
If rsBarang.State = 1 Then rsBarang.Close
rsBarang.Open "SELECT Pcode FROM barang", dbConn, adOpenStatic
With rsBarang
txtPcode.Clear
If .RecordCount > 0 Then .MoveFirst
For X = 1 To .RecordCount
txtPcode.AddItem !Pcode
If Not .EOF Then .MoveNext
Next X
End With
End Sub
Sub IsiComboBarang()
Dim X As Integer
Set rsBarang = New ADODB.Recordset
rsQuery = "SELECT Pcode from Barang" ' where NomorFaktur = '" & txtNomorFaktur(0).Text & "'"
rsBarang.Open rsQuery, dbConn, adOpenStatic, adLockOptimistic
With rsBarang
txtPcode.Clear
If .RecordCount > 0 Then .MoveFirst
For X = 1 To .RecordCount
txtPcode.AddItem !Pcode
If Not .EOF Then .MoveNext
Next X
End With
End Sub
Public Sub cbo2()
If rsSalesman.State = 1 Then rsSalesman.Close
rsSalesman.Open "SELECT nomorIndukSalesman FROM Salesman", dbConn, adOpenStatic
With rsSalesman
txtNomorIndukSalesman.Clear
If .RecordCount > 0 Then .MoveFirst
For X = 1 To .RecordCount
txtNomorIndukSalesman.AddItem !nomorIndukSalesman
If Not .EOF Then .MoveNext
Next X
End With
End Sub
Sub IsiComboSalesman()
Dim X As Integer
Set rsSalesman = New ADODB.Recordset
rsQuery = "SELECT nomorIndukSalesman from Salesman" ' where NomorFaktur = '" & txtNomorFaktur(0).Text & "'"
rsSalesman.Open rsQuery, dbConn, adOpenStatic, adLockOptimistic
With rsSalesman
txtNomorIndukSalesman.Clear
If .RecordCount > 0 Then .MoveFirst
For X = 1 To .RecordCount
txtNomorIndukSalesman.AddItem !nomorIndukSalesman
If Not .EOF Then .MoveNext
Next X
End With
End Sub
Sub IsiComboCustomer()
Dim X As Integer
Set rsCustomer = New ADODB.Recordset
rsQuery = "SELECT nomorCustomer from Customer" ' where NomorFaktur = '" & txtNomorFaktur(0).Text & "'"
rsCustomer.Open rsQuery, dbConn, adOpenStatic, adLockOptimistic
With rsCustomer
txtNomorCustomer.Clear
If .RecordCount > 0 Then .MoveFirst
For X = 1 To .RecordCount
txtNomorCustomer.AddItem !nomorCustomer
If Not .EOF Then .MoveNext
Next X
End With
End Sub
Public Sub cbo1()
Dim X As Integer
Set rsCustomer = New ADODB.Recordset
rsQuery = "SELECT nomorCustomer from Customer" ' where NomorFaktur = '" & txtNomorFaktur(0).Text & "'"
rsCustomer.Open rsQuery, dbConn, adOpenStatic, adLockOptimistic
With rsCustomer
txtNomorCustomer.Clear
If .RecordCount > 0 Then .MoveFirst
For X = 1 To .RecordCount
txtNomorCustomer.AddItem !nomorCustomer
If Not .EOF Then .MoveNext
Next X
End With
End Sub
dan jika ada yang tertarik atau mungkin kurang paham dengan apa yang saya jelaskan maka untuk memudahkan memperlajari program ini pengunjung tinggal download folder di http://www.4shared.com/file/h-qZQSC7/TGS.html
JANGAN LUPA UNTUK MENINGGALKAN KOMENTAR, SEBAGAI BLOGER ATAU PENGUNJUNG YANG BAIK!!!!!!!!!!!!!!
DAN APA BILA ANDA INGIN MENGCOPY ARTIKEL SAYA DIHARAP MENCANTUMKAN ALAMAT BLOG SAYA........!!!!!!!!!!!!!
0 komentar:
Posting Komentar