📄 metertype.frm
字号:
VERSION 5.00
Begin VB.Form MeterType
BorderStyle = 1 'Fixed Single
Caption = "表计类型"
ClientHeight = 3720
ClientLeft = 45
ClientTop = 435
ClientWidth = 6135
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3720
ScaleWidth = 6135
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command4
Height = 300
Left = 2320
Picture = "MeterType.frx":0000
Style = 1 'Graphical
TabIndex = 11
Top = 200
Width = 300
End
Begin VB.CommandButton Command3
Caption = "退出"
Height = 375
Left = 5040
TabIndex = 10
Top = 3120
Width = 975
End
Begin VB.CommandButton Command2
Caption = "删除"
Height = 375
Left = 3960
TabIndex = 9
Top = 3120
Width = 975
End
Begin VB.CommandButton Command1
Caption = "添加"
Height = 375
Left = 2880
TabIndex = 8
Top = 3120
Width = 975
End
Begin VB.Frame Frame2
Caption = " 表型信息 "
Height = 2895
Left = 2880
TabIndex = 3
Top = 120
Width = 3135
Begin VB.TextBox Text2
Height = 1695
Left = 1080
TabIndex = 7
Top = 840
Width = 1815
End
Begin VB.TextBox Text1
Height = 375
Left = 1080
TabIndex = 5
Top = 240
Width = 1815
End
Begin VB.Label Label3
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "备注"
Height = 180
Left = 240
TabIndex = 6
Top = 960
Width = 360
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "表型名称"
Height = 180
Left = 240
TabIndex = 4
Top = 360
Width = 720
End
End
Begin VB.Frame Frame1
Caption = " 现有表型 "
Height = 2895
Left = 120
TabIndex = 2
Top = 600
Width = 2535
Begin VB.ListBox List1
Height = 2400
ItemData = "MeterType.frx":058A
Left = 120
List = "MeterType.frx":058C
TabIndex = 12
Top = 240
Width = 2295
End
End
Begin VB.ComboBox BM
Height = 300
Left = 960
TabIndex = 1
Top = 200
Width = 1335
End
Begin VB.Line Line1
BorderColor = &H80000010&
X1 = 2760
X2 = 2760
Y1 = 120
Y2 = 3480
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "部门选择"
Height = 180
Left = 120
TabIndex = 0
Top = 285
Width = 720
End
End
Attribute VB_Name = "MeterType"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub BM_Click()
MeterTypeToList List1, BM.Text
End Sub
Private Sub Command1_Click()
AddType Text1.Text
MeterTypeToList List1, BM.Text
End Sub
Private Sub Command2_Click()
DelType Text1.Text
MeterTypeToList List1, BM.Text
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Command4_Click()
DepartmentInfo.Show vbModal
DepartToCombo BM
End Sub
Private Sub Form_Load()
Me.Left = (Screen.Width - Me.Width) / 2
Me.Top = (Screen.Height - Me.Height) / 2
DepartToCombo BM
ConvertFont Me
End Sub
Private Sub List1_Click()
Text1.Text = List1.List(List1.ListIndex)
End Sub
Private Sub Text1_Change()
Text2.Text = GetDemo(Text1.Text)
End Sub
Private Function GetDemo(txt As String) As String
GetDemo = ""
SQL = "Select * from 表计类型 where 部门名称='" & BM.Text & "' and 表计类型='" & txt & "'"
If rs.State = 1 Then rs.Close
rs.Open SQL, DBConn, adOpenKeyset, adLockOptimistic, adCmdText
If Not rs.EOF Then GetDemo = rs.Fields("备注").Value
End Function
Private Sub DelType(txt As String)
If MsgBox("是否确定删除", vbInformation Or vbYesNo, "提示") = vbYes Then
If AssertTypeOK(txt) = True Then
SQL = "delete from 表计类型 where 部门名称='" & BM.Text & "' and 表计类型='" & txt & "'"
If rs.State = 1 Then rs.Close
rs.Open SQL, DBConn, adOpenKeyset, adLockOptimistic, adCmdText
MsgBox "删除完成", vbInformation, "提示"
End If
End If
End Sub
Private Sub AddType(txt As String)
If MsgBox("是否确定添加", vbInformation Or vbYesNo, "提示") = vbYes Then
If AssertTypeOK(txt) = False Then
If rs.State = 1 Then rs.Close
rs.Open "表计类型", DBConn, adOpenKeyset, adLockOptimistic, adCmdTable
rs.AddNew
rs.Fields("部门名称").Value = BM.Text
rs.Fields("表计类型").Value = txt
rs.Fields("备注").Value = Text2.Text
rs.Update
MsgBox "添加完成", vbInformation, "提示"
End If
End If
End Sub
Private Function AssertTypeOK(txt As String) As Boolean
SQL = "Select * from 表计类型 where 部门名称='" & BM.Text & "' and 表计类型='" & txt & "'"
If rs.State = 1 Then rs.Close
rs.Open SQL, DBConn, adOpenKeyset, adLockOptimistic, adCmdText
If Not rs.EOF Then
AssertTypeOK = True
Else
AssertTypeOK = False
End If
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -