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

📄 frmlodg.frm

📁 一个实用的学生宿舍管理系统
💻 FRM
📖 第 1 页 / 共 2 页
字号:
      BackColorBkg    =   -2147483643
      Appearance      =   0
   End
   Begin CSCommand.Command Command1 
      Height          =   495
      Left            =   120
      TabIndex        =   1
      Top             =   4320
      Width           =   1095
      _ExtentX        =   1931
      _ExtentY        =   873
      IconAlign       =   0
      Icon            =   "frmlodg.frx":1822
      Caption         =   "查询空房间"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin VB.Label Label1 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      BackStyle       =   0  'Transparent
      BorderStyle     =   1  'Fixed Single
      Caption         =   "       住    宿    信    息    列    表"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H8000000D&
      Height          =   375
      Index           =   1
      Left            =   0
      TabIndex        =   26
      Top             =   240
      Width           =   6015
   End
End
Attribute VB_Name = "frmlodg"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Dim mrc As ADODB.Recordset
Dim MsgText As String
Dim tSQL As String


Private Sub Command1_Click()
Dim txtSQL As String
txtSQL = "select * from room_stud where room_YZPeople = 0"
    Set mrc = ExecuteSQL(txtSQL, MsgText)
    ShowData
   
    With MSFlexGrid1
 Do While Not mrc.EOF
            .Rows = .Rows + 1
            For i = 0 To mrc.Fields.Count - 1
                .TextMatrix(.Rows - 1, i) = mrc.Fields(i) & ""
            Next i
            mrc.MoveNext
        Loop
        End With
End Sub

Private Sub Command2_Click()
Dim txtSQL As String
txtSQL = "select * from room_stud where room_KQPeople = 0 "
    Set mrc = ExecuteSQL(txtSQL, MsgText)
    ShowData
    
    With MSFlexGrid1
 Do While Not mrc.EOF
            .Rows = .Rows + 1
            For i = 0 To mrc.Fields.Count - 1
                .TextMatrix(.Rows - 1, i) = mrc.Fields(i) & ""
            Next i
            mrc.MoveNext
        Loop
        End With
End Sub

Private Sub Command3_Click()
Dim txtSQL As String
Dim xu As String

xu = Trim(MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 0))
If xu <> "" Then
  txtSQL = "delete from room_stud where room_NO='" & xu & "'"
    Set mrc = ExecuteSQL(txtSQL, MsgText)
   
 
    MsgBox "该房间信息已被删除!", vbOKOnly, "警告"
    Else
     MsgBox "未选中要删除的房间!", vbOKOnly, "警告"
    End If
    ShowData
End Sub

Private Sub Command4_Click()
Dim txtSQL As String
Dim txSQL As String
If Text1 = "" Then
        MsgBox "学号不能为空!", vbOKOnly, "提示"
        Text1.SetFocus
        Exit Sub
    End If
    If Text2 = "" Then
        MsgBox "房间不能为空!", vbOKOnly, "提示"
        Text2.SetFocus
        Exit Sub
    End If
  txtSQL = "select * from student_Form where student_NO='" & Trim(Text1) & "' and student_Room='" & Trim(Text2) & "'"
    Set mrc = ExecuteSQL(txtSQL, MsgText)
   If mrc.EOF = True Then
        MsgBox "该纪录不存在,请核实后再删除!", vbOKOnly, "警告"
        Text1.SetFocus
        Exit Sub
        Else
         txtSQL = "delete from student_Form where student_NO='" & Trim(Text1) & "'"
    Set mrc = ExecuteSQL(txtSQL, MsgText)
    txSQL = "update room_stud set room_YZPeople=room_YZPeople -'" & 1 & "',room_KQPeople=room_KQPeople +'" & 1 & "' where room_NO='" & Trim(Text2) & "'"
    Set mrc = ExecuteSQL(txSQL, MsgText)
    Text1 = ""
   Text2 = ""
    MsgBox "该学生已被迁出!", vbOKOnly, "警告"
    End If
  
End Sub

Private Sub Command5_Click()
Dim txtSQL As String
Dim ttSQL As String
Dim txSQL As String
 If Text3 = "" Then
        MsgBox "姓名不能为空!", vbOKOnly, "提示"
        Text3.SetFocus
        Exit Sub
    End If
    If Combo1 = "" Then
        MsgBox "性别不能为空!", vbOKOnly, "提示"
        Combo1.SetFocus
        Exit Sub
    End If
    If Text4 = "" Then
        MsgBox "班级不能为空!", vbOKOnly, "提示"
        Text4.SetFocus
        Exit Sub
    End If
    If Text5 = "" Then
        MsgBox "学号不能为空!", vbOKOnly, "提示"
        Text5.SetFocus
        Exit Sub
    End If
    If Combo2 = "" Then
        MsgBox "日期不能为空!", vbOKOnly, "提示"
        Combo2.SetFocus
        Exit Sub
    End If
    If Text7 = "" Then
        MsgBox "房间不能为空!", vbOKOnly, "提示"
        Text7.SetFocus
        Exit Sub
    End If
    txtSQL = "select * from student_Form where student_NO='" & Trim(Text5) & "'"
    Set mrc = ExecuteSQL(txtSQL, MsgText)
    If mrc.EOF = False Then
        MsgBox "此学号已存在!", vbOKOnly, "警告"
        Text5.SetFocus
        Exit Sub
    End If
     ttSQL = "select * from room_Form where room_NO='" & Trim(Text7) & "'"
    Set mrc = ExecuteSQL(ttSQL, MsgText)
   If mrc.EOF = False Then
        txSQL = "select * from room_stud where room_NO='" & Trim(Text7) & "' and room_KQPeople=" & 0 & ""
    Set mrc = ExecuteSQL(txSQL, MsgText)
If mrc.EOF = False Then
        MsgBox "该房间已满!", vbOKOnly, "警告"
        Text7.SetFocus
        Exit Sub
        Else
             txSQL = "update room_stud set room_YZPeople=room_YZPeople +'" & 1 & "',room_KQPeople=room_KQPeople -'" & 1 & "' where room_NO='" & Trim(Text7) & "'"
    Set mrc = ExecuteSQL(txSQL, MsgText)
End If
Else
 MsgBox "该房间不存在!", vbOKOnly, "警告"
        Text7.SetFocus
        Exit Sub
    End If
'    mrc.Close
    txtSQL = "select * from student_Form"
    Set mrc = ExecuteSQL(txtSQL, MsgText)
    mrc.AddNew
    mrc.Fields(0) = Trim(Text3)
    mrc.Fields(1) = Trim(Combo1)
    mrc.Fields(2) = Trim(Text4)
    mrc.Fields(3) = Trim(Text5)
     mrc.Fields(4) = Trim(Text6)
       mrc.Fields(5) = Trim(Combo2)
         mrc.Fields(6) = Trim(Text7)
    mrc.Update
    mrc.Close
   ' For i = 0 To 3
     '   Text1(i) = ""
  '  Next
  Text3 = ""
  Text4 = ""
  Text5 = ""
  Text6 = ""
  Text7 = ""
' Combo1 = ""
Combo2 = ""
    MsgBox "入住信息添加成功!", vbOKOnly, "提示"
   ' ShowData
End Sub

Private Sub Form_Load()
With Combo1
.AddItem "男"
.AddItem "女"
Combo1.Text = "男"
End With
With Combo2
.AddItem Str$(Date - 1)
.AddItem Str$(Date - 2)
.AddItem Str$(Date - 3)

Combo2.Text = Date$
End With
End Sub
Private Sub ShowData()
    Dim txSQL As String
    Dim mrcc As ADODB.Recordset
    txSQL = "select * from room_stud"
    Set mrcc = ExecuteSQL(txSQL, MsgText)
        With MSFlexGrid1
        .ColWidth(0) = 1000
        .ColWidth(1) = 1000
        .ColWidth(2) = 1000
        .ColWidth(3) = 1000
        .ColWidth(4) = 1000
        .ColWidth(5) = 1000
        .TextMatrix(0, 0) = "房间号码"
        .TextMatrix(0, 1) = "入住性别"
        .TextMatrix(0, 2) = "电话号码"
        .TextMatrix(0, 3) = "可住人数"
        .TextMatrix(0, 4) = "入住人数"
        .TextMatrix(0, 5) = "空缺人数"
        .Rows = 1
'        Do While Not mrcc.EOF
'            .Rows = .Rows + 1
'            For i = 0 To mrcc.Fields.Count - 1
'                .TextMatrix(.Rows - 1, i) = mrcc.Fields(i) & ""
'            Next i
'            mrcc.MoveNext
'        Loop
    End With
    mrcc.Close
End Sub

⌨️ 快捷键说明

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