-
-
Save kewang/e3de08d7728cbb4c053da0ab35e27e47 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function bin_emissions(ByVal gasID As Integer) As Data.DataTable | |
Dim liEmissions As List(Of Pollute.GHG.Info.Gas.Emissions) = sysLogic.GetEmissionsList(gasID) | |
Dim dt As New Data.DataTable | |
dt.Columns.Add("years") | |
dt.Columns.Add("cow") | |
dt.Columns.Add("otherCow") | |
dt.Columns.Add("buffalo") | |
dt.Columns.Add("goat") | |
dt.Columns.Add("pig") | |
dt.Columns.Add("whiteBroiler") | |
dt.Columns.Add("colorBroiler") | |
dt.Columns.Add("eggBroiler") | |
dt.Columns.Add("goose") | |
dt.Columns.Add("duck") | |
dt.Columns.Add("count") | |
Dim yearfirst As Integer = 10000 | |
Dim yearlast As Integer = -1 | |
Dim hasCow As Boolean = False | |
Dim hasOtherCow As Boolean = False | |
Dim hasBuffalo As Boolean = False | |
Dim hasGoat As Boolean = False | |
For Each emissions In liEmissions | |
If emissions.year > yearlast Then | |
yearlast = emissions.year | |
End If | |
If emissions.year < yearfirst Then | |
yearfirst = emissions.year | |
End If | |
Next | |
For i = yearlast To yearfirst Step -1 | |
Dim newRow As Data.DataRow = dt.NewRow | |
Dim total As Decimal = 0 | |
For Each emissions In liEmissions | |
If emissions.year = i Then | |
newRow("years") = i | |
If emissions.animalID = Pollute.GHG.Info.AnimalType.產乳牛 Then | |
hasCow = True | |
newRow("cow") = Format(emissions.emission, "0.00") | |
total += emissions.emission | |
ElseIf emissions.animalID = Pollute.GHG.Info.AnimalType.其他牛 Then | |
hasOtherCow = True | |
newRow("otherCow") = Format(emissions.emission, "0.00") | |
total += emissions.emission | |
ElseIf emissions.animalID = Pollute.GHG.Info.AnimalType.水牛 Then | |
hasBuffalo = True | |
newRow("buffalo") = Format(emissions.emission, "0.00") | |
total += emissions.emission | |
ElseIf emissions.animalID = Pollute.GHG.Info.AnimalType.山羊 Then | |
hasGoat = True | |
newRow("goat") = Format(emissions.emission, "0.00") | |
total += emissions.emission | |
ElseIf emissions.animalID = Pollute.GHG.Info.AnimalType.猪 Then | |
newRow("pig") = Format(emissions.emission, "0.00") | |
total += emissions.emission | |
ElseIf emissions.animalID = Pollute.GHG.Info.AnimalType.白色肉雞 Then | |
newRow("whiteBroiler") = Format(emissions.emission, "0.00") | |
total += emissions.emission | |
ElseIf emissions.animalID = Pollute.GHG.Info.AnimalType.有色肉雞 Then | |
newRow("colorBroiler") = Format(emissions.emission, "0.00") | |
total += emissions.emission | |
ElseIf emissions.animalID = Pollute.GHG.Info.AnimalType.蛋雞 Then | |
newRow("eggBroiler") = Format(emissions.emission, "0.00") | |
total += emissions.emission | |
ElseIf emissions.animalID = Pollute.GHG.Info.AnimalType.鵝 Then | |
newRow("goose") = Format(emissions.emission, "0.00") | |
total += emissions.emission | |
ElseIf emissions.animalID = Pollute.GHG.Info.AnimalType.肉鴨 Then | |
newRow("duck") = Format(emissions.emission, "0.00") | |
total += emissions.emission | |
End If | |
newRow("count") = total | |
End If | |
Next | |
dt.Rows.Add(newRow) | |
Next | |
If hasCow = False Then | |
For Each col in gridview.columns | |
If col.HeaderText = "牛" Then | |
col.Visible = False | |
End If | |
Next | |
End If | |
If hasOtherCow = False Then | |
dt.Columns.Remove("othercow") | |
End If | |
If hasBuffalo = False Then | |
dt.Columns.Remove("buffalo") | |
End If | |
If hasGoat = False Then | |
dt.Columns.Remove("goat") | |
End If | |
Return dt | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Visible=<%# If(Eval("Status") = 0, "False", "True") %>