📄 frmperson.frm
字号:
VERSION 5.00
Begin VB.Form frmPerson
BackColor = &H00A56E3A&
Caption = "人员管理"
ClientHeight = 5130
ClientLeft = 60
ClientTop = 345
ClientWidth = 4650
Icon = "frmPerson.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5130
ScaleWidth = 4650
StartUpPosition = 2 '屏幕中心
Begin VB.TextBox Text1
Height = 330
Index = 2
Left = 3195
TabIndex = 9
Text = "Text1"
Top = 1710
Width = 1320
End
Begin VB.TextBox Text1
Height = 330
Index = 1
Left = 3195
TabIndex = 7
Text = "Text1"
Top = 1050
Width = 1320
End
Begin VB.TextBox Text1
Height = 330
Index = 0
Left = 3180
TabIndex = 4
Text = "Text1"
Top = 420
Width = 1320
End
Begin VB.CommandButton cmd1
Caption = "退 出"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 3
Left = 3285
TabIndex = 3
Top = 4455
Width = 1095
End
Begin VB.CommandButton cmd1
Caption = "删 除"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 2
Left = 3285
TabIndex = 2
Top = 4050
Width = 1095
End
Begin VB.CommandButton cmd1
Caption = "保 存"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 0
Left = 3285
TabIndex = 1
Top = 3630
Width = 1095
End
Begin VB.ListBox List1
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 4620
Left = 120
TabIndex = 0
Top = 405
Width = 2895
End
Begin VB.Label Label1
BackColor = &H00A56E3A&
Caption = "员工姓名"
ForeColor = &H8000000E&
Height = 240
Index = 4
Left = 1515
TabIndex = 11
Top = 150
Width = 930
End
Begin VB.Label Label1
BackColor = &H00A56E3A&
Caption = "员工编号"
ForeColor = &H8000000E&
Height = 240
Index = 3
Left = 390
TabIndex = 10
Top = 150
Width = 930
End
Begin VB.Label Label1
BackColor = &H00A56E3A&
Caption = "员工密码"
Height = 240
Index = 2
Left = 3180
TabIndex = 8
Top = 1470
Width = 930
End
Begin VB.Label Label1
BackColor = &H00A56E3A&
Caption = "员工姓名"
Height = 240
Index = 1
Left = 3180
TabIndex = 6
Top = 825
Width = 930
End
Begin VB.Label Label1
BackColor = &H00A56E3A&
Caption = "员工编号"
Height = 240
Index = 0
Left = 3180
TabIndex = 5
Top = 210
Width = 930
End
End
Attribute VB_Name = "frmPerson"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmd1_Click(Index As Integer)
Dim str1 As String
Dim i As Integer
Select Case Index
Case 0
For i = 0 To 2
If Text1(i).Text = "" Then
MsgBox "这里不能为空!!", , "提示"
Text1(i).SetFocus
Exit Sub
End If
Next i
If Len(Trim(Text1(0).Text)) > 4 Then
MsgBox "对不起,员工编号不能大于四位!", , "提示"
Text1(0).SetFocus
Exit Sub
End If
str1 = "select * from employees where employee_id='" & Trim(Text1(0).Text) & "'"
Set rs2 = GetRsBySQL(str1)
If rs2.EOF Then
rs2.Close
str1 = "insert into employees (employee_id,employee_name,employee_dept_id,company_id,qx,qtqx,pwd) values ('" & Trim(Text1(0).Text) & "','" & Trim(Text1(1).Text) & "','001','001','0','0','" & Trim(Text1(2).Text) & "')"
Call ExeSQLByCmd(str1)
MsgBox "保存成功!!", , "提示"
Call IntoList
Text1(0).Text = ""
Text1(1).Text = ""
Text1(2).Text = ""
Exit Sub
Else
MsgBox "编号不能重复!", , "提示"
rs2.Close
Text1(0).SetFocus
Exit Sub
End If
Case 2
If MsgBox("你确定要删除这条记录吗?", vbYesNoCancel = vbYes, "提示") Then
str1 = "delete from employees where employee_id='" & Trim(Mid(List1.Text, 1, 6)) & "'"
Call ExeSQLByCmd(str1)
Call IntoList
End If
Case 3
Unload Me
End Select
End Sub
Private Sub Form_Load()
Text1(0).Text = ""
Text1(1).Text = ""
Text1(2).Text = ""
Call IntoList
End Sub
Private Sub IntoList()
Dim str1 As String
List1.Clear
str1 = "select employee_id,employee_name from employees where employee_id <> '0000'"
Set Rs1 = GetRsBySQL(str1)
If Rs1.EOF Then
MsgBox "对不起,没有员工可以进行维护!"
Exit Sub
End If
Do While Not Rs1.EOF
List1.AddItem Rs1.Fields(0) + Space(5) + Rs1.Fields(1)
Rs1.MoveNext
Loop
Rs1.Close
End Sub
Private Sub List1_DblClick()
Dim str As String
str = "select employee_id,employee_name,pwd from employees where employee_id='" & Trim(Mid(List1.Text, 1, 6)) & "'"
Set rs2 = GetRsBySQL(str)
MsgBox "用户编号=>" & rs2.Fields(0) & "用户名称=>" & rs2.Fields(1) & "用户密码=>" & rs2.Fields(2)
rs2.Close
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -