Design Login
Coding :
Imports System.Data.Odbc
Public Class Login
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Koneksi()
cmd = New OdbcCommand("select * from Kasir where Nama_Kasir='" & TextBox1.Text & "' and Pass_Kasir='" & TextBox2.Text & "'", Conn)
rd = cmd.ExecuteReader
rd.Read()
If rd.HasRows Then
Me.Visible = False
MenuUtama.Show()
MenuUtama.Panel1.Text = rd.GetString(0)
MenuUtama.Panel2.Text = rd.GetString(1)
MenuUtama.Panel3.Text = rd.GetString(3)
If MenuUtama.Panel3.Text <> "ADMIN" Then
MenuUtama.KasirToolStripMenuItem.Enabled = False
Else
MenuUtama.KasirToolStripMenuItem.Enabled = True
End If
Else
MsgBox("login salah, periksan kembali user name dan password")
TextBox1.Focus()
End If
End Sub
Private Sub btnTutup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTutup.Click
Me.Close()
End
End Sub
Private Sub Login_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
If Asc(e.KeyChar) = Keys.Enter Then
SendKeys.Send("{tab}")
End If
End Sub
End Class
Imports System.Data.Odbc
Module Module1
Public Conn As OdbcConnection
Public da As OdbcDataAdapter
Public ds As DataSet
Public cmd As OdbcCommand
Public rd As OdbcDataReader
Public str As String
Public Sub Koneksi()
str = "Dsn=dbservicekendaraan;uid=root;server=localhost;database=dbservicekendaraan;port=3306"
Conn = New OdbcConnection(str)
If Conn.State = ConnectionState.Closed Then
Conn.Open()
End If
End Sub
End Module
0 Post a Comment:
Post a Comment