Namespace Dal Public NotInheritable Class Helpers Private Sub New() End Sub ' Formatear cadenas para sentencias SQL Public Shared Function ParseCadena(ByVal value As String) As String If value Is Nothing OrElse value.Length = 0 Then Return "NULL" Return String.Format("'{0}'", value.Replace("'", "''")) End Function ' Formatear cadenas para sentencias SQL Public Shared Function ParseNulableInteger(ByVal value As String) As String Dim i As Integer If Integer.TryParse(value, i) = False Then Return "NULL" If i = 0 Then Return "NULL" Return i End Function ' Formatear N�meros para sentencias SQL Public Shared Function FormateaNumero(ByVal value As String) As String If value Is Nothing OrElse value.Length = 0 Then Return "NULL" Return Replace(value, ",", ".") End Function ' Formatear Fechas para sentencias SQL Public Shared Function ParseFecha(ByVal value As String) As String If value Is Nothing OrElse value.Length = 0 Then Return "NULL" Try Return Date.Parse(value).ToString("\'yyyyMMdd HH:mm:ss\'") Catch e As Exception Return "NULL" End Try End Function End Class Public Module HexHelper <System.Runtime.CompilerServices.Extension()> _ Public Function ToHexString(ByVal value As Byte()) As String Dim hex As System.Text.StringBuilder = New System.Text.StringBuilder(value.Length * 2) For Each b As Byte In value hex.AppendFormat("{0:x2}", b) Next Return hex.ToString() End Function End Module End Namespace
martes, 16 de diciembre de 2008
Dal.Core.Helper.vb
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario