📄 dlgbuildexpression.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Object = "{0B81E4A9-BE4E-4AEF-9272-33AB5B51C6FC}#1.0#0"; "XPControls.ocx"
Begin VB.Form dlgBuildExpression
BackColor = &H80000018&
BorderStyle = 3 'Fixed Dialog
Caption = "构造表达式"
ClientHeight = 5685
ClientLeft = 2760
ClientTop = 3750
ClientWidth = 8010
Icon = "dlgBuildExpression.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5685
ScaleWidth = 8010
ShowInTaskbar = 0 'False
StartUpPosition = 1 '所有者中心
Begin VB.Frame Frame1
BackColor = &H80000018&
Caption = "运算符"
Height = 2070
Left = 5235
TabIndex = 5
Top = 1860
Width = 2445
Begin XPControls.XPCommandButton cmdOperator
Height = 285
Index = 5
Left = 1410
TabIndex = 11
Top = 1560
Width = 390
_ExtentX = 688
_ExtentY = 503
Caption = ")"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin XPControls.XPCommandButton cmdOperator
Height = 285
Index = 4
Left = 540
TabIndex = 10
Top = 1560
Width = 390
_ExtentX = 688
_ExtentY = 503
Caption = "("
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin XPControls.XPCommandButton cmdOperator
Height = 285
Index = 3
Left = 1410
TabIndex = 9
Top = 967
Width = 390
_ExtentX = 688
_ExtentY = 503
Caption = "/"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin XPControls.XPCommandButton cmdOperator
Height = 285
Index = 2
Left = 540
TabIndex = 8
Top = 967
Width = 390
_ExtentX = 688
_ExtentY = 503
Caption = "*"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin XPControls.XPCommandButton cmdOperator
Height = 285
Index = 1
Left = 1410
TabIndex = 7
Top = 375
Width = 390
_ExtentX = 688
_ExtentY = 503
Caption = "-"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin XPControls.XPCommandButton cmdOperator
Height = 285
Index = 0
Left = 540
TabIndex = 6
Top = 375
Width = 390
_ExtentX = 688
_ExtentY = 503
Caption = "+"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
End
Begin MSComctlLib.TreeView tvwXMu
Height = 3645
Left = 315
TabIndex = 1
Top = 1755
Width = 4725
_ExtentX = 8334
_ExtentY = 6429
_Version = 393217
HideSelection = 0 'False
LabelEdit = 1
Style = 7
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin VB.TextBox txtExpression
BeginProperty Font
Name = "宋体"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 840
Left = 315
MultiLine = -1 'True
TabIndex = 0
Top = 780
Width = 7320
End
Begin XPControls.XPCommandButton cmdCancel
Cancel = -1 'True
Height = 375
Left = 6585
TabIndex = 3
Top = 4650
Width = 930
_ExtentX = 1640
_ExtentY = 661
Caption = "取消(&C)"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin XPControls.XPCommandButton cmdOK
Default = -1 'True
Height = 375
Left = 5385
TabIndex = 4
Top = 4650
Width = 945
_ExtentX = 1667
_ExtentY = 661
Caption = "确定(&O)"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = $"dlgBuildExpression.frx":1982
BeginProperty Font
Name = "宋体"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 615
Left = 315
TabIndex = 2
Top = 105
Width = 7320
End
End
Attribute VB_Name = "dlgBuildExpression"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim mstrLawlessValue As String
Dim mstrRet_Show As String
Dim mstrRet_Database As String
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
Dim Status
Dim strSQL As String
Dim rstemp As ADODB.Recordset
Dim strExpression As String
Dim strRet_Show As String
Dim strRet_Database As String
Me.MousePointer = vbHourglass
strExpression = Trim(txtExpression.Text)
'去掉可能存在的回车换行
strExpression = Replace(strExpression, vbCr, "")
strExpression = Replace(strExpression, vbLf, "")
strRet_Show = CheckExpression(strExpression, mstrLawlessValue, False)
If strRet_Show = "" Then
txtExpression.SetFocus
GoTo ExitLab
Else
'记录数据库表达式
strRet_Database = strExpression
'去掉括号后再校验一次
strExpression = strRet_Show
strExpression = Replace(strExpression, "(", "")
strExpression = Replace(strExpression, ")", "")
If CheckExpression(strExpression, mstrLawlessValue, True) = "" Then
txtExpression.SetFocus
GoTo ExitLab
End If
'成功返回
mstrRet_Show = strRet_Show
mstrRet_Database = strRet_Database
Unload Me
End If
GoTo ExitLab
ExitLab:
Me.MousePointer = vbDefault
End Sub
Private Sub cmdOperator_Click(Index As Integer)
txtExpression.SelText = cmdOperator(Index).Caption
txtExpression.SetFocus
End Sub
Private Sub Form_Load()
On Error GoTo ErrMsg
Dim Status
Dim strSQL As String
Dim rsKS As ADODB.Recordset
Dim rsXX As ADODB.Recordset
Dim nodTemp As Node
Screen.MousePointer = vbHourglass
'添加根节点
'关键字长度:1=1
strSQL = "select KSID,KSMC from SET_KSSZ order by SXH"
Set rsKS = New ADODB.Recordset
rsKS.Open strSQL, GCon, adOpenStatic, adLockOptimistic
Set nodTemp = tvwXMu.Nodes.Add(, , "W", "所有科室")
nodTemp.Expanded = True
'外层循环,添加所有科室
If rsKS.RecordCount > 0 Then
rsKS.MoveFirst
With tvwXMu.Nodes
Do
'关键字长度:1+2=3
Set nodTemp = .Add("W", tvwChild, "W" & rsKS("KSID"), rsKS("KSMC"))
'对每个科室,循环添加下属的所有项目
'只显示数值型项目
strSQL = "select XXID,XXMC from SET_XX" _
& " where left(XXID,2)='" & rsKS("KSID") & "'" _
& " and XXType=1" _
& " order by SXH"
Set rsXX = New ADODB.Recordset
rsXX.Open strSQL, GCon, adOpenStatic, adLockOptimistic
If rsXX.RecordCount > 0 Then
rsXX.MoveFirst
'内层循环
Do
'关键字长度:1+7=8
Set nodTemp = .Add("W" & rsKS("KSID"), tvwChild, "W" & rsXX("XXID"), rsXX("XXMC"))
rsXX.MoveNext
Loop Until rsXX.EOF
rsXX.Close
End If
rsKS.MoveNext
Loop Until rsKS.EOF
End With
rsKS.Close
End If
If tvwXMu.Nodes.Count > 1 Then
'说明至少存在一个科室
'默认选中第一个科室,即第二个节点
Set tvwXMu.SelectedItem = tvwXMu.Nodes(2)
Else
'没有科室
'选中第一个根节点
Set tvwXMu.SelectedItem = tvwXMu.Nodes(1)
' MsgBox "尚未建立任何科室,无法添加项目!" & vbCrLf & "请首先添加科室!", vbInformation, "提示"
End If
GoTo ExitLab
ErrMsg:
Status = SetError(Err.Number, Err.Description, Err.Source)
ErrMsg Status
ExitLab:
Screen.MousePointer = vbDefault
End Sub
'***************************************************************
'被调函数(被“项目设置”模块调用)
'参数1:添加或修改
'参数2:当前欲设置表达式的小项名称
'参数3:如果是修改,则为欲修改的表达式,否则为空
'返回值:用户单击取消时,返回空字符串,否则返回生成的表达式
'***************************************************************
Public Function GetExpression(ByVal enuOperation As OperationType, _
ByVal strXXMC As String, _
Optional ByVal strExpression As String) As String
On Error GoTo ErrMsg
Dim Status
mstrLawlessValue = strXXMC '表达式中不能包含自己
If enuOperation = Modify Then
txtExpression.Text = strExpression
End If
Me.Show vbModal
If mstrRet_Show <> "" Then
GetExpression = mstrRet_Show & "," & mstrRet_Database
End If
GoTo ExitLab
ErrMsg:
Status = SetError(Err.Number, Err.Description, Err.Source)
ErrMsg Status
ExitLab:
'
End Function
'双击时,添加项目到指定位置
Private Sub tvwXMu_DblClick()
Dim Status
Me.MousePointer = vbHourglass
If tvwXMu.SelectedItem Is Nothing Then GoTo ExitLab
If Len(tvwXMu.SelectedItem.Key) = 8 Then
txtExpression.SelText = tvwXMu.SelectedItem.Text
txtExpression.SetFocus
End If
GoTo ExitLab
ExitLab:
Me.MousePointer = vbDefault
End Sub
Private Sub txtExpression_Change()
txtExpression.Text = Trim(txtExpression.Text)
If txtExpression.Text = "" Then
cmdOK.Enabled = False
Else
cmdOK.Enabled = True
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -