Form Supplier,Konsumen dan Sales
Form
master selanjutnya adalah form supplier,konsumen dan sales. Ketiganya memiliki
kesamaan dalam design dan alur programnya oleh karena itu saya akan
menggabungkan ketiganya dalam satu pembahasan. Fungsi dari form-form ini
hanyalah untuk input,edit dan delete data saja. Yang dibutuhkan dalam pembuatan
form-form ini adalah
Object
|
Properties
|
Setting
|
Form
|
Name
|
frmJenisBarang
|
|
BorderStyle
|
0-None
|
|
BackColor
|
&H00FFC0C0&
|
|
StartUpPosition
|
2-CenterScreen
|
Label
|
Name
|
Label1
|
|
Font
|
Calibri
|
|
ForeColor
|
&H8000000D&
|
|
Caption
|
Form Data Suplier
|
|
Name
|
Label2
|
|
Font
|
Calibri
|
|
ForeColor
|
&H8000000D&
|
|
Caption
|
Kode Supplier
|
|
Name
|
Label3
|
|
Font
|
Calibri
|
|
ForeColor
|
&H8000000D&
|
|
Caption
|
Nama Supplier
|
|
Name
|
Label4
|
|
Font
|
Calibri
|
|
ForeColor
|
&H8000000D&
|
|
Caption
|
Alamat
|
|
Name
|
Label5
|
|
Font
|
Calibri
|
|
ForeColor
|
&H8000000D&
|
|
Caption
|
Kota
|
|
Name
|
Label6
|
|
Font
|
Calibri
|
|
ForeColor
|
&H8000000D&
|
|
Caption
|
Telepon
|
|
Name
|
Label7
|
|
Font
|
Calibri
|
|
ForeColor
|
&H8000000D&
|
|
Caption
|
Cari Supplier
|
Textbox
|
Name
|
TxtKode
|
|
Appearance
|
0-Flat
|
|
Height
|
330
|
|
Name
|
TxtNama
|
|
Appearance
|
0-Flat
|
|
Height
|
330
|
|
Name
|
TxtAlamat
|
|
Appearance
|
0-Flat
|
|
Height
|
330
|
|
Name
|
TxtKota
|
|
Appearance
|
0-Flat
|
|
Height
|
330
|
|
Name
|
TxtTelepon
|
|
Appearance
|
0-Flat
|
|
Height
|
330
|
|
Name
|
TxtCari
|
|
Appearance
|
0-Flat
|
|
Height
|
330
|
VBButton
|
Name
|
CmdSave
|
|
ButtonType
|
4-Mac
|
|
Caption
|
&Save
|
|
Name
|
CmdCancel
|
|
ButtonType
|
4-Mac
|
|
Caption
|
&Cancel
|
|
Name
|
CmdCari
|
|
ButtonType
|
4-Mac
|
|
Caption
|
&Cari
|
|
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
|
Tampilan design dari
masing-masing form :
Tampilan Desgin Form Supplier
|
Tampilan Desgin Form Konsumen
|
Tampilan Desgin Form Sales
|
Tampilan form-form saat dijalankan
:
Tampilan Form Supplier
|
Tampilan Form Konsumen
|
Tampilan Form Sales
|
Source code program :
Dim Edit As
Boolean
Sub
RefreshData()
Grid.DataSource
= Nothing
SQL =
"Select KodeSupplier as [Kode Suplier],namaSupplier as [Nama Supplier],
" & _
"Alamat,Kota,Telepon from Supplier
order by KodeSupplier"
Set
Grid.DataSource = DbCon.Execute(SQL)
Grid.Refresh
End Sub
Private Sub
CmdCancel_Click()
Form_Load
End Sub
Function
CekIsi() As Boolean
If
Trim(TxtNama) = "" Then
MsgBox "Nama Masih Kosong"
CekIsi = False
ElseIf
Trim(TxtAlamat) = "" Then
MsgBox "Alamat Masih Kosong"
CekIsi = False
ElseIf
Trim(TxtKota) = "" Then
MsgBox "Kota Masih Kosong"
CekIsi = False
ElseIf
Trim(TxtTelepon) = "" Then
MsgBox "Telepon Masih Kosong"
CekIsi = False
Else
CekIsi = True
End If
End Function
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
namaSupplier like '%" & Query & "%'"
Next Query
Kalimat = Mid(Kalimat, 4, Len(Kalimat) - 3)
SQL =
"select KodeSupplier as [Kode Supplier],NamaSupplier as [Nama
Supplier],Alamat,Kota,Telepon " & _
" from Supplier where " &
Kalimat & _
" order by KodeSupplier"
Set Grid.DataSource
= DbCon.Execute(SQL)
Grid.Refresh
TxtCari =
""
Timer1.Enabled
= True
End Sub
Private Sub
CmdSave_Click()
If Not CekIsi
Then Exit Sub
If Edit Then
SQL = "update supplier set
namaSupplier='" & Trim(TxtNama) & "',alamat='" & _
Trim(TxtAlamat.Text) &
"',kota='" & Trim(TxtKota.Text) & "',telepon='"
& _
Trim(TxtTelepon.Text) & "' where
kodeSupplier='" & Trim(TxtKode.Text) & "'"
DbCon.Execute SQL
MsgBox "Data Saved"
Form_Load
ElseIf Not
Edit Then
TxtKode = KodeAuto
SQL = "Insert Into Supplier values
('" & Trim(TxtKode.Text) & "','" &
Trim(TxtNama.Text) & _
"','" & Trim(TxtAlamat.Text)
& "','" & Trim(TxtKota.Text) & "','" & _
Trim(TxtTelepon.Text) & "')"
DbCon.Execute SQL
MsgBox "Data Saved"
Form_Load
End If
End Sub
Private Sub
CmdSave_KeyDown(KeyCode As Integer, Shift As Integer)
Enter KeyCode
End Sub
Private Sub
Form_Load()
TxtKode =
KodeAuto
TxtKode.Locked
= True
Bersih
RefreshData
Edit = False
Timer1.Enabled
= False
End Sub
Sub Bersih()
TxtNama =
""
TxtAlamat =
""
TxtKota =
""
TxtTelepon =
""
End Sub
Private Sub
Grid_DblClick()
Edit = True
TxtKode =
Trim(Grid.Columns(0).Text)
TxtNama =
Trim(Grid.Columns(1).Text)
TxtAlamat =
Trim(Grid.Columns(2).Text)
TxtKota =
Trim(Grid.Columns(3).Text)
TxtTelepon =
Trim(Grid.Columns(4).Text)
End Sub
Private Sub
Grid_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode =
46 Then
If MsgBox("Supplier " &
Trim(Grid.Columns(1).Text) & " Yakin Akan Dihapus", vbYesNo +
vbCritical) = vbYes Then
SQL = "delete from supplier where
kodeSupplier='" & Trim(Grid.Columns(0).Text) & "'"
DbCon.Execute SQL
MsgBox "Data Deleted"
Form_Load
End If
End If
End Sub
Private Sub
Timer1_Timer()
RefreshData
End Sub
Private Sub
TxtAlamat_KeyDown(KeyCode As Integer, Shift As Integer)
Enter KeyCode
End Sub
Private Sub
TxtKota_KeyDown(KeyCode As Integer, Shift As Integer)
Enter KeyCode
End Sub
Private Sub
TxtNama_KeyDown(KeyCode As Integer, Shift As Integer)
Enter KeyCode
End Sub
Private Sub
TxtTelepon_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
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 KodeSupplier from Supplier order by KodeSupplier Desc"
Set RSFind =
DbCon.Execute(SQL)
If RSFind.BOF
Then
KodeAuto = "0001"
Else
KodeAuto =
Format(CInt(Left(RSFind!KodeSupplier, 4)) + 1, "0000")
End If
End Function
Comments
Post a Comment