2014-04-04 123 views
0

我改變了上面使用字符串生成器,但由於某種原因,它不是通過對循環其確定返回通過OrdersLine變量,但不爲stream正在添加。下面是循環IM宣佈它函數返回的信息

Dim OrdersLine As String 


    For Each item As String In split 



     For Each thisEntry As DataRow In orderHeaderInformation.Rows 
      orderLineInformation = connection.SqlSelectToDataTable(scriptBuilder.GetOrderLineInformation(item, thisEntry.Item("location"))) 
      Dim orderNumber = From row In newEntries.AsEnumerable() 
      Select row.Field(Of String)("ordernumber") Distinct 
      For Each c In IO.Path.GetInvalidFileNameChars 
       filename = thisEntry.Item("orderNumber").ToString().Replace(c, "") 
      Next 
      ediExportPath = configuration.EditExport 

      filename = ediExportPath & "\" & filename & "_" & thisEntry.Item("location") & ".edi" 
      Dim streamWriter As New IO.StreamWriter(filename) 
      OrdersLine = ExportOrdersLine(orderLineInformation).ToString() 
      streamWriter.WriteLine(OrdersLine) 


      streamWriter.Close() 
      streamWriter.Dispose() 

     Next 

    Next 


Public Function ExportOrdersLine(editProductLine As DataTable) As String 
    Dim retVal As String 

    Dim newRecord As infoEDILine 
    Dim filenameWithoutExtensions As String 

    Dim i As Integer = 1 

    Dim edilIneOrder As New StringBuilder 

    For Each thisentry In editProductLine.Rows 
     edilIneOrder.AppendLine("LIN+" & i & thisentry.Item("TagBcode") & ":EN'") 
     edilIneOrder.AppendLine("PIA+1" & thisentry.Item("PLU") & ":SA'") 
     edilIneOrder.AppendLine("IMD+C++CU'") 
     edilIneOrder.AppendLine("IMD+F++:::" & thisentry.Item("Style.Description") & "'") 
     edilIneOrder.AppendLine("QTY+" & thisentry.Item("PLU") & ":1'") 
     edilIneOrder.AppendLine("QTY+" & thisentry.Item("OnOrder") & ":1'") 
     edilIneOrder.AppendLine("TAX+7+VAT+++:::00" & thisentry.item("VatRate") & "'") 
     ' if the vat rate is zero add three zeros to above line 
     ' if the vat rate is not zero add only two 00 lke above line 
     ' if no decimal places add one decimal place of zero 

     edilIneOrder.AppendLine("MOA+203:" & thisentry.item("LineNetCost") & "'") 
     edilIneOrder.AppendLine("PRI++AAA:" & thisentry.Item("GrossCost") & "'") 
     edilIneOrder.AppendLine("PRI++AAB:" & thisentry.Item("WholeSaleCost") & "'") 
     edilIneOrder.AppendLine("UNS+S'") 

     i = i + 1 

    Next 


    Return edilIneOrder.ToString() 

End Function 
+0

究竟你「空行」是什麼意思?你真的調試過代碼嗎?放在第一行設置一個斷點,然後通過它逐行與'retVal'手錶步驟。 – jmcilhinney

+0

調試時,你在你的循環弦看到添加到retVal的?你有明確規定,嚴格規定嗎?如果是,就不要這樣做。如果你寫C#上面不會編譯:) –

+0

@kostasch。請看看編輯是的,我有 – rogue39nin

回答

0

原來我失蹤

  streamWriter.AutoFlush = True