Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共11 条记录, 每页显示 10 条, 页签: [1] [2]
[浏览完整版]

标题:[求助]条件判断

1楼
苏州老街 发表于:2025/3/20 6:45:00
老师好,我想在下面再增加一个判断条件(房屋主体),房屋主体下有: 
                                                                            一号楼
                                                                            二号楼
                                                                            三号楼


If e.DataCol.Name = "项目" Then
    If e.DataCol.Name = "项目" OrElse  e.DataCol.Name ="抄表日期" Then
        Dim dr1 As DataRow = e.DataTable.Find("项目='" & e.NewValue & "' and 抄表日期 is not null and _sortkey <" & e.DataRow("_sortkey"), "_sortkey desc")
        Dim sl As Double
        Dim st As Decimal=0
        If dr1 IsNot Nothing Then
            sl = dr1("总表_本期读数")
            st  = dr1("_sortkey")
            e.DataRow("总表_上期读数") = sl
        End If
        Dim dr2 As DataRow = e.DataTable.find("项目='" & e.NewValue & "' and 购气_数量 is not null and _sortkey <" & e.DataRow("_sortkey") & " and _sortkey > " & st, "_sortkey desc")
        If dr2 IsNot Nothing Then
            e.DataRow("总表_上期读数") = sl + dr2("购气_数量")
        End If
    End If
End If
2楼
有点蓝 发表于:2025/3/20 9:42:00
http://www.foxtable.com/webhelp/topics/1284.htm
3楼
苏州老街 发表于:2025/3/20 19:35:00
老师好,我新增一列名称为(房屋主体)如果该列字段是(二号楼)就复制本期读数,如果不是就不复制。谢谢老师!
If e.DataCol.Name = "项目" Then
    If e.DataCol.Name = "项目" OrElse  e.DataCol.Name ="抄表日期" Then
        Dim dr1 As DataRow = e.DataTable.Find("项目='" & e.NewValue & "' and 抄表日期 is not null and _sortkey <" & e.DataRow("_sortkey"), "_sortkey desc")
        Dim sl As Double
        Dim st As Decimal=0
        If dr1 IsNot Nothing Then
            sl = dr1("总表_本期读数")
            st  = dr1("_sortkey")
            e.DataRow("总表_上期读数") = sl
        End If
        Dim dr2 As DataRow = e.DataTable.find("项目='" & e.NewValue & "' and 购气_数量 is not null and _sortkey <" & e.DataRow("_sortkey") & " and _sortkey > " & st, "_sortkey desc")
        If dr2 IsNot Nothing Then
            e.DataRow("总表_上期读数") = sl + dr2("购气_数量")
        End If
    End If
End If
4楼
有点蓝 发表于:2025/3/20 20:01:00
If e.DataRow("房屋主体") = "二号楼" Then
    If e.DataCol.Name = "项目" OrElse  e.DataCol.Name ="抄表日期" Then
        Dim dr1 As DataRow = e.DataTable.Find("项目='" & e.DataRow("项目") & "' and 抄表日期 is not null and _sortkey <" & e.DataRow("_sortkey"), "_sortkey desc")
……
5楼
苏州老街 发表于:2025/3/20 20:24:00
老师,上面代码不能复制
6楼
有点蓝 发表于:2025/3/20 21:31:00
可以复制粘贴呀
7楼
苏州老街 发表于:2025/3/21 10:53:00
老师好


图片点击可在新窗口打开查看此主题相关图片如下:2025-03-17 12 19 54.png
图片点击可在新窗口打开查看



If e.DataRow("房屋主体") = "一号楼" Then
    If e.DataCol.Name = "项目" OrElse  e.DataCol.Name ="抄表日期" Then
        Dim dr1 As DataRow = e.DataTable.Find("项目='" & e.DataRow("项目") & "' and 抄表日期 is not null and _sortkey <" & e.DataRow("_sortkey"), "_sortkey desc")
        
        
        Dim sl As Double
        Dim st As Decimal=0
        If dr1 IsNot Nothing Then
            sl = dr1("总表_本期读数")
            st  = dr1("_sortkey")
            e.DataRow("总表_上期读数") = sl
        End If
        Dim dr2 As DataRow = e.DataTable.find("项目='" & e.NewValue & "' and 购气_数量 is not null and _sortkey <" & e.DataRow("_sortkey") & " and _sortkey > " & st, "_sortkey desc")
        If dr2 IsNot Nothing Then
            e.DataRow("总表_上期读数") = sl + dr2("购气_数量")
        End If
    End If
End If
8楼
有点蓝 发表于:2025/3/21 10:54:00
把房屋主体添加到查询条件里
9楼
苏州老街 发表于:2025/3/21 15:29:00
老师,添加不好,谢谢老师帮忙。

Dim dr1 As DataRow = e.DataTable.Find("项目='" & e.DataRow("项目") & "' and 抄表日期 is not null and _sortkey <" & e.DataRow("_sortkey"), "_sortkey desc")
        
10楼
有点蓝 发表于:2025/3/21 15:45:00
添加了什么东西?添加后的代码发上来看看
共11 条记录, 每页显示 10 条, 页签: [1] [2]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .02539 s, 2 queries.