以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  求计算页数的代码  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=149903)

--  作者:SZDVYE
--  发布时间:2020/5/15 1:44:00
--  求计算页数的代码
老大,我不懂怎么写代码,求帮助:
有两个表,如下图:
希望在表一中,B是需要计算的对象,当A 变量变动时,根据表二的计算规则,计算出C列和D列的结果,求代码:

我想的代码大概的模式是,但是写不出来:

在表一中的表事件DataColChanged中:


Select Case e.DataCol.Name

    Case "A"

        Dim dr As DataRow = e.DataRow

        Dim pr As DataRow

        If dr.IsNulL("A") Then

            dr("主页") = Nothing

            dr("续页") = Nothing

          Else

            Dim filter As String

    Dim pr As DataRow

            Dim drs As List(of DataRow) = e.DataRow.GetChildRows("计算表")

            filter = "A = \'" & dr("A") \'"

            pr = DataTables("报价表").Find(filter)

            If pr IsNot Nothing Then

            For Each drc As DataRow In drs

                If e.DataRow("项数") < = 0 Or e.DataRow("项数") > 50 Then

                   e.DataRow("项数") = 0

                   e.DataRow("主页") = 0

                   e.DataRow("续页") = 0                                

                    drc("主页") = 0

                    drc("续页") = 0

                    MessageBox.Show("超过准许的项数")

                ElseIf e.DataRow("项数") >= 1 And e.DataRow("项数") <= 5  And e.DataRow("客户类别") = "甲"Then

                    e.DataRow("主页") = 1

                    e.DataRow("续页") = 0

                    ......



写不下去了......




此主题相关图片如下:11111.jpg
按此在新窗口浏览图片







[此贴子已经被作者于2020/5/15 1:55:28编辑过]

--  作者:有点蓝
--  发布时间:2020/5/15 8:25:00
--  
请上传实例测试