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

📄 宿舍卫生.vb

📁 一个功能强大的学生公寓管理系统 界面非常友好 十分强大
💻 VB
📖 第 1 页 / 共 4 页
字号:
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint

    End Sub

    Private Sub 宿舍卫生_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim Conn As New System.Data.OleDb.OleDbConnection
        Dim Cmd As New System.Data.OleDb.OleDbCommand
        Dim DataReader As System.Data.OleDb.OleDbDataReader
        Try
            Conn.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=学生公寓管理系统.mdb"
            Conn.Open()
            Cmd.CommandText = "Select Distinct 栋号 from 房源库 order by 栋号"
            Cmd.Connection = Conn
            DataReader = Cmd.ExecuteReader
            While DataReader.Read()
                ComboBox1.Items.Add(DataReader.Item(0))
                ComboBox4.Items.Add(DataReader.Item(0))
            End While
            DataReader.Close()
            Conn.Close()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

        Try

            OleDbDataAdapter1.SelectCommand.CommandText = "select * from 卫生检查"
            Da1.Clear()
            OleDbDataAdapter1.Fill(Da1)
            Me.DataGrid1.Select(DataGrid1.CurrentRowIndex)

        Catch ex As Exception
            MsgBox("表中没有数据!")
        End Try

    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        Try
            OleDbDataAdapter1.SelectCommand.CommandText = "select * from 卫生检查"
            Da1.Clear()
            OleDbDataAdapter1.Fill(Da1)
            Me.DataGrid1.Select(DataGrid1.CurrentRowIndex)

        Catch ex As Exception
            MsgBox("表中没有数据!")
        End Try
        TextBox8.Text = ""
        ComboBox3.Text = ""
        ComboBox4.Text = ""
        TextBox9.Text = ""

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            If Button1.Text = "添加" Then
                Me.BindingContext(Da1, "卫生检查").AddNew()
                Button1.Text = "确定"
                Button2.Enabled = False
                Button3.Enabled = False
                Button5.Enabled = False
                Button6.Enabled = False
                Button8.Enabled = False

            Else
                If Button1.Text <> "确定" Then
                    Exit Sub
                End If
                Me.BindingContext(Da1, "卫生检查").EndCurrentEdit()
                OleDbDataAdapter1.Update(Da1.卫生检查)
                MsgBox("添加成功!")
                Button1.Text = "添加"
                Button2.Enabled = True
                Button3.Enabled = True
                Button5.Enabled = True
                Button6.Enabled = True
                Button8.Enabled = True

            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Me.BindingContext(Da1, "卫生检查").CancelCurrentEdit()
        Button1.Text = "添加"
        Button2.Enabled = True
        Button3.Enabled = True
        Button5.Enabled = True
        Button6.Enabled = True
        Button8.Enabled = True

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Try
            If MsgBox("你真的要删除此记录吗?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
                Me.BindingContext(Da1, "卫生检查").EndCurrentEdit()
                OleDbDataAdapter1.Update(Da1.卫生检查)
            Else
                Exit Sub
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Try
            Me.BindingContext(Da1, "卫生检查").EndCurrentEdit()
            OleDbDataAdapter1.Update(Da1.卫生检查)
            MsgBox("更改成功!")

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Me.Close()
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

    End Sub

    Private Sub ComboBox1_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ComboBox1.Validating
        If ComboBox1.Text = "" Then
            Exit Sub
        End If

        Dim Conn As New System.Data.OleDb.OleDbConnection
        Dim Cmd As New System.Data.OleDb.OleDbCommand
        Dim DataReader As System.Data.OleDb.OleDbDataReader
        Dim ComString As String
        ComString = "Select Distinct 房号 from 房源库 Where 栋号=" & "'" & ComboBox1.Text & "'" & "order by 房号"

        Try
            Conn.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=学生公寓管理系统.mdb"
            Conn.Open()

            Cmd.CommandText = ComString
            Cmd.Connection = Conn
            DataReader = Cmd.ExecuteReader
            DataReader.Read()
            ComboBox2.Items.Clear()
            While DataReader.Read()
                ComboBox2.Items.Add(DataReader.Item(0))
            End While
            DataReader.Close()
            Conn.Close()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

    Private Sub ComboBox4_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ComboBox4.Validating
        If ComboBox4.Text = "" Then
            Exit Sub
        End If

        Dim Conn As New System.Data.OleDb.OleDbConnection
        Dim Cmd As New System.Data.OleDb.OleDbCommand
        Dim DataReader As System.Data.OleDb.OleDbDataReader
        Dim ComString As String
        ComString = "Select Distinct 房号 from 房源库 Where 栋号=" & "'" & ComboBox4.Text & "'" & "order by 房号"

        Try
            Conn.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=学生公寓管理系统.mdb"
            Conn.Open()

            Cmd.CommandText = ComString
            Cmd.Connection = Conn
            DataReader = Cmd.ExecuteReader
            DataReader.Read()
            ComboBox3.Items.Clear()
            While DataReader.Read()
                ComboBox3.Items.Add(DataReader.Item(0))
            End While
            DataReader.Close()
            Conn.Close()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        Try
            Dim ComStr As String
            ComStr = "Select * from 卫生检查 where "
            ComStr &= "栋号 like '" & Trim(ComboBox4.Text) & "%" & "'"
            ComStr &= "and 房号 like '" & Trim(ComboBox3.Text) & "%" & "'"
            ComStr &= "and 总分 like '" & Trim(TextBox8.Text) & "%" & "'"
            ComStr &= "and 日期 like '" & "%" & Trim(TextBox9.Text) & "%" & "'"
            OleDbDataAdapter1.SelectCommand.CommandText = ComStr
            Da1.Clear()
            OleDbDataAdapter1.Fill(Da1)
            Me.DataGrid1.Select(DataGrid1.CurrentRowIndex)
        Catch ex As Exception
            MsgBox("没有您要查询的数据!")
        End Try
    End Sub
End Class

⌨️ 快捷键说明

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