Form Jenis Barang
From yang
selanjutnya akan kita buat adalah form master data. Yang termasuk master di
dalam aplikasi SIP-Toko ini adalah barang,jenis barang,supplier,konsumen, sales
dan mutasi barang . Pada kesempatan kali ini kita akan membuat form jenis
barang. Kita membuat form jenis barang terlebih dahulu karena jenis barang
sangat dibutuhkan di form input barang jadi lebih baik kita membuatnya terlebih
dahulu agar tidak berkerja berulang-ulang.
Yang kita
butuhkan untuk membuatnya adalah :
Object
|
Properties
|
Setting
|
Form
|
Name
|
frmJenisBarang
|
|
BorderStyle
|
0-None
|
|
BackColor
|
&H00FFC0C0&
|
|
StartUpPosition
|
2-CenterScreen
|
Label
|
Name
|
Label1
|
|
Font
|
Calibri
|
|
ForeColor
|
&H8000000D&
|
|
Caption
|
Form Jenis Barang
|
|
Name
|
Label2
|
|
Font
|
Calibri
|
|
ForeColor
|
&H8000000D&
|
|
Caption
|
Kode Jenis
|
|
Name
|
Label3
|
|
Font
|
Calibri
|
|
ForeColor
|
&H8000000D&
|
|
Caption
|
Nama Jenis
|
|
Name
|
Label4
|
|
Font
|
Calibri
|
|
ForeColor
|
&H8000000D&
|
|
Caption
|
Cari Jenis Barang
|
Textbox
|
Name
|
TxtKode
|
|
Appearance
|
0-Flat
|
|
Height
|
330
|
|
Name
|
TxtJenis
|
|
Appearance
|
0-Flat
|
|
Height
|
330
|
VBButton
|
Name
|
CmdSave
|
|
ButtonType
|
4-Mac
|
|
Caption
|
&Save
|
|
Name
|
CmdSave
|
|
ButtonType
|
4-Mac
|
|
Caption
|
&Cancel
|
|
Name
|
vbButton1
|
|
ButtonType
|
3-WindowsXP
|
|
Caption
|
-
|
|
BackColor
|
&H00FFC0C0&
|
|
Name
|
vbButton2
|
|
ButtonType
|
3-WindowsXP
|
|
Caption
|
X
|
|
BackColor
|
&H00FFC0C0&
|
Timmer
|
Name
|
Timmer1
|
|
Interval
|
9000
|
|
Enabled
|
False
|
TDBGrid
|
Name
|
Grid
|
|
DeadAreaColor
|
&H00FFC0C0&
|
|
ColumnFooter
|
False
|
|
MarqueeStyle
|
2-HighlightCell
|
Gambar design
form jenis barang :
Tampilan saat
aplikasi dijalankan :
Source Code
Program :
Dim Edit As Boolean
Private Sub CmdCancel_Click()
Form_Load
End Sub
Private Sub CmdCari_Click()
Dim Kata() As String
Dim Kalimat As String
Dim Query As Variant
If Trim(TxtCari) = "" Then
MsgBox "Tidak Ada
Kriteria"
TxtCari.SetFocus
Exit Sub
End If
Kata() = Split(Trim(TxtCari),
" ")
For Each Query In Kata()
Kalimat = Kalimat +
" or namaJenis like '%" & Query & "%'"
Next Query
Kalimat = Mid(Kalimat, 4,
Len(Kalimat) - 3)
SQL = "select KodeJenis as [Kode Jenis],NamaJenis as [Jenis
Barang] from jenis where " & Kalimat & _
" order by
KodeJenis"
Set Grid.DataSource = DbCon.Execute(SQL)
Grid.Refresh
TxtCari = ""
Timer1.Enabled = True
End Sub
Private Sub CmdSave_Click()
If Edit Then
SQL = "Update Jenis set
NamaJenis='" & Trim(TxtJenis) & "' where KodeJenis='"
& Trim(TxtKode) & "'"
Set RSFind =
DbCon.Execute(SQL)
Form_Load
FrmDataBarang.Adodc1.Refresh
FrmDataBarang.TDBDropDown1.Refresh
FrmDataBarang.TDBDropDown1.Columns(0).Visible = False
Else
TxtKode = KodeAuto
SQL = "select kodejenis
from Jenis where NamaJenis='" & Trim(TxtJenis) & "'"
Set RSFind =
DbCon.Execute(SQL)
If RSFind.BOF Then
SQL = "insert into
Jenis values('" & Trim(TxtKode) & "','" &
Trim(TxtJenis) & "')"
DbCon.Execute SQL
Form_Load
FrmDataBarang.Adodc1.Refresh
FrmDataBarang.TDBDropDown1.Refresh
FrmDataBarang.TDBDropDown1.Columns(0).Visible = False
Else
MsgBox "Data Jenis
Ini Sudah Ada"
TxtJenis = ""
TxtJenis.SetFocus
Exit Sub
End If
End If
End Sub
Private Sub CmdSave_KeyDown(KeyCode As Integer, Shift As Integer)
Enter KeyCode
End Sub
Private Sub Form_Activate()
If Connect2 = False Then
MsgBox "User Tidak
Login"
FrmLogin.Show
End If
End Sub
Private Sub Form_Load()
TxtKode = KodeAuto
TxtKode.Locked = True
TxtJenis = ""
Edit = False
RefreshData
Timer1.Enabled = False
End Sub
Sub RefreshData()
Grid.DataSource = Nothing
SQL = "Select KodeJenis as
[Kode Jenis],NamaJenis as [Jenis Barang] from Jenis order by KodeJenis"
Set Grid.DataSource = DbCon.Execute(SQL)
Grid.Refresh
End Sub
Function KodeAuto()
'SQL = "Select No_Urut from ServiceMobil order by No_Urut"
'Set RSFind = DbCon.Execute(SQL)
'If Not RSFind.BOF Then
' KodeAuto = RSFind!no_urut
' Exit Function
'End If
SQL = "Select KodeJenis from Jenis order by KodeJenis Desc"
Set RSFind = DbCon.Execute(SQL)
If RSFind.BOF Then
KodeAuto = "0001"
Else
KodeAuto =
Format(CInt(Left(RSFind!KodeJenis, 4)) + 1, "0000")
End If
End Function
Private Sub Grid_DblClick()
Edit = True
TxtKode = Trim(Grid.Columns(0).Text)
TxtJenis = Trim(Grid.Columns(1).Text)
End Sub
Private Sub Grid_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 46 Then
If MsgBox("Jenis Barang
" & Trim(Grid.Columns(1).Text) & "Ini Akan Di Hapus??",
vbCritical + vbYesNo) = vbYes Then
SQL = "Delete from
Jenis Where kodeJenis='" & Trim(Grid.Columns(0).Text) &
"'"
DbCon.Execute SQL
Form_Load
End If
End If
End Sub
Private Sub Timer1_Timer()
Form_Load
End Sub
Private Sub TxtJenis_Change()
Enter KeyCode
End Sub
Private Sub TxtKode_KeyDown(KeyCode As Integer, Shift As Integer)
Enter KeyCode
End Sub
Private Sub vbButton1_Click()
Me.WindowState = vbMinimized
End Sub
Private Sub vbButton2_Click()
Unload Me
End Sub
Comments
Post a Comment