以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  错误提示,列为只读,搞不清楚问题出在哪  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=115921)

--  作者:yetle
--  发布时间:2018/3/16 16:30:00
--  错误提示,列为只读,搞不清楚问题出在哪

Button5,Click事件:

 

Dim r As Row = Tables("报价单").Current
Dim dnew As Row = Tables("报价单").AddNew
Dim name As String = r("订单编号") & "*"
For Each c As Col In Tables("报价单").Cols
    If c.Name = "订单编号" Then
        dnew(c.Name) = name
    ElseIf c.Name <> "_Identify" Then
        dnew(c.Name) = r(c.Name)
    End If
Next
Tables("报价单").Current("财务审核") = Nothing
Tables("报价单").Current("总经理审批") = Nothing

 


Dim drs As List(Of DataRow)
drs = r.DataRow.GetChildRows("报价明细")
Dim rc As DataRow
For Each dr As DataRow In drs
    rc = dr.Clone
    rc("订单编号") = name
Next

 

运行弹出提示:

.NET Framework 版本:2.0.50727.8669
Foxtable 版本:2018.3.3.1
错误所在事件:窗口,报价记录,Button5,Click
详细错误信息:
列“研发管理费”为只读。

 

关键是列“研发管理费”没有设只读



--  作者:狐狸爸爸
--  发布时间:2018/3/16 16:55:00
--  
说明这一列是表达式列,表达式列不能用代码修改值,排除掉表达式列:

Dim r As Row = Tables("报价单").Current
Dim dnew As Row = Tables("报价单").AddNew
Dim name As String = r("订单编号") & "*"
For Each c As Col In Tables("报价单").Cols
    If c.DataCol.Expression = "" Then
        If c.Name = "订单编号" Then
            dnew(c.Name) = name
        ElseIf c.Name <> "_Identify" Then
            dnew(c.Name) = r(c.Name)
        End If
    End If
Next
Tables("报价单").Current("财务审核") = Nothing
Tables("报价单").Current("总经理审批") = Nothing

Dim drs As List(Of DataRow)
drs = r.DataRow.GetChildRows("报价明细")
Dim rc As DataRow
For Each dr As DataRow In drs
    rc = dr.Clone
    rc("订单编号") = name
Next


或者直接判断列名:


Dim r As Row = Tables("报价单").Current
Dim dnew As Row = Tables("报价单").AddNew
Dim name As String = r("订单编号") & "*"
For Each c As Col In Tables("报价单").Cols
    If c.Name <> "研发管理费" Then
        If c.Name = "订单编号" Then
            dnew(c.Name) = name
        ElseIf c.Name <> "_Identify" Then
            dnew(c.Name) = r(c.Name)
        End If
    End If
Next
Tables("报价单").Current("财务审核") = Nothing
Tables("报价单").Current("总经理审批") = Nothing

Dim drs As List(Of DataRow)
drs = r.DataRow.GetChildRows("报价明细")
Dim rc As DataRow
For Each dr As DataRow In drs
    rc = dr.Clone
    rc("订单编号") = name
Next
[此贴子已经被作者于2018/3/16 16:56:53编辑过]