以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  帮忙看看代码那错了?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=87350)

--  作者:manyifuwu
--  发布时间:2016/7/8 18:21:00
--  帮忙看看代码那错了?

If e.DataCol.Name = "编号" Then
    If e.DataRow.IsNull("编号") Then
    Else
        Dim dr As DataRow = DataTables("派工").Find("[_Identify] = \'" & e.DataRow("编号") & "\'")
        If dr IsNot Nothing Then
            e.DataRow("日期") = dr("截止日期")
            e.DataRow("户名") = dr("户名")
            e.DataRow("地址") = dr("详细地址")
            e.DataRow("编号2") = dr("客户id")
            e.DataRow("客户编号") = dr("编号")
            e.DataRow("类型") = dr("类型")
            e.DataRow("业务途径") = dr("业务途径")
            e.DataRow("转账银行") = dr("转账银行")
            e.DataRow("付款方式") = dr("付款方式")
            e.DataRow("应收金额") = dr("收款")
            e.DataRow("部门") = dr("部门")
            e.DataRow("业务人员") = dr("业务人员")
        Else
            e.DataRow("编号") = Nothing
        End If
    End If
End If

If e.DataCol.name = "审批" Then
    Dim pr As DataRow = e.DataRow.GetParentRow("派工")
    If pr IsNot Nothing Then
        Dim crs As List(of DataRow) = pr.GetChildRows("财务")
        Dim cnt As Integer
        For Each cr As DataRow In crs
            If cr("审批") = True
                cnt = cnt + 1
            End If
        Next
        pr("审批") = (crs.Count = cnt)
    End If
End If

Select Case e.DataCol.name
    Case "编号","付款方式"
        Dim count As Integer = e.DataTable.compute("count(_Identify)", "付款方式 = \'" & e.DataRow("付款方式") & "\' and 编号 = \'" & e.DataRow("编号") & "\'")
        If count > 1 Then
            msgbox("重复了")

            e.DataRow.Delete
        End If
End Select


图片点击可在新窗口打开查看此主题相关图片如下:fullsizerender(1).jpg
图片点击可在新窗口打开查看

--  作者:manyifuwu
--  发布时间:2016/7/8 18:22:00
--  
.NET Framework 版本:2.0.50727.8689
Foxtable 版本:2016.6.26.1
错误所在事件:表,财务,DataColChanged
详细错误信息:
调用的目标发生了异常。
此行已从表中移除并且没有任何数据。BeginEdit() 将允许在此行中创建新数据

--  作者:大红袍
--  发布时间:2016/7/8 18:30:00
--  

 去你的AddNew的代码那里,先判断一下子表有没有存在对应的数据,有就不要新增

 

Dim count As Integer = DataTables("子表").compute("count(_Identify)", "付款方式 = \'" & e.DataRow("付款方式") & "\' and 编号 = \'" & e.DataRow("编号") & "\'")

If count > 1 Then

     msgbox("不能新增")

End If


--  作者:manyifuwu
--  发布时间:2016/7/8 18:49:00
--  

If e.DataCol.Name = "是否" AndAlso e.DataRow("是否") = True Then
    Dim nma() As String = {"派工id"} \'A表数据来源列
    Dim nmb() As String = {"编号"} \'B表数据接收列
    Dim dr As DataRow = DataTables("财务").AddNew
    For i As Integer = 0 To nma.Length - 1
        dr(nmb(i)) = e.DataRow(nma(i))
    Next
End If

是在这里改吗?怎么改呢?谢谢!


--  作者:manyifuwu
--  发布时间:2016/7/8 19:23:00
--  

If e.DataCol.Name = "是否" AndAlso e.DataRow("是否") = True Then
    Dim nma() As String = {"派工id"} \'A表数据来源列
    Dim nmb() As String = {"编号"} \'B表数据接收列
    Dim dr As DataRow = DataTables("财务").AddNew
    Dim count As Integer = DataTables("财务").compute("count(_Identify)", "付款方式 = \'" & e.DataRow("付款方式") & "\' and 编号 = \'" & e.DataRow("编号") & "\'")
    If count > 1 Then
        msgbox("不能新增")
    End If
    For i As Integer = 0 To nma.Length - 1
        dr(nmb(i)) = e.DataRow(nma(i))
    Next
End If

 

这样改不对,请忙指教一哈。错在哪?

 


--  作者:Hyphen
--  发布时间:2016/7/9 8:55:00
--  
If e.DataCol.Name = "是否" AndAlso e.DataRow("是否") = True Then
    Dim count As Integer = DataTables("财务").compute("count(_Identify)", "付款方式 = \'" & e.DataRow("付款方式") & "\' and 编号 = \'" & e.DataRow("编号") & "\'")
    If count > 1 Then
        msgbox("不能新增")
return
    End If
    Dim nma() As String = {"派工id"} \'A表数据来源列
    Dim nmb() As String = {"编号"} \'B表数据接收列
    Dim dr As DataRow = DataTables("财务").AddNew
    For i As Integer = 0 To nma.Length - 1
        dr(nmb(i)) = e.DataRow(nma(i))
    Next
End If

--  作者:manyifuwu
--  发布时间:2016/7/9 12:19:00
--  

.NET Framework 版本:2.0.50727.8689
Foxtable 版本:2016.6.26.1
错误所在事件:表,财务,DataColChanged
详细错误信息:
调用的目标发生了异常。
此行已从表中移除并且没有任何数据。BeginEdit() 将允许在此行中创建新数据

还是有这个问题。好像没有执行判定子行重复,不能新增行,这个代码。。。

[此贴子已经被作者于2016/7/9 12:20:41编辑过]

--  作者:manyifuwu
--  发布时间:2016/7/9 12:31:00
--  

还是错误。

 

 

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

--  作者:Hyphen
--  发布时间:2016/7/9 12:44:00
--  
1楼的代码去掉最后一段select case 的代码
--  作者:manyifuwu
--  发布时间:2016/7/9 12:58:00
--  
主要问题,是没有判断子行重复,重复了不新增行,这条没实现。