⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shezhi.frm

📁 本宿舍管理系统采用VB为系统开发平台
💻 FRM
📖 第 1 页 / 共 3 页
字号:
TreeView1.Nodes.Clear
Dim I As Integer
TreeView1.LineStyle = tvwRootLines   '根线
Set nod1 = TreeView1.Nodes.add(, , "公寓管理系统", "公寓管理系统")
For I = 1 To Adodc1.Recordset.RecordCount
Set nod2 = TreeView1.Nodes.add("公寓管理系统", tvwChild, "child" & I, Adodc1.Recordset.Fields("公寓名称"))
    Adodc4.Mode = adModeReadWrite
    Adodc4.ConnectionString = provider & ";" & datasource
    Adodc1.Recordset.MoveNext
    Adodc4.CommandType = adCmdText
    Adodc4.RecordSource = "select 寝室 from qinshi where 公寓名称='" & nod2.Text & "'"
    Adodc4.Refresh
    Dim k As Long
    Do While Not Adodc4.Recordset.EOF
        Call TreeView1.Nodes.add(nod2, tvwChild, "childdorm" & CStr(k), Adodc4.Recordset.Fields("寝室"))
        k = k + 1
        Adodc4.Recordset.MoveNext
    Loop
Next
End Function

Private Sub Command1_Click()
main.Refresh
Unload Me
End Sub

Private Sub Command10_Click()
'修改班级
On Error Resume Next
If Text5.Text = "" Then
MsgBox "选择要修改的班级", , "提示"
Exit Sub
End If
If Command10.Caption = "修改" Then
Text4.Text = Text5.Text
Label6.Caption = "输入想要修改的班级名称"
Command10.Caption = "更新"
Command6.Enabled = False
Command9.Enabled = False
ElseIf Command10.Caption = "更新" Then
Command9.Enabled = True
Command6.Enabled = True
Label6.Caption = "输入想要添加的班级名称"
Adodc3.Recordset.Fields("class") = Text4.Text
Adodc3.Recordset.Update

Adodc5.Recordset.ActiveConnection.Execute "update users set 班级='" & Text4.Text & "' where 班级='" & Trim(Text5.Text) & "'"
Adodc5.Recordset.Update

Adodc7.Recordset.ActiveConnection.Execute "update weigui set 班级='" & Text4.Text & "' where 班级='" & Trim(Text5.Text) & "'"
Adodc7.Recordset.Update

Adodc8.Recordset.ActiveConnection.Execute "update qingjia set 班级='" & Text4.Text & "' where 班级='" & Trim(Text5.Text) & "'"
Adodc8.Recordset.Update

Command10.Caption = "修改"
End If

Set DataGrid3.datasource = Adodc3
DataGrid3.Refresh
End Sub

Private Sub Command11_Click()
On Error Resume Next
'修改寝室
Adodc1.Refresh
Adodc1.Recordset.Find "公寓名称='" & Combo1.Text & "'"
If Adodc1.Recordset.EOF = True Then
MsgBox "此公寓不存在", , "提示"
Adodc1.Recordset.MoveFirst
Exit Sub
End If

Dim sql As String
On Error Resume Next
If Combo1.Text = "" Or Text1.Text = "" Then
MsgBox "请在下面选择所要修改的寝室", , "提示"
Exit Sub
End If
'sql = "select * form qinshi where 公寓名称='" & Trim(Combo1.Text) & "' and 寝室='" & Trim(Text1.Text) & "'"

Adodc2.Recordset.ActiveConnection.Execute "update qinshi set 寝室='" & Text1.Text & "',公寓名称='" & Trim(Combo1.Text) & "'where 寝室='" & Trim(Text6.Text) & "'and 公寓名称='" & Trim(Text7.Text) & "'"
Adodc2.Recordset.Update
Adodc5.Recordset.ActiveConnection.Execute "update users set 寝室='" & Text1.Text & "',公寓名称='" & Trim(Combo1.Text) & "'where 寝室='" & Trim(Text6.Text) & "'and 公寓名称='" & Trim(Text7.Text) & "'"
Adodc5.Recordset.Update

Adodc6.Recordset.ActiveConnection.Execute "update weisheng set 寝室='" & Text1.Text & "',公寓名称='" & Trim(Combo1.Text) & "'where 寝室='" & Trim(Text6.Text) & "'and 公寓名称='" & Trim(Text7.Text) & "'"
Adodc6.Recordset.Update

Adodc7.Recordset.ActiveConnection.Execute "update weigui set 寝室='" & Text1.Text & "',公寓名称='" & Trim(Combo1.Text) & "'where 寝室='" & Trim(Text6.Text) & "'and 公寓名称='" & Trim(Text7.Text) & "'"
Adodc7.Recordset.Update

Adodc8.Recordset.ActiveConnection.Execute "update qingjia set 寝室='" & Text1.Text & "',公寓名称='" & Trim(Combo1.Text) & "'where 寝室='" & Trim(Text6.Text) & "'and 公寓名称='" & Trim(Text7.Text) & "'"
Adodc8.Recordset.Update

Combo1.Text = ""
Text1.Text = ""

Call startree1
End Sub

Private Sub Command12_Click()
On Error Resume Next
'修改公寓

If Text3.Text = "" Then
MsgBox "选择要修改的公寓", , "提示"
Exit Sub
End If
If Command12.Caption = "修改" Then
Text2.Text = Text3.Text
Label6.Caption = "输入想要修改的公寓名称"
Command12.Caption = "更新"
Command3.Enabled = False
Command7.Enabled = False
ElseIf Command12.Caption = "更新" Then
Command3.Enabled = True
Command7.Enabled = True
Label6.Caption = "输入想要添加的公寓名称"
Adodc1.Recordset.Fields("公寓名称") = Text2.Text
Adodc1.Recordset.Update

Adodc2.Recordset.ActiveConnection.Execute "update qinshi set 公寓名称='" & Text2.Text & "' where 公寓名称='" & Trim(Text3.Text) & "'"
Adodc2.Recordset.Update

Adodc5.Recordset.ActiveConnection.Execute "update users set 公寓='" & Text2.Text & "' where 公寓='" & Trim(Text3.Text) & "'"
Adodc5.Recordset.Update

Adodc6.Recordset.ActiveConnection.Execute "update weisheng set 公寓='" & Text2.Text & "' where 公寓='" & Trim(Text3.Text) & "'"
Adodc6.Recordset.Update

Adodc7.Recordset.ActiveConnection.Execute "update weigui set 公寓='" & Text2.Text & "' where 公寓='" & Trim(Text3.Text) & "'"
Adodc7.Recordset.Update

Adodc8.Recordset.ActiveConnection.Execute "update qingjia set 公寓='" & Text2.Text & "' where 公寓='" & Trim(Text3.Text) & "'"
Adodc8.Recordset.Update

Adodc9.Recordset.ActiveConnection.Execute "update zichan set 公寓='" & Text2.Text & "' where 公寓='" & Trim(Text3.Text) & "'"
Adodc9.Recordset.Update
Command12.Caption = "修改"
End If

Set DataGrid2.datasource = Adodc1
DataGrid2.Refresh
Adodc5.Recordset.Update
Set main.DataGrid1.datasource = Adodc5
main.DataGrid1.Refresh
End Sub

Private Sub Command2_Click()
'添加寝室
On Error Resume Next
Adodc1.Refresh
Adodc1.Recordset.Find "公寓名称='" & Combo1.Text & "'"
If Adodc1.Recordset.EOF = True Then
MsgBox "此公寓不存在", , "提示"
Adodc1.Recordset.MoveFirst
Exit Sub
End If

Adodc2.Recordset.MoveFirst
For I = 1 To Adodc2.Recordset.RecordCount

If Adodc2.Recordset.Fields("寝室") = Text1.Text And Adodc2.Recordset.Fields("公寓名称") = Combo1.Text Then
MsgBox "此寝室已存在", , "提示"
Adodc2.Recordset.MoveFirst
Exit Sub
End If
Adodc2.Recordset.MoveNext
Next I

If Combo1.Text = "" Or Text1.Text = "" Then
MsgBox "请输入所要添加的寝室及其所属公寓", , "提示"
Exit Sub
End If



With Adodc2
.Recordset.AddNew
.Recordset.Fields(0).Value = Combo1.Text
.Recordset.Fields(1).Value = Text1.Text
.Recordset.Update
End With
Combo1.Text = ""
Text1.Text = ""

Call startree1
End Sub

Private Sub Command3_Click()
'添加公寓
Adodc1.Recordset.MoveFirst
For I = 1 To Adodc1.Recordset.RecordCount

If Adodc1.Recordset.Fields("公寓名称") = Text2.Text Then
MsgBox "此公寓已存在", , "提示"
Adodc1.Recordset.MoveFirst
Exit Sub
End If
Adodc1.Recordset.MoveNext
Next I
Text3.Text = ""
If Text2.Text = "" Then
MsgBox "输入所要添加公寓的名称", , "提示"
Exit Sub
End If

Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("公寓名称") = Text2.Text
Adodc1.Recordset.Update
Adodc1.RecordSource = "gongyu"
Text2.Text = ""
Set DataGrid2.datasource = Adodc1
DataGrid2.Refresh

'Call startree1
End Sub

Private Sub Command4_Click()

Unload Me
End Sub

Private Sub Command5_Click()


Unload Me

End Sub

Private Sub Command6_Click()
'添加班级
On Error Resume Next
Adodc3.Recordset.Find "class='" & Text4.Text & "'"
If Adodc3.Recordset.EOF = False Then
MsgBox "此班级已存在", , "提示"
Adodc3.Recordset.MoveFirst
Exit Sub
End If

Text5.Text = ""
If Text4.Text = "" Then
MsgBox "输入所要添加班级的名称", , "提示"
Exit Sub
End If

Adodc3.Recordset.AddNew
Adodc3.Recordset.Fields("class") = Text4.Text
Adodc3.Recordset.Update
Adodc3.RecordSource = "class"
Text4.Text = ""
Set DataGrid3.datasource = Adodc3
DataGrid3.Refresh

End Sub

Private Sub Command7_Click()
'删除公寓
On Error Resume Next
On Error Resume Next
If Text3.Text = "" Then
MsgBox "选择所要删除公寓的名称", , "提示"
Exit Sub
End If
If (MsgBox("你真的想删除公寓名称为  " & Text3.Text & "  的记录吗?", vbOKCancel, "系统提示")) = vbOK Then
    Adodc1.Recordset.Delete
    Adodc1.Recordset.Update
End If

Text3.Text = ""
Set DataGrid2.datasource = Adodc1
    DataGrid2.Refresh
End Sub

Private Sub Command8_Click()
'删除寝室
On Error Resume Next
If Combo1.Text = "" Or Text1.Text = "" Or Combo1.Text = "公寓管理系统" Then
MsgBox "选择所要删除的寝室", , "提示"
Exit Sub
End If

If (MsgBox("你真的想删除  " & Combo1.Text & "  " & "寝室为" & Text1.Text & "   的记录吗?", vbOKCancel, "系统提示")) = vbOK Then
Adodc2.Refresh
Adodc2.Recordset.ActiveConnection.Execute "delete from qinshi where 公寓名称='" & Trim(Combo1.Text) & "' and 寝室='" & Trim(Text1.Text) & "'"
Adodc2.Recordset.Update
End If
Combo1.Text = ""
Text1.Text = ""
Call startree1
End Sub

Private Sub Command9_Click()
'删除班级

On Error Resume Next
If Text5.Text = "" Then
MsgBox "选择所要删除班级的名称", , "提示"
Exit Sub
End If

If (MsgBox("你真的想删除班级名称 为  " & Text5.Text & "  的记录吗?", vbOKCancel, "系统提示")) = vbOK Then
    Adodc3.Recordset.Delete
    Adodc3.Recordset.Update
End If

Text5.Text = ""
Set DataGrid3.datasource = Adodc3
    DataGrid3.Refresh
End Sub

Private Sub DataGrid2_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
    On Error Resume Next
    Text3.Text = Adodc1.Recordset.Fields("公寓名称")
End Sub

Private Sub DataGrid3_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
    On Error Resume Next
    Text5.Text = Adodc3.Recordset.Fields("class")
End Sub

Private Sub Form_Activate()
Combo1.Clear
       Dim J As Integer
        J = 0
        If Adodc1.Recordset.RecordCount <> 0 Then
        Adodc1.Recordset.MoveFirst
        Do While J < Adodc1.Recordset.RecordCount
    
        Combo1.AddItem (Adodc1.Recordset.Fields("公寓名称"))
        Adodc1.Recordset.MoveNext
        J = J + 1
        Loop
        End If
End Sub

Private Sub Form_Load()
On Error Resume Next
provider = "provider=Microsoft.jet.oledb.4.0"
datasource = "data source=" & App.Path & "\DB.mdb"

With Adodc1
.Mode = adModeReadWrite
.ConnectionString = provider & ";" & datasource
.CommandType = adCmdTable
.RecordSource = "gongyu"
.Refresh
End With

With Adodc2
.Mode = adModeReadWrite
.ConnectionString = provider & ";" & datasource
.CommandType = adCmdTable
.RecordSource = "qinshi"
.Refresh
End With

With Adodc3
.Mode = adModeReadWrite
.ConnectionString = provider & ";" & datasource
.CommandType = adCmdTable
.RecordSource = "class"
.Refresh
End With

With Adodc5
.Mode = adModeReadWrite
.ConnectionString = provider & ";" & datasource
.CommandType = adCmdTable
.RecordSource = "users"
.Refresh
End With

With Adodc6
.Mode = adModeReadWrite
.ConnectionString = provider & ";" & datasource
.CommandType = adCmdTable
.RecordSource = "weisheng"
.Refresh
End With

With Adodc7
.Mode = adModeReadWrite
.ConnectionString = provider & ";" & datasource
.CommandType = adCmdTable
.RecordSource = "weigui"
.Refresh
End With

With Adodc8
.Mode = adModeReadWrite
.ConnectionString = provider & ";" & datasource
.CommandType = adCmdTable
.RecordSource = "qingjia"
.Refresh
End With

With Adodc9
.Mode = adModeReadWrite
.ConnectionString = provider & ";" & datasource
.CommandType = adCmdTable
.RecordSource = "zichan"
.Refresh
End With

Call startree1
Set DataGrid2.datasource = Adodc1
DataGrid2.Refresh

End Sub

Private Sub SSTab1_Click(PreviousTab As Integer)
Select Case PreviousTab
       Case 0
       Call startree1
       Case 1
        Combo1.Clear
       Dim I As Integer
        I = 1
        If Adodc1.Recordset.RecordCount <> 0 Then
        Adodc1.Recordset.MoveFirst
        Do While I < Adodc1.Recordset.RecordCount
    
        Combo1.AddItem (Adodc1.Recordset.Fields("公寓名称"))
        Adodc1.Recordset.MoveNext
        I = I + 1
        Loop
        End If
       Call startree1
       Case 2
       Call startree1
End Select
End Sub


Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
On Error Resume Next
Text1.Text = TreeView1.SelectedItem.Text
Combo1.Text = TreeView1.SelectedItem.Parent
Text6.Text = TreeView1.SelectedItem.Text
Text7.Text = TreeView1.SelectedItem.Parent
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -