📄 frmdocbrowse.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "MSHFLXGD.OCX"
Begin VB.Form frmDocBrowse
BackColor = &H00C0C0C0&
BorderStyle = 1 'Fixed Single
Caption = "浏览档案"
ClientHeight = 5430
ClientLeft = 45
ClientTop = 330
ClientWidth = 11520
LinkTopic = "Form3"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 5430
ScaleWidth = 11520
Begin VB.CommandButton cmdDelete
Caption = "删除"
Height = 375
Left = 2040
TabIndex = 4
Top = 4920
Width = 855
End
Begin VB.CommandButton cmdModify
Caption = "修改"
Height = 375
Left = 1080
TabIndex = 3
Top = 4920
Width = 975
End
Begin VB.CommandButton cmdFind
Caption = "查找"
Height = 375
Left = 120
TabIndex = 2
Top = 4920
Width = 975
End
Begin MSHierarchicalFlexGridLib.MSHFlexGrid flgDocData
Height = 5175
Left = 2880
TabIndex = 0
Top = 120
Width = 8535
_ExtentX = 15055
_ExtentY = 9128
_Version = 393216
BackColor = -2147483624
BackColorSel = 16777215
ForeColorSel = 255
BackColorBkg = -2147483624
GridColor = 12632256
GridColorFixed = 4210752
SelectionMode = 1
AllowUserResizing= 3
_NumberOfBands = 1
_Band(0).Cols = 2
End
Begin MSComctlLib.TreeView trvDocument
Height = 4815
Left = 120
TabIndex = 1
Top = 120
Width = 2775
_ExtentX = 4895
_ExtentY = 8493
_Version = 393217
HideSelection = 0 'False
LineStyle = 1
Style = 7
FullRowSelect = -1 'True
HotTracking = -1 'True
BorderStyle = 1
Appearance = 1
End
End
Attribute VB_Name = "frmDocBrowse"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'----------------------------------frmDocBrowse.frm----------------------------------
Option Explicit
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
'显示表格中档案的字段名称名称
Public Sub ShowDocTitle()
Dim i As Integer
flgDocData.Clear
With flgDocData
.Cols = 14
.TextMatrix(0, 1) = "学号"
.TextMatrix(0, 2) = "姓名"
.TextMatrix(0, 3) = "性别"
.TextMatrix(0, 4) = "年级"
.TextMatrix(0, 5) = "班级"
.TextMatrix(0, 6) = "专业"
.TextMatrix(0, 7) = "年制"
.TextMatrix(0, 8) = "出生年月"
.TextMatrix(0, 9) = "家庭住址"
.TextMatrix(0, 10) = "邮政编码"
.TextMatrix(0, 11) = "联系电话"
.TextMatrix(0, 12) = "入学时间"
.TextMatrix(0, 13) = "备注"
.ColWidth(0) = 200
.ColWidth(1) = 500
.ColWidth(2) = 700
.ColWidth(3) = 500
.ColWidth(4) = 1000
.ColWidth(5) = 800
.ColWidth(6) = 700
.ColWidth(7) = 800
.ColWidth(8) = 800
.ColWidth(9) = 3000
.ColWidth(10) = 800
.ColWidth(11) = 1000
.ColWidth(12) = 800
.ColWidth(13) = 6000
.FixedRows = 1
For i = 1 To 13
.ColAlignment(i) = 0
Next i
.FillStyle = flexFillSingle
.Col = 0
.Row = 0
.RowSel = 1
.ColSel = .Cols - 1
.CellAlignment = 4
.Row = 1
End With
End Sub
'删除档案
Private Sub cmdDelete_Click()
Dim objRecordset As ADODB.Recordset
If Trim(flgDocData.TextMatrix(flgDocData.Row, 1)) = "" Then
MsgBox "你还没有选择记录!", vbOKOnly + vbExclamation, "警告"
Else
If strUserManage = "ReadOnly" Then
MsgBox "对不起,你是只读用户不能删除记录,请与管理员联系!", vbInformation + vbOKOnly, " 警告"
Exit Sub
End If
If MsgBox("确定要删除学号为 " & Trim(flgDocData.TextMatrix(flgDocData.Row, 1)) & " 的记录吗?" & Chr(10) & Chr(13) _
& "该操作会导致该学生交费记录和成绩记录的丢失!确定吗?", vbOKCancel + vbExclamation, "警告") = vbOK Then
'删除学生的档案和成绩
strSQL = "delete * from Documents where 学号='" & Trim(flgDocData.TextMatrix(flgDocData.Row, 1)) & "'"
Set objRecordset = ExecuteSQL(strSQL)
strSQL = "delete * from Scores where 学号='" & Trim(flgDocData.TextMatrix(flgDocData.Row, 1)) & "'"
Set objRecordset = ExecuteSQL(strSQL)
'更新数据表格
trvDocument_DblClick
End If
End If
End Sub
'查找
Private Sub cmdFind_Click()
frmDocFind.Show
End Sub
'修改
Private Sub cmdModify_Click()
If Trim(flgDocData.TextMatrix(flgDocData.Row, 1)) = "" Then
MsgBox "你还没有选择记录!", vbOKOnly + vbExclamation, "警告"
Exit Sub
Else
strUserManage = UserManage(2)
If strUserManage = "ReadOnly" Then
MsgBox "对不起,你是只读用户不能修改记录,请与管理员联系!", vbInformation + vbOKOnly, " 警告"
Exit Sub
End If
blnModifyDoc = True
frmDocModify.Show
frmDocModify.ZOrder 0
End If
End Sub
Private Sub Form_Activate()
If blnFindDoc = True Then
frmDocFind.ZOrder
Exit Sub
ElseIf blnModifyDoc = True Then
ShowDocData
blnModifyDoc = False
Else
DocTree
End If
End Sub
'显示档案信息
Public Sub ShowDocData()
Dim i As Integer
Dim objRecordset As ADODB.Recordset
Set objRecordset = New ADODB.Recordset
Set objRecordset = ExecuteSQL(strSQL)
'如果有记录,将数据显示在表格中
If objRecordset.EOF = False Then
objRecordset.MoveFirst
With flgDocData
.Rows = 50
.Row = 1
Do While Not objRecordset.EOF
.Rows = .Rows + 1
For i = 1 To objRecordset.Fields.Count
.TextMatrix(.Row, i) = objRecordset.Fields(i - 1)
Next
.Row = .Row + 1
objRecordset.MoveNext
Loop
End With
'如果没有记录,显示添加档案界面
Else
If blnFindDoc = True Then
frmDocBrowse.Hide
frmDocFind.Show
MsgBox "对不起,没有此学生的档案记录!", vbOKOnly, "查询"
frmDocFind.ZOrder (0)
frmDocFind.txtDocument(0).SetFocus
End If
End If
Set objRecordset = Nothing
End Sub
Private Sub Form_Unload(Cancel As Integer)
If blnFindDoc = True Then
blnFindDoc = False
frmDocFind.txtDocument(0).SetFocus
End If
End Sub
'使用TreeView控件显示学生
Public Sub DocTree()
Dim Nodex As Node
Dim objRecordset As ADODB.Recordset
Dim objSubRecordset As ADODB.Recordset
Dim strSQL As String
Dim strDoc As String
trvDocument.Nodes.Clear
'查询数据
strDoc = "年级"
strSQL = "select distinct 年级 from Classes order by 年级"
Set objRecordset = ExecuteSQL(strSQL)
strSQL = "select distinct 年级,班级 from Classes order by 年级,班级"
Set objSubRecordset = ExecuteSQL(strSQL)
objRecordset.MoveFirst
'将符合条件的数据显示在TreeView控件中
Do Until objRecordset.EOF
objSubRecordset.MoveFirst
'设置根节点
Set Nodex = trvDocument.Nodes.Add(, , strDoc, objRecordset.Fields(0))
'设置子节点
Do While Not objSubRecordset.EOF
If objSubRecordset.Fields(0) = objRecordset.Fields(0) Then
Set Nodex = trvDocument.Nodes.Add(strDoc, tvwChild, , objSubRecordset.Fields(1))
End If
objSubRecordset.MoveNext
Loop
strDoc = strDoc & "1"
objRecordset.MoveNext
Loop
objSubRecordset.Close
objRecordset.Close
Set objRecordset = Nothing
Set objSubRecordset = Nothing
End Sub
'双击节点,将学生信息显示在表格中
Private Sub trvDocument_DblClick()
On Error GoTo ErrorTrap
If trvDocument.SelectedItem.Index = 0 Then
flgDocData.Clear
Exit Sub
End If
strSQL = trvDocument.Nodes.Item(trvDocument.SelectedItem.Index)
strSQL = "select Documents.学号,Documents.姓名,Documents.性别,Classes.年级,Documents.班级,Classes.专业,Classes.年制,Documents.出生年月,Documents.家庭住址,Documents.邮政编码,Documents.联系电话,Documents.入学时间,Documents.备注 from Documents inner join Classes on Documents.班级=Classes.班级 where Documents.班级='" & strSQL & "' or 年级=' & strSQL & ' order by Classes.年级 ,Classes.班级 ,Documents.学号 "
ShowDocTitle
ShowDocData
Exit Sub
ErrorTrap:
flgDocData.Clear
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -