以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  求助,一段流程控制代码,麻烦老师看下  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=144936)

--  作者:frankcat
--  发布时间:2020/1/3 14:16:00
--  求助,一段流程控制代码,麻烦老师看下

下面这段代码,走到case “wai“,value的值等于“wai”,出现两次,不往下走了,到不了 case “res”,不知道什么原因

Dim dtp As WinForm.DateTimePicker = Forms("凭证生成").Controls("Date1")
dtp.value = Date.today.adddays(-1)
Dim Values As New List(Of String)
Dim value As String
values.add(e.DataRow("key2"))
For Each value In values
    Select Case value
          Case "WAI"
messagebox.show(value)
            If e.DataRow("YYYYMMDD") = dtp.value Then
                If  DataTables("cbdata").compute("count(date)","date = \'" & dtp.value & "\' And incomecategory = \'散客收入\'") = 0 Then
                    Dim dr As DataRow = DataTables("CBDATA").AddNew()
                    dr("DATE") = e.DataRow("YYYYMMDD")
                    dr("posstation") = "客房部"
                    dr("paycode") = "客房收入"
                    dr("incomecategory") = "散客收入"
                    dr("amount")= e.DataRow("dicvalue")
                End If
            End If
Case "RES"   
 messagebox.show(2)
            If e.DataRow("YYYYMMDD") = dtp.value Then
                If  DataTables("cbdata").compute("count(date)","incomecategory = \'订房中心\'") = 0 Then
                    Dim dr As DataRow = DataTables("CBDATA").AddNew()
                    dr("DATE") = e.DataRow("YYYYMMDD")
                    dr("posstation") = "客房部"
                    dr("paycode") = "客房收入"
                    dr("incomecategory") = "订房中心"
                    dr("amount")= e.DataRow("dicvalue")
                End If
            End If
End Select
Next


--  作者:有点蓝
--  发布时间:2020/1/3 14:31:00
--  
msgbox(e.DataRow("key2")) \'key2存储的是什么内容
--  作者:frankcat
--  发布时间:2020/1/3 14:41:00
--  
详见附件!
图片点击可在新窗口打开查看此主题相关图片如下:key2.png
图片点击可在新窗口打开查看

--  作者:有点蓝
--  发布时间:2020/1/3 14:43:00
--  
代码放在什么事件的?完整代码发上来
--  作者:frankcat
--  发布时间:2020/1/3 14:48:00
--  
datacolchenged事件,这个就是事件里面的完整代码了,别的地方还没有写代码
--  作者:有点蓝
--  发布时间:2020/1/3 15:09:00
--  
先看看:http://www.foxtable.com/webhelp/topics/1522.htm

感觉这个处理逻辑是有问题的,但是看不懂到底要干嘛


--  作者:frankcat
--  发布时间:2020/1/3 15:10:00
--  

我把他改成这种格式,数组手动添加,可以走下去,但是死循环

 

Dim dtp As WinForm.DateTimePicker = Forms("凭证生成").Controls("Date1")
dtp.value = Date.today.adddays(-1)
Dim Values As New List(Of String)
Dim value As String
values.add("WAI")
values.add("RES")
For  i As Integer = 0 To Values.Count -1
messagebox.show(values(i))
    Select Case values(i)
          Case "WAI"
            If e.DataRow("YYYYMMDD") = dtp.value Then
                If  DataTables("cbdata").compute("count(date)","date = \'" & dtp.value & "\' And incomecategory = \'散客收入\'") = 0 Then
                    Dim dr As DataRow = DataTables("CBDATA").AddNew()
                    dr("DATE") = e.DataRow("YYYYMMDD")
                    dr("posstation") = "客房部"
                    dr("paycode") = "客房收入"
                    dr("incomecategory") = "散客收入"
                    dr("amount")= e.DataRow("dicvalue")
                End If
            End If
Case "RES"   
 messagebox.show(2)
            If e.DataRow("YYYYMMDD") = dtp.value Then
                If  DataTables("cbdata").compute("count(date)","incomecategory = \'订房中心\'") = 0 Then
                    Dim dr As DataRow = DataTables("CBDATA").AddNew()
                    dr("DATE") = e.DataRow("YYYYMMDD")
                    dr("posstation") = "客房部"
                    dr("paycode") = "客房收入"
                    dr("incomecategory") = "订房中心"
                    dr("amount")= e.DataRow("dicvalue")
                End If
            End If
End Select
Next


--  作者:有点蓝
--  发布时间:2020/1/3 15:12:00
--  
if Forms("凭证生成").opened andalso e.datacol.name = "key2"
Dim dtp As WinForm.DateTimePicker = Forms("凭证生成").Controls("Date1")
dtp.value = Date.today.adddays(-1)
if e.DataRow("YYYYMMDD") <> dtp.value then return
    Select Case e.newvalue
          Case "WAI" 
messagebox.show(value)
                If  DataTables("cbdata").compute("count(date)","date = \'" & dtp.value & "\' And incomecategory = \'散客收入\'") = 0 Then
                    Dim dr As DataRow = DataTables("CBDATA").AddNew()
                    dr("DATE") = e.DataRow("YYYYMMDD")
                    dr("posstation") = "客房部"
                    dr("paycode") = "客房收入"
                    dr("incomecategory") = "散客收入"
                    dr("amount")= e.DataRow("dicvalue")
                End If
Case "RES"    
 messagebox.show(2)
                If  DataTables("cbdata").compute("count(date)","incomecategory = \'订房中心\'") = 0 Then
                    Dim dr As DataRow = DataTables("CBDATA").AddNew()
                    dr("DATE") = e.DataRow("YYYYMMDD")
                    dr("posstation") = "客房部"
                    dr("paycode") = "客房收入"
                    dr("incomecategory") = "订房中心"
                    dr("amount")= e.DataRow("dicvalue")
                End If
End Select
Next
end if

最后选中"key2"列,重置一下列

--  作者:frankcat
--  发布时间:2020/1/3 15:16:00
--  

好的,谢谢老师