📄 form5.frm
字号:
VERSION 5.00
Begin VB.Form 录入工作人员
Caption = "录入工作人员"
ClientHeight = 2475
ClientLeft = 1890
ClientTop = 1950
ClientWidth = 6060
LinkTopic = "Form5"
MaxButton = 0 'False
ScaleHeight = 2475
ScaleWidth = 6060
Begin VB.CommandButton Command2
Caption = "删除"
Height = 615
Left = 3360
TabIndex = 5
Top = 1200
Width = 1335
End
Begin VB.CommandButton Command1
Caption = "修改"
Height = 615
Left = 1320
TabIndex = 4
Top = 1200
Width = 1095
End
Begin VB.ComboBox Combo1
Height = 300
Left = 3840
Style = 2 'Dropdown List
TabIndex = 3
Top = 600
Width = 1335
End
Begin VB.TextBox Text1
Height = 375
Left = 1320
TabIndex = 1
Top = 480
Width = 1215
End
Begin VB.Label Label2
Caption = "岗位"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 3000
TabIndex = 2
Top = 600
Width = 735
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 = 255
Left = 600
TabIndex = 0
Top = 480
Width = 495
End
End
Attribute VB_Name = "录入工作人员"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Private Sub Command2_Click()
If Text1.Text = "" Or Combo1.Text = "" Then
MsgBox "请先输入姓名和岗位!", vbOKOnly + vbExclamation, "提示"
Else
strsql7 = "select * from 工作人员表 where 姓名='" & Text1.Text & "' and 岗位='" & Combo1.Text & "'"
Set rs = cnn.Execute(strsql7)
If rs.EOF = False Then '该岗位存在,可以进行删除
strsql6 = "delete * from 工作人员表 where 姓名='" & Text1.Text & "' and 岗位='" & Combo1.Text & "'"
cnn.Execute (strsql6)
MsgBox "删除成功!", vbOKOnly, "提示"
Text1.Text = ""
Else
MsgBox "此岗位不存在!", vbOKOnly, "警告"
Text1.Text = ""
End If
End If
End Sub
Private Sub Form_Load()
Dim mypath As String
Set cnn = New ADODB.Connection
Set rs = New ADODB.Recordset
mypath = App.Path & "/data" '获取当前路径
If Right(mypath, 1) <> "/" Then mypath = mypath + "/"
cnn.Open "Data Source=" & mypath & "db1.mdb" & ";Provider=Microsoft.Jet.OLEDB.4.0 " '连接并打开数据库
strsql0 = "select count(*) from 岗位表"
strsql10 = "select 岗位名称 from 岗位表"
Set rs = cnn.Execute(strsql0)
Sum = Val(rs.Fields(0)) + 1
Set rs = cnn.Execute(strsql10)
Combo1.List(0) = ""
For i = 1 To Sum - 1 '为课程名称选项的值进行初始化处理
Combo1.List(i) = rs.Fields(0)
rs.MoveNext
Next
End Sub
Private Sub Command1_Click()
If Text1.Text = "" Or Combo1.Text = "" Then
MsgBox "请先输入姓名和岗位", vbOKOnly + vbExclamation, "提示"
Else
strsql = "select * from 工作人员表 where 姓名='" & Text1.Text & "'"
Set rs = cnn.Execute(strsql)
If rs.EOF = True Then '该岗位没被您选择,可以入库
strsql3 = "insert into 工作人员表 values('" + Text1.Text + "','" + Combo1.Text + "')"
cnn.Execute (strsql3)
MsgBox "修改成功!", vbOKOnly, "提示"
Text1.Text = ""
Else
strsq2 = "select * from 工作人员表 where 姓名='" & Text1.Text & "' and '" + Combo1.Text + "'"
Set rs = cnn.Execute(strsq2)
If rs.EOF = True Then
MsgBox "您已经选过了此岗位!", vbYesNoCancel + vbExclamation, "提示"
Else
strsql4 = "insert into 工作人员表 values('" + Text1.Text + "','" + Combo1.Text + "')"
cnn.Execute (strsql4)
MsgBox "修改成功!", vbOKOnly, "提示"
Text1.Text = ""
End If
End If
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -