private void Button_Clicked(object sender, System.EventArgs e)
        {
            if (!IsCancelPressed)
            {
                System.Threading.ThreadPool.QueueUserWorkItem(async _ =>
                {
                    await Task.Run(async() =>
                    {
                        if (categoryButton.Text == Strings["choose_category"])
                        {
                            await PopupNavigation.Instance.PushAsync(new AlertPopupView(Strings["alert_need_category"]), true);
                            return;
                        }
                        if (String.IsNullOrEmpty(entry.Text))
                        {
                            await PopupNavigation.Instance.PushAsync(new AlertPopupView(Strings["alert_no_value"]), true);
                        }
                        else if (entry.Text[0] == '-')
                        {
                            await PopupNavigation.Instance.PushAsync(new AlertPopupView(Strings["alert_no_minus"]), true);
                        }
                        else if (entry.Text[0] == '0')
                        {
                            await PopupNavigation.Instance.PushAsync(new AlertPopupView(Strings["alert_no_value_zero"]), true);
                        }
                        else if (entry.Text[0] == '.')
                        {
                            await PopupNavigation.Instance.PushAsync(new AlertPopupView(Strings["alert_no_value"]), true);
                        }
                        else
                        {
                            var moneyValue = decimal.Parse(entry.Text);
                            var result     = entryDescription.Text;

                            if (String.IsNullOrWhiteSpace(entryDescription.Text))
                            {
                                var type = UnwrapAddingCategoryType(CrossSettings.Current.GetValueOrDefault("SelectedBankCategory", 0));
                                result   = type.Name + " " + Strings["missed"];
                            }
                            CrossSettings.Current.AddOrUpdateValue("CreditValue", moneyValue);
                            CrossSettings.Current.AddOrUpdateValue("CreditMessage", result);
                            CrossSettings.Current.AddOrUpdateValue("CurrentAddedMoneyTo", FuncMoneyFrom());

                            await PopupNavigation.Instance.PopAsync(true);
                            ActionAfter?.Invoke();
                        }
                    });
                });
            }
        }
Exemplo n.º 2
0
        private async void Button_Clicked(object sender, System.EventArgs e)
        {
            if (!IsCancelPressed)
            {
                if (categoryButton.Text == Strings["choose_category"])
                {
                    await PopupNavigation.Instance.PushAsync(new AlertPopupView(Strings["alert_need_category"]), true);

                    return;
                }
                var result = entry.Text;
                if (String.IsNullOrWhiteSpace(entry.Text))
                {
                    var type = UnwrapSpendingCategoryType(CrossSettings.Current.GetValueOrDefault("SelectedSpendingCategory", 0));
                    result = type.Name + " " + Strings["missed"];
                }
                CrossSettings.Current.AddOrUpdateValue("CommitMessage", result);
                CrossSettings.Current.AddOrUpdateValue("CurrentCommitMoneyFrom", FuncMoneyFrom());

                await PopupNavigation.Instance.PopAsync(true);

                ActionAfter?.Invoke();
            }
        }