Imports VB = Microsoft.VisualBasic
Imports SO = System.IO
Public Class PW
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents cbUser As System.Windows.Forms.ComboBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents txtPWord As System.Windows.Forms.TextBox
Friend WithEvents btnOK As System.Windows.Forms.Button
Friend WithEvents btnCancel As System.Windows.Forms.Button
Friend WithEvents Label2 As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(PW))
Me.cbUser = New System.Windows.Forms.ComboBox
Me.Label1 = New System.Windows.Forms.Label
Me.txtPWord = New System.Windows.Forms.TextBox
Me.btnOK = New System.Windows.Forms.Button
Me.btnCancel = New System.Windows.Forms.Button
Me.Label2 = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'cbUser
'
Me.cbUser.Location = New System.Drawing.Point(24, 32)
Me.cbUser.Name = "cbUser"
Me.cbUser.Size = New System.Drawing.Size(232, 21)
Me.cbUser.TabIndex = 0
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(24, 16)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(232, 16)
Me.Label1.TabIndex = 1
Me.Label1.Text = "&User Name"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'txtPWord
'
Me.txtPWord.Location = New System.Drawing.Point(24, 88)
Me.txtPWord.Name = "txtPWord"
Me.txtPWord.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.txtPWord.Size = New System.Drawing.Size(224, 20)
Me.txtPWord.TabIndex = 2
Me.txtPWord.Text = ""
'
'btnOK
'
Me.btnOK.Cursor = System.Windows.Forms.Cursors.Hand
Me.btnOK.FlatStyle = System.Windows.Forms.FlatStyle.Popup
Me.btnOK.Location = New System.Drawing.Point(24, 136)
Me.btnOK.Name = "btnOK"
Me.btnOK.TabIndex = 3
Me.btnOK.Text = "&OK"
'
'btnCancel
'
Me.btnCancel.Cursor = System.Windows.Forms.Cursors.Hand
Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.Popup
Me.btnCancel.Location = New System.Drawing.Point(176, 136)
Me.btnCancel.Name = "btnCancel"
Me.btnCancel.TabIndex = 4
Me.btnCancel.Text = "&Cancel"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(24, 72)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(232, 16)
Me.Label2.TabIndex = 5
Me.Label2.Text = "&Password"
Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'PW
'
Me.AcceptButton = Me.btnOK
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.CancelButton = Me.btnCancel
Me.ClientSize = New System.Drawing.Size(280, 176)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.btnCancel)
Me.Controls.Add(Me.btnOK)
Me.Controls.Add(Me.txtPWord)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.cbUser)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "PW"
Me.ShowInTaskbar = False
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Enter Password"
Me.ResumeLayout(False)
End Sub
#End Region
#Region "Form"
#Region "Buttons and Events"
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
Dispose()
End Sub 'btnCancel_Click
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
User = cbUser.Text
If User = "" Then Exit Sub
Static i As Int16
If cbUser.Text = "Administrator" Then
If txtPWord.Text = "abcdef" Then
PWord = txtPWord.Text
Visible = False
'LogInToDatabase("In")
LoggedIn = True ''Boolean passed throughout program.
[b]LoadBio()'''this is where you open your main form[/b]
Exit Sub
End If
End If
PWord = GetPassword()
If i >= 3 Then End
If txtPWord.Text = PWord Then
If cbUser.Text = "Administrator" Then
PWord = "abcdef"
End If
Visible = False
'LogInToDatabase("In")
LoggedIn = True
[b]LoadBio()'''this is where you open your main form[/b]
Else
Select Case i
Case 0
If MessageBox.Show("That's strike one" & vbNewLine _
& "Would you like to try again?", "Logon", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
txtPWord.Text = String.Empty
txtPWord.Focus()
Else
End
End If
Case 1
If MessageBox.Show("That's strike two" & vbNewLine _
& "Would you like to try again?", "Logon", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
txtPWord.Text = String.Empty
txtPWord.Focus()
Else
End
End If
Case 2
MessageBox.Show("Strike 3! You're out!", "Logon", MessageBoxButtons.OK, MessageBoxIcon.Question)
End
End Select
i += 1
End If
End Sub 'btnOK_Click
Private Sub cbUser_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cbUser.KeyUp
Select Case e.KeyCode
Case Keys.Tab
cbUser.DroppedDown = False
txtPWord.Focus()
Case Keys.Enter
cbUser.DroppedDown = False
txtPWord.Focus()
Case Else
cbUser.DroppedDown = True
End Select
End Sub 'cbUser_KeyUp
Private Sub PW_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Cursor = Cursors.WaitCursor
LoadUsers()
Cursor = Cursors.Default
End Sub 'PW_Load
#End Region
Private Sub LoadUsers()
Try
Me.Cursor = Cursors.WaitCursor
Dim Con As ADODB.Connection
Dim RS As ADODB.Recordset
Dim SQL As String
Dim strCon As String
cbUser.Items.Clear()
cbUser.Items.Add("Administrator")
Con = New ADODB.Connection
RS = New ADODB.Recordset
strCon = "Provider=SQLOLEDB.1;Password=sa;Persist Security Info=True;" & _
"User ID=sa;Initial Catalog=CatalogName;Data Source=ServerName"
Con.Open(strCon)
SQL = "SELECT UserName FROM SV_Online ORDER BY UserName"
RS.Open(SQL, Con, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockBatchOptimistic, ADODB.CommandTypeEnum.adCmdText)
Do While Not RS.EOF
cbUser.Items.Add(RS(0).Value)
RS.MoveNext()
Loop
Me.Cursor = Cursors.Default
RS.Close()
Con.Close()
RS = Nothing
Con = Nothing
Catch ex As System.Exception
MessageBox.Show("You have encountered an error!" & vbCrLf & "Your Users did not load!", "Information Services", MessageBoxButtons.OK, MessageBoxIcon.Error)
SendErrorMessage("Get Password " & vbCrLf & CName & vbCrLf & ex.Message)
End Try
End Sub 'LoadUsers
#End Region
End Class