功能返回信息

时间:2014-04-04 12:54:26

标签: vb.net

我改变了上面的内容以使用字符串构建器,但有些原因是它没有通过循环返回它通过OrdersLine变量返回ok而不是stream。下面是我在

中声明它的循环
    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

1 个答案:

答案 0 :(得分:0)

结果我错过了

            streamWriter.AutoFlush = True