jj 25.04 CURRENCY $$$
This commit is contained in:
@@ -1166,44 +1166,45 @@ Public Class ClassControlBuilder
|
|||||||
End Function
|
End Function
|
||||||
Private Sub Textbox_Currency_Handler(sender As Object, e As EventArgs)
|
Private Sub Textbox_Currency_Handler(sender As Object, e As EventArgs)
|
||||||
Dim control As TextBox = DirectCast(sender, TextBox)
|
Dim control As TextBox = DirectCast(sender, TextBox)
|
||||||
|
|
||||||
If control.Text <> "" Then
|
If control.Text <> "" Then
|
||||||
|
Dim GermanCulture = Globalization.CultureInfo.GetCultureInfo("de-DE")
|
||||||
Dim controlvalue = control.Text
|
Dim controlvalue = control.Text
|
||||||
If controlvalue.Contains(".") Then
|
|
||||||
controlvalue = controlvalue.Replace(".", ",")
|
|
||||||
End If
|
|
||||||
Dim value As Double
|
Dim value As Double
|
||||||
If Double.TryParse(controlvalue, Globalization.NumberStyles.Currency, Nothing, value) Then
|
|
||||||
'Valid.
|
' Tausenderzeichen entfernen
|
||||||
control.Text = value.ToString("c"c)
|
controlvalue = controlvalue.Replace(".", "")
|
||||||
Else
|
|
||||||
|
If Not Double.TryParse(controlvalue, Globalization.NumberStyles.Currency, GermanCulture, value) Then
|
||||||
'Invalid.
|
'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.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
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
|
'ALT
|
||||||
'If Decimal.TryParse(control.Text.Trim(), value) Then
|
'If control.Text <> "" Then
|
||||||
' 'control.Text = value.ToString("c")
|
' Dim controlvalue = control.Text
|
||||||
' 'control.SelectionStart = control.SelectionStart + 1
|
' If controlvalue.Contains(".") Then
|
||||||
' 'control.Text = FormatCurrency(control.Text)
|
' controlvalue = controlvalue.Replace(".", ",")
|
||||||
' 'value = FormatNumber(value, -1, TriState.UseDefault, TriState.UseDefault, TriState.True)
|
' End If
|
||||||
' 'control.Text = value.ToString("n")
|
' 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 If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
@@ -1479,6 +1480,7 @@ Public Class ClassControlBuilder
|
|||||||
metadata.Id = id
|
metadata.Id = id
|
||||||
metadata.Name = name
|
metadata.Name = name
|
||||||
metadata.Required = required
|
metadata.Required = required
|
||||||
|
metadata.Format = format
|
||||||
control.Tag = metadata
|
control.Tag = metadata
|
||||||
|
|
||||||
control.Name = name
|
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)
|
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
|
Try
|
||||||
Dim ControlId As Integer = DirectCast(control.Tag, ClassControlMetadata).Id
|
Dim ControlMeta As ClassControlMetadata = DirectCast(control.Tag, ClassControlMetadata)
|
||||||
If ControlId = 272 Then
|
Dim ControlId As Integer = ControlMeta.Id
|
||||||
Console.WriteLine("272")
|
Dim ControlFormat As String = ControlMeta.Format
|
||||||
End If
|
|
||||||
If CURRENT_RECORD_ENABLED = False Then
|
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
|
Else
|
||||||
If VARIABLE_VALUE = True Then
|
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
|
Else
|
||||||
Dim drarray() As DataRow = CURRENT_SQL_AUTO_VALUES_DT.Select("CONTROL_ID = " & ControlId)
|
Dim drarray() As DataRow = CURRENT_SQL_AUTO_VALUES_DT.Select("CONTROL_ID = " & ControlId)
|
||||||
If drarray.Length > 0 Then
|
If drarray.Length > 0 Then
|
||||||
|
|||||||
@@ -2,4 +2,5 @@
|
|||||||
Public Property Id As Integer
|
Public Property Id As Integer
|
||||||
Public Property Name As String
|
Public Property Name As String
|
||||||
Public Property Required As Boolean
|
Public Property Required As Boolean
|
||||||
|
Public Property Format As String
|
||||||
End Structure
|
End Structure
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ Public Class ClassGridFormatter
|
|||||||
|
|
||||||
Public checkboxColumns As New List(Of String)
|
Public checkboxColumns As New List(Of String)
|
||||||
Public dateColumns 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)
|
Public Sub New(DT As DataTable, EntityId As Integer)
|
||||||
Me.EntityId = EntityId
|
Me.EntityId = EntityId
|
||||||
@@ -115,8 +116,56 @@ Public Class ClassGridFormatter
|
|||||||
End If
|
End If
|
||||||
Next
|
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
|
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()
|
Private Function GetCheckboxColumns()
|
||||||
Try
|
Try
|
||||||
Dim listcheck As New List(Of String)
|
Dim listcheck As New List(Of String)
|
||||||
|
|||||||
@@ -2,6 +2,24 @@
|
|||||||
Imports System.Globalization
|
Imports System.Globalization
|
||||||
Imports DD_LIB_Standards
|
Imports DD_LIB_Standards
|
||||||
Public Class ClassHelper
|
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)
|
Public Shared Function Convert_Date(input As String, format As String)
|
||||||
Try
|
Try
|
||||||
Dim dt As Date = CDate(input)
|
Dim dt As Date = CDate(input)
|
||||||
@@ -107,11 +125,11 @@ Public Class ClassHelper
|
|||||||
''' <param name="sFilename">Dateiname ohne Pfadangabe</param>
|
''' <param name="sFilename">Dateiname ohne Pfadangabe</param>
|
||||||
''' <param name="sChar">Ersatzzeichen für alle unzulässigen Zeichen
|
''' <param name="sChar">Ersatzzeichen für alle unzulässigen Zeichen
|
||||||
''' im Dateinamen</param>
|
''' 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
|
Optional ByVal REPLACEChar As String = "") As String
|
||||||
|
|
||||||
' alle nicht zulässigen Zeichen ersetzen
|
' alle nicht zulässigen Zeichen ersetzen
|
||||||
Return System.Text.RegularExpressions.Regex.Replace( _
|
Return System.Text.RegularExpressions.Regex.Replace(
|
||||||
sFilename, "[?*^""<>|]", REPLACEChar)
|
sFilename, "[?*^""<>|]", REPLACEChar)
|
||||||
End Function
|
End Function
|
||||||
Public Shared Sub File_open(RESULT_DOC_PATH As Object, DocID As String)
|
Public Shared Sub File_open(RESULT_DOC_PATH As Object, DocID As String)
|
||||||
|
|||||||
Reference in New Issue
Block a user