📄 administrationform.frm
字号:
Begin VB.TextBox Text4
Height = 270
Left = 1200
TabIndex = 22
Top = 2520
Width = 2775
End
Begin VB.TextBox Text5
Height = 270
Left = 1200
TabIndex = 21
Top = 3240
Width = 2775
End
Begin VB.TextBox Text6
Height = 270
Left = 1200
TabIndex = 20
Top = 3600
Width = 2775
End
Begin VB.TextBox Text7
Height = 270
Left = 1200
TabIndex = 19
Top = 3960
Width = 2775
End
Begin VB.TextBox Text9
Height = 270
Left = 1200
TabIndex = 18
Top = 4680
Width = 2775
End
Begin VB.ComboBox Combo1
Height = 300
ItemData = "AdministrationForm.frx":0127
Left = 1200
List = "AdministrationForm.frx":0131
TabIndex = 17
Top = 2880
Width = 2775
End
Begin VB.ComboBox Combo2
Height = 300
ItemData = "AdministrationForm.frx":013D
Left = 1200
List = "AdministrationForm.frx":014D
TabIndex = 16
Top = 5040
Width = 2775
End
Begin VB.Label Label12
AutoSize = -1 'True
Caption = "职位:"
Height = 180
Left = 2160
TabIndex = 40
Top = 1770
Width = 450
End
Begin VB.Label Label13
Caption = "年龄:"
Height = 255
Left = 240
TabIndex = 38
Top = 3255
Width = 495
End
Begin VB.Image Image1
BorderStyle = 1 'Fixed Single
Height = 1695
Left = 240
Top = 360
Width = 1815
End
Begin VB.Label Label11
AutoSize = -1 'True
Caption = "姓名:"
Height = 180
Left = 240
TabIndex = 33
Top = 2610
Width = 450
End
Begin VB.Label Label10
AutoSize = -1 'True
Caption = "性别:"
Height = 180
Left = 240
TabIndex = 32
Top = 2940
Width = 450
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "年龄:"
Height = 180
Left = 240
TabIndex = 31
Top = 2610
Width = 450
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "户口状况:"
Height = 180
Left = 240
TabIndex = 30
Top = 3690
Width = 810
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "政治面貌:"
Height = 180
Left = 240
TabIndex = 29
Top = 4050
Width = 810
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "生理状况:"
Height = 180
Left = 240
TabIndex = 28
Top = 4410
Width = 810
End
Begin VB.Label Label7
AutoSize = -1 'True
Caption = "合同:"
Height = 180
Left = 240
TabIndex = 27
Top = 4770
Width = 450
End
Begin VB.Label Label8
AutoSize = -1 'True
Caption = "所属部门:"
Height = 180
Left = 240
TabIndex = 26
Top = 5100
Width = 810
End
Begin VB.Label Label9
AutoSize = -1 'True
Caption = "工号:"
Height = 180
Left = 240
TabIndex = 25
Top = 2250
Width = 450
End
End
End
Attribute VB_Name = "AdministrationForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
AddManagerFrom.Show
End Sub
Private Sub Command10_Click()
Me.Width = 6780
End Sub
Private Sub Command11_Click()
If Text3.Text = "" Then '没有选择员工
MsgBox "请选择需要修改的员工。", vbCritical, "修改失败"
Exit Sub
End If
'检测性别
If Combo1.Text = "男" Or Combo1.Text = "女" Then '该工号重复
Else
MsgBox "性别只能为男或女!", vbCritical, "修改错误"
Exit Sub
End If
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find "工号='" & Text3.Text & "'"
Adodc1.Recordset.Fields("工号") = Text3.Text
Adodc1.Recordset.Fields("姓名") = Text4.Text
Adodc1.Recordset.Fields("性别") = Combo1.Text
Adodc1.Recordset.Fields("年龄") = Text5.Text
Adodc1.Recordset.Fields("户口状况") = Text6.Text
Adodc1.Recordset.Fields("政治面貌") = Text7.Text
Adodc1.Recordset.Fields("生理状况") = Text8.Text
Adodc1.Recordset.Fields("合同") = Text9.Text
Adodc1.Recordset.Fields("所属部门") = Combo2.Text
Adodc1.Recordset.Fields("职位") = Combo3.Text
Adodc1.Recordset.Update
Adodc1.Refresh
MsgBox "数据已成功修改数据库。", vbInformation, "修改成功。"
If Combo3.Text = "员工" Then
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Combo1.Text = ""
Combo2.Text = ""
Combo3.Text = ""
End If
End Sub
Private Sub Command12_Click() '清空输入框
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Combo1.Text = ""
Combo2.Text = ""
Combo3.Text = ""
End Sub
Private Sub Command2_Click()
Me.Width = 11310
End Sub
Private Sub Command3_Click()
Dim myval As Integer
If Text3.Text = "" Then '还没有选择要删除的员工
MsgBox "请选择要删除的员工。", vbCritical, "删除错误"
Exit Sub
End If
myval = MsgBox("请慎重确定是否删除员工" & Text3.Text & "。" & vbCrLf & "因为该操作将会及联删除该员工的考勤、培训等等的信息,而且操作不可逆。", vbQuestion + vbYesNo, "请确认是否删除")
If myval = vbNo Then Exit Sub '如果选择取消,那就取消操作
'删除考勤表中数据
Set Ado_Conn = New ADODB.Connection
Set Ado_RS = New ADODB.Recordset
str_CS = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=ManageSystem"
str_RS = "select * from ExtendTable"
SqlConnect Ado_Conn, Ado_RS, str_CS, str_RS
Ado_Conn.Execute "select * from ExtendTable where EID='" & Adodc1.Recordset.Fields("工号") & "'"
SqlDisConnect Ado_RS
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find "工号='" & Text3.Text & "'"
Adodc1.Recordset.Delete
Adodc1.Recordset.Update
Adodc1.Refresh
MsgBox "已经成功从数据库中把工号为 " & Text3.Text & " 删除。"
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Combo1.Text = ""
Combo2.Text = ""
Combo3.Text = ""
End Sub
Private Sub Command4_Click()
Unload Me
End Sub
Private Sub Command5_Click() '退出
SureExit
End Sub
Private Sub Command6_Click() '查询
If Text1.Text = "" And Text2.Text = "" Then '工号,姓名都为空
MsgBox "请输入工号或者姓名", vbExclamation, "查询错误"
Exit Sub
End If
If Text1.Text <> "" And Text2.Text = "" Then '只填了工号
Adodc1.RecordSource = "select BID 工号,BName 姓名,BDepartment 部门, BAge 年龄, BSex 性别, BResidence 户口状况, BPolity 政治面貌, BHealthy 生理状况, BAgreement 合同, BDepartment 所属部门 , BPosition 职位 from basetable where BPosition in ('经理') and BID='" & Text1.Text & "'"
Adodc1.Refresh
End If
If Text1.Text = "" And Text2.Text <> "" Then '只填了姓名
Adodc1.RecordSource = "select BID 工号,BName 姓名,BDepartment 部门, BAge 年龄, BSex 性别, BResidence 户口状况, BPolity 政治面貌, BHealthy 生理状况, BAgreement 合同, BDepartment 所属部门 , BPosition 职位 from basetable where BPosition in ('经理') and BName='" & Text2.Text & "'"
Adodc1.Refresh
End If
If Text1.Text <> "" And Text2.Text <> "" Then '只填了工号&姓名
Adodc1.RecordSource = "select BID 工号,BName 姓名,BDepartment 部门, BAge 年龄, BSex 性别, BResidence 户口状况, BPolity 政治面貌, BHealthy 生理状况, BAgreement 合同, BDepartment 所属部门 , BPosition 职位 from basetable where BPosition in ('经理') and BID='" & Text1.Text & "' and BName='" & Text2.Text & "'"
Adodc1.Refresh
End If
'没有找到信息
If MSHFlexGrid1.Rows <= 1 Then
MsgBox "找不到该人员,请确认该人员帐号的存在。", vbCritical, "查找出错"
Exit Sub
End If
'输出信息
Adodc1.Refresh
If Adodc1.Recordset.Fields("工号").Value <> "" Then Text3.Text = Adodc1.Recordset.Fields("工号").Value
If Adodc1.Recordset.Fields("姓名").Value <> "" Then Text4.Text = Adodc1.Recordset.Fields("姓名").Value
If Adodc1.Recordset.Fields("性别").Value <> "" Then Combo1.Text = Adodc1.Recordset.Fields("性别").Value
If Adodc1.Recordset.Fields("年龄").Value <> "" Then Text5.Text = Adodc1.Recordset.Fields("年龄").Value
If Adodc1.Recordset.Fields("户口状况").Value <> "" Then Text6.Text = Adodc1.Recordset.Fields("户口状况").Value
If Adodc1.Recordset.Fields("政治面貌").Value <> "" Then Text7.Text = Adodc1.Recordset.Fields("政治面貌").Value
If Adodc1.Recordset.Fields("生理状况").Value <> "" Then Text8.Text = Adodc1.Recordset.Fields("生理状况").Value
If Adodc1.Recordset.Fields("合同").Value <> "" Then Text9.Text = Adodc1.Recordset.Fields("合同").Value
If Adodc1.Recordset.Fields("所属部门").Value <> "" Then Combo2.Text = Adodc1.Recordset.Fields("所属部门").Value
If Adodc1.Recordset.Fields("职位").Value <> "" Then Combo3.Text = Adodc1.Recordset.Fields("职位").Value
End Sub
Private Sub Command7_Click()
Text1.Text = ""
Text2.Text = ""
End Sub
Private Sub Command8_Click() '还原
Adodc1.RecordSource = "select BID 工号,BName 姓名,BDepartment 部门,BAge 年龄,BSex 性别, BResidence 户口状况,BPolity 政治面貌,BHealthy 生理状况,BAgreement 合同,BDepartment 所属部门,BPassword 密码,BPosition 职位 from basetable where BPosition in ('经理')"
Adodc1.Refresh
End Sub
Private Sub Form_Load()
If user_Position = "总裁" Then
Combo3.Visible = True
Label2.Visible = True
End If
End Sub
Private Sub MSHFlexGrid1_SelChange()
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find "工号='" & MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 1) & "'"
If Adodc1.Recordset.Fields("工号").Value <> "" Then Text3.Text = Adodc1.Recordset.Fields("工号").Value
If Adodc1.Recordset.Fields("姓名").Value <> "" Then Text4.Text = Adodc1.Recordset.Fields("姓名").Value
If Adodc1.Recordset.Fields("性别").Value <> "" Then Combo1.Text = Adodc1.Recordset.Fields("性别").Value
If Adodc1.Recordset.Fields("年龄").Value <> "" Then Text5.Text = Adodc1.Recordset.Fields("年龄").Value
If Adodc1.Recordset.Fields("户口状况").Value <> "" Then Text6.Text = Adodc1.Recordset.Fields("户口状况").Value
If Adodc1.Recordset.Fields("政治面貌").Value <> "" Then Text7.Text = Adodc1.Recordset.Fields("政治面貌").Value
If Adodc1.Recordset.Fields("生理状况").Value <> "" Then Text8.Text = Adodc1.Recordset.Fields("生理状况").Value
If Adodc1.Recordset.Fields("合同").Value <> "" Then Text9.Text = Adodc1.Recordset.Fields("合同").Value
If Adodc1.Recordset.Fields("所属部门").Value <> "" Then Combo2.Text = Adodc1.Recordset.Fields("所属部门").Value
If Adodc1.Recordset.Fields("职位").Value <> "" Then Combo3.Text = Adodc1.Recordset.Fields("职位").Value
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -