📄 frmlogin.frm
字号:
VERSION 5.00
Begin VB.Form frmLogin
BorderStyle = 3 'Fixed Dialog
Caption = "Login-jsgs"
ClientHeight = 1635
ClientLeft = 2835
ClientTop = 3480
ClientWidth = 4305
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 966.012
ScaleMode = 0 'User
ScaleWidth = 4042.162
ShowInTaskbar = 0 'False
StartUpPosition = 2 'CenterScreen
Begin VB.CommandButton cmdconn
Caption = "设置"
Height = 390
Left = 3000
TabIndex = 15
Top = 1080
Width = 1020
End
Begin VB.Frame fraStep3
Caption = "Connection Values"
Height = 2115
Index = 0
Left = 0
TabIndex = 6
Top = 1680
Width = 4230
Begin VB.TextBox txtserver
Height = 330
Left = 1140
TabIndex = 10
Top = 1620
Width = 2535
End
Begin VB.TextBox txtdatabase
Height = 300
Left = 1140
TabIndex = 9
Top = 1200
Width = 2535
End
Begin VB.TextBox txtpwd
Height = 300
IMEMode = 3 'DISABLE
Left = 1125
PasswordChar = "*"
TabIndex = 8
Top = 780
Width = 2535
End
Begin VB.TextBox txtUser
Height = 300
Left = 1140
TabIndex = 7
Top = 360
Width = 2535
End
Begin VB.Label conn
AutoSize = -1 'True
Caption = "&Server:"
Height = 195
Index = 3
Left = 300
TabIndex = 14
Top = 1620
Width = 510
End
Begin VB.Label conn
AutoSize = -1 'True
Caption = "Data&base:"
Height = 195
Index = 2
Left = 240
TabIndex = 13
Top = 1260
Width = 735
End
Begin VB.Label conn
AutoSize = -1 'True
Caption = "&Password:"
Height = 195
Index = 1
Left = 240
TabIndex = 12
Top = 840
Width = 735
End
Begin VB.Label conn
AutoSize = -1 'True
Caption = "user"
Height = 195
Index = 0
Left = 360
TabIndex = 11
Top = 360
Width = 300
End
End
Begin VB.TextBox txtuserid
Height = 345
Left = 1290
TabIndex = 1
Top = 135
Width = 2325
End
Begin VB.CommandButton cmdOK
Caption = "确定"
Default = -1 'True
Height = 390
Left = 240
TabIndex = 4
Top = 1080
Width = 1020
End
Begin VB.CommandButton cmdCancel
Cancel = -1 'True
Caption = "取消"
Height = 390
Left = 1620
TabIndex = 5
Top = 1080
Width = 1020
End
Begin VB.TextBox txtPassword
Height = 345
IMEMode = 3 'DISABLE
Left = 1290
PasswordChar = "*"
TabIndex = 3
Top = 540
Width = 2325
End
Begin VB.Label lblLabels
Caption = "用户ID"
Height = 270
Index = 0
Left = 420
TabIndex = 0
Top = 180
Width = 720
End
Begin VB.Label lblLabels
Caption = "口令"
Height = 270
Index = 1
Left = 480
TabIndex = 2
Top = 540
Width = 600
End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private oDb As New Connection
Private szuser As String
Private szdatabase As String
Private szserver As String
Private szpassword As String
Public LoginSucceeded As Boolean
Private Sub Form_Load()
Me.Width = 4400: Me.Height = 1980
Me.Top = (Screen.Height - Me.Height) / 2
Me.Left = (Screen.Width - Me.Height) / 2
txtserver.Text = "192.168.0.3"
txtpwd.Text = "hlsql5186"
'txtserver.Text = "center"
'txtpwd.Text = ""
txtdatabase.Text = "jsgsdata"
txtUser.Text = "sa"
txtuserid.Text = ""
txtPassword.Text = ""
'txtuserid.Text = "admini"
'txtPassword.Text = "51865186"
End Sub
Private Sub cmdOK_Click()
Dim password As String
szserver = txtserver.Text
szdatabase = txtdatabase.Text
szuser = txtUser.Text
szpassword = txtpwd.Text
szConnection = "Provider=SQLOLEDB.1;Persist Security Info=False" _
& ";User ID=" & szuser _
& ";Initial Catalog=" & szdatabase _
& ";Data Source=" & szserver _
& ";Password=" & szpassword
If Not oDb.State = sckOpen Then
oDb.ConnectionString = szConnection
oDb.Open
oDb.CursorLocation = adUseClient
End If
password = txtPassword.Text
userid = txtuserid.Text
szSql = "select * from awork where userid='" & userid & "'"
Set rsTempA = oDb.Execute(szSql)
If rsTempA.RecordCount > 0 Then
If IsNull(rsTempA!pass) Then
If password = "" Then
LoginSucceeded = True
Mainform.Show
Unload frmLogin
Else
MsgBox "密码不符!重试", , "登录"
txtPassword.SetFocus
SendKeys "{Home}+{End}"
End If
Else
If Trim(rsTempA!pass) <> password Then
MsgBox "密码不符!重试", , "登录"
txtPassword.SetFocus
SendKeys "{Home}+{End}"
Else
LoginSucceeded = True
Mainform.Show
Unload frmLogin
End If
End If
Else
MsgBox "用户名不符!重试", , "登录"
txtPassword.SetFocus
SendKeys "{Home}+{End}"
End If
End Sub
Private Sub cmdCancel_Click()
LoginSucceeded = False
End
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -