以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  请教时时重置列问题!  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=63293)

--  作者:syczmg
--  发布时间:2015/1/18 10:42:00
--  请教时时重置列问题!
 

Ylx表与ht表以xmbh关联,Ylx表(父表)的cgzt由ht表(子表)的cgzt判断命名,在子表属性中将DataColChanged事件设为:

If e.DataCol.name="cgzt" AndAlso e.DataRow.isnull("xmbh")=False Then

    If e.DataTable.Compute("count(_Identify)","cgzt=\'未完成\' and xmbh=\'" & e.DataRow("xmbh") & "\'") > 0 Then

        e.DataRow.GetParentRow("ylx")("cgzt")="未完成"

    Else

        e.DataRow.GetParentRow("ylx")("cgzt")="已完成"

    End If

End If

并且,在窗口中增加状态重置按钮,将Click事件设为:

DataTables("ylx").DataCols("xmbh").RaiseDataColChanged()
DataTables("ht").DataCols("cgzt").RaiseDataColChanged()

以上两部用以判断Ylx表的cgzt。

问题是单击状态重置按钮麻烦,且易忘。

能否有不用单击状态重置按钮却能判断Ylx表的cgzt的方法?如何解决?谢谢!


--  作者:有点甜
--  发布时间:2015/1/18 10:59:00
--  

 代码写到子表的datacolchanged事件

 

DataTables("ylx").DataCols("xmbh").RaiseDataColChanged()
DataTables("ht").DataCols("cgzt").RaiseDataColChanged()

 

 http://www.foxtable.com/help/topics/1453.htm

 


--  作者:syczmg
--  发布时间:2015/1/18 11:21:00
--  

子表DataColChanged事件中有如下代码:

If e.DataCol.Name = "xmbh" Then
    If e.DataRow.IsNull("xmbh") Then
        e.DataRow("pmbh") = Nothing
    Else
        Dim xmh As String = e.DataRow("xmbh")
        If e.DataRow("pmbh").StartsWith(xmh) = False \'如果单据编号前缀不符
            Dim max As String
            Dim idx As Integer
            max = e.DataTable.Compute("Max(pmbh)","xmbh = \'" & xmh & "\' And [_Identify] <> " & e.DataRow("_Identify")) \'取得该类别的最大编号
            If max > "" Then \'如果存在最大编号
                idx = CInt(max.Substring(10,3)) + 1 \'获得最大编号的后三位顺序号,并加1
            Else
                idx = 1 \'否则顺序号等于1
            End If
            e.DataRow("pmbh") = xmh & "-" & Format(idx,"000")
        End If
    End If
End If

将下列代码写到子表的datacolchanged事件后,项目自动退出!如何解决?

 

DataTables("ylx").DataCols("xmbh").RaiseDataColChanged()
DataTables("ht").DataCols("cgzt").RaiseDataColChanged()


--  作者:有点甜
--  发布时间:2015/1/18 11:26:00
--  

 

[此贴子已经被作者于2015-1-18 11:26:45编辑过]

--  作者:有点甜
--  发布时间:2015/1/18 11:30:00
--  

 呃,看了一下,没有必要重置列的吧?

 

 你修改了子表的数据,父表的数据就会自动更新的啊。


--  作者:有点甜
--  发布时间:2015/1/18 11:33:00
--  

试试这样写

 

DataTables("ht").DataCols("cgzt").RaiseDataColChanged()