?? 宿舍衛(wèi)生.vb
字號(hào):
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 宿舍衛(wèi)生_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=學(xué)生公寓管理系統(tǒng).mdb"
Conn.Open()
Cmd.CommandText = "Select Distinct 棟號(hào) from 房源庫 order by 棟號(hào)"
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 衛(wèi)生檢查"
Da1.Clear()
OleDbDataAdapter1.Fill(Da1)
Me.DataGrid1.Select(DataGrid1.CurrentRowIndex)
Catch ex As Exception
MsgBox("表中沒有數(shù)據(jù)!")
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 衛(wèi)生檢查"
Da1.Clear()
OleDbDataAdapter1.Fill(Da1)
Me.DataGrid1.Select(DataGrid1.CurrentRowIndex)
Catch ex As Exception
MsgBox("表中沒有數(shù)據(jù)!")
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, "衛(wèi)生檢查").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, "衛(wèi)生檢查").EndCurrentEdit()
OleDbDataAdapter1.Update(Da1.衛(wèi)生檢查)
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, "衛(wèi)生檢查").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("你真的要?jiǎng)h除此記錄嗎?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
Me.BindingContext(Da1, "衛(wèi)生檢查").EndCurrentEdit()
OleDbDataAdapter1.Update(Da1.衛(wèi)生檢查)
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, "衛(wèi)生檢查").EndCurrentEdit()
OleDbDataAdapter1.Update(Da1.衛(wèi)生檢查)
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 房號(hào) from 房源庫 Where 棟號(hào)=" & "'" & ComboBox1.Text & "'" & "order by 房號(hào)"
Try
Conn.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=學(xué)生公寓管理系統(tǒng).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 房號(hào) from 房源庫 Where 棟號(hào)=" & "'" & ComboBox4.Text & "'" & "order by 房號(hào)"
Try
Conn.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=學(xué)生公寓管理系統(tǒng).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 衛(wèi)生檢查 where "
ComStr &= "棟號(hào) like '" & Trim(ComboBox4.Text) & "%" & "'"
ComStr &= "and 房號(hào) 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("沒有您要查詢的數(shù)據(jù)!")
End Try
End Sub
End Class
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -