Login Form

Login Form




Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
' Try
'If smode = "N" Then
If txtUsername.Text = "" Then
MsgBox("Enter UserName !..", MsgBoxStyle.Information)
txtUsername.Focus()
Exit Sub
End If
If txtPassword.Text = "" Then
MsgBox("Enter Password!..", MsgBoxStyle.Information)
txtPassword.Focus()
Exit Sub
End If

If btnLogin.Text = "Create" Then
cmd = New SqlClient.SqlCommand("select USERNAME from LOGIN where USERNAME= ' " & txtUsername.Text & " '", conn)
sda = New SqlDataAdapter(cmd)
Dim ds As New DataSet()
sda.Fill(ds, "LOGIN")

If ds.Tables(0).Rows.Count = 0 Then
cmd1 = New SqlCommand("insert into Login Values(' " & txtUsername.Text & " ',' " & txtPassword.Text & " ')", conn)
cmd1.ExecuteNonQuery()
MsgBox("New Account Created..", MsgBoxStyle.Information)
txtUsername.Text = ""
txtPassword.Text = ""
LinkLabel1.Enabled = True
btnLogin.Text = "Login"
btnCancle.Text = "&Close"
Else
MsgBox("UserName Already Exists...", MsgBoxStyle.Information)
txtUsername.Text = ""
txtUsername.Focus()
End If
Else
cmd = New SqlCommand("Select USERNAME from LOGIN where USERNAME = ' " & txtUsername.Text & " '", conn)
sda = New SqlDataAdapter(cmd)
Dim ds As New DataSet()
ds.Clear()
sda.Fill(ds, "LOGIN")

If ds.Tables(0).Rows.Count = 0 Then
MsgBox("Invalid UsrName..", MsgBoxStyle.Information)
txtUsername.Text = ""
txtPassword.Text = ""
txtUsername.Focus()
Exit Sub
ElseIf ds.Tables(0).Rows.Count <> 0 Then
cmd = New SqlCommand("Select USERNAME,PASSWORD from LOGIN where USERNAME = ' " & txtUsername.Text & " ' and PASSWORD =' " & txtPassword.Text & " ' ", conn)
sda = New SqlDataAdapter(cmd)
ds.Clear()
sda.Fill(ds, "LOGIN")
If ds.Tables(0).Rows.Count = 0 Then
MsgBox("Invalid Password", MsgBoxStyle.Information)
txtPassword.Text = ""
txtPassword.Focus()
Exit Sub
Else
'MsgBox("OK")
'Dim p As New PRO
'p.Show()
'Me.Hide()

'Dim mn As New Menu
'mn.Show()
'Me.Hide()
Dim p As New P1
p.Show()
Me.Hide()
End If
End If
End If

'Catch ex As Exception
' MsgBox(ex.Message)
'End Try

End Sub


Comments

No responses found. Be the first to comment...