jj 25.04 CURRENCY $$$

This commit is contained in:
Digital Data
2017-04-25 16:47:40 +02:00
parent 29692430d8
commit 5a00b63de1
5 changed files with 114 additions and 36 deletions

View File

@@ -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