Imports System.Data.SqlClient
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim conn As New SqlConnection("Data source=.;initial catalog=login3;integrated security=true")
If conn.State = ConnectionState.Closed Then
conn.Open()
End If
Dim cmd As New SqlCommand("Select * from Admin where username='admin' and password=@password", conn)
cmd.Parameters.AddWithValue("password", TextBox1.Text)
Dim myreader As SqlDataReader = cmd.ExecuteReader
If (myreader.Read()) Then
username_v = myreader("username")
Form2.Show()
Me.Hide()
Else
MsgBox("Error Password")
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.Close()
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Dim conn As New SqlConnection("Data source=.;initial catalog=login3;integrated security=true")
If conn.State = ConnectionState.Closed Then
conn.Open()
End If
Dim cmd As New SqlCommand("Select * from users where username=@username and password=@password", conn)
cmd.Parameters.AddWithValue("username", TextBox3.Text)
cmd.Parameters.AddWithValue("password", TextBox2.Text)
Dim myreader As SqlDataReader = cmd.ExecuteReader
If (myreader.Read()) Then
username_v = myreader("username")
If Not myreader.IsDBNull(myreader.GetOrdinal("insert")) Then
CheckBox1.Checked = myreader("insert")
End If
If Not myreader.IsDBNull(myreader.GetOrdinal("update")) Then
CheckBox2.Checked = myreader("update")
End If
If Not myreader.IsDBNull(myreader.GetOrdinal("delete")) Then
CheckBox3.Checked = myreader("delete")
End If
If CheckBox1.Checked = False Then
Form2.Button1.Visible = False
End If
If CheckBox2.Checked = False Then
Form2.Button2.Visible = False
End If
If CheckBox3.Checked = False Then
Form2.Button3.Visible = False
End If
Form2.Show()
Me.Hide()
Else
MsgBox("Error Password")
End If
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Me.Close()
End Sub
End Class
ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ
Public Class Form2
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Label1.Text = "Welcome, " & username_v
End Sub
End Class
ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ
Module Module1
Public username_v As String
End Module
Dear Brother very Very Nice your All tutor. I am very like to your Programming Code very easy & Simple thnks. May Allah God bless You.
ReplyDelete