📄 frmlogin.frm
字号:
VERSION 5.00
Object = "{CE671F01-259E-40DA-92FE-95803E2ECBB5}#1.0#0"; "SmartXPButton.ocx"
Begin VB.Form FrmLogin
BackColor = &H00E7DFE7&
BorderStyle = 0 'None
Caption = "登录"
ClientHeight = 3885
ClientLeft = 0
ClientTop = 0
ClientWidth = 4755
ClipControls = 0 'False
ControlBox = 0 'False
Icon = "FrmLogin.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3885
ScaleWidth = 4755
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin SmartXPButton.XpButton cmdcancel
Height = 495
Left = 2640
TabIndex = 5
Top = 3120
Width = 1335
_ExtentX = 2355
_ExtentY = 873
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Caption = "取消(&C)"
CaptionMouseOverColor= 16711935
PictureSmoothBackColor= 15460844
ShadowColor = 8438015
ButtonPicture = "FrmLogin.frx":0A02
End
Begin SmartXPButton.XpButton cmdok
Height = 495
Left = 840
TabIndex = 4
Top = 3120
Width = 1335
_ExtentX = 2355
_ExtentY = 873
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Caption = "确定(&O)"
CaptionMouseOverColor= 16711935
PictureSmoothBackColor= 15460844
ShadowColor = 12632256
ButtonPicture = "FrmLogin.frx":30A0
End
Begin VB.TextBox txtPwd
BackColor = &H00FFFFFF&
Height = 360
IMEMode = 3 'DISABLE
Left = 2040
PasswordChar = "*"
TabIndex = 1
Top = 2280
Width = 2295
End
Begin VB.TextBox txtUser
Height = 360
IMEMode = 3 'DISABLE
Left = 2040
MaxLength = 12
TabIndex = 0
Top = 1485
Width = 2295
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "学生信息管理系统"
BeginProperty Font
Name = "隶书"
Size = 21.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00C00000&
Height = 495
Left = 960
TabIndex = 6
Top = 240
Width = 3855
End
Begin VB.Image Image3
Height = 870
Left = 0
Picture = "FrmLogin.frx":573E
Top = 0
Width = 4770
End
Begin VB.Image Image2
Height = 480
Left = 360
Picture = "FrmLogin.frx":6282
Stretch = -1 'True
Top = 2265
Width = 480
End
Begin VB.Image Image1
Height = 480
Left = 360
Picture = "FrmLogin.frx":7C04
Stretch = -1 'True
Top = 1425
Width = 480
End
Begin VB.Label lblLabels
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "密码(&P):"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Index = 1
Left = 1080
TabIndex = 2
Top = 2400
Width = 840
End
Begin VB.Label lblLabels
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "用户名:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Index = 0
Left = 1080
TabIndex = 3
Top = 1560
Width = 735
End
End
Attribute VB_Name = "FrmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim myconn As New ADODB.Connection
Dim str As String
Dim WithEvents MyRs As ADODB.Recordset
Attribute MyRs.VB_VarHelpID = -1
Dim MyStr As String
Private Sub cmdcancel_Click()
Unload Me
End Sub
Private Sub cmdok_Click()
dluser = Trim(txtUser.Text)
str = "select username,password from manager where username='" + Trim(txtUser.Text) + "'" + "and password='" + Trim(txtPwd.Text) + "'"
Set MyRs = myconn.Execute(str)
If MyRs.EOF Then '未找到用户记录
n = n + 1
If n < 3 Then
MsgBox "登录用户名或密码错误!", vbOKOnly + vbExclamation, "警告"
txtUser.Text = ""
txtPwd.Text = ""
txtUser.SetFocus
Else
MsgBox "已登录失败三次,退出系统!", vbOKOnly + vbExclamation, "错误提示"
MyRs.Close
Unload Me
End If
Else
Unload Me
myconn.Close
Load FrmMain
FrmMain.Show
End If
End Sub
Private Sub Form_Load()
On Error GoTo DbnotOpen
n = 0
Set myconn = New ADODB.Connection
myconn.ConnectionString = "driver={SQL Server};" & _
"server=(local);uid=sa;pwd=;database=student_info"
myconn.Open
'MyStr = "FileDSN=student_info.dsn;UID=sa;PWD="
'MyConn.Open MyStr
DbnotOpen:
If Err = -2147467259 Then
Set myconn = Nothing
MsgBox "连接后台数据库失败!" & vbCrLf & vbCrLf & "请检查配置是否完好,数据库student_info是否存在?", vbOKOnly + vbInformation, "学生信息管理系统"
End
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -