//this method here when clicked will return to the home page
        private async void saveBtn_Click(object sender, RoutedEventArgs e)
        {
            if (Action == GoalAction.Create)
            {
                //create a new goal
                var newGoal = new Goal();
                newGoal.Name       = GoalNameTextBox.Text;
                newGoal.SavingGoal = Convert.ToInt32(savingAmountTextBox.Text);
                newGoal.Notes      = notesTextBox.Text;
                newGoal.Date       = DateTime.Now;
                newGoal.Balance    = 0;

                //add a new goal to the list
                await DataContextHelper.AddRecord <Goal>(newGoal);
            }
            else if (Action == GoalAction.Update)
            {
                var goal = DataContextHelper.GetItem <Goal>(GoalId);
                goal.Name       = GoalNameTextBox.Text;
                goal.SavingGoal = Convert.ToInt32(savingAmountTextBox.Text);
                goal.Notes      = notesTextBox.Text;

                await DataContextHelper.UpdateGoal(goal);
            }

            //fire our on goal save event
            fireOneGoalSaved();

            cleartextBoxes();
            Visibility = Visibility.Collapsed;
        }
        private async void ConfirmButton_ClickAsync(object sender, RoutedEventArgs e)
        {
            var NewTransaction = new Transaction();

            NewTransaction.Date   = DateTime.Now;
            NewTransaction.Amount = Convert.ToDecimal(AmountTextBox.Text);
            NewTransaction.GoalId = GoalId;

            await DataContextHelper.AddRecord <Transaction>(NewTransaction);

            //fire this event
            FireTransactionSavedFinished();
            ClearFields();
            HideControl();
        }
        private async void ConfirmBtn_Click(object sender, RoutedEventArgs e)
        {
            //Updates all the fields
            var newTransaction = new Transaction();

            newTransaction.Date   = DateTime.Now;
            newTransaction.Amount = Convert.ToDecimal(AmtTxtBox.Text);

            newTransaction.TargetId = TargetId;//assosicates target with target id for that transaction
            await DataContextHelper.AddRecord <Transaction>(newTransaction);

            FireTransactionSaveFinished(); //trigegrs this method so new values are saved
            ClearTxtBox();                 //clears all text boxes
            CollapseControl();             //collapse the control so the user can see the main menu with updates targets
        }
Пример #4
0
 public async void AddNewGoalAsync(Goal newGoal)
 {
     //add item to our goal list
     await DataContextHelper.AddRecord <Goal>(newGoal);
 }
 public async void addNewTarget(Target newTarget)
 {
     //adds a new item to the list
     await DataContextHelper.AddRecord(newTarget);
 }