Version 1.0.1
This commit is contained in:
49
WheresMyMoney.Maui/AddPlannedPaymentPage.xaml.cs
Normal file
49
WheresMyMoney.Maui/AddPlannedPaymentPage.xaml.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System.Diagnostics;
|
||||
using WheresMyMoney.Maui.Core;
|
||||
|
||||
namespace WheresMyMoney.Maui;
|
||||
|
||||
public partial class AddPlannedPaymentPage : ContentPage
|
||||
{
|
||||
public AddPlannedPaymentPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
RepeatPicker.SelectedIndex = 2;
|
||||
}
|
||||
|
||||
private async void Add_OnClicked(object? sender, EventArgs e)
|
||||
{
|
||||
if (!decimal.TryParse(AmountEntry.Text, out decimal amount)) return;
|
||||
var isSubscription = SubscriptionSwitch.IsToggled;
|
||||
var every = -1;
|
||||
var reoccurenceType = (ReoccurenceType)RepeatPicker.SelectedIndex;
|
||||
if (isSubscription)
|
||||
{
|
||||
isSubscription = int.TryParse(EveryEntry.Text, out every) && every > 0;
|
||||
}
|
||||
|
||||
Repository.Instance.InsertPlannedPayment(amount, NameEntry.Text, StartDateEntry.Date,
|
||||
!isSubscription || IndefiniteSwitch.IsToggled ? null : EndDateEntry.Date,
|
||||
isSubscription, isSubscription ? every : null,
|
||||
isSubscription ? reoccurenceType : null);
|
||||
|
||||
await Navigation.PopModalAsync();
|
||||
}
|
||||
|
||||
private void NameEntry_OnCompleted(object? sender, EventArgs e)
|
||||
{
|
||||
if (SubscriptionSwitch.IsToggled)
|
||||
{
|
||||
EveryEntry.Focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
EveryEntry_OnCompleted(sender, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void EveryEntry_OnCompleted(object? sender, EventArgs e)
|
||||
{
|
||||
AmountEntry.Focus();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user