📄 frm_adduser.frm
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "Msflxgrd.ocx"
Begin VB.Form Frm_AddUser
Caption = "添加用户"
ClientHeight = 6660
ClientLeft = 60
ClientTop = 345
ClientWidth = 8070
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 6660
ScaleWidth = 8070
StartUpPosition = 2 '屏幕中心
Begin VB.Frame Frame1
Height = 6555
Left = 90
TabIndex = 8
Top = 0
Width = 7935
Begin VB.CommandButton Cmd_Cancel
Caption = "取 消"
Height = 375
Left = 6480
TabIndex = 6
Top = 690
Width = 1155
End
Begin VB.CommandButton Cmd_OK
Caption = "确 定"
Height = 375
Left = 6480
TabIndex = 5
Top = 240
Width = 1155
End
Begin MSFlexGridLib.MSFlexGrid Grid1
Height = 4965
Left = 120
TabIndex = 7
Top = 1500
Width = 7695
_ExtentX = 13573
_ExtentY = 8758
_Version = 393216
Cols = 3
Appearance = 0
End
Begin VB.ComboBox Combo1
Height = 300
Left = 1200
TabIndex = 4
Top = 1110
Width = 1575
End
Begin VB.TextBox Text4
Height = 315
IMEMode = 3 'DISABLE
Left = 3810
PasswordChar = "*"
TabIndex = 3
Top = 690
Width = 1545
End
Begin VB.TextBox Text3
Height = 315
IMEMode = 3 'DISABLE
Left = 1200
PasswordChar = "*"
TabIndex = 2
Top = 690
Width = 1545
End
Begin VB.TextBox Text2
Height = 315
Left = 3780
TabIndex = 1
Top = 270
Width = 1545
End
Begin VB.TextBox Text1
Height = 315
Left = 1200
TabIndex = 0
Top = 270
Width = 1545
End
Begin VB.Label Label1
Caption = "用户级别"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 225
Index = 4
Left = 300
TabIndex = 13
Top = 1170
Width = 915
End
Begin VB.Label Label1
Caption = "确认密码"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 225
Index = 3
Left = 2880
TabIndex = 12
Top = 750
Width = 915
End
Begin VB.Label Label1
Caption = "用户密码"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 225
Index = 2
Left = 300
TabIndex = 11
Top = 750
Width = 915
End
Begin VB.Label Label1
Caption = "用户名称"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 225
Index = 1
Left = 2880
TabIndex = 10
Top = 330
Width = 915
End
Begin VB.Label Label1
Caption = "用户代码"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 225
Index = 0
Left = 300
TabIndex = 9
Top = 330
Width = 915
End
End
End
Attribute VB_Name = "Frm_AddUser"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command2_Click()
End Sub
Private Sub Cmd_Cancel_Click()
Unload Me
End Sub
Private Sub Cmd_OK_Click()
Dim m_Rs As New ADODB.Recordset ''''定义临时记录集'''''
Dim strSql As String '''''''存储临时用的sql语句
Dim i As Integer
If MsgBox("确定是否添加?", vbYesNo + vbQuestion, "存盘?") = vbYes Then
'''''输入检测''''''''''''''
If Text1.Text = "" Then
MsgBox "请输入用户代码,用户代码不能为空..."
Exit Sub
End If
If Text2.Text = "" Then
MsgBox "请输入用户名称,用户名称不能为空..."
Exit Sub
End If
If Text3.Text <> Text4.Text Then
MsgBox "密码输入不一致,请确认输入密码..."
Exit Sub
End If
''''''存盘'''''''''''''
''''首先检测此用户代码的用户是否存在'''''''''''
strSql = "Select Count(*) From UserInfo Where UserID='" & Trim(Text1.Text) & "'"
If isRecordExist(strSql, "person.mdb") Then
MsgBox "此用户代码的记录已经存在..."
Exit Sub
End If
strSql = "INSERT INTO UserInfo(UserID,UserName,UserPwd,UserLevel) VALUES('" & Trim(Text1.Text) & "','" & Trim(Text2.Text) & "','" & Trim(Text3.Text) & "','" & Trim(Combo1.Text) & "')"
'''MsgBox strSql
Set m_Rs = ExecuteSQL(strSql, "Person.Mdb")
'''''''将记录显示在表格中'''''''''''''''
strSql = "Select * From UserInfo Order By ID"
Set m_Rs = ExecuteSQL(strSql, "person.mdb")
i = 1
Do While Not m_Rs.EOF
grid1.Rows = i + 2
grid1.TextMatrix(i, 0) = m_Rs("UserID")
grid1.TextMatrix(i, 1) = m_Rs("UserName")
grid1.TextMatrix(i, 2) = m_Rs("UserLevel")
m_Rs.MoveNext
i = i + 1
Loop
''''''''''''''''''''''''''''''''''''''''''''
MsgBox "添加成功..."
Else
Exit Sub
End If
End Sub
Private Sub Form_Load()
Combo1.AddItem "管理员"
Combo1.AddItem "操作员"
grid1.FormatString = " 用户代码 |^ 用户名称 |^ 用户级别 "
Dim i As Integer
Dim strSql As String
Dim m_Rs As New ADODB.Recordset
Set m_Rs = ExecuteSQL(strSql, "Person.Mdb")
'''''''将记录显示在表格中'''''''''''''''
strSql = "Select * From UserInfo Order By ID"
Set m_Rs = ExecuteSQL(strSql, "person.mdb")
i = 2
Do While Not m_Rs.EOF
grid1.Rows = i + 1
grid1.TextMatrix(i - 1, 0) = m_Rs("UserID")
grid1.TextMatrix(i - 1, 1) = m_Rs("UserName")
grid1.TextMatrix(i - 1, 2) = m_Rs("UserLevel")
m_Rs.MoveNext
i = i + 1
Loop
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
TabToEnter (KeyAscii)
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
TabToEnter (KeyAscii)
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
TabToEnter (KeyAscii)
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
TabToEnter (KeyAscii)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -