📄 frmlogin.vb
字号:
'************************************************************
'Copyright(c) 2007 长沙南方职业学院 信息系 软件2-061班
'All rights reserved
'
'程序名称:学校基本信息管理系统
'
'作者(原):易湘陵
'完成日期:2007-11-12
'作者(改):
'修改日期:
'************************************************************
Imports SchoolManage.FrmMain
Public Class FrmLogin
Inherits System.Windows.Forms.Form
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写 dispose 以清理组件列表。
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
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents CmbServerAddress As System.Windows.Forms.ComboBox
Friend WithEvents LabServerAddress As System.Windows.Forms.Label
Friend WithEvents LabUserName As System.Windows.Forms.Label
Friend WithEvents LabPassWord As System.Windows.Forms.Label
Friend WithEvents TxtPassWord As System.Windows.Forms.TextBox
Friend WithEvents LabImage As System.Windows.Forms.Label
Friend WithEvents BtnLogin As System.Windows.Forms.Button
Friend WithEvents BtnExit As System.Windows.Forms.Button
Friend WithEvents TxtTId As System.Windows.Forms.TextBox
Friend WithEvents LabTid As System.Windows.Forms.Label
Friend WithEvents SkinUI1 As DotNetSkin.SkinUI
Friend WithEvents TxtUserName As System.Windows.Forms.TextBox
Friend WithEvents Label1 As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(FrmLogin))
Me.CmbServerAddress = New System.Windows.Forms.ComboBox
Me.LabServerAddress = New System.Windows.Forms.Label
Me.LabUserName = New System.Windows.Forms.Label
Me.LabPassWord = New System.Windows.Forms.Label
Me.TxtPassWord = New System.Windows.Forms.TextBox
Me.LabImage = New System.Windows.Forms.Label
Me.BtnLogin = New System.Windows.Forms.Button
Me.BtnExit = New System.Windows.Forms.Button
Me.TxtTId = New System.Windows.Forms.TextBox
Me.LabTid = New System.Windows.Forms.Label
Me.SkinUI1 = New DotNetSkin.SkinUI
Me.TxtUserName = New System.Windows.Forms.TextBox
Me.Label1 = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'CmbServerAddress
'
Me.CmbServerAddress.Items.AddRange(New Object() {"localhost"})
Me.CmbServerAddress.Location = New System.Drawing.Point(120, 78)
Me.CmbServerAddress.Name = "CmbServerAddress"
Me.CmbServerAddress.Size = New System.Drawing.Size(184, 20)
Me.CmbServerAddress.TabIndex = 1
'
'LabServerAddress
'
Me.LabServerAddress.Location = New System.Drawing.Point(56, 80)
Me.LabServerAddress.Name = "LabServerAddress"
Me.LabServerAddress.Size = New System.Drawing.Size(56, 23)
Me.LabServerAddress.TabIndex = 1
Me.LabServerAddress.Text = "服务器:"
'
'LabUserName
'
Me.LabUserName.Location = New System.Drawing.Point(56, 140)
Me.LabUserName.Name = "LabUserName"
Me.LabUserName.Size = New System.Drawing.Size(56, 23)
Me.LabUserName.TabIndex = 1
Me.LabUserName.Text = "用 户:"
'
'LabPassWord
'
Me.LabPassWord.Location = New System.Drawing.Point(56, 170)
Me.LabPassWord.Name = "LabPassWord"
Me.LabPassWord.Size = New System.Drawing.Size(56, 23)
Me.LabPassWord.TabIndex = 1
Me.LabPassWord.Text = "密 码:"
'
'TxtPassWord
'
Me.TxtPassWord.Location = New System.Drawing.Point(120, 168)
Me.TxtPassWord.Name = "TxtPassWord"
Me.TxtPassWord.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.TxtPassWord.Size = New System.Drawing.Size(184, 21)
Me.TxtPassWord.TabIndex = 4
Me.TxtPassWord.Text = ""
'
'LabImage
'
Me.LabImage.Font = New System.Drawing.Font("宋体", 21.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.LabImage.Location = New System.Drawing.Point(32, 16)
Me.LabImage.Name = "LabImage"
Me.LabImage.Size = New System.Drawing.Size(312, 40)
Me.LabImage.TabIndex = 3
Me.LabImage.Text = "学校基本信息管理系统"
'
'BtnLogin
'
Me.BtnLogin.Location = New System.Drawing.Point(144, 206)
Me.BtnLogin.Name = "BtnLogin"
Me.BtnLogin.TabIndex = 4
Me.BtnLogin.Text = "登录"
'
'BtnExit
'
Me.BtnExit.Location = New System.Drawing.Point(240, 206)
Me.BtnExit.Name = "BtnExit"
Me.BtnExit.TabIndex = 4
Me.BtnExit.Text = "退出"
'
'TxtTId
'
Me.TxtTId.Location = New System.Drawing.Point(120, 110)
Me.TxtTId.Name = "TxtTId"
Me.TxtTId.ReadOnly = True
Me.TxtTId.Size = New System.Drawing.Size(184, 21)
Me.TxtTId.TabIndex = 2
Me.TxtTId.Text = ""
'
'LabTid
'
Me.LabTid.Location = New System.Drawing.Point(56, 112)
Me.LabTid.Name = "LabTid"
Me.LabTid.Size = New System.Drawing.Size(56, 23)
Me.LabTid.TabIndex = 1
Me.LabTid.Text = "编 号:"
'
'SkinUI1
'
Me.SkinUI1.Active = True
Me.SkinUI1.Button = True
Me.SkinUI1.Caption = True
Me.SkinUI1.CheckBox = True
Me.SkinUI1.ComboBox = True
Me.SkinUI1.ContextMenu = True
Me.SkinUI1.DisableTag = 999
Me.SkinUI1.Edit = True
Me.SkinUI1.GroupBox = True
Me.SkinUI1.ImageList = Nothing
Me.SkinUI1.MaiMenu = True
Me.SkinUI1.Panel = True
Me.SkinUI1.Progress = True
Me.SkinUI1.RadioButton = True
Me.SkinUI1.ScrollBar = True
Me.SkinUI1.SkinFile = "I:\Visual Studio Projects\SchoolManage\Office 2007-OFFICE07.skn"
Me.SkinUI1.SkinSteam = Nothing
Me.SkinUI1.Spin = True
Me.SkinUI1.StatusBar = True
Me.SkinUI1.SystemMenu = True
Me.SkinUI1.TabControl = True
Me.SkinUI1.Text = "Mycontrol1=edit" & Microsoft.VisualBasic.ChrW(13) & Microsoft.VisualBasic.ChrW(10) & "Mycontrol2=edit" & Microsoft.VisualBasic.ChrW(13) & Microsoft.VisualBasic.ChrW(10)
Me.SkinUI1.ToolBar = True
Me.SkinUI1.TrackBar = True
'
'TxtUserName
'
Me.TxtUserName.Location = New System.Drawing.Point(120, 136)
Me.TxtUserName.Name = "TxtUserName"
Me.TxtUserName.ReadOnly = True
Me.TxtUserName.Size = New System.Drawing.Size(184, 21)
Me.TxtUserName.TabIndex = 3
Me.TxtUserName.Text = ""
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(72, 56)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(264, 16)
Me.Label1.TabIndex = 5
Me.Label1.Text = "初始化用户名 sa 密码 sa"
'
'FrmLogin
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(376, 261)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.BtnLogin)
Me.Controls.Add(Me.LabImage)
Me.Controls.Add(Me.TxtPassWord)
Me.Controls.Add(Me.LabServerAddress)
Me.Controls.Add(Me.CmbServerAddress)
Me.Controls.Add(Me.LabUserName)
Me.Controls.Add(Me.LabPassWord)
Me.Controls.Add(Me.BtnExit)
Me.Controls.Add(Me.TxtTId)
Me.Controls.Add(Me.LabTid)
Me.Controls.Add(Me.TxtUserName)
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Name = "FrmLogin"
Me.Text = "用户登录"
Me.ResumeLayout(False)
End Sub
#End Region
Public LoginUserName As String = ""
Public LoginUserRole As String = ""
Public LoginPassWord As String = ""
Public Login_on As Boolean = False
Private Sub FrmLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
CmbServerAddress.SelectedIndex = 0
Catch ex As Exception
MsgBox("该系统需要将 SQL SERVER 2000 升级至SP2 以上版本!" & vbCrLf & ex.Message, 48, "错误")
Application.Exit()
End Try
If CmbServerAddress.Items.Count > 0 Then
CmbServerAddress.SelectedIndex = 0
End If
End Sub
Private Sub CmbServerAddress_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmbServerAddress.SelectedIndexChanged
End Sub
Private Sub BtnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnLogin.Click
Dim UserNameStr As String = TxtUserName.Text '得到用户名
Dim PassWordStr As String = TxtPassWord.Text.Trim '得到密码
Dim UserTidStr As String = TxtTId.Text.Trim '得到ID
If PassWordStr = "" Then
MsgBox("密码不能为空,请输入有效的密码!")
Exit Sub
End If
Dim Con As SqlClient.SqlConnection
Dim Sqlstr As String = "select Utype from UserInfo where (TID='" & UserTidStr & "' or Uname='" & UserNameStr & "') and Upassword='" & PassWordStr & "'"
Try
Con = New SqlClient.SqlConnection(FrmMain.DBCONN.DataConStr)
Dim Cmd As New SqlClient.SqlCommand(Sqlstr, Con)
Con.Open()
Dim MyDataRead As SqlClient.SqlDataReader = Cmd.ExecuteReader
While MyDataRead.Read
LoginUserRole = MyDataRead(0)
End While
Catch ex As Exception
MsgBox("效验用户信息出错" & vbCrLf & ex.Message, 48, "错误")
Application.Exit()
Finally
If Con.State = ConnectionState.Open Then
Con.Close()
End If
End Try
If LoginUserRole.Trim = "" Then
MsgBox("登录失败,用户名或密码错误", 64, "登录失败")
Exit Sub
Else
LoginUserName = UserNameStr '得到当前登录的用户名
LoginPassWord = PassWordStr
Login_on = True
Me.Close()
End If
End Sub
Private Sub BtnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnExit.Click
Application.Exit()
End Sub
Private Sub FrmLogin_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
If Not Login_on Then
Application.Exit()
End If
End Sub
Private Sub TxtTId_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TxtTId.Click
TxtUserName.ReadOnly = True
TxtUserName.Text = ""
TxtTId.ReadOnly = False
End Sub
Private Sub TxtUserName_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TxtUserName.Click
TxtUserName.ReadOnly = False
TxtTId.Text = ""
TxtTId.ReadOnly = True
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -