Membuat Form Surat Masuk
1.
Form ini terdapat 7 label, 5 textbox, 7 command, 1 DataGrid, 1 Adodc, 2 DTPicker, 1 Picture.
Objek
|
Properties
|
Pengaturan
|
Label1
|
Name
Caption
Backstyle
|
Label1
Nomor Surat
1 – Opaque
|
Label2
|
Name
Caption
Backstyle
|
Label2
Lampiran
1 – Opaque
|
Objek
|
Properties
|
Pengaturan
|
Label3
|
Name
Caption
Backstyle
|
Label3
Perihal
1 – Opaque
|
Label4
|
Name
Caption
Backstyle
|
Label4
Asal
1 – Opaque
|
Label5
|
Name
Caption
Backstyle
|
Label5
Tanggal Surat
1 – Opaque
|
Label6
|
Name
Caption
Backstyle
|
Label6
Tanggal
Diterima
1 – Opaque
|
Label7
|
Name
Caption
Backstyle
|
Label7
Lokasi
1 – Opaque
|
Txtno
|
Name
Text
|
Txtno
|
txtlampiran
|
Name
Text
|
Txtlampiran
|
txtperihal
|
Name
Text
|
Txtperihal
|
Objek
|
Properties
|
Pengaturan
|
txtasal
|
Name
Text
|
Txtasal
|
DTPicker1
|
Name
Visible
|
DTPicker1
True
|
DTPicker2
|
Name
Visible
|
DTPicker2
True
|
Lokasi
|
Name
Text
|
Lokasi
|
FNomor Surat
|
Name
Text
|
FtxtNo
|
DataGrid1
|
Name
Visible
|
DataGrid1
False
|
Script Form
Private Sub
CmdClear_Click()
Call TxtClear
End Sub
Sub TxtClear()
Txtno.Text = ""
txtlampiran.Text = ""
txtperihal.Text = ""
txtasal.Text = ""
txtlokasi.Text = ""
End Sub
Private Sub
CmdCari_Click()
If
Ftxtnomor.Text = "" Then
MsgBox "nomor surat masih kosong
!"
Else
StrSQL = "SELECT * FROM suratmasuk
WHERE nomor='" & Ftxtnomor.Text & "'"
Set Rs = conn.Execute(StrSQL)
If Rs.EOF Then
MsgBox "Data dengan nomor
""" + Ftxtnomor.Text + """ Tidak Ada ! ",
vbExclamation + vbOKOnly, "Peringatan"
Txtnomor.SetFocus
Else
Ftxtnomor.Text = "" +
Rs("nomor")
Txtno.Text = "" +
Rs("nomor")
txtlampiran.Text = "" +
Rs("lampiran")
txtperihal.Text = "" +
Rs("perihal")
txtasal.Text = "" +
Rs("asal")
DTPicker1.Value =
Rs("tanggalsurat")
DTPicker2.Value =
Rs("tanggalterima")
txtlokasi.Text = "" +
Rs("lokasi")
cmdEdit.Enabled = True
cmdHapus.Enabled = True
cmdSimpan.Enabled = True
'cmdUpdate.Enabled = True
End If
End If
End Sub
Private Sub
CmdEdit_Click()
Call
TxtKeadaan(True)
cmdUpdate.Enabled
= True
cmdSimpan.Enabled
= False
End Sub
Private Sub
cmdHapus_Click()
Dim pesan As
Integer
pesan =
MsgBox("Anda yakin ?", vbQuestion + vbYesNo, "Konfirmasi")
If pesan = 6
Then
StrSQL = "DELETE FROM suratmasuk WHERE
nomor='" & Txtno.Text & "'"
conn.Execute StrSQL
Call TxtClear
Call RefreshTampilan
MsgBox "Data Telah Berhasil Dihapus
!", vbInformation + vbOKOnly, "Informasi"
End If
End Sub
Private Sub
CmdTutup_Click()
Unload Me
FormMenu.Show
End Sub
Private Sub
CmdSimpan_Click()
If Txtno.Text =
"" Then
MsgBox "Nomor surat belum diisi",
vbExclamation + vbOKOnly, "Informasi"
Else
StrSQL = "SELECT nomor FROM suratmasuk
WHERE nomor='" & Txtno.Text & "'"
Set Rs = conn.Execute(StrSQL)
If Not Rs.EOF Then
MsgBox "Data sudah ada !",
vbInformation + vbOKOnly, "Informasi"
Txtno.SetFocus
Else
StrSQL = "INSERT INTO suratmasuk
(nomor,perihal,lampiran,asal,tanggalsurat,tanggalterima,lokasi) VALUES ('" & Txtno.Text &
"','" & txtlampiran.Text & "','" &
txtperihal.Text & "','" & txtasal.Text & "','"
& DTPicker1.Value & "','" & DTPicker2.Value &
"','" & txtlokasi.Text & "')"
conn.Execute (StrSQL)
RefreshTampilan
MsgBox "Data telah berhasil
tersimpan !", vbInformation + vbOKOnly, "Informasi"
End If
End If
End Sub
Private Sub
CmdTambah_Click()
Call TxtClear
Call TxtKeadaan(True)
Txtno.SetFocus
cmdSimpan.Enabled = True
cmdTambah.Enabled = True
End Sub
Private Sub
CmdUpdate_Click()
StrSQL =
"SELECT nomor FROM suratmasuk WHERE nomor='" & Txtno.Text &
"'"
Set Rs =
conn.Execute(StrSQL)
If (Txtno.Text
<> Txtno.Text) And (Not Rs.EOF) Then
MsgBox "Data dengan nomor " +
Txtno.Text + " Sudah ada !", vbInformation + vbOKOnly,
"Informasi"
Txtno.SetFocus
Else
StrSQL = "UPDATE suratmasuk SET
nomor='" & Txtno.Text & "',lampiran='" &
txtlampiran.Text & "', perihal='" & txtperihal.Text &
"',asal='" & txtasal.Text & "',tanggalsurat='"
& DTPicker1.Value & "',tanggalterima='" & DTPicker2.Value
& "',lokasi='" & txtlokasi.Text & "' WHERE
nomor='" & Txtno.Text & "'"
conn.Execute (StrSQL)
Call RefreshTampilan
MsgBox "Data telah berhasil diupdate
!", vbInformation + vbOKOnly, "PEMBERITAHUAAN"
End If
End Sub
Sub
RefreshTampilan()
Call Konek
Adodc1.ConnectionString
= StrConnect
Adodc1.RecordSource
= "SELECT * FROM suratmasuk"
Adodc1.Refresh
'LblJumlah.Caption
= "Jumlah Data : " & Adodc1.Recordset.RecordCount
Set
DataGrid1.DataSource = Adodc1
End Sub
Sub
TxtKeadaan(stat As Boolean)
txtasal.Enabled
= stat
DTPicker1.Enabled
= stat
DTPicker2.Enabled
= stat
txtlokasi.Enabled
= stat
Txtno.Enabled =
stat
txtperihal.Enabled
= stat
txtlampiran.Enabled
= stat
End Sub
Private Sub
DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
If
Adodc1.Recordset.BOF Or Adodc1.Recordset.EOF Then
MsgBox "Sudah akhir atau awal
data"
Else
With Adodc1
Txtno.Text =
.Recordset.Fields("nomor")
txtlampiran.Text =
.Recordset.Fields("lampiran")
txtperihal.Text = .Recordset.Fields("perihal")
txtasal.Text =
.Recordset.Fields("asal")
DTPicker1.Value =
.Recordset.Fields("tanggalsurat")
DTPicker2.Value =
.Recordset.Fields("tanggalterima")
txtlokasi.Text =
.Recordset.Fields("lokasi")
End With
cmdEdit.Enabled = True
cmdHapus.Enabled = True
End If
End Sub
Private Sub
Form_Load()
Call TxtKeadaan(False)
Call RefreshTampilan
cmdEdit.Enabled = False
cmdHapus.Enabled = False
cmdSimpan.Enabled = False
cmdUpdate.Enabled = False
Txtno.TabIndex = 0
FormMenu.Show
End Sub
Private Sub
Label2_Click()
End Sub
0 comments:
Posting Komentar
THANX.. :)