Visual Basic 2010 数据库开发之酒店管理系统09入住客史查询

Imports System.Data.SqlClient
Public Class frmKeShiChaXun
    Dim conn As SqlConnection = GetConnection()
    Dim strSql As String = "Select * From 退房信息"
    Dim myda As New SqlDataAdapter(strSql, conn)
    Dim mydt As DataTable

    Private Sub FillDataAndView()
        mydt = New DataTable
        myda.Fill(mydt)
    End Sub

    Private Sub frmKeShiChaXun_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Disposed
        Me.Close()
        frmMain.Show()
    End Sub

    Private Sub frmKeShiChaXun_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        FillDataAndView()

        DataGridView1.DataSource = mydt
    End Sub

    Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        DataGridView1.DataSource = Nothing
        strSql = "Select * From 退房信息 Where " & cmbMode.Text & " like '%{0}%'"

        Dim da As SqlDataAdapter = New SqlDataAdapter(strSql, conn)
        Dim dt As New DataTable
        Try
            da.Fill(dt)
        Catch ex As Exception
            MsgBox("不存在")
        End Try

        DataGridView1.DataSource = dt
    End Sub

    Private Sub btnRef_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRef.Click
        frmKeShiChaXun_Load(sender, e)
        Me.Close()
    End Sub
End Class

 

©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页