瀏覽代碼

Merge remote-tracking branch 'origin/kenric' into frank

frogsoftware 2 周之前
父節點
當前提交
f14aa816fa
共有 2 個文件被更改,包括 24 次插入3 次删除
  1. 13 2
      inabox.database.sqlite/SQLiteProvider.cs
  2. 11 1
      inabox.wpf/Utils/TextBoxUtils.cs

+ 13 - 2
inabox.database.sqlite/SQLiteProvider.cs

@@ -1753,7 +1753,7 @@ public class SQLiteProvider : IProvider
         {
             if (convertToNull && o.Equals(false))
                 return DBNull.Value;
-            return o;
+            return o.Equals(true) ? "1" : "0";
         }
 
         if (convertToNull && type == typeof(string) && string.IsNullOrEmpty(o.ToString()))
@@ -1865,6 +1865,8 @@ public class SQLiteProvider : IProvider
             return $"'{date:yyyy-MM-dd HH:mm:ss.FFFFFFF}'";
         if (value is TimeSpan time)
             return time.TotalHours.ToString();
+        if (value is bool b)
+            return b ? "'1'" : "'0'";
         return value.ToString() ?? "";
     }
     
@@ -1970,6 +1972,14 @@ public class SQLiteProvider : IProvider
         {
             return 0;
         }
+        else if (type == typeof(Guid))
+        {
+            return Guid.Empty;
+        }
+        else if (type == typeof(bool))
+        {
+            return false;
+        }
         else
         {
             return null;
@@ -2091,8 +2101,9 @@ public class SQLiteProvider : IProvider
                     }
                     else
                     {
+                        var strProp = $"IFNULL({prop},{EscapeValue(GetFilterDefaultValue(filter.Type))})";
                         value = useparams ? EncodeParameter(command, value) : EscapeValue(filter.Value);
-                        result = string.Format("(" + operators[filter.Operator] + ")", prop, value);
+                        result = string.Format("(" + operators[filter.Operator] + ")", strProp, value);
                     }
                 }
             }

+ 11 - 1
inabox.wpf/Utils/TextBoxUtils.cs

@@ -49,7 +49,17 @@ public static class TextBoxUtils
         if (sender is TextBox textBoxControl)
         {
             textBoxControl.Loaded -= TextBoxControl_Loaded;
-            GetOrCreateAdorner(textBoxControl, out _);
+            if(GetOrCreateAdorner(textBoxControl, out var adorner))
+            {
+                if(textBoxControl.Text.Length > 0)
+                {
+                    adorner.Visibility = Visibility.Hidden;
+                }
+                else
+                {
+                    adorner.Visibility = Visibility.Visible;
+                }
+            }
         }
     }