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

📄 room.frm

📁 宿舍管理系统 vb+SQL 可进行宿舍卫生情况打分统计
💻 FRM
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "msflxgrd.ocx"
Begin VB.Form Form2 
   Caption         =   "Form2"
   ClientHeight    =   8835
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   8505
   LinkTopic       =   "Form2"
   ScaleHeight     =   8835
   ScaleWidth      =   8505
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton cmdexit 
      Caption         =   "退出"
      Height          =   375
      Left            =   6120
      TabIndex        =   20
      Top             =   7920
      Width           =   1095
   End
   Begin VB.CommandButton cmddelete 
      Caption         =   "删除"
      Height          =   375
      Left            =   4680
      TabIndex        =   19
      Top             =   7920
      Width           =   1095
   End
   Begin VB.CommandButton cmdmodify 
      Caption         =   "修改"
      Height          =   375
      Left            =   3240
      TabIndex        =   18
      Top             =   7920
      Width           =   1095
   End
   Begin VB.CommandButton cmdadd 
      Caption         =   "添加"
      Height          =   375
      Left            =   1920
      TabIndex        =   17
      Top             =   7920
      Width           =   975
   End
   Begin VB.CommandButton Cmdclear 
      Caption         =   "清除"
      Height          =   375
      Left            =   600
      TabIndex        =   16
      Top             =   7920
      Width           =   975
   End
   Begin VB.TextBox rdate 
      Height          =   375
      Left            =   2280
      TabIndex        =   14
      Text            =   "rdate"
      Top             =   4320
      Width           =   1815
   End
   Begin VB.TextBox total 
      Height          =   375
      Left            =   2280
      TabIndex        =   12
      Text            =   "total"
      Top             =   3720
      Width           =   1815
   End
   Begin VB.TextBox beizi 
      Height          =   375
      Left            =   2280
      TabIndex        =   10
      Text            =   "beizi"
      Top             =   3120
      Width           =   1815
   End
   Begin VB.TextBox ground 
      Height          =   375
      Left            =   2280
      TabIndex        =   8
      Text            =   "ground"
      Top             =   2520
      Width           =   1815
   End
   Begin VB.TextBox clean 
      Height          =   375
      Left            =   2280
      TabIndex        =   6
      Text            =   "clean"
      Top             =   1920
      Width           =   1815
   End
   Begin VB.TextBox windows 
      Height          =   375
      Left            =   2280
      TabIndex        =   4
      Text            =   "windows"
      Top             =   1320
      Width           =   1815
   End
   Begin VB.TextBox rno 
      Height          =   375
      Left            =   2280
      TabIndex        =   2
      Text            =   "rno"
      Top             =   720
      Width           =   1815
   End
   Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1 
      Height          =   2175
      Left            =   480
      TabIndex        =   15
      Top             =   5280
      Width           =   6960
      _ExtentX        =   12277
      _ExtentY        =   3836
      _Version        =   393216
      Rows            =   8
      Cols            =   8
      GridColor       =   16384
      GridColorFixed  =   16384
      FormatString    =   "序号|寝室号码|窗户清洁|整理|地面|被子|总分|时间"
   End
   Begin VB.Label Label8 
      Caption         =   "日期"
      Height          =   375
      Left            =   360
      TabIndex        =   13
      Top             =   4320
      Width           =   1455
   End
   Begin VB.Label Label7 
      Caption         =   "总分"
      Height          =   375
      Left            =   480
      TabIndex        =   11
      Top             =   3720
      Width           =   1335
   End
   Begin VB.Label Label6 
      Caption         =   "被子"
      Height          =   375
      Left            =   480
      TabIndex        =   9
      Top             =   3120
      Width           =   1215
   End
   Begin VB.Label Label5 
      Caption         =   "地面"
      Height          =   375
      Left            =   480
      TabIndex        =   7
      Top             =   2520
      Width           =   1215
   End
   Begin VB.Label Label4 
      Caption         =   "整理"
      Height          =   375
      Left            =   480
      TabIndex        =   5
      Top             =   1920
      Width           =   1335
   End
   Begin VB.Label Label3 
      Caption         =   "窗户清洁"
      Height          =   375
      Left            =   480
      TabIndex        =   3
      Top             =   1320
      Width           =   1095
   End
   Begin VB.Label Label2 
      Caption         =   "寝室号码"
      Height          =   255
      Left            =   480
      TabIndex        =   1
      Top             =   840
      Width           =   1095
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      Caption         =   "第八宿舍卫生管理系统"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   5040
      TabIndex        =   0
      Top             =   2400
      Width           =   2895
   End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim SQL As String
Dim roomgrade As New ADODB.Recordset
Private Sub Clear()

    rno.Text = ""
    windows.Text = ""
    clean.Text = ""
    ground.Text = ""
    beizi.Text = ""
    total.Text = ""
    rdate.Text = ""
End Sub

Private Sub cmdadd_Click()
 If rno.Text = "" Or rdate = "" Then
            MsgBox "寝室号码或日期不能为空!", vbOKOnly, "information"
            rno.SetFocus
            Exit Sub
        End If
        
        SQL = "select rno,rdate from room_grade where rno='" & rno.Text & "' and rdate='" & rdate.Text & "'"
               Set roomgrade = cnn.Execute(SQL) '执行查询结果
        If roomgrade.BOF And roomgrade.EOF Then
          SQL = "insert into room_grade (rno,windows,clean,ground,beizi,total,rdate) values ('" & rno.Text & "','" & windows.Text & "','" & clean.Text & "','" & ground.Text & "','" & beizi.Text & "','" & total.Text & "','" & rdate.Text & "')"
            
          cnn.Execute (SQL)
          MsgBox "添加成功!", vbOKOnly, "information"
         Call Clear
         rno.SetFocus
         Call MSFG_display
         Call Data_Display
         Else
            
           MsgBox "该宿舍在当天已经打过分了,请重写!", vbOKOnly, "information"
           Call Clear
           rno.SetFocus
           Call MSFG_display
           Call Data_Display
        End If
End Sub

Private Sub Cmdclear_Click()
Call Clear
 
rno.SetFocus
End Sub

Private Sub Command1_Click()

End Sub

Private Sub Command2_Click()

End Sub

Private Sub Command5_Click()

End Sub

Private Sub Form_Load()
Call Clear
Call MSFG_display
Call Data_Display
End Sub
Private Sub SubWizard1_GotFocus()


End Sub
Private Sub MSFG_display()
    '分配显示新闻时每个项目的宽度,并让其居中
    MSFlexGrid1.ColWidth(0) = 500
    MSFlexGrid1.ColAlignment(0) = flexAlignCenterCenter
    MSFlexGrid1.ColWidth(1) = 500
    MSFlexGrid1.ColAlignment(1) = flexAlignCenterCenter
    MSFlexGrid1.ColWidth(2) = 800
    MSFlexGrid1.ColAlignment(2) = flexAlignCenterCenter
    MSFlexGrid1.ColWidth(3) = 800
    MSFlexGrid1.ColAlignment(3) = flexAlignCenterCenter
    MSFlexGrid1.ColWidth(4) = 800
    MSFlexGrid1.ColAlignment(4) = flexAlignCenterCenter
    MSFlexGrid1.ColWidth(5) = 800
    MSFlexGrid1.ColAlignment(5) = flexAlignCenterCenter
    MSFlexGrid1.ColWidth(6) = 800
    MSFlexGrid1.ColAlignment(6) = flexAlignCenterCenter
    MSFlexGrid1.ColWidth(7) = 1000
    MSFlexGrid1.ColAlignment(7) = flexAlignCenterCenter
    MSFlexGrid1.Rows = 1
End Sub

Private Sub Data_Display()
    
    Dim i As Integer
    SQL = "select * from room_grade"
    
    Set roomgrade = cnn.Execute(SQL)
    MSFlexGrid1.Rows = 1
    roomgrade.MoveFirst
              
           i = 1
        Do While Not roomgrade.EOF
        
        
            
            MSFlexGrid1.Rows = MSFlexGrid1.Rows + 1
           
            MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 0) = i
            MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 1) = Trim(roomgrade("rno"))
            MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 2) = Trim(roomgrade("windows"))
            MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 3) = Trim(roomgrade("clean"))
            MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 4) = Trim(roomgrade("ground"))
            MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 5) = Trim(roomgrade("beizi"))
            MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 6) = Trim(roomgrade("total"))
            MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 7) = Trim(roomgrade("rdate"))
            roomgrade.MoveNext
            i = i + 1
        Loop
      
  
End Sub

Private Sub MSFlexGrid1_Click()
    
     rno.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 1)
     windows.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 2)
     clean.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 3)
       ground.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 4)
   beizi.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 5)
  total.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 6)
   rdate.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 7)
   
End Sub

Private Sub MSFlexGrid1_RowColChange()
    Call MSFlexGrid1_Click
End Sub
Private Sub cmdmodify_Click()

    Dim Msg As String
      
        If rno.Text = "" Then
            MsgBox "寝室号码不能为空!", vbOKOnly, "information"
            rno.SetFocus
            Exit Sub
        Else
   
        '查询当前新闻标题
            SQL = "select rno,rdate from room_grade where rno='" & rno.Text & "' and rdate='" & rdate.Text & "'"
            Set roomgrade = cnn.Execute(SQL) '执行当前查询结果
            SQL = "update room_grade set rno='" & rno.Text & "',windows='" & windows.Text & "',clean='" & clean.Text & "',ground='" & ground.Text & "',beizi='" & beizi.Text & "',total='" & total.Text & "',rdate='" & rdate.Text & "'where rno='" & rno.Text & "' and rdate='" & rdate.Text & "'"
            cnn.Execute (SQL) '对数据执行更新操作
          
            MsgBox "修改成功!", vbOKOnly, "information"
         Call Clear
         rno.SetFocus
         Call MSFG_display
         Call Data_Display
        End If
        
End Sub
Private Sub cmddelete_Click()
    If rno.Text = "" Then
        MsgBox "寝室号码不能为空!", vbOKOnly, "information"
        rno.SetFocus
        Exit Sub
    End If

    SQL = "delete from room_grade where rno='" & rno.Text & "' and rdate='" & rdate.Text & "'"
    cnn.Execute (SQL)
    MsgBox "删除成功!", vbOKOnly, "information"
    Call Clear
    Call Data_Display
    rno.SetFocus
End Sub

Private Sub cmdexit_Click()
    If cnn.State <> 0 Then
       cnn.Close
    End If
    Set cnn = Nothing
    End

End Sub



⌨️ 快捷键说明

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