以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  大红袍老师:帮我看一下签到表打印加载哪儿出了问题?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=70006)

--  作者:zgjmost
--  发布时间:2015/6/14 16:26:00
--  大红袍老师:帮我看一下签到表打印加载哪儿出了问题?

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:签到表加载问题.rar

 

大红老师:请您帮我审查一下签到表打印加载的问题,基本思路是得到FILTER后,对这个进行OR 和 AND 划分,得到的数组分别给到短日期,起始时间,教室三个变量中,再进行筛选,但总是报错,不知哪出问题?

 

请指导


--  作者:大红袍
--  发布时间:2015/6/14 16:49:00
--  

DataTables("考试数据表").LoadFilter = ""
DataTables("考试数据表").Load

Dim nms As String() = {"短日期","起始时间","教室"} \'指定生成目录树的各列
Dim qts As String() = {"\'","\'","\'"} \'指定将各列的值括起来的符号,这里都是字符型,所以都是单引号
Dim trv As WinForm.TreeView = e.Form.Controls("签到单时间")
Dim filter As String
For Each nd As object In trv.AllNodes
    If nd.Level > 2 Then
        If nd.Checked  Then
            Dim rts() As String = nd.FullPath.Split("\\")
            Dim val As String = ""
            For i As Integer = 1 To rts.length - 1
                If val > "" Then
                    val = val & " And "
                End If
                val = val & nms(i-1) & " = " & qts(i-1) & rts(i) & qts(i-1)
            Next
            If filter > "" Then
                filter = filter & " Or (" & val & ")"
            Else
                filter = val
            End If
        End If
    End If
Next

filter = filter.Replace("(","").Replace(")","")

msgbox(filter)

DataTables("考试数据表").ResumeRedraw
DataTables("考试数据表").StopRedraw
For Each ary() As String In DataTables("考试数据表").GetValues("短日期|起始时间|教室", filter)
   
    Vars("qdd1") = ary(0)
   
   
    Vars("qdd2") = ary(1)
   
   
    Vars("qdd3") = ary(2)
   

   
   
    With Tables("考试数据表")
        .Filter = "机考安排 is null and 短日期 = \'" & ary(0) & "\' and 起始时间 = \'" & ary(1) & "\' and 教室 = \'" & ary(2) & "\'"
        If .Rows.count > 0 Then
            .Select(0,0,.Rows.count - 1,.Cols.count - 1 )
            Dim Book As New XLS.Book(ProjectPath & "Attachments\\纸考签到单.xls")
            Dim fl As String = ProjectPath & "Reports\\纸考签到表\\" & ary(0) & " "  & ary(1).Replace(":", "点") &  " "  &  ary(2) & "签到单.xls"
            Book.Build() \'生成细节区
            Book.Save(fl) \'保存工作簿
        End If
    End With
   
   
    With Tables("考试数据表")
        .Filter = "机考安排 is not null and 短日期 = \'" & ary(0) & "\' and 起始时间 = \'" & ary(1) & "\' and 教室 = \'" & ary(2) & "\'"
        If .Rows.count > 0 Then
            .Select(0,0,.Rows.count - 1,.Cols.count - 1 )
            Dim  book = New XLS.Book(ProjectPath & "Attachments\\机考签到单.xls")
            Dim fl = ProjectPath & "Reports\\机考签到表\\" & ary(0) & " "  & ary(1).Replace(":", "点") &  " "  &  ary(2) & "签到单.xls"
           
            Book.Build() \'生成细节区
            Book.Save(fl) \'保存工作簿
        End If
    End With
   
   
   
Next                                      \'结束遍历value2s的数组
DataTables("考试数据表").ResumeRedraw