📄 frmsys_person.frm
字号:
UserName = ""
Password = ""
RecordSource = ""
Caption = "adoDept"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "员工管理"
ForeColor = &H00C00000&
Height = 180
Left = 420
TabIndex = 36
Top = 2130
Width = 720
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "部门管理"
ForeColor = &H00C00000&
Height = 180
Left = 420
TabIndex = 37
Top = 225
Width = 720
End
Begin VB.Line Line1
BorderColor = &H00000080&
X1 = 30
X2 = 8655
Y1 = 285
Y2 = 285
End
Begin VB.Line Line2
BorderColor = &H00000080&
X1 = 30
X2 = 8655
Y1 = 345
Y2 = 345
End
Begin VB.Line Line3
X1 = 0
X2 = 8700
Y1 = 2175
Y2 = 2175
End
Begin VB.Line Line4
X1 = -15
X2 = 8700
Y1 = 2220
Y2 = 2220
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "部门名称:"
Height = 180
Left = 240
TabIndex = 35
Top = 630
Width = 810
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "职责描述:"
Height = 180
Left = 240
TabIndex = 34
Top = 1005
Width = 810
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "员工编号:"
Height = 180
Left = 150
TabIndex = 33
Top = 2640
Width = 810
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "员工姓名:"
Height = 180
Left = 2040
TabIndex = 32
Top = 2640
Width = 810
End
Begin VB.Label Label7
AutoSize = -1 'True
Caption = "性别:"
Height = 180
Left = 4365
TabIndex = 31
Top = 2640
Width = 450
End
Begin VB.Label Label9
AutoSize = -1 'True
Caption = "所属部门:"
Height = 180
Left = 2040
TabIndex = 30
Top = 2970
Width = 810
End
Begin VB.Label Label11
AutoSize = -1 'True
Caption = "电话:"
Height = 180
Left = 4365
TabIndex = 29
Top = 3330
Width = 450
End
Begin VB.Label Label12
AutoSize = -1 'True
Caption = "职务:"
Height = 180
Left = 4365
TabIndex = 28
Top = 2970
Width = 450
End
Begin VB.Label Label13
AutoSize = -1 'True
Caption = "政治面貌:"
Height = 180
Left = 2040
TabIndex = 27
Top = 3330
Width = 810
End
Begin VB.Label Label8
AutoSize = -1 'True
Caption = "出生日期:"
Height = 180
Left = 150
TabIndex = 26
Top = 2970
Width = 810
End
Begin VB.Label Label10
AutoSize = -1 'True
Caption = "学历:"
Height = 180
Left = 150
TabIndex = 25
Top = 3285
Width = 450
End
Begin VB.Label Label14
AutoSize = -1 'True
Caption = "备注:"
Height = 180
Left = 150
TabIndex = 24
Top = 3585
Width = 450
End
End
Attribute VB_Name = "frmSys_person"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub DataGrid1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtPerson(4).Text = Adodc1.Recordset.Fields(0).Value
DataGrid1.Visible = False
txtPerson(5).SetFocus
End If
End Sub
Private Sub Form_Load()
'///部门管理
adoDept.ConnectionString = PublicStr
adoDept.RecordSource = "SELECT * FROM tbOA_dept"
adoDept.Refresh
Me.cmdDeptCancel.Enabled = False
Me.cmdDeptSave.Enabled = False
Text1.Enabled = False
Text2.Enabled = False
'///员工管理
adoEmployee.ConnectionString = PublicStr
adoEmployee.RecordSource = "SELECT * FROM tbOA_employee"
adoEmployee.Refresh
Me.cmdEcancel.Enabled = False
For i = 0 To txtPerson.Count - 1
txtPerson(i).Enabled = False
Next i
End Sub
Private Sub txtPerson_Change(Index As Integer)
If Index = 4 Then
If txtPerson(4).Enabled = False Then Exit Sub
Adodc1.ConnectionString = PublicStr
Adodc1.RecordSource = "select dept_name as 部门名称 from tbOA_dept where dept_name like'%" & txtPerson(4).Text & "%' "
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
Set DataGrid1.DataSource = Adodc1
DataGrid1.Visible = True
DataGrid1.SetFocus
End If
End If
End Sub
Private Sub txtPerson_KeyPress(Index As Integer, KeyAscii As Integer)
If KeyAscii = 13 Then SendKeys "{TAB}"
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Text2.SetFocus
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Me.cmdDeptSave.SetFocus
End Sub
Private Sub cmdDeptShow_Click()
showDept.Show
End Sub
Private Sub cmdDeptCancel_Click()
Me.cmdDeptCancel.Enabled = False
Me.cmdDeptSave.Enabled = False
Text1.Enabled = False
Text2.Enabled = False
Me.cmdDeptAdd.Enabled = True
Me.cmdDeptUpdate.Enabled = True
Me.cmdDeptDel.Enabled = True
End Sub
Private Sub cmdDeptAdd_Click()
Text1.Text = ""
Text2.Text = ""
Text2.Enabled = True
Text1.Enabled = True
Me.cmdDeptSave.Enabled = True
Text1.SetFocus
Me.cmdDeptAdd.Tag = "添加"
Me.cmdDeptAdd.Enabled = False
Me.cmdDeptCancel.Enabled = True
End Sub
Private Sub cmdDeptSave_Click()
If Text1.Text = "" Then MsgBox "部门名称不能为空!", vbInformation: Exit Sub
If Me.cmdDeptAdd.Tag = "添加" Then
adoDept.Recordset.AddNew
adoDept.Recordset.Fields(1).Value = Text1.Text
adoDept.Recordset.Fields(2).Value = Text2.Text
adoDept.Recordset.Update
MsgBox "数据添加成功!"
Me.cmdDeptAdd.Tag = ""
End If
If Me.cmdDeptUpdate.Tag = "修改" Then
adoDept.Recordset.Fields(1).Value = Text1.Text
adoDept.Recordset.Fields(2).Value = Text2.Text
adoDept.Recordset.Update
MsgBox "数据更改成功!"
Me.cmdDeptUpdate.Tag = ""
End If
Me.cmdDeptAdd.Enabled = True
Me.cmdDeptUpdate.Enabled = True
Me.cmdDeptDel.Enabled = True
Me.cmdDeptSave.Enabled = False
Text1.Text = ""
Text2.Text = ""
Text1.Enabled = False
Text2.Enabled = False
cmdDeptAdd.SetFocus
End Sub
Private Sub cmdDeptUpdate_Click()
Me.cmdDeptUpdate.Tag = "修改"
Me.cmdDeptSave.Enabled = True
Me.cmdDeptUpdate.Enabled = False
Me.cmdDeptCancel.Enabled = True
Me.cmdDeptDel.Enabled = False
Me.cmdDeptAdd.Enabled = False
Text1.Enabled = True
Text2.Enabled = True
End Sub
Private Sub cmdDeptDel_Click()
On Error Resume Next
adoDept.Recordset.Delete
MsgBox "成功删除数据!", vbInformation
Text1.Text = ""
Text2.Text = ""
End Sub
Private Sub cmdEshow_Click()
showEmployee.Show
End Sub
Private Sub cmdEcancel_Click()
Me.cmdEcancel.Enabled = False
Me.cmdEsave.Enabled = False
For i = 0 To txtPerson.Count - 1
txtPerson(i).Enabled = False
Next i
Me.cmdEadd.Enabled = True
Me.cmdEupdate.Enabled = True
Me.cmdEdel.Enabled = True
End Sub
Private Sub cmdEadd_Click()
For i = 0 To txtPerson.Count - 1
txtPerson(i).Text = ""
Next i
For i = 0 To txtPerson.Count - 1
txtPerson(i).Enabled = True
Next i
adoEmployee.RecordSource = "select * from tbOA_employee"
adoEmployee.Refresh
If adoEmployee.Recordset.RecordCount > 0 Then
adoEmployee.Recordset.MoveLast
txtPerson(0).Text = "E" & Left(Mid(adoEmployee.Recordset.Fields(0), 2, 5), 5) + 1
Else
txtPerson(0).Text = "E1001"
End If
Me.cmdEsave.Enabled = True
txtPerson(1).SetFocus
Me.cmdEadd.Tag = "添加"
Me.cmdEadd.Enabled = False
Me.cmdEcancel.Enabled = True
End Sub
Private Sub cmdEsave_Click()
For i = 0 To txtPerson.Count - 2
If txtPerson(i).Text = "" Then MsgBox "除备注信息可以为空,其于均不能为空!", vbInformation: Exit Sub
Next i
If Me.cmdEadd.Tag = "添加" Then
Set con = New ADODB.Connection
con.Open PublicStr
Set rs1 = New ADODB.Recordset
rs1.Open "exec add_employee @e_id='" & txtPerson(0).Text & "',@e_name='" & txtPerson(1).Text & "',@e_sex='" & txtPerson(2).Text & "',@e_birth='" & txtPerson(3).Text & "',@e_dept='" & txtPerson(4).Text & "',@e_duty='" & txtPerson(5).Text & "',@e_study='" & txtPerson(6).Text & "',@e_gov='" & txtPerson(7).Text & "',@e_phone='" & txtPerson(8).Text & "',@e_memo='" & txtPerson(9).Text & "'", con, 1, 3
con.Close
MsgBox "数据添加成功!"
Me.cmdEadd.Tag = ""
End If
If Me.cmdEupdate.Tag = "修改" Then
Set con = New ADODB.Connection
con.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=db_OA"
Set rs = New ADODB.Recordset
rs.Open "exec update_employee @e_find_id='" & txtPerson(0).Text & "',@e_id='" & txtPerson(0).Text & "',@e_name='" & txtPerson(1).Text & "',@e_sex='" & txtPerson(2).Text & "',@e_birth='" & txtPerson(3).Text & "',@e_dept='" & txtPerson(4).Text & "',@e_duty='" & txtPerson(5).Text & "',@e_study='" & txtPerson(6).Text & "',@e_gov='" & txtPerson(7).Text & "',@e_phone='" & txtPerson(8).Text & "',@e_memo='" & txtPerson(9).Text & "'", con, 1, 3
con.Close
MsgBox "数据更改成功!"
Me.cmdEupdate.Tag = ""
End If
adoEmployee.Refresh
Me.cmdEadd.Enabled = True
Me.cmdEupdate.Enabled = True
Me.cmdEdel.Enabled = True
Me.cmdEsave.Enabled = False
For i = 0 To txtPerson.Count - 1
txtPerson(i).Text = ""
Next i
For i = 0 To txtPerson.Count - 1
txtPerson(i).Enabled = False
Next i
cmdEadd.SetFocus
DataGrid1.Visible = False
End Sub
Private Sub cmdEupdate_Click()
Me.cmdEupdate.Tag = "修改"
Me.cmdEsave.Enabled = True
Me.cmdEupdate.Enabled = False
Me.cmdEcancel.Enabled = True
Me.cmdEdel.Enabled = False
Me.cmdEadd.Enabled = False
For i = 0 To txtPerson.Count - 1
txtPerson(i).Enabled = True
Next i
End Sub
Private Sub cmdEdel_Click()
If txtPerson(0).Text = "" Then Exit Sub
Set cn = New ADODB.Connection
cn.Open PublicStr
Set rss = New ADODB.Recordset
rss.Open "exec delete_employee @e_id='" & txtPerson(0).Text & "'", cn, 1, 3
cn.Close
adoEmployee.Refresh
For i = 0 To txtPerson.Count - 1
txtPerson(i).Text = ""
Next i
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -