📄 frmworkerinfo.frm
字号:
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin MSDataGridLib.DataGrid DataGrid1
Height = 2055
Left = 240
TabIndex = 26
Top = 840
Width = 8535
_ExtentX = 15055
_ExtentY = 3625
_Version = 393216
HeadLines = 1
RowHeight = 15
FormatLocked = -1 'True
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ColumnCount = 6
BeginProperty Column00
DataField = "工号"
Caption = "工号"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = "0"
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = "姓名"
Caption = "姓名"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column02
DataField = "性别"
Caption = "性别"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column03
DataField = "部门"
Caption = "管理部门"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column04
DataField = "电话"
Caption = "电话"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column05
DataField = "备注"
Caption = "备注"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
ColumnWidth = 975.118
EndProperty
BeginProperty Column01
ColumnWidth = 1005.165
EndProperty
BeginProperty Column02
ColumnWidth = 945.071
EndProperty
BeginProperty Column03
EndProperty
BeginProperty Column04
ColumnWidth = 824.882
EndProperty
BeginProperty Column05
EndProperty
EndProperty
End
Begin VB.Label Label1
Caption = "员工资料添加/查询/修改/删除"
BeginProperty Font
Name = "楷体_GB2312"
Size = 21.75
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1320
TabIndex = 27
Top = 240
Width = 6375
End
End
Attribute VB_Name = "frmworkerinfo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim con As ADODB.Connection
Private Sub cmdadd_Click()
'添加记录前清空文本框
yxm.Text = Empty
ybm.Text = Empty
ygh.Text = Empty
End Sub
Private Sub cmdcancel_Click()
Dim tx As New ADODB.Recordset
Dim query As String
If DataGrid1 <> "" Then
If MsgBox("是否确认删除?", vbYesNo + vbCritical, "删除") = vbYes Then
query = "SELECT * FROM 员工信息"
tx.Open query, con, 3, 3, 1
tx.Delete
tx.Update
MsgBox "删除记录成功!刷新后可看到!"
End If
Else
MsgBox "请选择需要删除的记录!", vbOKOnly, "删除"
End If '删除一条记录
End Sub
Private Sub cmdexit_Click()
Unload Me
End Sub
Private Sub cmdinquire_Click()
Dim rs As New ADODB.Recordset
Dim query1 As String
If Option1.Value = True Then
query1 = "SELECT * FROM 员工信息 WHERE 工号 = '" & Trim(ygh.Text) & "'"
rs.Open query1, con, adOpenForwardOnly, adLockReadOnly
Set DataGrid1.DataSource = Nothing
End If
If Option2.Value = True Then
query1 = "SELECT * FROM 员工信息 WHERE 姓名 = '" & Trim(yxm.Text) & "'"
Set DataGrid1.DataSource = Nothing
End If
If Option3.Value = True Then
query1 = "SELECT * FROM 员工信息 WHERE 部门 = '" & Trim(ybm.Text) & "'"
rs.Open query1, con, adOpenForwardOnly, adLockReadOnly
Set DataGrid1.DataSource = Nothing
End If
If Not (rs.EOF And rs.BOF) Then
rs.MoveFirst
rs.MoveLast
End If
If rs.RecordCount > 0 Then
Set DataGrid1.DataSource = rs
MsgBox "总共查到" & rs.RecordCount & "记录", vbInformation
Else
MsgBox "没有找到记录,请重新输入查询数据", vbInformation
End If
End Sub
Private Sub Form_Load()
Set con = New ADODB.Connection
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\数据.mdb;Persist Security Info=False"
con.CursorLocation = adUseClient
con.Open '创建打开连接
Dim rs As New ADODB.Recordset '加载员工表信息
rs.CursorLocation = adUseClient
rs.Open "Select * from 员工信息", con
Set DataGrid1.DataSource = rs
End Sub
Private Sub save_Click()
'保存记录
Dim rs As New ADODB.Recordset
rs.Open "SELECT * FROM 员工信息", con, adOpenDynamic, adLockOptimistic, adCmdText
rs.AddNew
If txtteacherid.Text = Empty Then
MsgBox "工号不能为空!"
txtteacherid.SetFocus
Exit Sub
End If
If xingming.Text = Empty Then
MsgBox "姓名不能为空!"
xingming.SetFocus
Exit Sub
End If
If bumen.Text = Empty Then
MsgBox "请输入员工部门!"
bumen.SetFocus
Exit Sub
End If
If txttel.Text = Empty Then
MsgBox "请输入联系电话!"
txttel.SetFocus
Exit Sub
End If
rs.Fields(0) = txtteacherid.Text
rs.Fields(1) = xingming.Text
rs.Fields(2) = Text1.Text
rs.Fields(3) = bumen.Text
rs.Fields(4) = txttel.Text
rs.Fields(5) = Text8.Text
rs.Update '调用Recordset对象Update方法保存数据
Set DataGrid1.DataSource = rs
MsgBox "添加员工信息成功!"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -