-component yang di gunakan common dialog untuk gambar
-buat foto make image, component nya windows common contro 6.0
-terus di database foto itu nya text
siapkan folder buat nampung foto
codingan nya di bawah iini
jika kurang jelas silahkan download project ( Download )
Dim yedit As Boolean
Dim vimg As Boolean
Private Sub cmdadd_Click()
cmdsave.Enabled = True
cmdadd.Enabled = False
cmdfind.Enabled = False
cmddelete.Enabled = False
cmdcancel.Enabled = True
End Sub
Private Sub cmdcancel_Click()
cmdsave.Enabled = False
cmdadd.Enabled = True
cmdfind.Enabled = True
End Sub
Private Sub cmdclose_Click()
Unload Me
End Sub
Private Sub cmddelete_Click()
Dim tanya As String
Dim ssql As String
tanya = MsgBox("Apakah Anda Yakin akan menghapus data ini ?", vbYesNo, "konfirmasi")
If tanya = vbYes Then
ssql = "Delete * from siswa where NIS='" & txtnis & "'"
conndb.Execute (ssql)
MsgBox " Data Telah terhapus ", vbInformation, " konfirmasi"
bersih
End If
End Sub
Private Sub cmdfind_Click()
Dim cari As String
Dim ssql As String
Dim rsis As Recordset
cari = InputBox("Masukan NO Anggota Yang di Cari ", " Pencarian")
ssql = " select * from siswa where nis='" & cari & " '"
Set rsis = conndb.Execute(ssql)
If rsis.EOF Then
MsgBox " Data Tidak di temukan ", vbInformation, "Pencarian"
Exit Sub
End If
txttgl.Enabled = True
yedit = True
txtnis = rsis![nis]
txtnamasiswa = rsis![nama]
txtkelas = rsis![kelas]
txttgl = Format(rsis![tgl_lahir], "dd-mm-yyyy")
Txtnamafoto = rsis("foto")
strPictureName = rsis("foto") & ""
imgfoto.Picture = LoadPicture(App.Path & "\foto\" & strPictureName)
cmdcancel.Enabled = False
cmddelete.Enabled = True
cmdupdate.Enabled = True
cmdadd.Enabled = False
End Sub
Private Sub cmdfoto_Click()
Dim rsis As Recordset
cdi.ShowOpen
imgfoto.Picture = LoadPicture(cdi.FileName)
vimg = True
Txtnamafoto = "nama_" & txtnamasiswa.Text & ".jpeg"
End Sub
Private Sub cmdsave_Click()
If txtnis.Text = "" Then
MsgBox " Masukan Nis "
End If
If txtnamasiswa.Text = "" Then
MsgBox " nama siswa masih kosong "
End If
If txttgl = "__-__-____" Then
MsgBox " Masukan Tanggal lahir "
End If
If txtkelas.Text = "" Then
MsgBox " Kelas Masih kosong "
If imgfoto.Picture = LoadPicture("") Then
MsgBox " masukan Foto "
End If
Exit Sub
Else
saverec
End If
imgfoto.Picture = Nothing
End Sub
Sub simpan_gambar()
SavePicture imgfoto.Picture, App.Path & "\foto\nama_" & txtnamasiswa.Text & ".jpeg"
End Sub
Private Sub editrec()
Dim ssql As String
ssql = "Update siswa Set nama ='" & txtnamasiswa & _
"',tgl_lahir ='" & Format(txttgl, "dd/mm/yyyy") & _
"',kelas ='" & txtkelas & _
"',foto ='" & Txtnamafoto & _
"' where nis ='" & txtnis & "'"
conndb.Execute (ssql)
End Sub
Public Sub saverec()
rssiswa.AddNew
rssiswa![nis] = txtnis
rssiswa![nama] = txtnamasiswa
rssiswa![tgl_lahir] = Format(txttgl, "MM/dd/yyyy")
rssiswa![kelas] = txtkelas
rssiswa![foto] = Txtnamafoto
rssiswa.Update
simpan_gambar
End Sub
Private Sub Command1_Click()
If yedit = False Then
saverec
Else
editrec
End If
simpan_gambar
End Sub
Private Sub Form_Load()
opensis
End Sub
Sub bersih()
txtnis.Text = ""
txtnamasiswa.Text = ""
txttgl.Enabled = False
txtkelas.Text = ""
imgfoto.Picture = LoadPicture("")
End Sub
MOdule
Public conndb As New ADODB.Connection
Public rssiswa As Recordset
Public Sub main()
Set rssiswa = New ADODB.Recordset
OpenDB
Form1.Show
End Sub
Public Sub OpenDB()
Dim mypath As String
mypath = App.Path + "\perpus.mdb"
conndb.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mypath & ";Persist Security Info=False"
End Sub
Public Sub opensis()
rssiswa.Open "siswa", conndb, adOpenDynamic, adLockOptimistic
End Sub
Public Sub cleartext(myform As Form)
Dim ctrl As Control
For Each ctrl In myform
If TypeName(ctrl) = "TextBox" Then ctrl.Text = ""
If TypeName(ctrl) = "ComboBox" Then ctrl.Text = ""
Next
End Sub
Perhatian: Yuk Baca Artikel bagus di Nurul Musthofa
mantap kk :a1
ReplyDelete:a7
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteKalau pengen nampilin siapa yang sedang login gimana?
ReplyDeleteloginnya pake DB.
link broken gan
ReplyDeleteminta link alternativ nya gan
sudah di perbaiki
Delete