?? frmlogin.frm
字號:
VERSION 5.00
Begin VB.Form frmLogin
BackColor = &H00FFFFFF&
BorderStyle = 0 'None
ClientHeight = 3405
ClientLeft = 2790
ClientTop = 3150
ClientWidth = 5250
ControlBox = 0 'False
LinkTopic = "Form1"
Moveable = 0 'False
ScaleHeight = 2011.784
ScaleMode = 0 'User
ScaleWidth = 4929.465
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Command2
Cancel = -1 'True
Caption = "退出"
DownPicture = "frmLogin.frx":0000
BeginProperty Font
Name = "宋體"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 2760
Picture = "frmLogin.frx":38444
Style = 1 'Graphical
TabIndex = 3
Top = 2520
Width = 1455
End
Begin VB.CommandButton Command1
BackColor = &H00808080&
Caption = "登錄"
Default = -1 'True
DownPicture = "frmLogin.frx":39A7E
BeginProperty Font
Name = "宋體"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 960
Picture = "frmLogin.frx":71EC2
Style = 1 'Graphical
TabIndex = 2
Top = 2520
Width = 1455
End
Begin VB.TextBox Text2
ForeColor = &H00000000&
Height = 270
IMEMode = 3 'DISABLE
Left = 2640
PasswordChar = "*"
TabIndex = 0
Top = 1920
Width = 1575
End
Begin VB.TextBox Text1
Height = 285
Left = 2640
TabIndex = 7
Top = 1560
Width = 1575
End
Begin VB.ComboBox Combo1
Height = 315
Left = 2640
TabIndex = 6
Top = 1200
Width = 1575
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "密 碼(&P):"
BeginProperty Font
Name = "宋體"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00400000&
Height = 255
Left = 960
TabIndex = 4
Top = 1920
Width = 1815
End
Begin VB.Label Label1
BackColor = &H80000004&
BackStyle = 0 'Transparent
Caption = "用戶名稱(&U):"
BeginProperty Font
Name = "宋體"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00400000&
Height = 255
Left = 960
TabIndex = 1
Top = 1560
Width = 1695
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "用戶類別(&B):"
BeginProperty Font
Name = "宋體"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00400000&
Height = 255
Left = 960
TabIndex = 5
Top = 1200
Width = 1695
End
Begin VB.Image Image1
Height = 3660
Left = -120
Picture = "frmLogin.frx":734FC
Top = -120
Width = 5490
End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public LoginSucceeded As Boolean
Private Sub Combo1_Click()
If Combo1.Text = "管理員" Then
Text1.Text = "administrator"
Text1.Enabled = False
Text2.SetFocus
End If
If Combo1.Text = "一般用戶" Then
Text1.Enabled = True
Text1.Text = ""
Text1.SetFocus
End If
End Sub
Private Sub Command1_Click()
If Combo1.Text = "" Then
MsgBox "請選擇用戶類別"
Exit Sub
End If
Set rsuser = New ADODB.Recordset
rsuser.Open "select * from userinfo where username='" + Text1.Text + "'", cn, adOpenStatic, adLockOptimistic
gusername = Text1.Text
If rsuser.RecordCount > 0 Then
'檢查正確的密碼
If Text2.Text = rsuser.Fields(1) Then
' If Combo1.Text = "管理員" And Text1 = "administrator" Then
'將代碼放在這里傳遞
'成功到 calling 函數
'設置全局變量時最容易的
'gusername = rsuser.Fields(0)
LoginSucceeded = True
Me.Hide
frmmain.Show
Else
MsgBox "無效的密碼 ,請重試!", , "登錄"
Text2.SetFocus
SendKeys "{Home}+{End}"
End If
Else
MsgBox "請輸入有效的用戶名與密碼!"
Text1.Text = ""
Text2.Text = ""
Text2.SetFocus
End If
rsuser.Close
Set rsuser = Nothing
End Sub
Private Sub Command2_Click()
'設置全局變量為 false
'不提示失敗的登錄
LoginSucceeded = False
End
End Sub
Private Sub Form_Load()
Set cn = New ADODB.Connection
'cn.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=ok;Initial Catalog=hhhh;Data Source=QQ", "sa", ""
cn.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=ok;Initial Catalog=man;Data Source=75DE96E8084748F", "sa", ""
'cn.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=man;Data Source=75DE96E8084748F", "sa", """"
DataEnvironment1.人事檔案管理.ConnectionString = cn.ConnectionString
Combo1.AddItem "一般用戶"
Combo1.AddItem "管理員"
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -