📄 loginform.vb
字号:
Public Class LoginForm
Private Sub LoginForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Initialize()
'填充账套下拉列表框
fillCboAccountBook()
'填充用户下拉列表框
fillCboUserName()
End Sub
Private Sub Initialize()
Me.Text = "登陆"
Me.MaximizeBox = False
End Sub
'填充账套下拉列表框
Private Sub fillCboAccountBook()
Me.CboAccountBook.DataSource = DbOperate.getDataBases
End Sub
Private Sub fillCboUserName()
End Sub
Private Sub CboAccountBook_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CboAccountBook.SelectedIndexChanged
CboUserName.DataSource = Nothing
CboUserName.Refresh()
Dim userList As List(Of S_User) = New DbOperate().getUsers(CboAccountBook.SelectedValue)
CboUserName.DataSource = userList
CboUserName.DisplayMember = "fcUserName"
CboUserName.ValueMember = "fcUserName"
Login.userList = userList
End Sub
Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
End
End Sub
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
'点击确认后登陆
Login.fcAccountBook = CboAccountBook.SelectedValue
Login.fcLoginName = CboUserName.SelectedValue
Login.fcLoginPassword = IIf(txtPassword.Text.ToString IsNot Nothing, txtPassword.Text.ToString, "")
Login.fdLoginDate = DtpLoginDate.Text
Logon(Login.userList)
End Sub
Private Sub txtPassword_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtPassword.KeyDown
If e.KeyCode = Keys.Enter Then
Login.fcAccountBook = CboAccountBook.SelectedValue
Login.fcLoginName = CboUserName.SelectedValue
Login.fcLoginPassword = IIf(txtPassword.Text.ToString IsNot Nothing, txtPassword.Text.ToString, "")
Login.fdLoginDate = DtpLoginDate.Text
Logon(Login.userList)
End If
End Sub
Private Sub Logon(ByVal userList As List(Of S_User))
For Each u As S_User In userList
If u.fcUserName = Login.fcLoginName Then
If u.fcPass = Login.fcLoginPassword Then
Dim mainForm As New MainForm
mainForm.fcConn = DbOperate.csb.ToString
mainForm.Show()
Me.Visible = False
Exit For
Else
MessageBox.Show("密码错误!", "", MessageBoxButtons.OK, MessageBoxIcon.Information)
Exit For
End If
End If
Next
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -