📄 frmdazhcx.frm
字号:
End If
End Sub
Private Sub Command1_Click()
Dim numI As Integer
Dim strExec As String
If Text2.Text <> "" And Right(Text3.Text, 1) <> ")" Then '制定了查询条件,所以补充查询表达式的右括号
Text3.Text = Text3.Text & ")"
End If
Set objRs = objCon.Execute(Text3.Text)
If objRs.EOF Then
MsgBox "没有找到任何记录,请检查您的查询条件!", vbCritical, "系统信息"
Command2.Enabled = False
Else
Command2.Enabled = True
numI = 1
Cell1_Setup Cell1
Do While Not objRs.EOF
Cell1.DoAppendRow 1
Cell1.DoSetCellString 0, numI, Trim(objRs("xh"))
Cell1.DoSetCellString 1, numI, Trim(objRs("xm"))
Cell1.DoSetCellString 2, numI, Trim(objRs("csny"))
Cell1.DoSetCellString 3, numI, Trim(objRs("xb"))
Cell1.DoSetCellString 4, numI, Trim(objRs("mz"))
Cell1.DoSetCellString 5, numI, Trim(objRs("zzmm"))
Cell1.DoSetCellString 6, numI, Trim(objRs("nj"))
Cell1.DoSetCellString 7, numI, Trim(objRs("xbmc"))
Cell1.DoSetCellString 8, numI, Trim(objRs("zymc"))
Cell1.DoSetCellString 9, numI, Trim(objRs("bj"))
objRs.MoveNext
numI = numI + 1
Loop
End If
objRs.Close
End Sub
Private Sub Command2_Click()
MsgBox "请在打印机中放入A4打印纸...", vbOKOnly, "数据打印"
Load FrmPrePrint
' 复制数据到打印窗口中
Cell1.DoCopyArea 0, 0, Cell1.Cols - 1, Cell1.Rows - 1
FrmPrePrint.Cell1.DoPaste 0, 0, True
FrmPrePrint.Cell1.Cols = Cell1.Cols
FrmPrePrint.Cell1.Rows = Cell1.Rows
' 设置报表标题
FrmPrePrint.Cell1.DoInsertRow 0, 1
FrmPrePrint.Cell1.DoJoinCells 0, 0, FrmPrePrint.Cell1.Cols - 1, 0
FrmPrePrint.Cell1.DoSetRowHeight 0, 60
FrmPrePrint.Cell1.DoSetCellFont 0, 0, 12, 1, "宋体" '12号宋体字,粗体
FrmPrePrint.Cell1.DoSetCellString 0, 0, "学生档案组合查询表"
FrmPrePrint.Cell1.DoSetCellAlignment 0, 0, 36
' 设置页脚
FrmPrePrint.Cell1.DoSetPrintFoot "", "&P &D", ""
' 显示网格
FrmPrePrint.Cell1.DoDrawLine 0, 1, FrmPrePrint.Cell1.Cols, FrmPrePrint.Cell1.Rows, 0, 1, 0
FrmPrePrint.Cell1.DoSetPrintPara 1, 9, False
FrmPrePrint.Cell1.DoPrintPreview True
Unload FrmPrePrint
End Sub
Private Sub Command4_Click()
Dim bIsValid As Boolean
If Right(Text3.Text, 1) = ")" Then '数据查询结束后继续指定其它条件,所以去掉右括号
Text3.Text = Left(Text3.Text, Len(Text3.Text) - 1)
End If
If Not bRe_enter Then '第一个查询条件不需要指定与或关系
If Combo1.Text = "" Or Combo2.Text = "" Or (Combo3.Text = "" And Text1.Text = "") Or (Combo3.Text <> "" And Combo3.Visible = False And Text1.Text = "") Then
MsgBox "查询条件不全,请重新选择(1)!", vbCritical, "错误信息"
bIsValid = False
Else
Text3.Text = Text3.Text & " And ("
bRe_enter = True
bIsValid = True
End If
Else
If Combo1.Text = "" Or Combo2.Text = "" Or (Combo3.Text = "" And Text1.Text = "") Or (Combo3.Text <> "" And Combo3.Visible = False And Text1.Text = "") Or Combo4.Text = "" Then
MsgBox "查询条件不全,请重新选择(2)!", vbCritical, "错误信息"
bIsValid = False
Else
Text3.Text = Text3.Text & IIf(Combo4.Text = "且", " And ", " Or ")
Text2.Text = Text2.Text & " " & Combo4.Text & " "
bIsValid = True
End If
End If
If bIsValid Then
Select Case Combo1.Text
Case "学号"
Text3.Text = Text3.Text & "a.xh" & Combo2.Text & "'" & Trim(Text1.Text) & "'"
Text2.Text = Text2.Text & "学号" & Combo2.Text & "'" & Trim(Text1.Text) & "'"
Case "姓名"
Text3.Text = Text3.Text & "a.xm" & Combo2.Text & "'" & Trim(Text1.Text) & "'"
Text2.Text = Text3.Text & "姓名" & Combo2.Text & "'" & Trim(Text1.Text) & "'"
Case "出生年月"
If (Len(Text1.Text) <> 5 And Len(Text1.Text) <> 6) Or Not IsNumeric(Text1.Text) Then
MsgBox "出生年月无效,请重新输入!", vbCritical, "错误信息"
If Right(Text3.Text, 3) = "Or " Then
Text3.Text = Left(Text3.Text, Len(Text3.Text) - 4) '去掉 " Or "
ElseIf Right(Text3.Text, 4) = "And " Then
Text3.Text = Left(Text3.Text, Len(Text3.Text) - 5) '去掉 " And "
Else
Text3.Text = Left(Text3.Text, Len(Text3.Text) - 6) '去掉 " And ("
bRe_enter = False '第一个检索条件出错,所以bRe_enter重新设置为false
End If
If Len(Text2.Text) > 0 Then
Text2.Text = Left(Text2.Text, Len(Text2.Text) - 3)
End If
Text1.SetFocus
Else
Text1.Text = IIf(Len(Text1.Text) = 5, Left(Text1.Text, 4) & "0" & Right(Text1.Text, 1), Text1.Text)
If Not IsDate(Left(Text1.Text, 4) & "/" & Right(Text1.Text, 2) & "/01") Then
MsgBox "出生年月无效,请重新输入!", vbCritical, "错误信息"
If Right(Text3.Text, 3) = "Or " Then
Text3.Text = Left(Text3.Text, Len(Text3.Text) - 4) '去掉 " Or "
ElseIf Right(Text3.Text, 4) = "And " Then
Text3.Text = Left(Text3.Text, Len(Text3.Text) - 5) '去掉 " And "
Else
Text3.Text = Left(Text3.Text, Len(Text3.Text) - 6) '去掉 " Where "
bRe_enter = False
End If
If Len(Text2.Text) > 0 Then
Text2.Text = Left(Text2.Text, Len(Text2.Text) - 3)
End If
Text1.SetFocus
Else
Text3.Text = Text3.Text & "a.csny" & Combo2.Text & "'" & Text1.Text & "'"
Text2.Text = Text2.Text & "出生年月" & Combo2.Text & "'" & Text1.Text & "'"
End If
End If
Case "性别"
Text3.Text = Text3.Text & "a.xb" & Combo2.Text & "'" & Trim(Combo3.Text) & "'"
Text2.Text = Text2.Text & "性别" & Combo2.Text & "'" & Trim(Combo3.Text) & "'"
Case "民族"
Text3.Text = Text3.Text & "a.mz" & Combo2.Text & "'" & Trim(Combo3.Text) & "'"
Text2.Text = Text2.Text & "民族" & Combo2.Text & "'" & Trim(Combo3.Text) & "'"
Case "政治面貌"
Text3.Text = Text3.Text & "a.zzmm" & Combo2.Text & "'" & Trim(Combo3.Text) & "'"
Text2.Text = Text2.Text & "政治面貌" & Combo2.Text & "'" & Trim(Combo3.Text) & "'"
Case "年级"
Text3.Text = Text3.Text & "a.nj" & Combo2.Text & "'" & Trim(Text1.Text) & "'"
Text2.Text = Text2.Text & "年级" & Combo2.Text & "'" & Trim(Text1.Text) & "'"
Case "系别"
Text3.Text = Text3.Text & "b.xbmc" & Combo2.Text & "'" & Trim(Combo3.Text) & "'"
Text2.Text = Text2.Text & "系别" & Combo2.Text & "'" & Trim(Combo3.Text) & "'"
Case "专业"
Text3.Text = Text3.Text & "c.zymc" & Combo2.Text & "'" & Trim(Combo3.Text) & "'"
Text2.Text = Text2.Text & "专业" & Combo2.Text & "'" & Trim(Combo3.Text) & "'"
Case "班级"
Text3.Text = Text3.Text & "a.bj" & Combo2.Text & "'" & Trim(Text1.Text) & "'"
Text2.Text = Text2.Text & "班级" & Combo2.Text & "'" & Trim(Text1.Text) & "'"
End Select
End If
End Sub
Private Sub command5_click()
Text3.Text = "Select a.xm,a.xh,a.csny,a.xb,a.mz,a.zzmm,a.nj,a.bj,b.xbmc,c.zymc From XSDAB a,XBMCB b,ZYMCB c " & _
"Where a.xbbh=b.xbbh And a.zybh=c.zybh"
Text2.Text = ""
bRe_enter = False
End Sub
Private Sub Form_Load()
Combo1.AddItem ("学号")
Combo1.AddItem ("姓名")
Combo1.AddItem ("出生年月")
Combo1.AddItem ("性别")
Combo1.AddItem ("民族")
Combo1.AddItem ("政治面貌")
Combo1.AddItem ("年级")
Combo1.AddItem ("系别")
Combo1.AddItem ("专业")
Combo1.AddItem ("班级")
Combo1.ListIndex = 0
Cell1_Setup Cell1
Text3.Text = "Select a.xm,a.xh,a.csny,a.xb,a.mz,a.zzmm,a.nj,a.bj,b.xbmc,c.zymc From XSDAB a,XBMCB b,ZYMCB c " & _
"Where a.xbbh=b.xbbh And a.zybh=c.zybh"
bRe_enter = False
' Combo1.SetFocus
End Sub
Private Sub Form_Unload(Cancel As Integer)
FrmMain.Enabled = True
End Sub
Private Sub Command3_Click()
Unload frmDazhcx
FrmMain.Enabled = True
End Sub
Private Sub Cell1_Setup(ByRef obj As Object)
Dim numI As Integer
obj.DoResetContent
obj.EnablePopMenu = False
obj.PageLabelVisible = False
obj.SideLabelVisible = False
obj.TopLabelVisible = False
obj.ResizeWhenPasteNeed = False
obj.Cols = 10
obj.Rows = 1
obj.GridReadOnly = True
obj.DoSetCellString -1, 0, "编号"
obj.DoSetCellString 0, 0, "学号"
obj.DoSetCellString 1, 0, "姓名"
obj.DoSetCellString 2, 0, "出生年月"
obj.DoSetCellString 3, 0, "性别"
obj.DoSetCellString 4, 0, "民族"
obj.DoSetCellString 5, 0, "政治面貌"
obj.DoSetCellString 6, 0, "年级"
obj.DoSetCellString 7, 0, "系别"
obj.DoSetCellString 8, 0, "专业"
obj.DoSetCellString 9, 0, "班级"
For numI = -1 To 9
obj.DoSetCellAlignment numI, 0, 36
Next
obj.DoSetColWidth 0, 80
obj.DoSetColWidth 7, 128
obj.DoSetColWidth 8, 128
obj.DoSetDefaultFont 8, 0, "宋体"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -