Foxtable(狐表)用户栏目专家坐堂 → [求助]


  共有4357人关注过本帖树形打印复制链接

主题:[求助]

帅哥哟,离线,有人找我吗?
大红袍
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/6/28 9:36:00 [显示全部帖子]

 无语,你根据就没写代码。

 

 AfterSelectNode事件

 

Dim s As String = e.Form.Controls("CheckedComboBox筛选树").Text
Dim Colstr() As String
Dim qts As String() = {"'","#",""}
Dim trv As WinForm.TreeView = e.Sender
Dim flt As String = ""
Dim nd As WinForm.TreeNode
Dim pd As WinForm.TreeNode
Dim notchecked As Integer = 0
Colstr = s.split("|")
nd = e.Node
If nd.Name = "显示所有行" Then
    flt = ""
Else
    Dim rts() As String = nd.FullPath.Split("\")
    Dim val As String = ""
    For i As Integer = 0 To rts.length - 1
        If e.Form.Controls("Tbl_Main").Table.DataTable.DataCols(Colstr(i)).IsString Then
            If rts(i) <> "空" Then
                If val > "" Then
                    val = val & " And "
                    val = val & Colstr(i) & " = " & qts(0) & rts(i) & qts(0)
                Else
                    val = val & Colstr(i) & " = " & qts(0) & rts(i) & qts(0)
                End If
            ElseIf rts(i) = "空" Then
                If val > "" Then
                    val = val & " And "
                    val = val & Colstr(i) & " Is Null"
                Else
                    val = val & Colstr(i) & " Is Null"
                End If
            End If
        ElseIf e.Form.Controls("Tbl_Main").Table.DataTable.DataCols(Colstr(i)).IsDate Then
            If rts(i) <> #0001-1-1 0:00:00# Then
                If val > "" Then
                    val = val & " And "
                    val = val & Colstr(i) & " = " & qts(1) & rts(i) & qts(1)
                Else
                    val = val & Colstr(i) & " = " & qts(1) & rts(i) & qts(1)
                End If
            ElseIf rts(i) = #0001-1-1 0:00:00# Then
                If val > "" Then
                    val = val & " And "
                    val = val & Colstr(i) & " Is Null"
                Else
                    val = val & Colstr(i) & " Is Null"
                End If
            End If
        ElseIf e.Form.Controls("Tbl_Main").Table.DataTable.DataCols(Colstr(i)).IsNumeric Then
            If rts(i) <> 0 Then
                If val > "" Then
                    val = val & " And "
                    val = val & Colstr(i) & " = " & qts(2) & rts(i) & qts(2)
                Else
                    val = val & Colstr(i) & " = " & qts(2) & rts(i) & qts(2)
                End If
            ElseIf rts(i) = 0 Then
                If val > "" Then
                    val = val & " And "
                    val = val & Colstr(i) & " Is Null"
                Else
                    val = val & Colstr(i) & " Is Null"
                End If
            End If
        ElseIf e.Form.Controls("Tbl_Main").Table.DataTable.DataCols(Colstr(i)).IsBoolean Then
            If rts(i) <> False Then
                If val > "" Then
                    val = val & " And "
                    val = val & Colstr(i) & " = " & qts(0) & True & qts(0)
                Else
                    val = val & Colstr(i) & " = " & qts(0) & True & qts(0)
                End If
            ElseIf rts(i) = False Then
                If val > "" Then
                    val = val & " And "
                    val = val & Colstr(i) & " = " & qts(0) & False & qts(0)
                Else
                    val = val & Colstr(i) & " = " & qts(0) & False & qts(0)
                End If
            End If
        End If
    Next
    If flt > "" Then
        flt = flt & " Or (" & val & ")"
    Else
        flt = val
    End If
End If


e.Form.Controls("Tbl_Main").Table.Filter = flt


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/6/28 15:50:00 [显示全部帖子]

 你要说什么窗口,什么表,什么列不保存啊

 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/6/28 16:01:00 [显示全部帖子]


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/6/28 17:57:00 [显示全部帖子]

呃....哪个窗口,什么操作后,代码不执行?


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/6/28 18:15:00 [显示全部帖子]

 不明白你的意思,我测试没什么问题。

 

 怎么操作,怎样的现象?


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/6/29 9:30:00 [显示全部帖子]

 回复14楼,没测试出你的问题;

 

 回复15楼,DataRowAdded事件加入代码

 

If Tables("股piao.股piao明细").Current IsNot Nothing Then
    Tables("股piao.股piao明细").Select(Tables("股piao.股piao明细").Current.Index, 0)
End If

 

 回复16楼,有计算,没有你说的问题。


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/6/29 11:20:00 [显示全部帖子]

Select Case e.DataCol.Name
    Case "股piao名称","买入量","卖出量"

        Dim dr As DataRow
        Dim mr As DataRow = e.DataRow
        Dim drs As List(of DataRow)
        dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [股piao名称] = '" & mr("股piao名称") & "'", "[_SortKey] Desc")
        If dr Is Nothing Then
            mr("仓储") = mr("买入量") - mr("卖出量")
            dr = mr
        Else
            mr("仓储") = dr("仓储")
        End If

        drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [股piao名称] = '" & dr("股piao名称") & "'", "[_SortKey]")
        For i As Integer = 1 To drs.Count - 1

            drs(i)("仓储") = drs(i-1)("仓储") + drs(i)("买入量") - drs(i)("卖出量")
        Next
        If e.DataCol.Name = "股piao名称" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then

            dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [股piao名称] = '" & e.OldValue & "'", "[_SortKey] Desc")
            If dr Is Nothing Then
                dr = e.DataTable.Find("[股piao名称] = '" & e.OldValue & "'", "[_SortKey]")
                If dr IsNot Nothing Then
                    dr("仓储") = dr("买入量") - dr("卖出量")
                End If
            End If
            If dr IsNot Nothing Then
                drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [股piao名称] = '" & dr("股piao名称") & "'", "[_SortKey]")
                For i As Integer = 1 To drs.Count - 1
                    drs(i)("仓储") = drs(i-1)("仓储") + drs(i)("买入量") - drs(i)("卖出量")
                Next
            End If
        End If
End Select


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/6/29 14:17:00 [显示全部帖子]

Select Case e.DataCol.name
    Case "股piao名称"
        e.DataRow("买入均价")=e.DataTable.Compute("sum(买入价)","股piao名称='" & e.DataRow("股piao名称") & "' and 买入价 is not null") / e.DataTable.Compute("Count(买入价)","股piao名称='" & e.DataRow("股piao名称") & "' and 买入价 is not null")
        e.DataRow("卖出均价")=e.DataTable.Compute("sum(卖出价)","股piao名称='" & e.DataRow("股piao名称") & "' and 卖出价 is not null") / e.DataTable.Compute("Count(卖出价)","股piao名称='" & e.DataRow("股piao名称") & "' and 卖出价 is not null")
    Case "买入价","买入量"
        e.DataRow("买入均价")=e.DataTable.Compute("sum(买入价)","股piao名称='" & e.DataRow("股piao名称") & "' and 买入价 is not null") / e.DataTable.Compute("Count(买入价)","股piao名称='" & e.DataRow("股piao名称") & "' and 买入价 is not null")
    Case "卖出价","卖出量"
        e.DataRow("卖出均价")=e.DataTable.Compute("sum(卖出价)","股piao名称='" & e.DataRow("股piao名称") & "' and 卖出价 is not null") / e.DataTable.Compute("Count(卖出价)","股piao名称='" & e.DataRow("股piao名称") & "' and 卖出价 is not null")
End Select

 


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  9楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/6/29 20:32:00 [显示全部帖子]

Case "买入价","买入量"
        Dim filter As String = "股piao名称='" & e.DataRow("股piao名称") & "'"
        Dim sum1 As Double = 0
        Dim sum2 As Double = 0
        Dim count1 As Double = 0
        Dim count2 As Double = 0
        For Each dr As DataRow In e.DataTable.Select(filter, "_sortkey")
            sum1 += dr("买入价") * dr("买入量")
            sum2 += dr("卖出价") * dr("卖出量")
            count1 += dr("买入量")
            count2 += dr("卖出量")
            e.DataRow("买入均价") = (sum1-sum2) / (count1-count2)
        Next

 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  10楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/6/29 20:54:00 [显示全部帖子]

替换21楼的代码啊。


 回到顶部
总数 17 1 2 下一页