Ver Fonte

Fix to DirectEdit on currency columns for TreeGrid; minor tweaks

Kenric Nugteren há 8 meses atrás
pai
commit
84bf7a0eb7

+ 19 - 10
inabox.wpf/DigitalForms/Designer/DynamicEditFormWindow.xaml.cs

@@ -197,10 +197,10 @@ public partial class DynamicFormEditWindow : Window, IDynamicFormWindow
     {
         if (!Grid.Validate(out var messages))
         {
-            MessageBox.Show(string.Join('\n', messages));
+            MessageWindow.ShowMessage(string.Join('\n', messages), "Validation Error", image: MessageWindow.WarningImage);
             return;
         }
-        if (MessageBox.Show("Are you sure you want to complete this form?", "Confirm Completion", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
+        if (MessageWindow.ShowYesNo("Are you sure you want to complete this form?", "Confirm Completion"))
         {
             Result = FormResult.Complete;
             DialogResult = true;
@@ -265,10 +265,10 @@ public partial class DynamicFormEditWindow : Window, IDynamicFormWindow
     {
         if (DataModel?.Instance.FormCompleted.IsEmpty() == false && !Grid.Validate(out var messages))
         {
-            MessageBox.Show(string.Join('\n', messages));
+            MessageWindow.ShowMessage(string.Join('\n', messages), "Validation Error", image: MessageWindow.WarningImage);
             return;
         }
-        if (MessageBox.Show("Are you sure you want to save this form?", "Confirm Save", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
+        if (MessageWindow.ShowYesNo("Are you sure you want to save this form?", "Confirm Save"))
         {
             Result = FormResult.Save;
             DialogResult = true;
@@ -306,7 +306,8 @@ public partial class DynamicFormEditWindow : Window, IDynamicFormWindow
         DigitalFormLayout layout = null;
         DigitalFormVariable[] variables = null;
         DFLoadStorage? values = null;
-        String error = "";
+        string? error = null;
+        string? errorDetails = null;
 
         Progress.ShowModal("Loading Form", (progress) =>
         {
@@ -351,19 +352,27 @@ public partial class DynamicFormEditWindow : Window, IDynamicFormWindow
 
                     if (parent == null)
                     {
-                        Logger.Send(LogType.Error, "",
-                            $"Form parent is null; Form Type: {formInstance.GetType()}; Parent Type: {parenttype}; Form ID: {formInstance.ID}");
                         error = "An error occurred while loading the form: Form Entity is null";
+                        errorDetails = $"Form parent is null; Form Type: {formInstance.GetType()}; Parent Type: {parenttype}; Form ID: {formInstance.ID}";
                     }
                 }
             }
             else
+            {
                 error = "No layout found for form!";
+            }
         });
 
-        if (!String.IsNullOrWhiteSpace(error))
+        if (!error.IsNullOrWhiteSpace())
         {
-            MessageBox.Show(error);
+            if(errorDetails is null)
+            {
+                MessageWindow.ShowError(error, error, shouldLog: false);
+            }
+            else
+            {
+                MessageWindow.ShowError(error, errorDetails);
+            }
             return false;
         }
 
@@ -444,7 +453,7 @@ public partial class DynamicFormEditWindow : Window, IDynamicFormWindow
     {
         if (DialogResult != true && HasUnsavedChanges)
         {
-            if (MessageBox.Show("This form has unsaved changes. Do you wish to discard them?", "Discard Changes?", MessageBoxButton.YesNo) != MessageBoxResult.Yes)
+            if (!MessageWindow.ShowYesNo("This form has unsaved changes. Do you wish to discard them?", "Discard Changes?"))
             {
                 e.Cancel = true;
             }

+ 1 - 1
inabox.wpf/DigitalForms/Designer/SignaturePadWindow.xaml

@@ -7,7 +7,7 @@
         xmlns:wpf="clr-namespace:InABox.Wpf"
         xmlns:sf="http://schemas.syncfusion.com/wpf"
         mc:Ignorable="d"
-        Title="SignaturePadWindow" Height="550" Width="800" ResizeMode="NoResize">
+        Title="Enter Signature:" Height="550" Width="800" ResizeMode="NoResize">
     <Grid Background="LightGray">
         <Grid.RowDefinitions>
             <RowDefinition Height="*"/>

+ 24 - 0
inabox.wpf/DynamicGrid/Columns/EditorColumns/DynamicGridCurrencyColumn.cs

@@ -1,6 +1,9 @@
+using System;
 using System.Collections.Generic;
+using System.Windows.Data;
 using System.Windows.Media;
 using InABox.Core;
+using InABox.Wpf;
 using Syncfusion.Data;
 using Syncfusion.UI.Xaml.Grid;
 using Syncfusion.UI.Xaml.TreeGrid;
@@ -26,6 +29,27 @@ public class DynamicGridCurrencyColumn<TEntity> : DynamicGridNumericColumn<TEnti
         column.CurrencyGroupSizes = new Int32Collection(new[] { 3, 3, 3, 3, 3, 3 });
     }
 
+    protected override void UpdateBinding(TreeGridCurrencyColumn column)
+    {
+        base.UpdateBinding(column);
+        (column.ValueBinding as Binding).Converter = new FuncConverter<object?, decimal?>(
+            x =>
+            {
+                if(x is null)
+                {
+                    return null;
+                }
+                else
+                {
+                    return Convert.ToDecimal(x);
+                }
+            },
+            x =>
+            {
+                return x.HasValue ? (double)x.Value : null;
+            });
+    }
+
     public override GridSummaryColumn? Summary()
     {
         if (Definition == null || Definition.Editor.Summary == Core.Summary.None)