我想让用户点击某个日期后检索出数据库相应记录

解决方案 »

  1.   

    Private Function getdate(ByVal currentday As String)
            Dim return_date As String
            Dim OS As Integer        OS = currentday.IndexOf("/")        If OS = -1 Then
                'OS is Chinese System
                Select Case Len(currentday)
                    Case 8
                        return_date = Left(currentday, 4) + "-0" + Right(Left(currentday, 6), 1) + "-0" + Right(currentday, 1)
                        Return return_date
                    Case 9
                        Select Case Right(Left(currentday, 7), 1)
                            Case "-"
                                return_date = Left(currentday, 4) + "-0" + Right(Left(currentday, 6), 1) + "-" + Right(currentday, 2)
                                Return return_date
                            Case Else
                                return_date = Left(currentday, 7) + "-0" + Right(currentday, 1)
                                Return return_date
                        End Select
                    Case 10
                        Return currentday
                    Case Else
                End Select
            Else
                'OS is English System
                Select Case Len(currentday)
                    Case 8
                        return_date = Right(currentday, 4) + "-0" + Left(currentday, 1) + "-0" + Right(Left(currentday, 3), 1)
                        Return return_date
                    Case 9
                        Select Case Right(Left(currentday, 2), 1)
                            Case "/"
                                return_date = Right(currentday, 4) + "-0" + Left(currentday, 1) + "-" + Right(Left(currentday, 4), 2)
                                Return return_date
                            Case Else
                                return_date = Right(currentday, 4) + "-" + Left(currentday, 2) + "-0" + Right(Left(currentday, 4), 1)
                                Return return_date
                        End Select
                    Case 10
                        Return currentday
                    Case Else
                End Select
            End If    End Function
      

  2.   

    Sub Date_Selected(ByVal sender As Object, ByVal e As EventArgs)
            Dim startdate As String
            Select Case (Calendar1.SelectedDates.Count)
                Case 0 'None
                    startdate = getdate(Today)
                    Session("sr") = 0
                    Response.Write("<script>parent.frrighttop1.location.href='righttop_receive.aspx?startdate=" & CStr(startdate) & "&count=1';</script>")
                    'Label1.Text = "No dates are currently selected"
                Case 1 'Day
                    startdate = getdate(Calendar1.SelectedDate)
                    If IsNothing(Session("sr")) = True Then
                        Session("sr") = 0
                        Response.Write("<script>parent.frrighttop1.location.href='righttop_receive.aspx?startdate=" & CStr(startdate) & "&count=1';</script>")
                    Else
                        Select Case Session("sr")
                            Case "0"
                                Response.Write("<script>parent.frrighttop1.location.href='righttop_receive.aspx?startdate=" & CStr(startdate) & "&count=1';</script>")
                            Case "1"
                                Response.Write("<script>parent.frrighttop1.location.href='righttop_send.aspx?startdate=" & CStr(startdate) & "&count=1';</script>")
                        End Select
                    End If
                Case 7 'Week
                    startdate = getdate(Calendar1.SelectedDate)
                    If IsNothing(Session("sr")) = True Then
                        Session("sr") = 0
                        Response.Write("<script>parent.frrighttop1.location.href='righttop_receive.aspx?startdate=" & CStr(startdate) & "&count=7';</script>")
                    Else
                        Select Case Session("sr")
                            Case "0"
                                Response.Write("<script>parent.frrighttop1.location.href='righttop_receive.aspx?startdate=" & CStr(startdate) & "&count=7';</script>")
                            Case "1"
                                Response.Write("<script>parent.frrighttop1.location.href='righttop_send.aspx?startdate=" & CStr(startdate) & "&count=7';</script>")
                        End Select
                    End If
                Case Else 'Month
                    startdate = getdate(Calendar1.SelectedDate)
                    If IsNothing(Session("sr")) = True Then
                        Session("sr") = 0
                        Response.Write("<script>parent.frrighttop1.location.href='righttop_receive.aspx?startdate=" & CStr(startdate) & "&count=30';</script>")
                    Else
                        Select Case Session("sr")
                            Case "0"
                                Response.Write("<script>parent.frrighttop1.location.href='righttop_receive.aspx?startdate=" & CStr(startdate) & "&count=30';</script>")
                            Case "1"
                                Response.Write("<script>parent.frrighttop1.location.href='righttop_send.aspx?startdate=" & CStr(startdate) & "&count=30';</script>")
                        End Select
                    End If
            End Select
        End Sub
      

  3.   

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            If Not IsPostBack Then
                If Session("passed") = True Then
                    If Request.QueryString("flag") <> 1 Then
                        Dim count As Integer                    If IsNothing(Request.QueryString("count")) = False Then
                            Session("count") = Request.QueryString("count")
                        Else
                            Session("startdate") = getdate(Today())
                            Session("enddate") = getdate(Today())
                        End If.....................
            Dim Select_Information, currentday As String
            Dim DAinformation As SqlDataAdapter        currentday = getdate(Today)
            If Len(CStr(Session("startdate"))) > 0 Then
                Select_Information = "SELECT a.send_id, b.title, a.send_time, a.receive_time, a.requestinformation, " & _
                                    "a.information_id, c.clerkName, a.receive_id, b.accessory_flag, d.infor_image, " & _
                                    "e.urgence_image, a.send_flag, f.flag_image AS sendflag, a.receive_flag, " & _
                                    "g.flag_image AS receflag " & _
                                    "FROM dbo.send_receive a INNER JOIN " & _
                                    "dbo.information b ON a.information_id = b.information_id INNER JOIN " & _
                                    "dbo.clerk c ON a.send_id = c.SN INNER JOIN " & _
                                    "dbo.infor_type d ON b.infor_type_id = d.infor_type_id INNER JOIN " & _
                                    "dbo.infor_urgence e ON b.urgence_caption_id = e.urgence_caption_id INNER JOIN " & _
                                    "dbo.handle_flag f ON a.send_flag = f.flag_id INNER JOIN " & _
                                    "dbo.handle_flag g ON a.receive_flag = g.flag_id " & _
                                    "WHERE a.receive_id = '" & Session("person_id") & _
                                    "' and substring(Convert(varchar, a.send_time, 20), 1,10)" & _
                                    " between '" & Session("startdate") & "' and '" & Session("enddate") & "'" & _
                                    " order by a.send_time desc"
      

  4.   

    我有一个相关的demo,要的话发给你,可以加我Q:88930228