?? enter.frm
字號:
VERSION 5.00
Begin VB.Form enter
BorderStyle = 3 'Fixed Dialog
Caption = "用戶登陸"
ClientHeight = 1875
ClientLeft = 45
ClientTop = 435
ClientWidth = 3180
BeginProperty Font
Name = "宋體"
Size = 9.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Icon = "enter.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1875
ScaleWidth = 3180
StartUpPosition = 2 '屏幕中心
Begin VB.TextBox Text1
BeginProperty Font
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 270
Left = 360
TabIndex = 7
Text = "Text1"
Top = 2040
Width = 975
End
Begin VB.ComboBox Combo1
BackColor = &H00C0E0FF&
Height = 315
Left = 1200
TabIndex = 0
Top = 360
Width = 1695
End
Begin VB.CommandButton Command2
Caption = "退 出"
Height = 375
Left = 1800
TabIndex = 5
Top = 1320
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "登 陸"
Height = 375
Left = 240
TabIndex = 4
Top = 1320
Width = 1215
End
Begin VB.TextBox Text2
BackColor = &H00C0E0FF&
Height = 270
IMEMode = 3 'DISABLE
Left = 1200
MaxLength = 20
PasswordChar = "*"
TabIndex = 3
Top = 840
Width = 1695
End
Begin VB.Label txtadm
Caption = "0"
BeginProperty Font
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1800
TabIndex = 6
Top = 2880
Width = 855
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "密 碼:"
Height = 255
Left = 360
TabIndex = 2
Top = 840
Width = 855
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "賬 戶:"
Height = 255
Left = 360
TabIndex = 1
Top = 360
Width = 975
End
End
Attribute VB_Name = "enter"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim cnnUser As New ADODB.Connection
Dim rstUser As New ADODB.Recordset
Private Sub Combo2_Change()
End Sub
Private Sub Command1_Click()
Dim cc As String
Dim jibie As String
cc = Combo1.Text
If cc = "" Then
Combo1.SetFocus
MsgBox "請輸入用戶名!", vbOKOnly, "輸入不正確!"
Exit Sub
End If
With rstUser
If .State = adStateOpen Then .Close
.Open ("Select * from users where name='" & cc & "'"), cnnUser, adOpenKeyset, adLockOptimistic
If .EOF And .BOF Then
MsgBox "請檢查用戶名!", vbOKOnly, "賬戶不正確!"
Combo1.SetFocus
Else
If Trim(Combo1.Text & "") = Trim(rstUser.Fields("name").Value) And Trim(Text2.Text & "") = decipher(Trim(rstUser.Fields("password").Value)) Then
If rstUser.Fields("adm").Value > 0 Then
jibie = "管理員"
op.commShanchu.Enabled = True
op.commQingkong.Enabled = True
op.cShanchu.Enabled = True
op.cTianjia.Enabled = True
op.cXg.Enabled = True
op.cXiugai.Enabled = True
op.txtyuan.Enabled = False
Else
jibie = "司磅員"
End If
Text2.Text = ""
Me.Hide
op.Label2.Caption = rstUser.Fields("name").Value
op.Label3.Caption = jibie
Call comm
op.Show
Else
Text2.Text = ""
Text2.SetFocus
MsgBox "請檢查密碼!", vbOKOnly, "密碼不正確!"
Exit Sub
End If
End If
.Close
End With
End Sub
Private Sub comm()
On Error GoTo p:
op.MSComm1.Settings = GetIni("MSCOMM", "settings", "Config.ini")
op.MSComm1.CommPort = GetIni("MSCOMM", "commport", "Config.ini")
If op.MSComm1.PortOpen = False Then
op.MSComm1.PortOpen = True
op.Timer2.Enabled = True
End If
op.Timer1.Enabled = True
Exit Sub
p:
MsgBox "串口通信出錯!", vbOKOnly, "錯誤:"
End
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
Dim password As String
Dim DB As String
Dim ds As String
Dim uId As String
On Error GoTo k
password = GetIni("DataSource", "Password", "Config.ini")
DB = GetIni("DataSource", "Database", "Config.ini")
ds = GetIni("DataSource", "DataSource", "Config.ini")
uId = GetIni("DataSource", "UserID", "Config.ini")
On Error GoTo p
With cnnUser
If .State = adStateOpen Then .Close
.ConnectionString = "Provider=SQLOLEDB.1;Password=" & password & ";Persist Security Info=True;User ID=" & uId & ";Initial Catalog= " & DB & " ;Data Source=" & ds
.Open
End With
Call data
Exit Sub
p:
MsgBox "連接不上數(shù)據(jù)庫!", vbOKOnly, "錯誤"
End
k:
MsgBox "配置文件錯誤!", vbOKOnly, "錯誤"
End
End Sub
Private Sub data()
On Error GoTo p
With rstUser
Set .ActiveConnection = cnnUser
.CursorType = adOpenKeyset 'adOpenKeyset,adOpenStatic可使用Recordset的RecordCount,其他兩個屬性不行
End With
With rstUser
If .State = adStateOpen Then .Close
.Open "Select * from users"
Do While Not .EOF
Combo1.AddItem rstUser.Fields("name").Value
'Combo1.AddItem decipher(Trim(rstUser.Fields("password").Value))
.MoveNext
Loop
.Close
End With
Exit Sub
p:
MsgBox "數(shù)據(jù)庫讀取!", vbOKOnly, "錯誤"
End
End Sub
Private Sub Form_Unload(Cancel As Integer)
End
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Command1_Click
End If
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -