Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Protected Sub LoadCarbonFootprint()
- Dim data As New DataCarbonFootprint
- Dim ProdName As String = ""
- Dim ProdNameStored As String = ""
- Dim newDt As New DataTable
- newDt.Columns.Add("ProdName", GetType(String))
- newDt.Columns.Add("DisplayName", GetType(String))
- newDt.Columns.Add("ValidityYear", GetType(Integer))
- newDt.Columns.Add("Toe1", GetType(Decimal))
- newDt.Columns.Add("Toe2", GetType(Decimal))
- newDt.Columns.Add("Toe3", GetType(Decimal))
- newDt.Columns.Add("Toe4", GetType(Decimal))
- newDt.Columns.Add("Toe5", GetType(Decimal))
- newDt.Columns.Add("Toe6", GetType(Decimal))
- newDt.Columns.Add("Toe7", GetType(Decimal))
- newDt.Columns.Add("Toe8", GetType(Decimal))
- newDt.Columns.Add("Toe9", GetType(Decimal))
- newDt.Columns.Add("Toe10", GetType(Decimal))
- For Each prodrow As DataRow In productList
- //hämtar en rad från databawsen med ProdName, MIll, Year och 10 decimalvärden
- Dim dt As DataTable = data.CalculateCarbonFootprint(prodrow("productno"), prodrow("DelSupNo"), theYear.Year, 1, userId).Tables(0)
- //lägger in det i mina nya tabell
- If dt.Rows.Count > 0 Then
- newDt.ImportRow(dt.Rows(0))
- End If
- Next
- //här är det jag funderar över. Även om ingen data finns, ska namnet samt mill visas för kund. Utan värden. Hur många rader ska ska vara kan jag se i min productList, där hitar jag även vilken produkt det är. Nedan jämför jag om de är lika stora, och om den produkten med det bruket (mill/displayname) finns i newdt, då gör jag inget, annat lägger jag in namn, bruk, år och tomma värden.
- If productList.Count <> newDt.Rows.Count Then
- Dim exist As Boolean
- For Each prodrow As DataRow In productList
- ProdName = data.GetProdNameOnProdNo(prodrow("productno"), userId)
- For Each row As DataRow In newDt.Rows
- If row("ProdName").Trim = ProdName.Trim And prodrow("displayname").Trim = row("displayname").Trim Then
- exist = True
- End If
- Next
- If Not exist Then
- newDt.Rows.Add(ProdName, prodrow("displayname"), theYear.Year, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing)
- End If
- Next
- End If
- 'TG 2018-01-18 select distinct
- Dim results As DataTable = newDt.AsEnumerable().Distinct().CopyToDataTable()
- For Each row As DataRow In results.Rows
- Dim info As ProductInfo = New ProductInfo(CStr(row("ProdName")).Trim, row("displayname"), row)
- products.Add(info)
- Next
- End Sub
- Public Class ProductInfo
- Public ProductName As String
- Public MillName As String
- Public CarbonTable As New DataTable
- Public Sub New(ByVal bajs1 As String, ByVal bajs2 As String, ByVal dtRow As DataRow)
- ProductName = bajs1
- MillName = bajs2
- CarbonTable = addDatarow(dtRow)
- End Sub
- Public Function addDatarow(ByVal row As DataRow) As DataTable
- CarbonTable.ImportRow(row)
- Return CarbonTable
- End Function
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement