Option Strict Off
Option Explicit On
Imports System.Linq
Imports System.Collections.Generic
Namespace FMSTest
   Public Module utils
   Public Const gLogFile As String = "FMSTest.log"
   Public Function reportRecordSet(ByVal rs As gmRTL.DataLib.SqlClient.Recordset) As String
      reportRecordSet = ""
      If (rs Is Nothing) Then
         reportRecordSet = "RS IS NOTHING"
         Exit Function
      End If
      Dim rpt As String = ""
      Dim r As Integer = 0
      Const rptstr As String = "%fld%[%r%]=%v%" '& vbCrLf
      r = 1

      rs.MoveFirst()
      Do While Not rs.EOF
         For Each fld As gmRTL.DataLib.SqlClient.Field In rs.Fields
            rpt = rpt & rptstr & Environment.NewLine
            rpt = Strings.Replace(rpt,"%fld%",fld.Name)
            rpt = Strings.Replace(rpt,"%r%",r)
            If (fld.ProviderDbType = System.Data.SqlDbType.Bit) Then
               rpt = Strings.Replace(rpt,"%v%",IIf(fld.Value,"True","False"))
            ElseIf (gmRTL.Core.InformationHelper.IsNumeric(fld.Value)) Then
               rpt = Strings.Replace(rpt,"%v%",gmRTL.Core.FormatHelper.Format(fld.Value,"0.00"))
            Else
               rpt = Strings.Replace(rpt,"%v%",fld.Value)
            End If
         Next
         r = r + 1
         rs.MoveNext()
      Loop
      reportRecordSet = rpt
   End Function
   Public Sub Main(args As string())
      If (FileSystem.Dir(gLogFile,FileAttribute.Normal) <> "") Then
         FileSystem.Kill(gLogFile)
      End If

      If (Interaction.Command() = "/batch") Then
         frmFMSTest.DefInstance.cmdTest_Click(Nothing,New EventArgs())
         Environment.Exit(0)
      Else
         System.Windows.Forms.Application.Run(frmFMSTest.DefInstance)
      End If

   End Sub
   End Module
End Namespace
