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