예제 #1
0
        public static View MakeEditView(TreeFieldValue tfv)
        {
            View editView = null;

            switch (tfv.DBType)
            {
            case "REAL":
            {
                editView = new Entry()
                {
                    Keyboard = Keyboard.Numeric
                };
                editView.SetBinding(Entry.TextProperty, "ValueReal", converter: _nullableDoubleConverter);
                break;
            }

            case "INT":
            case "INTEGER":
            {
                editView = new Entry()
                {
                    Keyboard = Keyboard.Numeric
                };
                editView.SetBinding(Entry.TextProperty, "ValueInt", converter: _nullableIntConverter);
                break;
            }

            case "TEXT":
            {
                editView = new Entry()
                {
                    Keyboard = Keyboard.Text
                };
                editView.SetBinding(Entry.TextProperty, "ValueText");
                break;
            }

            case "BOOL":
            case "BOOLEAN":
            {
                editView = new Switch();
                editView.SetBinding(Switch.IsToggledProperty, "ValueBool");
                break;
            }
            }

            if (editView != null)
            {
                editView.BindingContext = tfv;
            }
            if (editView is Entry entry)
            {
                entry.Effects.Add(new Xamarin.CommunityToolkit.Effects.SelectAllTextEffect());
            }

            return(editView);
        }
        public void UpdateTreeFieldValue(TreeFieldValue treeFieldValue)
        {
            if (treeFieldValue is null)
            {
                throw new ArgumentNullException(nameof(treeFieldValue));
            }

            Database.Execute(
                "INSERT INTO TreeMeasurment " +
                $"(TreeID, {treeFieldValue.Field}, CreatedBy)" +
                $"VALUES (@p1, @p2, @p3)" +
                $"ON CONFLICT (TreeID) DO " +
                $"UPDATE SET {treeFieldValue.Field} = @p2, ModifiedBy = @p3 WHERE TreeID = @p1;",
                treeFieldValue.TreeID, treeFieldValue.Value, DeviceID);
        }