以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]代码问题  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=87162)

--  作者:陈卫
--  发布时间:2016/7/5 9:30:00
--  [求助]代码问题
专家您好,我有3个表:当前表、能力表、生产表,分别如下:
当前表
图片点击可在新窗口打开查看此主题相关图片如下:当前表.bmp
图片点击可在新窗口打开查看
能力表
图片点击可在新窗口打开查看此主题相关图片如下:能力表.bmp
图片点击可在新窗口打开查看
生产表
图片点击可在新窗口打开查看此主题相关图片如下:生产表.bmp
图片点击可在新窗口打开查看
在当前表的DataColChanged事件中编写代码如下:
Select Case e.DataCol.Name
    Case "杆径","长度","编号"
        Dim dc As DataRow = e.DataRow
        Dim qc As DataRow
        Dim pc As DataRow
        Dim filter1 As String
        Dim filter2 As String
        filter1 = "杆径 = \'" & dc("杆径") & "\' And 长度 = \'" & dc("长度") & "\'"
        filter2 = "编号 = \'" & dc("编号") & "\'"
        pc = DataTables("能力表").Find(filter1)
        If pc IsNot Nothing Then
            qc = DataTables("生产表").Find(filter2)
            If qc IsNot Nothing Then
                If qc("工位") = "平锻机1"
                    dc("平锻机1") = pc("能力_350t")
                End If
                If qc("工位") = "平锻机2"
                    dc("平锻机2") = pc("能力_450t")
                End If
                If qc("工位") = "平锻机3"
                    dc("平锻机3") = pc("能力_500t")
                End If
                If qc("工位") = "平锻机4"
                    dc("平锻机4") = pc("能力_800t")
                End If
            End If
        End If
End Select
目的是当生产表中在不同的合同中安排设备生产时,当前表可以将设备能力显示出来,但以上代码只显示“平锻机1”的能力,其他设备不显示,问题出在哪里?

--  作者:大红袍
--  发布时间:2016/7/5 9:38:00
--  

 

[此贴子已经被作者于2016/7/5 9:37:50编辑过]

--  作者:大红袍
--  发布时间:2016/7/5 9:38:00
--  

 

[此贴子已经被作者于2016/7/5 9:39:14编辑过]

--  作者:陈卫
--  发布时间:2016/7/5 9:41:00
--  
还是只在“平锻机1”列有数据,其他没有数据
--  作者:大红袍
--  发布时间:2016/7/5 9:46:00
--  
Select Case e.DataCol.Name
    Case "杆径","长度","编号"
        Dim dc As DataRow = e.DataRow
        Dim pc As DataRow
        Dim filter1 As String
        Dim filter2 As String
       
        filter2 = "编号 = \'" & dc("编号") & "\'"
        For Each gw As String In DataTables("生产表").GetValues("工位", filter2)
            If e.DataTable.DataCols.contains(gw) Then
                Dim nl As String = ""
                If gw = "平锻机1"
                    nl = "能力_350t"
                ElseIf gw = "平锻机2"
                    nl = "能力_450t"
                ElseIf gw = "平锻机3"
                    nl = "能力_500t"
                ElseIf gw = "平锻机4"
                    nl = "能力_800t"
                End If
                filter1 = "杆径 = \'" & dc("杆径") & "\' And 长度 = \'" & dc("长度") & "\' and " & nl & " is not Null"
                pc = DataTables("能力表").Find(filter1)
                If pc IsNot Nothing Then
                    dc(gw) = pc(nl)
                Else
                    dc(gw) = Nothing
                End If
               
            End If
        Next
       
End Select

--  作者:陈卫
--  发布时间:2016/7/5 9:51:00
--  
谢谢专家!


--  作者:陈卫
--  发布时间:2016/7/5 10:58:00
--  
Select Case e.DataCol.Name
    Case "杆径","长度","编号"
        Dim dc As DataRow = e.DataRow
        Dim pc As DataRow
        Dim filter1 As String
        Dim filter2 As String
        
        filter2 = "编号 = \'" & dc("编号") & "\'"
        For Each gw As String In DataTables("生产表").GetValues("工位", filter2)
            If e.DataTable.DataCols.contains(gw) Then
                Dim nl As String = ""
                If gw = "平锻机1"
                    nl = "能力_350t"
                ElseIf gw = "平锻机2"
                    nl = "能力_450t"
                ElseIf gw = "平锻机3"
                    nl = "能力_500t"
                ElseIf gw = "平锻机4"
                    nl = "能力_800t"
                End If
                filter1 = "杆径 = \'" & dc("杆径") & "\' And 长度 = \'" & dc("长度") & "\' and " & nl & " is not Null"
                pc = DataTables("能力表").Find(filter1)
                If pc IsNot Nothing Then
                    dc(gw) = pc(nl)      在“当前表”中,实际列的名称与“生产表”不一致。在实际案例中为“本工序_日生产能力_平锻机1”、“本工序_日生产能力_平锻机2”......“本工序_日生产能力_平锻机6”.不能直接用 dc(gw) = pc(nl),怎么改?
                Else,
                    dc(gw) = Nothing
                End If
                
            End If
        Next
        
End Select
--  作者:大红袍
--  发布时间:2016/7/5 11:03:00
--  

Select Case e.DataCol.Name
    Case "杆径","长度","编号"
        Dim dc As DataRow = e.DataRow
        Dim pc As DataRow
        Dim filter1 As String
        Dim filter2 As String
       
        filter2 = "编号 = \'" & dc("编号") & "\'"
        For Each gw As String In DataTables("生产表").GetValues("工位", filter2)
            gw = "本工序_日生产能力_" & gw
            If e.DataTable.DataCols.contains(gw) Then
                Dim nl As String = ""
                If gw = "平锻机1"
                    nl = "能力_350t"
                ElseIf gw = "平锻机2"
                    nl = "能力_450t"
                ElseIf gw = "平锻机3"
                    nl = "能力_500t"
                ElseIf gw = "平锻机4"
                    nl = "能力_800t"
                End If
                filter1 = "杆径 = \'" & dc("杆径") & "\' And 长度 = \'" & dc("长度") & "\' and " & nl & " is not Null"
                pc = DataTables("能力表").Find(filter1)
                If pc IsNot Nothing Then
                    dc(gw) = pc(nl)
                Else,
                    dc(gw) = Nothing
                End If
               
            End If
        Next
       
End Select


--  作者:陈卫
--  发布时间:2016/7/5 11:14:00
--  
这是我的实际代码
 Case "品种_杆径","品种_长度","合同编号"
        Dim dc As DataRow = e.DataRow
        Dim pc As DataRow
        
        Dim filter1 As String
        Dim filter2 As String
        
        filter2 = "执行合同编号 = \'" & dc("合同编号") & "\'"
        For Each gw As String In DataTables("生产安排表").GetValues("工位", filter2)
            gw = "本工序_日生产能力_" & gw
            If e.DataTable.DataCols.contains(gw) Then
                Dim nl As String = ""
                If gw = "平锻机1"
                    nl = "日生产能力_锻造_350t"
                ElseIf gw = "平锻机2"
                    nl = "日生产能力_锻造_450t"
                ElseIf gw = "平锻机3"
                    nl = "日生产能力_锻造_350t"
                ElseIf gw = "平锻机4"
                    nl = "日生产能力_锻造_450t"
                ElseIf gw = "平锻机5"
                    nl = "日生产能力_锻造_500t"
                ElseIf gw = "平锻机6"
                    nl = "日生产能力_锻造_800t"
                End If
                
                filter1 = "品种_杆径 = \'" & dc("品种_杆径") & "\' And 品种_长度 = \'" & dc("品种_长度") & "\'and " & nl & " is not Null"
                pc = DataTables("工序能力表").Find(filter1)
                If pc IsNot Nothing Then
                    dc(gw) = pc(nl)
                Else
                    dc(gw) = Nothing
                End If
            End If
        Next
错误信息为:调用的目标发生了异常,详细信息如下:
.NET Framework 版本:2.0.50727.3655
Foxtable 版本:2016.6.14.1
错误所在事件:表,拉动排产计划_锻造, DataColChanged
详细错误信息:
调用的目标发生了异常。
语法错误:“Is”运算符前缺少操作数

--  作者:大红袍
--  发布时间:2016/7/5 11:28:00
--  

Dim dc As DataRow = e.DataRow
Dim pc As DataRow

Dim filter1 As String
Dim filter2 As String

filter2 = "执行合同编号 = \'" & dc("合同编号") & "\'"
For Each gw As String In DataTables("生产安排表").GetValues("工位", filter2)
    gw = "本工序_日生产能力_" & gw
    If e.DataTable.DataCols.contains(gw) Then
        Dim nl As String = ""
        If gw = "平锻机1"
            nl = "日生产能力_锻造_350t"
        ElseIf gw = "平锻机2"
            nl = "日生产能力_锻造_450t"
        ElseIf gw = "平锻机3"
            nl = "日生产能力_锻造_350t"
        ElseIf gw = "平锻机4"
            nl = "日生产能力_锻造_450t"
        ElseIf gw = "平锻机5"
            nl = "日生产能力_锻造_500t"
        ElseIf gw = "平锻机6"
            nl = "日生产能力_锻造_800t"
        End If
        If nl > "" Then
            filter1 = "品种_杆径 = \'" & dc("品种_杆径") & "\' And 品种_长度 = \'" & dc("品种_长度") & "\' and " & nl & " is not Null"
            pc = DataTables("工序能力表").Find(filter1)
            If pc IsNot Nothing Then
                dc(gw) = pc(nl)
            Else
                dc(gw) = Nothing
            End If
            endif
        End If
    Next