Public Function SecondFloor() As List(Of List(Of bDatafield))
Dim result As New List(Of List(Of bDatafield))
For Aisle As Short = 1 To MaxAisle
For Column As Short = 1 To MaxColumn
If Not SecondFloorExceptions(Aisle, Column) Then
For shelf As Short = 1 To MaxShelf
For Position As Short = 1 To MaxPositions
Dim Location As New List(Of bDatafield)
Location.Add(MakeNewField("Floor", Floor2))
Location.Add(MakeNewField("Aisle", Aisle.ToString))
Location.Add(MakeNewField("Column", Column.ToString))
Location.Add(MakeNewField("Shelf", shelf.ToString))
Location.Add(MakeNewField("Position", Position.ToString))
result.Add(Location)
Next
Next
End If
Next
Next
Return result
End Function
Public Function MakeNewField(ByVal column As String, ByVal value As String) As bDatafield
MakeNewField = New bDatafield(column, New Nullable(Of Integer))
MakeNewField.SqlColumnTransformer = New TransformField(AddressOf MapSqlColumn)
MakeNewField.Value = value
End Function
Public Function SecondFloorExceptions(ByVal Aisle As Short, ByVal column As Short) As Boolean
If column > MinAisleLength Then
ElseIf column > MaxColumn Then
SecondFloorExceptions = True
Else
Select Case Aisle
Case 2 ''//Items with 39
If column > 39 Then SecondFloorExceptions = True
Case 3 To 10, 26 To 30, 32 To 38 ''//Items with 41
If column > 41 Then SecondFloorExceptions = True
Case 11 ''//Items with 32
If column > 32 Then SecondFloorExceptions = True
Case 12, 13 ''//Items with 38
If column > 38 Then SecondFloorExceptions = True
Case 14 To 24 ''//Items with 36
If column > 36 Then SecondFloorExceptions = True
Case 25, 31 ''//Item with 35
If column > 35 Then SecondFloorExceptions = True
End Select
End If
End Function
然后我将它转储到数据库中:
Public Sub InsertLocationRow(ByVal cn As bInheritance.bCnNativeMs _
, ByVal data As List(Of bDatafield))
Dim leftSide As String = "insert into " + My.Settings.ProjectSchema + "." + My.Settings.tblLocations + "("
Dim rightSide As String = " values ("
Dim first As Boolean = True
For index As Integer = 0 To data.Count - 1
If data(index).isValid Then
If Not first Then
leftSide += ","
rightSide += ","
End If
leftSide += data(index).SqlColumn()
rightSide += BLib.AddQSafe(data(index).Value, True)
first = False
End If
Next
leftSide += ")"
rightSide += ")"
cn.ExeNonQuery(leftSide + rightSide)
End Sub