如何将 public 假期 table 从 sql 到 vb.net 中的日期选择器范围?

How to get public holiday table from sql to date picker range in vb.net?

我的问题是我想要 sql 中的 public 假期 table 连接到日期选择器范围。这样当用户想请假时,他们不能选择与 public 假期相同的日期。我正在使用 asp.net 和 vb.net 作为日期范围选择器。

The date range picker i use is this

我的问题解决了

    Private Function getHoliday(ByVal strtDate As String, ByVal endDate As String) As DataTable
        Dim dt As New DataTable
        Dim strGetHoliday As String = "SELECT ID,Name FROM holiday WHERE Start_Date=@Start_Date OR End_Date=@End_Date"
        myconn.AddParameter("@Start_Date", MySqlDbType.VarChar)
        myconn.SetParameter("@Start_Date", strtDate)
        myconn.AddParameter("@End_Date", MySqlDbType.VarChar)
        myconn.SetParameter("@End_Date", endDate)

        Try
            myconn.OpenConnection()
            myconn.FillDataTable(dt, strGetHoliday)
            myconn.CloseConnection()
            myconn.ClearAllParameter()

        Catch ex As Exception
            myconn.CloseConnection()
            myconn.ClearAllParameter()
        End Try
        Return dt
    End Function

然后我调用了datepickerto_DateChanged sub

中的函数
 Protected Sub datepickerto_DateChanged(sender As Object, e As EventArgs) Handles datepickerto.DateChanged
        Dim dt As DataTable
        dt = getHoliday(datepickerFrom.Text, datepickerto.Text)
        If dt.Rows.Count > 0 Then
            DisplayMessage("Error", "Error", "Public Holiday")
        End If
    End Sub