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

📄 frmmain.frm

📁 学生宿舍管理系统vb源码
💻 FRM
📖 第 1 页 / 共 4 页
字号:
            Grid1.Column(1).Locked = True
            dbStr = QuaryString
            opType = 0
            ShowRecord dbStr
            DataGrid
        Case "SysUser"
            '用户管理---用户信息
            SetUseHead  '设置用户信息标题
            Grid1.Column(1).Locked = True
            dbStr = "select * from loginin"
            opType = 0
            ShowRecord dbStr
            DataGrid
        Case "SysAdd"
            '用户管理---添加用户
            SetUseHead  '设置用户信息标题
            Grid1.Column(1).Locked = False
            opType = 1
        Case "SysDel"
            '用户管理---删除用户
            opType = 3
            If MsgBox("您确实要删除所选数据吗?", vbOKCancel + vbExclamation, "提示") = vbOK Then
                dbStr = "delete from loginin where UserName in('"
                For i = Grid1.Selection.FirstRow To Grid1.Selection.LastRow
                    If Grid1.Cell(i, 1).Text <> "" Then
                        dbStr = dbStr & Grid1.Cell(i, 1).Text & "','"
                    End If
                Next i
                dbStr = Left(dbStr, Len(dbStr) - 2)
                dbStr = dbStr & ")"
                ExecuteSQL dbStr, MsgString     '执行删除
                '刷新数据
                SetUseHead
                Grid1.Column(1).Locked = True
                dbStr = "select * from loginin"
                opType = 0
                ShowRecord dbStr
                DataGrid
                MsgBox "删除成功!", vbOKOnly + vbExclamation, "提示"
            End If
        Case "SysEdit"
            '用户管理---修改密码
            If Grid1.Cell(1, 1).Text = "" Then
                MsgBox "无数据可修改!", vbOKOnly + vbExclamation, "提示"
                Exit Sub
            End If
            Grid1.Column(1).Locked = True
            opType = 2
        Case "SysQuit"
            '系统管理---退出
            If MsgBox("您确定要退出吗?", vbOKCancel + vbExclamation, "提示") = vbOK Then
                End
            End If
    End Select
End Sub

Private Sub SetStudentHead()
    '学生表表头
    Dim r As Long
    Dim i As Long
    
    nPage = 0
    tPage = 0
    lblPage.Caption = "第" & nPage & "页,共" & tPage & "页"
    tableName = "student"
    ColCount = 12
    
    Grid1.Rows = 1
    Grid1.Rows = 21
    Grid1.Cols = 1
    Grid1.Cols = 13
    r = 0
    Grid1.Cell(r, 1).Text = "学号"
    Grid1.Cell(r, 2).Text = "姓名"
    Grid1.Cell(r, 3).Text = "性别"
    Grid1.Cell(r, 4).Text = "入学日期"
    Grid1.Cell(r, 5).Text = "出生日期"
    Grid1.Cell(r, 6).Text = "学院"
    Grid1.Cell(r, 7).Text = "专业"
    Grid1.Cell(r, 8).Text = "班级"
    Grid1.Cell(r, 9).Text = "政治面貌"
    Grid1.Cell(r, 10).Text = "家庭住址"
    Grid1.Cell(r, 11).Text = "联系方式"
    Grid1.Cell(r, 12).Text = "备注"
    
    Grid1.Column(3).CellType = cellComboBox
    Grid1.ComboBox(3).Clear
    Grid1.ComboBox(3).AddItem "男"
    Grid1.ComboBox(3).AddItem "女"
    
    Grid1.Column(4).CellType = cellCalendar
    Grid1.Column(5).CellType = cellCalendar
    
    Grid1.Column(6).CellType = cellComboBox
    Grid1.ComboBox(6).Clear
    Grid1.ComboBox(6).AddItem "计算机科学与工程学院"
    Grid1.ComboBox(6).AddItem "人文学院"
    Grid1.ComboBox(6).AddItem "管理学院"
    Grid1.ComboBox(6).AddItem "电子学院"
    Grid1.ComboBox(6).AddItem "机械学院"
    
    Grid1.Column(7).CellType = cellComboBox
    Grid1.ComboBox(7).Clear
    Grid1.ComboBox(7).AddItem "计算机科学与技术"
    Grid1.ComboBox(7).AddItem "计算机软件"
    Grid1.ComboBox(7).AddItem "计算机网络"
    Grid1.ComboBox(7).AddItem "历史系"
    Grid1.ComboBox(7).AddItem "社会科学系"
    Grid1.ComboBox(7).AddItem "经济管理"
    Grid1.ComboBox(7).AddItem "市场营销"
    Grid1.ComboBox(7).AddItem "通信工程"
    Grid1.ComboBox(7).AddItem "机械制造"
    
    Grid1.Column(9).CellType = cellComboBox
    Grid1.ComboBox(9).Clear
    Grid1.ComboBox(9).AddItem "党员"
    Grid1.ComboBox(9).AddItem "团员"
    Grid1.ComboBox(9).AddItem "清白"
End Sub

Private Sub SetDormHead()
    '宿舍表表头
    Dim r As Long
    Dim i As Long
    
    nPage = 0
    tPage = 0
    lblPage.Caption = "第" & nPage & "页,共" & tPage & "页"
    tableName = "dorm"
    ColCount = 7
    
    Grid1.Rows = 1
    Grid1.Rows = 21
    Grid1.Cols = 1
    Grid1.Cols = 8
    r = 0
    Grid1.Cell(r, 1).Text = "宿舍编号"
    Grid1.Cell(r, 2).Text = "居住性别"
    Grid1.Cell(r, 3).Text = "应住人数"
    Grid1.Cell(r, 4).Text = "实住人数"
    Grid1.Cell(r, 5).Text = "住宿费用"
    Grid1.Cell(r, 6).Text = "电话"
    Grid1.Cell(r, 7).Text = "备注"
    
    Grid1.Column(2).CellType = cellComboBox
    Grid1.ComboBox(2).Clear
    Grid1.ComboBox(2).AddItem "男"
    Grid1.ComboBox(2).AddItem "女"
End Sub

Private Sub SetSDHead()
    '学生住宿表表头
    Dim r As Long
    Dim i As Long
    
    nPage = 0
    tPage = 0
    lblPage.Caption = "第" & nPage & "页,共" & tPage & "页"
    tableName = "student_dorm"
    ColCount = 8
    
    Grid1.Rows = 1
    Grid1.Rows = 21
    Grid1.Cols = 1
    Grid1.Cols = 9
    r = 0
    Grid1.Cell(r, 1).Text = "学号"
    Grid1.Cell(r, 2).Text = "姓名"
    Grid1.Cell(r, 3).Text = "性别"
    Grid1.Cell(r, 4).Text = "班级"
    Grid1.Cell(r, 5).Text = "政治面貌"
    Grid1.Cell(r, 6).Text = "所住宿舍"
    Grid1.Cell(r, 7).Text = "应住人数"
    Grid1.Cell(r, 8).Text = "实住人数"
End Sub

Private Sub SetVisitHead()
    '访客表表头
    Dim r As Long
    Dim i As Long
    
    nPage = 0
    tPage = 0
    lblPage.Caption = "第" & nPage & "页,共" & tPage & "页"
    tableName = "visit"
    ColCount = 12
    
    Grid1.Rows = 1
    Grid1.Rows = 21
    Grid1.Cols = 1
    Grid1.Cols = 13
    r = 0
    Grid1.Cell(r, 1).Text = "编号"
    Grid1.Cell(r, 2).Text = "访客姓名"
    Grid1.Cell(r, 3).Text = "被访人姓名"
    Grid1.Cell(r, 4).Text = "宿舍编号"
    Grid1.Cell(r, 5).Text = "所属关系"
    Grid1.Cell(r, 6).Text = "来访日期"
    Grid1.Cell(r, 7).Text = "来访时间"
    Grid1.Cell(r, 8).Text = "离开时间"
    Grid1.Cell(r, 9).Text = "证件名称"
    Grid1.Cell(r, 10).Text = "证件号码"
    Grid1.Cell(r, 11).Text = "值班人"
    Grid1.Cell(r, 12).Text = "备注"
End Sub

Private Sub SetHealthHead()
    '卫生评定表表头
    Dim r As Long
    Dim i As Long
    
    nPage = 0
    tPage = 0
    lblPage.Caption = "第" & nPage & "页,共" & tPage & "页"
    tableName = "health"
    ColCount = 7
    
    Grid1.Rows = 1
    Grid1.Rows = 21
    Grid1.Cols = 1
    Grid1.Cols = 8
    r = 0
    Grid1.Cell(r, 1).Text = "编号"
    Grid1.Cell(r, 2).Text = "评定日期"
    Grid1.Cell(r, 3).Text = "宿舍号"
    Grid1.Cell(r, 4).Text = "卫生等级"
    Grid1.Cell(r, 5).Text = "评定人"
    Grid1.Cell(r, 6).Text = "评定意见"
    Grid1.Cell(r, 7).Text = "备注"
    
    Grid1.Column(2).CellType = cellCalendar
End Sub

Private Sub SetUseHead()
    '用户表表头
    Dim r As Long
    Dim i As Long
    
    nPage = 0
    tPage = 0
    lblPage.Caption = "第" & nPage & "页,共" & tPage & "页"
    tableName = "loginin"
    ColCount = 2
    
    Grid1.Rows = 1
    Grid1.Rows = 21
    Grid1.Cols = 1
    Grid1.Cols = 3
    r = 0
    Grid1.Cell(r, 1).Text = "用户名"
    Grid1.Cell(r, 2).Text = "用户密码"
    Grid1.Column(1).Width = 200
End Sub

Private Sub DataGrid()
    '显示数据库记录
    Dim i As Long
    Dim j As Long
    
    Grid1.Rows = 1      '清除表格数据
    Grid1.Rows = 21
    rst.PageSize = 20
    tPage = rst.PageCount
    If tPage = 0 Then
        nPage = 0
        lblPage.Caption = "第0页,共0页"
        Exit Sub
    End If
    rst.AbsolutePage = nPage
    
    lblPage.Caption = "第" & nPage & "页,共" & tPage & "页"
    
    For i = 1 To rst.PageSize
        If rst.BOF Or rst.EOF Then Exit For
        For j = 1 To ColCount
            If IsNull(rst.Fields(j - 1).Value) Then
                Grid1.Cell(i, j).Text = ""
            Else
                Grid1.Cell(i, j).Text = Trim(rst.Fields(j - 1).Value)
            End If
        Next j
        rst.MoveNext
    Next i
End Sub
Private Sub ShowRecord(ByVal sqlStr As String)
    '执行查询语句
    If rst.State = adStateOpen Then rst.Close
    
    Set rst = ExecuteSQL(sqlStr, MsgString)
    rst.PageSize = 20
    tPage = rst.PageCount
    
    If tPage = 0 Then
        nPage = 0
    Else
        nPage = 1
    End If
End Sub

⌨️ 快捷键说明

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