0% found this document useful (0 votes)
49 views3 pages

Loginnafis

1. This document contains code for a login form in VB.NET. 2. It includes code to clear textboxes on a button click, display the current time on a label, show/hide passwords on a checkbox click, and connect to a database to validate login credentials. 3. Upon successful login, it hides the login form and shows a home form, retrieving and displaying user details on labels and preventing certain actions based on user type (admin, staff, borrower).

Uploaded by

goodilham477
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views3 pages

Loginnafis

1. This document contains code for a login form in VB.NET. 2. It includes code to clear textboxes on a button click, display the current time on a label, show/hide passwords on a checkbox click, and connect to a database to validate login credentials. 3. Upon successful login, it hides the login form and shows a home form, retrieving and displaying user details on labels and preventing certain actions based on user type (admin, staff, borrower).

Uploaded by

goodilham477
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Imports System.Data.

Odbc
Public Class Login

Private Sub Login_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
lbltanggal.Text = Today
End Sub

'kodingan veriabel

Dim dicoba As String

'kodingan sub

Sub hapus()
TextBox1.Clear()
TextBox1.Focus()
TextBox2.Clear()
ComboBox1.Text = "peminjam"
End Sub

'kodingan jam

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Timer1.Tick
lbljam.Text = TimeOfDay
End Sub

'kodingan checkbox

Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked Then
TextBox2.PasswordChar = ""
Else
TextBox2.PasswordChar = "*"
End If
End Sub

'kodingan button

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Or ComboBox1.Text = ""
Then
MsgBox("Harap isi semua data!!", MsgBoxStyle.Information,
"Informasi")
Else
Call koneksi()

cmd = New OdbcCommand("select * from user where id_user='" &


TextBox1.Text & "' and password='" & TextBox2.Text & "' and status='" &
ComboBox1.Text & "'", conn)
dr = cmd.ExecuteReader
dr.Read()

If Not dr.HasRows Then


cmd = New OdbcCommand("select * from user where email='" &
TextBox1.Text & "' and password='" & TextBox2.Text & "' and status='" &
ComboBox1.Text & "'", conn)
dr = cmd.ExecuteReader
dr.Read()

If Not dr.HasRows Then


dicoba = dicoba + 1
MsgBox("Login Gagal")
TextBox2.Focus()
If dicoba > 2 Then
Call hapus()
MsgBox("Percobaan Login Telah Gagal Lebih Dari 3
Kali, Silahkan Coba Lagi", MsgBoxStyle.Critical, "Peringatan")
End If
Exit Sub
End If
End If
Me.Visible = False
home.Show()
home.Label4.Text = Format("Nama : " & dr("nama_lengkap"))
home.Label5.Text = Format("Status : " & dr("status"))

home.Panel1.Text = dr("id_user")
home.Panel2.Text = dr("nama_lengkap")
home.Panel3.Text = dr("status")

cmd = New OdbcCommand("select * from koleksi_pribadi inner join


buku on koleksi_pribadi.id_buku = buku.id_buku where id_user='" &
dr("id_user") & "'", conn)
dr = cmd.ExecuteReader
home.ListBox1.Items.Clear()
Do While dr.Read
home.ListBox1.Items.Add(dr("id_buku") & Space(2) &
dr("judul"))
Loop

If home.Panel3.Text = "admin" Then


'admin (Tidak Bisa Peminjaman/Pengembalian)

ElseIf home.Panel3.Text = "petugas" Then


'Petugas (Tidak Bisa Registrasi dan
Peminjaman/Pengembalian)

ElseIf home.Panel3.Text = "peminjam" Then


'Tidak Bisa Laporan

'Hapus TabPage

home.TabControl1.TabPages.Remove(home.TabControl1.TabPages(0))
End If
Call hapus()
End If
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
End
End Sub

'kodingan register
Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label3.Click
register.Show()
Me.Hide()
End Sub
End Class

You might also like