83 lines
2.8 KiB
VB.net
83 lines
2.8 KiB
VB.net
Imports System.Globalization
|
|
Imports DevExpress.CodeParser
|
|
Imports DevExpress.Data.Controls
|
|
Imports DevExpress.XtraPrinting
|
|
|
|
Public Class ClassFormat
|
|
Public Const CURRENCY_FORMAT = "C2"
|
|
Public Const DECIMAL_FORMAT = "F"
|
|
Public Const DATE_FORMAT = "d"
|
|
Public Const DATETIME_FORMAT = "G"
|
|
|
|
Public Shared Function GetFormatString(pFormatString As String) As String
|
|
Select Case pFormatString
|
|
Case ClassControlCreator.CONTROL_TYPE_CURRENCY
|
|
Return CURRENCY_FORMAT
|
|
|
|
Case ClassControlCreator.CONTROL_TYPE_DOUBLE
|
|
Return DECIMAL_FORMAT
|
|
|
|
Case ClassControlCreator.CONTROL_TYPE_DATE
|
|
Return DATE_FORMAT
|
|
|
|
Case ClassControlCreator.CONTROL_TYPE_DATETIME
|
|
Return DATETIME_FORMAT
|
|
|
|
Case Else
|
|
Return String.Empty
|
|
|
|
End Select
|
|
End Function
|
|
|
|
''' <summary>
|
|
''' Converts a string according to the type information, using the invariant culture
|
|
''' </summary>
|
|
''' <param name="pValue"></param>
|
|
''' <param name="pType"></param>
|
|
''' <returns></returns>
|
|
Public Shared Function GetConvertedValue(pValue As Object, pType As String) As Object
|
|
Dim oConvertedValue = pValue
|
|
|
|
Select Case pType
|
|
Case ClassControlCreator.CONTROL_TYPE_DOUBLE
|
|
If Double.TryParse(pValue, NumberStyles.Float, CultureInfo.InvariantCulture, oConvertedValue) Then
|
|
Return oConvertedValue
|
|
End If
|
|
|
|
Case ClassControlCreator.CONTROL_TYPE_CURRENCY
|
|
If Double.TryParse(pValue, NumberStyles.Currency, CultureInfo.InvariantCulture, oConvertedValue) Then
|
|
Return oConvertedValue
|
|
End If
|
|
|
|
Case ClassControlCreator.CONTROL_TYPE_INTEGER
|
|
If Integer.TryParse(pValue, NumberStyles.Integer, CultureInfo.InvariantCulture, oConvertedValue) Then
|
|
Return oConvertedValue
|
|
End If
|
|
End Select
|
|
|
|
Return oConvertedValue
|
|
End Function
|
|
|
|
Public Shared Function GetStringValue(pValue As Object) As String
|
|
Select Case pValue.GetType
|
|
Case GetType(Single)
|
|
Return DirectCast(pValue, Single).ToString(CultureInfo.InvariantCulture)
|
|
|
|
Case GetType(Double)
|
|
Return DirectCast(pValue, Double).ToString(CultureInfo.InvariantCulture)
|
|
|
|
Case GetType(Decimal)
|
|
Return DirectCast(pValue, Decimal).ToString(CultureInfo.InvariantCulture)
|
|
|
|
Case GetType(Date)
|
|
Return DirectCast(pValue, Date).ToString(CultureInfo.InvariantCulture)
|
|
|
|
Case GetType(DateTime)
|
|
Return DirectCast(pValue, DateTime).ToString(CultureInfo.InvariantCulture)
|
|
|
|
Case Else
|
|
Return pValue.ToString
|
|
End Select
|
|
End Function
|
|
End Class
|