📄 frm_xqyggl.frm
字号:
Caption = "员工姓名"
Height = 180
Index = 0
Left = 135
TabIndex = 26
Top = 675
Width = 720
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "员工编号"
Height = 180
Index = 0
Left = 135
TabIndex = 25
Top = 255
Width = 720
End
End
Begin MSDataGridLib.DataGrid DataGrid1
Height = 2610
Left = -74745
TabIndex = 14
Top = 420
Width = 5355
_ExtentX = 9446
_ExtentY = 4604
_Version = 393216
HeadLines = 1
RowHeight = 15
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 = 2
BeginProperty Column00
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 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
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
End
Begin VB.Label Label12
Caption = "Label12"
DataField = "部门名称"
DataSource = "Adodc3"
Height = 345
Left = 4605
TabIndex = 54
Top = 5040
Width = 885
End
Begin VB.Label Label11
Caption = "Label11"
DataField = "员工种类"
DataSource = "Adodc2"
Height = 285
Left = 2325
TabIndex = 53
Top = 4995
Width = 840
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "请输入查询条件:"
ForeColor = &H00FF0000&
Height = 180
Left = 90
TabIndex = 1
Top = 210
Width = 1440
End
End
Attribute VB_Name = "Frm_xqyggl"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim j As String '定义整型变量
Private Sub Combo2_Click()
If Combo2.Text = "=" Then
j = 1
ElseIf Combo2.Text = ">" Then
j = 2
ElseIf Combo2.Text = "<" Then
j = 3
ElseIf Combo2.Text = "<>" Then
j = 4
ElseIf Combo2.Text = "like" Then
j = 5
Else
End If
End Sub
Private Sub Command1_Click() '查询
If Combo2.Text = "like" Then
Adodc1.RecordSource = "select * from tab_yginfo where " & Combo1.Text & " like +'%" & Text1.Text & "%'"
Adodc1.Refresh
Else
Adodc1.RecordSource = "select * from tab_yginfo where " & Combo1.Text & " " & Combo2.Text & " '" & Text1.Text & "'"
Adodc1.Refresh
End If
End Sub
Private Sub Command6_Click() '添加
Frame3(0).Visible = True
Frame3(1).Visible = False
' Command6.Visible = False
' Command7.Visible = True
Text3(0).Text = ""
Text4(0).Text = ""
Text5(0).Text = ""
Text6(0).Text = ""
Combo3(0).Text = ""
Combo4(0).Text = ""
Combo5(0).Text = ""
Adodc1.RecordSource = "select * from tab_yginfo order by 员工编号"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
If Adodc1.Recordset.EOF = False Then
Adodc1.Recordset.MoveLast
Text2(0).Text = "yg" + Trim(Mid(Adodc1.Recordset.Fields("员工编号"), 3, 2) + 1)
Else
Text2(0).Text = "yg" + Trim(Mid(Adodc1.Recordset.Fields("员工编号"), 3, 2) + 1)
End If
Else
Text2(0).Text = "yg1"
End If
End Sub
Private Sub Command7_Click() '保存
If Text2(0).Text = "" Or Text3(0).Text = "" Or Text4(0).Text = "" Or Text5(0).Text = "" Or Text6(0).Text = "" Or Combo3(0).Text = "" Or Combo4(0).Text = "" Or Combo5(0).Text = "" Then
MsgBox "不允许为空", , "系统提示"
Exit Sub
Else
Set adors = cn.Execute("insert into tab_yginfo values('" & Text2(0) & "','" & Text3(0) & "','" & Combo3(0) & "','" & DTPicker1(0) & "','" & Combo4(0) & "','" & Text4(0) & "','" & Text5(0) & "','" & Combo5(0) & "','" & Text6(0) & "')")
MsgBox "数据保存成功", , "系统提示"
Adodc1.Refresh
cn.Close
End If
Unload Me
Frm_xqyggl.Show
End Sub
Private Sub Command10_Click() '删除
Dim myval As String
Adodc1.RecordSource = "select * from tab_yginfo"
If Adodc1.Recordset.RecordCount > 0 Then
myval = MsgBox("确定该信息删除吗?", vbYesNo, "系统提示")
If myval = vbYes Then
Adodc1.Recordset.Delete '删除该记录
Adodc1.Recordset.Update
Adodc1.RecordSource = "select * from tab_yginfo"
Adodc1.Refresh
Else
End If
Else
MsgBox "数据库中没有记录要删除", , "系统提示"
End If
Adodc1.RecordSource = "select * from tab_yginfo"
Adodc1.Refresh
'Unload Me
'Frm_xqyggl.Show
End Sub
Private Sub Command11_Click() '退出
Unload Me
Me.Hide
Frm_main.Show
End Sub
Private Sub Command2_Click() '“|<”按钮
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
Adodc1.Recordset.MoveFirst
DTPicker1(1).Value = Adodc1.Recordset.Fields("出生日期")
Else
MsgBox "没有记录!", , "系统提示"
End If
End Sub
Private Sub Command3_Click() '“<”按钮
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
Adodc1.Recordset.MovePrevious
On Error Resume Next
DTPicker1(1).Value = Adodc1.Recordset.Fields("出生日期")
If Adodc1.Recordset.BOF Then
Adodc1.Recordset.MoveFirst
DTPicker1(1).Value = Adodc1.Recordset.Fields("出生日期")
End If
Else
MsgBox "没有记录!", , "系统提示"
End If
End Sub
Private Sub Command4_Click() '“>”按钮
If Adodc1.Recordset.RecordCount > 0 Then
Adodc1.Recordset.MoveNext
On Error Resume Next
DTPicker1(1).Value = Adodc1.Recordset.Fields("出生日期")
If Adodc1.Recordset.EOF Then
Adodc1.Recordset.MoveLast
DTPicker1(1).Value = Adodc1.Recordset.Fields("出生日期")
End If
Else
MsgBox "没有记录!", , "系统提示"
End If
End Sub
Private Sub Command5_Click() '“>|”按钮
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
Adodc1.Recordset.MoveLast
DTPicker1(1).Value = Adodc1.Recordset.Fields("出生日期")
Else
MsgBox "没有记录!", , "系统提示"
End If
End Sub
Private Sub Command9_Click() '更新
Adodc1.Recordset.UpdateBatch
MsgBox "修改成功", , "系统提示"
Adodc1.Refresh
End Sub
Private Sub Form_Load()
Dim i As Integer
'自动识别路径
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db_wygl.mdb;Persist Security Info=False"
Adodc1.RecordSource = "select * from tab_yginfo"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
Adodc2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db_wygl.mdb;Persist Security Info=False"
Adodc2.RecordSource = "select * from tab_gzinfo"
Adodc2.Refresh
Dim rs As New ADODB.Recordset
rs.Open "select * from tab_gzinfo", cn, 1, 3
If rs.RecordCount > 0 Then
rs.MoveFirst
For i = 0 To rs.RecordCount - 1
Combo4(0).AddItem rs.Fields("员工种类")
rs.MoveNext
Next i
End If
rs.Close
Adodc3.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db_wygl.mdb;Persist Security Info=False"
Adodc3.RecordSource = "select * from tab_bminfo"
Adodc3.Refresh
Dim rs1 As New ADODB.Recordset
rs1.Open "select * from tab_bminfo", cn, 1, 3
If rs1.RecordCount > 0 Then
rs1.MoveFirst
For i = 0 To rs1.RecordCount - 1
Combo5(0).AddItem rs1.Fields("部门名称")
rs1.MoveNext
Next i
End If
rs1.Close
End Sub
Private Sub SSTab1_Click(PreviousTab As Integer)
'SSTab 控件提供了一组选项卡,每个选项卡都可作为其它控件的容器。
If SSTab1.Tab = 1 Then
'设置控件状态
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = True
Command5.Enabled = True
Command6.Enabled = False
Command7.Enabled = False
Command9.Enabled = True
Command10.Enabled = True
Command11.Enabled = True
Else
If SSTab1.Tab = 0 Then
'设置控件状态
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = True
Command5.Enabled = True
Command6.Enabled = True
Command7.Enabled = True
Command9.Enabled = True
Command10.Enabled = True
Command11.Enabled = True
Frame3(1).Visible = True
Frame3(0).Visible = False
End If
End If
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then '按回车键Command1获得焦点
Command1.SetFocus
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -