计算生成1 2..31天的员工的工作日,时间仅显示在那些日期

时间:2013-05-08 01:41:34

标签: vb.net if-statement while-loop switch-statement

Dim cmd As OdbcCommand = New OdbcCommand(“SELECT distinct checktime,format(CHECKTIME,'Short Date')as adlaws,format(CHECKTIME,'ampm​​')as formatz,checktype”& _                                                  “来自CHECKINOUT,其中userid =”& Label6.Text& “和#”之间的检查时间FormatDateTime(DateTimePicker1.Value,DateFormat.ShortDate)& _                                                  “#和#”& FormatDateTime(DateTimePicker2.Value,DateFormat.ShortDate)& “#”,con)

    Try
        Dim dr As OdbcDataReader
        ListView1.Items.Clear()
        dr = cmd.ExecuteReader


        MsgBox(i & " " & adlawan)
        Do While dr.Read()



            Dim Str1 As String = dr.Item("adlaws").ToString
            Dim Str2 As String = dr.Item("formatz").ToString
            Dim Str3 As String = dr.Item("checktype").ToString

            sLog = FormatDateTime(dr.Item("CHECKTIME").ToString, DateFormat.ShortDate)
            sTime = FormatDateTime(dr.Item("CHECKTIME").ToString, DateFormat.ShortTime)


            adlawan = Val(Mid(sLog, 3, 2))

            ' MsgBox(i & " " & adlawan)

            ' If adlawan = i Then
            'lv = ListView1.Items.Add(adlawan)
            Select Case Str3

                Case "I"

                    If Val(Mid(sTime, 1, 2)) > 3 And Val(Mid(sTime, 1, 2)) < 10 Then
                        lv = ListView1.Items.Add(adlawan)
                        a = FormatDateTime(dr.Item("CHECKTIME").ToString, DateFormat.ShortTime)
                        lv.SubItems.Add(a)
                    Else
                        d = FormatDateTime(dr.Item("CHECKTIME").ToString, DateFormat.ShortTime)
                        lv.SubItems.Add(d)
                    End If
                Case "O"
                    If Val(Mid(sTime, 1, 2)) > 10 And Val(Mid(sTime, 1, 2)) < 17 Then
                        b = FormatDateTime(dr.Item("CHECKTIME").ToString, DateFormat.ShortTime)
                        lv.SubItems.Add(b)
                    Else
                        c = FormatDateTime(dr.Item("CHECKTIME").ToString, DateFormat.ShortTime)
                        lv.SubItems.Add(c)
                    End If

            End Select

adlawan = adlawan + 1

        Loop


        con.Close()
    Catch oe As OdbcException
        MsgBox(oe.Message)
    End Try

0 个答案:

没有答案