1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
| Imports System.Data.SqlClient
Public Class ACLoginForm
Private ReadOnly SQL As New SqlControl
Private AuthUser As String
Dim ReadOnly firstvalue As Decimal
Dim ReadOnly secondvalue As Decimal
Dim ReadOnly answer As Decimal
Dim ReadOnly operations As String
Public SQLDS As DataSet
Private Sub CmdLogin_Click(sender As Object, e As EventArgs) Handles cmdLogin.Click
If SQL.HasConnection = True Then
If IsAuthenticated() = True Then
AuthUser = txtUser.Text
txtUser.Clear()
txtPass.Clear()
ShowPasswordCheckBox.Checked = False
Me.Hide()
Dim formMain As New MainForm
formMain.ShowDialog()
End If
End If
End Sub
Private Function IsAuthenticated() As Boolean
'CLEAR EXISTING RECORD
If SQL.SQLDS IsNot Nothing Then
SQL.SQLDS.Clear()
End If
SQL.RunQuery("SELECT Count(username) As UserCount " & _
"FROM UserLogin " & _
"WHERE username = '" & txtUser.Text & "' " & _
" AND password ='" & txtPass.Text & "' COLLATE SQL_Latin1_General_CP1_CS_AS ")
If SQL.SQLDS.Tables(0).Rows(0).Item("UserCount") = 1 Then
'MsgBox("Valid user credentials, WELCOME in AUTO Cash register!", MsgBoxStyle.Critical, "LOGIN SUCCESS")
Return True
Else
'MsgBox("Invalid user credentials, please try again!", MsgBoxStyle.Critical, "LOGIN FAILED")
Return False
end if
End Function
Private Function Empl1Exist() As Boolean
'CLEAR EXISTING RECORD
If SQL.SQLDS IsNot Nothing Then
SQL.SQLDS.Clear()
End If
SQL.RunQuery("SELECT Count(AutoID) As DataCount " & _
"FROM Empl1Query ")
If SQL.SQLDS.Tables(0).Rows(0).Item("DataCount") = 1 Then
Return True
Else
Return False
end if
End Function
Private Sub AcLogin_Activated(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Activated
If Empl1Exist() = True then
Empl1.BackgroundImage = My.Resources.EMPL1
SQL.RunQuery("SELECT AutoID, FirstName, LastName, Active FROM Employees WHERE AutoID = 1 And Active =1")
'Me.FirstName1.Text = SQL.SQLDS("FirstName").ToString() ' I tried this and no success FOR NOTE ONLY
'Me.LastName1.Text = SQL.SQLDS("LastName").ToString() ' I tried this and no success FOR NOTE ONLY
Me.FirstName1.Text = "Claude"
Me.LastName1.Text = "Larocque"
Else
Empl1.Visible=False
Me.FirstName1.Visible=False
Me.LastName1.Visible=False
End If
End Sub
Private Sub OpenRegisterFormLinkLabel_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles OpenRegisterFormLinkLabel.LinkClicked
RegisterForm.ShowDialog()
End Sub
Public Sub ShowPasswordCheckBox_CheckedChanged(sender As Object, e As EventArgs) Handles ShowPasswordCheckBox.CheckedChanged
With ShowPasswordCheckBox
If .Checked Then
txtPass.UseSystemPasswordChar = False
Else
txtPass.UseSystemPasswordChar = True
End If
End With
End Sub
Private Sub BtnCancel_Click(sender As Object, e As EventArgs) Handles BtnCancel.Click
application.Exit()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If Label1.Text = "0" Then
Label1.Text = "1"
Else
Label1.Text = Label1.Text + "1"
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
If Label1.Text = "0" Then
Label1.Text = "2"
Else
Label1.Text = Label1.Text + "2"
End If
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
If Label1.Text = "0" Then
Label1.Text = "3"
Else
Label1.Text = Label1.Text + "3"
End If
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
If Label1.Text = "0" Then
Label1.Text = "4"
Else
Label1.Text = Label1.Text + "4"
End If
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
If Label1.Text = "0" Then
Label1.Text = "5"
Else
Label1.Text = Label1.Text + "5"
End If
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
If Label1.Text = "0" Then
Label1.Text = "6"
Else
Label1.Text = Label1.Text + "6"
End If
End Sub
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
If Label1.Text = "0" Then
Label1.Text = "7"
Else
Label1.Text = Label1.Text + "7"
End If
End Sub
Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
If Label1.Text = "0" Then
Label1.Text = "8"
Else
Label1.Text = Label1.Text + "8"
End If
End Sub
Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
If Label1.Text = "0" Then
Label1.Text = "9"
Else
Label1.Text = Label1.Text + "9"
End If
End Sub
Private Sub ButtonOK_Click(sender As Object, e As EventArgs) Handles ButtonOK.Click
Me.txtPass.Text = Label1.Text
Me.Label1.Text="0"
End Sub
End Class |
Partager