jj 25.04 CURRENCY $$$
This commit is contained in:
@@ -1166,44 +1166,45 @@ Public Class ClassControlBuilder
|
||||
End Function
|
||||
Private Sub Textbox_Currency_Handler(sender As Object, e As EventArgs)
|
||||
Dim control As TextBox = DirectCast(sender, TextBox)
|
||||
|
||||
If control.Text <> "" Then
|
||||
Dim GermanCulture = Globalization.CultureInfo.GetCultureInfo("de-DE")
|
||||
Dim controlvalue = control.Text
|
||||
If controlvalue.Contains(".") Then
|
||||
controlvalue = controlvalue.Replace(".", ",")
|
||||
End If
|
||||
Dim value As Double
|
||||
If Double.TryParse(controlvalue, Globalization.NumberStyles.Currency, Nothing, value) Then
|
||||
'Valid.
|
||||
control.Text = value.ToString("c"c)
|
||||
Else
|
||||
|
||||
' Tausenderzeichen entfernen
|
||||
controlvalue = controlvalue.Replace(".", "")
|
||||
|
||||
If Not Double.TryParse(controlvalue, Globalization.NumberStyles.Currency, GermanCulture, value) Then
|
||||
'Invalid.
|
||||
MessageBox.Show("Please enter a valid curreny amount.")
|
||||
MessageBox.Show("Please enter a valid curreny amount.", "Invalid Format", MessageBoxButtons.OK, MessageBoxIcon.Warning)
|
||||
control.Focus()
|
||||
control.SelectAll()
|
||||
'control.SelectAll()
|
||||
Else
|
||||
'Alles gut, convertierung erfolgreich, wieder als currency anzeigen
|
||||
control.Text = ClassHelper.Format_Currency(value.ToString(), USER_LANGUAGE)
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
'Dim i = IsValidCurrency(control.Text)
|
||||
'If IsValidCurrency(control.Text) = False Then
|
||||
' MsgBox("Sorry but some input characters are invalid for the format currency!", MsgBoxStyle.Exclamation)
|
||||
' control.Focus()
|
||||
' control.SelectAll()
|
||||
'End If
|
||||
'Dim currencyRegex = New System.Text.RegularExpressions.Regex("[0-9,\.]*")
|
||||
'Dim match = currencyRegex.Match(control.Text)
|
||||
|
||||
'If match.Success Then
|
||||
|
||||
'End If
|
||||
|
||||
|
||||
|
||||
'If Decimal.TryParse(control.Text.Trim(), value) Then
|
||||
' 'control.Text = value.ToString("c")
|
||||
' 'control.SelectionStart = control.SelectionStart + 1
|
||||
' 'control.Text = FormatCurrency(control.Text)
|
||||
' 'value = FormatNumber(value, -1, TriState.UseDefault, TriState.UseDefault, TriState.True)
|
||||
' 'control.Text = value.ToString("n")
|
||||
'ALT
|
||||
'If control.Text <> "" Then
|
||||
' Dim controlvalue = control.Text
|
||||
' If controlvalue.Contains(".") Then
|
||||
' controlvalue = controlvalue.Replace(".", ",")
|
||||
' End If
|
||||
' Dim value As Double
|
||||
' If Double.TryParse(controlvalue, Globalization.NumberStyles.Currency, Nothing, value) Then
|
||||
' 'Valid.
|
||||
' control.Text = value.ToString("c"c)
|
||||
' Else
|
||||
' 'Invalid.
|
||||
' MessageBox.Show("Please enter a valid curreny amount.")
|
||||
' control.Focus()
|
||||
' control.SelectAll()
|
||||
' End If
|
||||
'End If
|
||||
End Sub
|
||||
|
||||
@@ -1479,6 +1480,7 @@ Public Class ClassControlBuilder
|
||||
metadata.Id = id
|
||||
metadata.Name = name
|
||||
metadata.Required = required
|
||||
metadata.Format = format
|
||||
control.Tag = metadata
|
||||
|
||||
control.Name = name
|
||||
|
||||
@@ -297,15 +297,23 @@
|
||||
|
||||
Public Shared Sub LoadValue(control As System.Windows.Forms.TextBox, recordId As Integer, parentRecordId As Integer, value As String, entity_ID As Integer, Optional VARIABLE_VALUE As Boolean = False)
|
||||
Try
|
||||
Dim ControlId As Integer = DirectCast(control.Tag, ClassControlMetadata).Id
|
||||
If ControlId = 272 Then
|
||||
Console.WriteLine("272")
|
||||
End If
|
||||
Dim ControlMeta As ClassControlMetadata = DirectCast(control.Tag, ClassControlMetadata)
|
||||
Dim ControlId As Integer = ControlMeta.Id
|
||||
Dim ControlFormat As String = ControlMeta.Format
|
||||
|
||||
If CURRENT_RECORD_ENABLED = False Then
|
||||
control.Text = value
|
||||
If ControlFormat = "Currency" Then
|
||||
control.Text = ClassHelper.Format_Currency(value, USER_LANGUAGE)
|
||||
Else
|
||||
control.Text = value
|
||||
End If
|
||||
Else
|
||||
If VARIABLE_VALUE = True Then
|
||||
control.Text = value
|
||||
If ControlFormat = "Currency" Then
|
||||
control.Text = ClassHelper.Format_Currency(value, USER_LANGUAGE)
|
||||
Else
|
||||
control.Text = value
|
||||
End If
|
||||
Else
|
||||
Dim drarray() As DataRow = CURRENT_SQL_AUTO_VALUES_DT.Select("CONTROL_ID = " & ControlId)
|
||||
If drarray.Length > 0 Then
|
||||
|
||||
@@ -2,4 +2,5 @@
|
||||
Public Property Id As Integer
|
||||
Public Property Name As String
|
||||
Public Property Required As Boolean
|
||||
Public Property Format As String
|
||||
End Structure
|
||||
|
||||
@@ -32,6 +32,7 @@ Public Class ClassGridFormatter
|
||||
|
||||
Public checkboxColumns As New List(Of String)
|
||||
Public dateColumns As New List(Of String)
|
||||
Public currencyColumns As New List(Of String)
|
||||
|
||||
Public Sub New(DT As DataTable, EntityId As Integer)
|
||||
Me.EntityId = EntityId
|
||||
@@ -115,8 +116,56 @@ Public Class ClassGridFormatter
|
||||
End If
|
||||
Next
|
||||
|
||||
currencyColumns = GetCurrencyColumns()
|
||||
|
||||
For Each columnName As String In currencyColumns
|
||||
Dim column As GridColumn = gridView.Columns(columnName)
|
||||
|
||||
If Not IsNothing(column) Then
|
||||
column.DisplayFormat.FormatType = FormatType.Numeric
|
||||
column.DisplayFormat.FormatString = "C"
|
||||
column.DisplayFormat.Format = New CurrencyFormatter()
|
||||
End If
|
||||
Next
|
||||
|
||||
End Sub
|
||||
|
||||
Class CurrencyFormatter
|
||||
Implements IFormatProvider, ICustomFormatter
|
||||
|
||||
Public Function GetFormat(formatType As Type) As Object Implements IFormatProvider.GetFormat
|
||||
Return Me
|
||||
End Function
|
||||
|
||||
Public Function Format(formatString As String, arg As Object, formatProvider As IFormatProvider) As String Implements ICustomFormatter.Format
|
||||
Dim formatValue As String = arg.ToString()
|
||||
|
||||
If (formatValue.Count > 0 And formatString.ToUpper() = "C") Then
|
||||
Return ClassHelper.Format_Currency(formatValue, USER_LANGUAGE)
|
||||
Else
|
||||
Return formatValue
|
||||
End If
|
||||
End Function
|
||||
End Class
|
||||
|
||||
Private Function GetCurrencyColumns() As List(Of String)
|
||||
Try
|
||||
Dim list As New List(Of String)
|
||||
' Alle Currency Felder für aktuelle Ansicht heraussuchen
|
||||
Dim sql As String = "SELECT COL_NAME FROM TBPMO_CONTROL WHERE CONTROL_TYPE_ID = 2 AND FORMAT_TYPE = 'Currency' AND SHOW_COLUMN = 1 AND FORM_ID = " & Me.EntityId
|
||||
Dim dt As DataTable = ClassDatabase.Return_Datatable(sql, True)
|
||||
|
||||
For Each row As DataRow In dt.Rows
|
||||
list.Add(row.Item("COL_NAME"))
|
||||
Next
|
||||
|
||||
Return list
|
||||
Catch ex As Exception
|
||||
ClassLogger.Add("Unexpected Error in GetCurrencyColumns: " & ex.Message, True)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function GetCheckboxColumns()
|
||||
Try
|
||||
Dim listcheck As New List(Of String)
|
||||
|
||||
@@ -2,6 +2,24 @@
|
||||
Imports System.Globalization
|
||||
Imports DD_LIB_Standards
|
||||
Public Class ClassHelper
|
||||
Public Shared Function Format_Currency(value As String, language As String)
|
||||
Try
|
||||
If language <> "de-DE" Then
|
||||
value = value.Replace(",", ".")
|
||||
End If
|
||||
|
||||
Dim dValue = Double.Parse(value)
|
||||
|
||||
Dim ci = Threading.Thread.CurrentThread.CurrentCulture
|
||||
Dim nfi As NumberFormatInfo = ci.NumberFormat.Clone()
|
||||
nfi.CurrencySymbol = "" ' KEIN Currency Symbol
|
||||
|
||||
Return dValue.ToString("C", nfi)
|
||||
Catch ex As Exception
|
||||
Return value.ToString()
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Shared Function Convert_Date(input As String, format As String)
|
||||
Try
|
||||
Dim dt As Date = CDate(input)
|
||||
@@ -107,11 +125,11 @@ Public Class ClassHelper
|
||||
''' <param name="sFilename">Dateiname ohne Pfadangabe</param>
|
||||
''' <param name="sChar">Ersatzzeichen für alle unzulässigen Zeichen
|
||||
''' im Dateinamen</param>
|
||||
Public Shared Function CleanFilename(ByVal sFilename As String, _
|
||||
Public Shared Function CleanFilename(ByVal sFilename As String,
|
||||
Optional ByVal REPLACEChar As String = "") As String
|
||||
|
||||
' alle nicht zulässigen Zeichen ersetzen
|
||||
Return System.Text.RegularExpressions.Regex.Replace( _
|
||||
Return System.Text.RegularExpressions.Regex.Replace(
|
||||
sFilename, "[?*^""<>|]", REPLACEChar)
|
||||
End Function
|
||||
Public Shared Sub File_open(RESULT_DOC_PATH As Object, DocID As String)
|
||||
|
||||
Reference in New Issue
Block a user