Foxtable(狐表)用户栏目专家坐堂 → 什么鬼,下面的代码在全局表事件中,菜单不能切换


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

主题:什么鬼,下面的代码在全局表事件中,菜单不能切换

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


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

Dim r As Row
Vars("fzToTal") = new List(Of String)
Vars("fzToTal").add("第三列")
Vars("fzToTal").add("第二列")
Dim sum(Vars("fzToTal").Count-1) As Double

If e.Row(e.Table.Cols(0).name) = "合计" Then
    e.Style = "abc"
   
    For i As Integer = 0 To sum.length - 1
        Dim  d1 As Double
        Dim flag As Integer = 0
        For n As Integer = 0 To e.Row.Index -1
            r = e.Table.Rows(n)
           
            If Double.TryParse(r(Vars("fzToTal")(i)).replace("%", ""),d1) Then
                If cstr(r(Vars("fzToTal")(i))).contains("%") Then
                    flag = 1
                    sum(i) += val(d1)/100
                Else
                    sum(i) += val(d1)
                End If
               
            End If
        Next
       
        If flag = 0 Then
            If Format(val(sum(i)),"n") <> 0 And Format(val(sum(i)),"n") <> "0" And Format(val(sum(i)),"n") IsNot Nothing  Then
                e.Row(Vars("fzToTal")(i)) = Format(val(sum(i)),"n")
            Else
                e.Row(Vars("fzToTal")(i)) = Nothing
            End If
        Else
            If flag = 1 Then
                If Format(val(sum(i)),"n") <> 0 And Format(val(sum(i)),"n") <> "0" And Format(val(sum(i)),"n") IsNot Nothing  Then
                    e.Row(Vars("fzToTal")(i)) = Format(sum(i),"Percent")
                Else
                    e.Row(Vars("fzToTal")(i)) = Nothing
                End If
            End If
        End If
    Next
End If


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


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

要改东西太多,做个简单例子上来吧。

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


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

上传项目测试啊。

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


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

Dim r As Row
Vars("fzToTal") = new List(Of String)
Vars("fzToTal").add("数量")
Vars("fzToTal").add("金额")
Vars("fzToTal").add("比率")
Dim sum(Vars("fzToTal").Count-1) As Double
e.Table.DataTable.AddUserStyle("abc", Color.yellow, Color.Black)
Dim cs1 As C1.Win.C1FlexGrid.CellStyle = e.Table.grid.Styles.Add("cs1")
cs1.TextAlign = 7
Dim cs2 As C1.Win.C1FlexGrid.CellStyle = e.Table.grid.Styles.Add("cs2")
cs2.TextAlign = 1

Dim d As Double
If Double.TryParse(e.Text.replace("%", ""),d) Then
    If e.Table.Grid.GetCellRange(e.Row.Index+1, e.Col.Index+1).style.name <> cs1.name Then
        e.Table.grid.SetCellStyle(e.Row.Index+1, e.Col.Index+1, cs1)
    End If
Else
    If e.Table.Grid.GetCellRange(e.Row.Index+1, e.Col.Index+1).style.name <> cs2.name Then
        e.Table.grid.SetCellStyle(e.Row.Index+1, e.Col.Index+1, cs2)
    End If
End If

If e.Row(e.Table.Cols(0).name) = "合计" Then
    e.Style = "abc"
   
    For i As Integer = 0 To sum.length - 1
        Dim  d1 As Double
        Dim flag As Integer = 0
        For n As Integer = 0 To e.Row.Index -1
            r = e.Table.Rows(n)
           
            If Double.TryParse(r(Vars("fzToTal")(i)).replace("%", ""),d1) Then
                If cstr(r(Vars("fzToTal")(i))).contains("%") Then
                    flag = 1
                    sum(i) += val(d1)/100
                Else
                    sum(i) += val(d1)
                End If
               
            End If
        Next
       
        If flag = 0 Then
            If Format(val(sum(i)),"n") <> 0 And Format(val(sum(i)),"n") <> "0" And Format(val(sum(i)),"n") IsNot Nothing  Then
                e.Row(Vars("fzToTal")(i)) = Format(val(sum(i)),"n")
            Else
                e.Row(Vars("fzToTal")(i)) = Nothing
            End If
        Else
            If flag = 1 Then
                If Format(val(sum(i)),"n") <> 0 And Format(val(sum(i)),"n") <> "0" And Format(val(sum(i)),"n") IsNot Nothing  Then
                    e.Row(Vars("fzToTal")(i)) = Format(sum(i),"Percent")
                Else
                    e.Row(Vars("fzToTal")(i)) = Nothing
                End If
            End If
        End If
    Next
End If

If e.Row(e.Table.Cols(0).name) = "差异" Then
   
    Dim r1 As Row = e.Table.Rows(e.Row.Index-1)
    Dim r2 As Row = e.Table.Rows(e.Row.Index-2)
   
    For i As Integer = 0 To sum.length - 1
        Dim cname As String = Vars("fzToTal")(i)
        If cstr(r2(cname)).contains("%") Then
            e.Row(cname) = format(val(r1(cname)) - val(r2(cname).Replace("%", "")) / 100,"Percent")
        Else
            e.Row(cname) = Format(val(r1(cname)) - val(r2(cname).Replace(",", "")), "n")
           
        End If
    Next
   
End If


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


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

Dim r As Row
Vars("fzToTal") = new List(Of String)
Vars("fzToTal").add("数量")
Vars("fzToTal").add("金额")
Vars("fzToTal").add("比率")
Dim sum(Vars("fzToTal").Count-1) As Double
e.Table.DataTable.AddUserStyle("abc", Color.yellow, Color.Black)
Dim cs1 As C1.Win.C1FlexGrid.CellStyle = e.Table.grid.Styles.Add("cs1")
cs1.TextAlign = 7
Dim cs2 As C1.Win.C1FlexGrid.CellStyle = e.Table.grid.Styles.Add("cs2")
cs2.TextAlign = 1

Dim d As Double
If Double.TryParse(e.Text.replace("%", ""),d) Then
    Dim cell = e.Table.Grid.GetCellRange(e.Row.Index+1, e.Col.Index+1).style
   
    If cell IsNot Nothing
        If cell.name <> cs1.name Then
            e.Table.grid.SetCellStyle(e.Row.Index+1, e.Col.Index+1, cs1)
           
        ElseIf cell.name <> cs2.name Then
            e.Table.grid.SetCellStyle(e.Row.Index+1, e.Col.Index+1, cs2)
        End If
    End If
End If

If e.Row(e.Table.Cols(0).name) = "合计" Then
    e.Style = "abc"
   
    For i As Integer = 0 To sum.length - 1
        Dim  d1 As Double
        Dim flag As Integer = 0
        For n As Integer = 0 To e.Row.Index -1
            r = e.Table.Rows(n)
           
            If Double.TryParse(r(Vars("fzToTal")(i)).replace("%", ""),d1) Then
                If cstr(r(Vars("fzToTal")(i))).contains("%") Then
                    flag = 1
                    sum(i) += val(d1)/100
                Else
                    sum(i) += val(d1)
                End If
               
            End If
        Next
       
        If flag = 0 Then
            If Format(val(sum(i)),"n") <> 0 And Format(val(sum(i)),"n") <> "0" And Format(val(sum(i)),"n") IsNot Nothing  Then
                e.Row(Vars("fzToTal")(i)) = Format(val(sum(i)),"n")
            Else
                e.Row(Vars("fzToTal")(i)) = Nothing
            End If
        Else
            If flag = 1 Then
                If Format(val(sum(i)),"n") <> 0 And Format(val(sum(i)),"n") <> "0" And Format(val(sum(i)),"n") IsNot Nothing  Then
                    e.Row(Vars("fzToTal")(i)) = Format(sum(i),"Percent")
                Else
                    e.Row(Vars("fzToTal")(i)) = Nothing
                End If
            End If
        End If
    Next
End If

If e.Row(e.Table.Cols(0).name) = "差异" Then
   
    Dim r1 As Row = e.Table.Rows(e.Row.Index-1)
    Dim r2 As Row = e.Table.Rows(e.Row.Index-2)
   
    For i As Integer = 0 To sum.length - 1
        Dim cname As String = Vars("fzToTal")(i)
        If cstr(r2(cname)).contains("%") Then
            e.Row(cname) = format(val(r1(cname)) - val(r2(cname).Replace("%", "")) / 100,"Percent")
        Else
            e.Row(cname) = Format(val(r1(cname)) - val(r2(cname).Replace(",", "")), "n")
           
        End If
    Next
   
End If


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


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

Dim r As Row
Vars("fzToTal") = new List(Of String)
Vars("fzToTal").add("数量")
Vars("fzToTal").add("金额")
Vars("fzToTal").add("比率")
Dim sum(Vars("fzToTal").Count-1) As Double
e.Table.DataTable.AddUserStyle("abc", Color.yellow, Color.Black)
Dim cs1 As C1.Win.C1FlexGrid.CellStyle = e.Table.grid.Styles.Add("cs1")
cs1.TextAlign = 7
Dim cs2 As C1.Win.C1FlexGrid.CellStyle = e.Table.grid.Styles.Add("cs2")
cs2.TextAlign = 1

Dim d As Double

Dim cell = e.Table.Grid.GetCellRange(e.Row.Index+1, e.Col.Index+1).style

If Double.TryParse(e.Text.replace("%", ""),d) OrElse Double.TryParse(e.Text.replace(",", ""),d) Then
    If e.text.contains("%") = False Then
        e.text = Format(d, "n")
    End If
    If cell IsNot Nothing
        If cell.name <> cs1.name Then
            e.Table.grid.SetCellStyle(e.Row.Index+1, e.Col.Index+1, cs1)
        End If
    Else
        e.Table.grid.SetCellStyle(e.Row.Index+1, e.Col.Index+1, cs1)
    End If
Else
    If cell IsNot Nothing
        If cell.name <> cs2.name Then
            e.Table.grid.SetCellStyle(e.Row.Index+1, e.Col.Index+1, cs2)
        End If
    Else
        e.Table.grid.SetCellStyle(e.Row.Index+1, e.Col.Index+1, cs2)
    End If
   
End If

If e.Row(e.Table.Cols(0).name) = "合计" Then
    e.Style = "abc"
   
    For i As Integer = 0 To sum.length - 1
        Dim  d1 As Double
        Dim flag As Integer = 0
        For n As Integer = 0 To e.Row.Index -1
            r = e.Table.Rows(n)
           
            If Double.TryParse(r(Vars("fzToTal")(i)).replace("%", ""),d1) OrElse Double.TryParse(e.Text.replace(",", ""),d) Then
                If cstr(r(Vars("fzToTal")(i))).contains("%") Then
                    flag = 1
                    sum(i) += val(d1)/100
                Else
                    sum(i) += val(d1)
                End If
               
            End If
        Next
       
        If flag = 0 Then
            If Format(val(sum(i)),"n") <> 0 And Format(val(sum(i)),"n") <> "0" And Format(val(sum(i)),"n") IsNot Nothing  Then
                e.Row(Vars("fzToTal")(i)) = Format(val(sum(i)),"n")
            Else
                e.Row(Vars("fzToTal")(i)) = Nothing
            End If
        Else
            If flag = 1 Then
                If Format(val(sum(i)),"n") <> 0 And Format(val(sum(i)),"n") <> "0" And Format(val(sum(i)),"n") IsNot Nothing  Then
                    e.Row(Vars("fzToTal")(i)) = Format(sum(i),"Percent")
                Else
                    e.Row(Vars("fzToTal")(i)) = Nothing
                End If
            End If
        End If
    Next
End If

If e.Row(e.Table.Cols(0).name) = "差异" Then
   
    Dim r1 As Row = e.Table.Rows(e.Row.Index-1)
    Dim r2 As Row = e.Table.Rows(e.Row.Index-2)
   
    For i As Integer = 0 To sum.length - 1
        Dim cname As String = Vars("fzToTal")(i)
        If cstr(r2(cname)).contains("%") Then
            e.Row(cname) = format(val(r1(cname)) - val(r2(cname).Replace("%", "")) / 100,"Percent")
        Else
            e.Row(cname) = Format(val(r1(cname)) - val(r2(cname).Replace(",", "")), "n")
           
        End If
    Next
   
End If


 回到顶部