📄 form4.frm
字号:
VERSION 5.00
Begin VB.Form Form4
BorderStyle = 1 'Fixed Single
Caption = "部门管理"
ClientHeight = 4935
ClientLeft = 9600
ClientTop = 1860
ClientWidth = 2520
Icon = "Form4.frx":0000
LinkTopic = "Form4"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4935
ScaleWidth = 2520
Begin VB.Frame Frame1
Caption = "统计结果如下"
Height = 1095
Left = 120
TabIndex = 4
Top = 3720
Width = 2295
Begin VB.Label Label1
Caption = "暂无统计信息"
Height = 735
Left = 120
TabIndex = 5
Top = 240
Width = 2055
End
End
Begin VB.TextBox Text1
Height = 270
Left = 120
TabIndex = 3
Top = 2880
Width = 2295
End
Begin VB.CommandButton Command2
Caption = "添加部门"
Height = 375
Left = 120
TabIndex = 2
Top = 3240
Width = 975
End
Begin VB.CommandButton Command1
Caption = "统计党费"
Height = 375
Left = 1440
TabIndex = 1
Top = 3240
Width = 975
End
Begin VB.ListBox List1
Height = 2580
Left = 120
TabIndex = 0
Top = 120
Width = 2295
End
Begin VB.Menu rightmenu
Caption = "菜单"
Visible = 0 'False
Begin VB.Menu delthis
Caption = "删除总支"
End
Begin VB.Menu countthis
Caption = "统计总支"
End
End
End
Attribute VB_Name = "Form4"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim people As Integer
Dim money As Double
people = 0
money = 0
Set cnn = New ADODB.Connection
cnn.Open cnstr
Set rec10 = New ADODB.Recordset
sqlstr = "select * from teacher2003 where 所属总支='" & List1.List(List1.ListIndex) & "'"
rec10.Open sqlstr, cnn, 3, 1
If rec10.RecordCount >= 1 Then
Do While Not rec10.EOF
money = money + rec10(3)
people = people + 1
rec10.MoveNext
Loop
Label1.Caption = "经统计:" & List1.List(List1.ListIndex) & "共有党员人数" & people & "人,共需交党费" & money & "元"
Else
Label1.Caption = "没有" & List1.List(List1.ListIndex) & "的记录信息"
End If
End Sub
Private Sub Command2_Click()
If Trim(Text1.Text) = "" Then
MsgBox "请在上文本框中输入部门名称"
Exit Sub
End If
Set cnn = New ADODB.Connection
cnn.Open cnstr
Set rec9 = New ADODB.Recordset
sqlstr = "select * from zongzhi where 总支名称='" & Trim(Text1.Text) & "'"
rec9.Open sqlstr, cnn, 3, 2
If rec9.RecordCount >= 1 Then
MsgBox "已存在该部门,不能再添加"
Exit Sub
Else
rec9.AddNew
rec9(0) = Trim(Text1.Text)
rec9.Update
End If
rec9.Close
For i = List1.ListCount - 1 To 0
List1.RemoveItem List1.List(i)
Next
rec9.Open sqlstr, cnn, 3, 1
If rec9.RecordCount >= 1 Then
Do While Not rec9.EOF
List1.AddItem rec9(0)
rec9.MoveNext
Loop
End If
rec9.Close
End Sub
Private Sub countthis_Click()
Call Command1_Click
End Sub
Private Sub delthis_Click()
If List1.List(List1.ListIndex) = "" Then
MsgBox "请先选中要删除的部门"
Exit Sub
End If
Set cnn = New ADODB.Connection
cnn.Open cnstr
Set rec11 = New ADODB.Recordset
sqlstr = "select * from zongzhi where 总支名称='" & List1.List(List1.ListIndex) & "'"
rec11.Open sqlstr, cnn, 3, 2
If rec11.RecordCount >= 1 Then
rec11.Delete
rec11.Update
List1.RemoveItem List1.ListIndex
MsgBox "删除成功"
End If
rec11.Close
End Sub
Private Sub Form_Load()
Set cnn = New ADODB.Connection
cnn.Open cnstr
Set rec9 = New ADODB.Recordset
sqlstr = "select * from zongzhi"
rec9.Open sqlstr, cnn, 3, 1
If rec9.RecordCount >= 1 Then
Do While Not rec9.EOF
List1.AddItem rec9(0)
rec9.MoveNext
Loop
End If
rec9.Close
End Sub
Private Sub List1_DblClick()
Command1_Click
End Sub
Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
Form1.PopupMenu rightmenu
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -