1、不需要两个逻辑列,一个“受注”逻辑列即可
2、不需要锁定行,用PrepareEdit事件动态控制:
http://www.foxtable.com/help/topics/0605.htm
将PrepareEdit事件代码设置为:
if e.Col.Name <> "受注" AndAlso e.Row("受注") = True Then
e.Cancel = true
End If
3、DataColChanged事件代码改为:
If e.DataCol.Name = "受注" Then
If e.DataRow("受注") = True Then ‘如果勾选
Dim nma() As String = {"客户代码","项目号","报价单编号","业务担当","采购担当","备注"} '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
Else ’如果是取消勾选
DataTables("项目订单").Deletefor("报价单编号 = '" & e.DataRow("报价单编号") & "'") '删除对应报价单号的行
End If
End If