📄 adlog.vb
字号:
' Human Resources Management System (HRMS)
'
' Programmed by: Nura Tijjani Abubakar (ntagrafix@yahoo.com)
' Submitted to: Mr. Ravindran Kanapathy
'
' Oxford Brookes University (OBU)
' Final Year Project (November, 2007)
Imports System.Data.OleDb
Public Class adLog
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 OleDbDataAdapter1 As System.Data.OleDb.OleDbDataAdapter
Friend WithEvents OleDbSelectCommand1 As System.Data.OleDb.OleDbCommand
Friend WithEvents OleDbInsertCommand1 As System.Data.OleDb.OleDbCommand
Friend WithEvents OleDbUpdateCommand1 As System.Data.OleDb.OleDbCommand
Friend WithEvents OleDbDeleteCommand1 As System.Data.OleDb.OleDbCommand
Friend WithEvents OleDbConnection1 As System.Data.OleDb.OleDbConnection
Friend WithEvents OleDbCommand1 As System.Data.OleDb.OleDbCommand
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Public WithEvents Button1 As System.Windows.Forms.Button
Public WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Label1 As System.Windows.Forms.Label
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(adLog))
Me.OleDbDataAdapter1 = New System.Data.OleDb.OleDbDataAdapter
Me.OleDbDeleteCommand1 = New System.Data.OleDb.OleDbCommand
Me.OleDbConnection1 = New System.Data.OleDb.OleDbConnection
Me.OleDbInsertCommand1 = New System.Data.OleDb.OleDbCommand
Me.OleDbSelectCommand1 = New System.Data.OleDb.OleDbCommand
Me.OleDbUpdateCommand1 = New System.Data.OleDb.OleDbCommand
Me.OleDbCommand1 = New System.Data.OleDb.OleDbCommand
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'OleDbDataAdapter1
'
Me.OleDbDataAdapter1.DeleteCommand = Me.OleDbDeleteCommand1
Me.OleDbDataAdapter1.InsertCommand = Me.OleDbInsertCommand1
Me.OleDbDataAdapter1.SelectCommand = Me.OleDbSelectCommand1
Me.OleDbDataAdapter1.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "tblSysLogin", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("usr_name", "usr_name"), New System.Data.Common.DataColumnMapping("usr_pass", "usr_pass")})})
Me.OleDbDataAdapter1.UpdateCommand = Me.OleDbUpdateCommand1
'
'OleDbDeleteCommand1
'
Me.OleDbDeleteCommand1.CommandText = "DELETE FROM tblSysLogin WHERE (usr_name = ?) AND (usr_pass = ? OR ? IS NULL AND u" & _
"sr_pass IS NULL)"
Me.OleDbDeleteCommand1.Connection = Me.OleDbConnection1
Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_usr_name", System.Data.OleDb.OleDbType.VarWChar, 15, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "usr_name", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_usr_pass", System.Data.OleDb.OleDbType.VarWChar, 20, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "usr_pass", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_usr_pass1", System.Data.OleDb.OleDbType.VarWChar, 20, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "usr_pass", System.Data.DataRowVersion.Original, Nothing))
'
'OleDbConnection1
'
Me.OleDbConnection1.ConnectionString = "Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database L" & _
"ocking Mode=1;Data Source=""C:\Program Files\HRMS\bin\EIS.mdb"";Jet OLEDB:Engine T" & _
"ype=5;Provider=""Microsoft.Jet.OLEDB.4.0"";Jet OLEDB:System database=;Jet OLEDB:SF" & _
"P=False;persist security info=False;Extended Properties=;Mode=Share Deny None;Je" & _
"t OLEDB:Encrypt Database=False;Jet OLEDB:Create System Database=False;Jet OLEDB:" & _
"Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=Fals" & _
"e;User ID=Admin;Jet OLEDB:Global Bulk Transactions=1"
'
'OleDbInsertCommand1
'
Me.OleDbInsertCommand1.CommandText = "INSERT INTO tblSysLogin(usr_name, usr_pass) VALUES (?, ?)"
Me.OleDbInsertCommand1.Connection = Me.OleDbConnection1
Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("usr_name", System.Data.OleDb.OleDbType.VarWChar, 15, "usr_name"))
Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("usr_pass", System.Data.OleDb.OleDbType.VarWChar, 20, "usr_pass"))
'
'OleDbSelectCommand1
'
Me.OleDbSelectCommand1.CommandText = "SELECT usr_name, usr_pass FROM tblSysLogin"
Me.OleDbSelectCommand1.Connection = Me.OleDbConnection1
'
'OleDbUpdateCommand1
'
Me.OleDbUpdateCommand1.CommandText = "UPDATE tblSysLogin SET usr_name = ?, usr_pass = ? WHERE (usr_name = ?) AND (usr_p" & _
"ass = ? OR ? IS NULL AND usr_pass IS NULL)"
Me.OleDbUpdateCommand1.Connection = Me.OleDbConnection1
Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("usr_name", System.Data.OleDb.OleDbType.VarWChar, 15, "usr_name"))
Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("usr_pass", System.Data.OleDb.OleDbType.VarWChar, 20, "usr_pass"))
Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_usr_name", System.Data.OleDb.OleDbType.VarWChar, 15, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "usr_name", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_usr_pass", System.Data.OleDb.OleDbType.VarWChar, 20, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "usr_pass", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_usr_pass1", System.Data.OleDb.OleDbType.VarWChar, 20, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "usr_pass", System.Data.DataRowVersion.Original, Nothing))
'
'TextBox1
'
Me.TextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.TextBox1.Location = New System.Drawing.Point(96, 16)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(104, 20)
Me.TextBox1.TabIndex = 1
Me.TextBox1.Text = ""
'
'TextBox2
'
Me.TextBox2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.TextBox2.Location = New System.Drawing.Point(96, 40)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.TextBox2.Size = New System.Drawing.Size(104, 20)
Me.TextBox2.TabIndex = 2
Me.TextBox2.Text = ""
'
'Button1
'
Me.Button1.BackColor = System.Drawing.Color.Chocolate
Me.Button1.Cursor = System.Windows.Forms.Cursors.Default
Me.Button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Button1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Button1.ForeColor = System.Drawing.SystemColors.ControlText
Me.Button1.Location = New System.Drawing.Point(37, 72)
Me.Button1.Name = "Button1"
Me.Button1.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.Button1.Size = New System.Drawing.Size(64, 23)
Me.Button1.TabIndex = 3
Me.Button1.Text = "&LogIn"
'
'Button2
'
Me.Button2.BackColor = System.Drawing.Color.Chocolate
Me.Button2.Cursor = System.Windows.Forms.Cursors.Default
Me.Button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Button2.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Button2.ForeColor = System.Drawing.SystemColors.ControlText
Me.Button2.Location = New System.Drawing.Point(125, 72)
Me.Button2.Name = "Button2"
Me.Button2.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.Button2.Size = New System.Drawing.Size(64, 23)
Me.Button2.TabIndex = 4
Me.Button2.Text = "&Cancel"
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(27, 16)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(64, 23)
Me.Label1.TabIndex = 5
Me.Label1.Text = "UserName:"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'Label2
'
Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label2.Location = New System.Drawing.Point(27, 40)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(64, 23)
Me.Label2.TabIndex = 5
Me.Label2.Text = "Password:"
Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'adLog
'
Me.AcceptButton = Me.Button1
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(226, 111)
Me.ControlBox = False
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Label2)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "adLog"
Me.ShowInTaskbar = False
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = " HRMS: System Admin"
Me.ResumeLayout(False)
End Sub
#End Region
Public sConn As OleDbConnection
Dim lDS As DataSet = New DataSet
Dim lDA As OleDbDataAdapter = New OleDbDataAdapter
Dim lDR As DataRow
Private Sub adLog_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
sConn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\EIS.mdb;Persist Security Info=False")
End Sub
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
sConn.Open()
lDA.SelectCommand = New OleDbCommand("SELECT * FROM tblSysLogin WHERE usr_name='" & TextBox1.Text.ToString & "' and usr_pass='" & TextBox2.Text & "'", sConn)
lDS.Clear()
lDA.Fill(lDS)
If lDS.Tables(0).Rows.Count > 0 Then
Dim fx As New frmAddAdmin
bExitApplication = False
Me.Close()
fx.Show()
Else
MsgBox("Sorry, you do NOT have Administrative permission. Please contact the System Administrator.", MsgBoxStyle.Exclamation + MsgBoxStyle.OKOnly, "Access Denied")
TextBox1.Focus()
End If
lDR = Nothing
lDS.Dispose()
lDA.Dispose()
sConn.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -