コード例 #1
0
        /// <summary>
        /// Rejects a completed Chore. If the Chore was generated by a Repeatable Chore it is deleted.
        /// If the Chore is Concrete or generated by a Reoccurring Chore it is set to status active and postponed.
        /// </summary>
        private void DenyChoreButton_Click(object sender, System.EventArgs e)
        {
            //Sets currentChore to the clicked button's tag
            Button clickedButton = (Button)sender;

            Model.Concrete currentChore = (Model.Concrete)clickedButton.Tag;

            //Loads the Child the Chore is assigned to
            var currentChild = Model.ChildUser.Load("child_id=" + currentChore.Assignment);

            //If generated by a Repeatable Chore it's deleted
            if (currentChore.Type == "rep")
            {
                currentChore.Delete();
            }

            //Otherwise it's postponed by 1 day and set to active
            else
            {
                currentChore.DueDate  = DateTime.Now.AddDays(1);
                currentChore.Status   = 1;
                currentChore.Reminder = 0;
                currentChore.Update();
            }

            //Creates a notification to the assigned ChildUser
            Model.Notification.Insert(currentChild[0].ID, "Chore Denied", $"The chore {currentChore.Name} has been denied.");

            //Reload ChoreUI
            LoadAmountOfNotifications();
            DisplayChores();
        }
コード例 #2
0
        /// <summary>
        /// Approves a Chore and reloads ChoreUI
        /// </summary>
        private void ApproveChoreButton_Click(object sender, System.EventArgs e)
        {
            //Sets currentChore to the clicked button's tag
            Button clickedButton = (Button)sender;

            Model.Concrete currentChore = (Model.Concrete)clickedButton.Tag;

            //Update the Chore's properties and update DB
            currentChore.Status    = 3;
            currentChore.FinalDate = DateTime.Now;
            currentChore.Update();

            //Load the ChildUser the Chore is assigned to
            var currentChild = Model.ChildUser.Load("child_id=" + currentChore.Assignment);

            //Update the ChildUser's points and update DB
            currentChild[0].Points += currentChore.Points;
            currentChild[0].Update();

            //Create a notification to the ChildUser
            Model.Notification.Insert(currentChild[0].ID, "Chore Approved", $"The chore {currentChore.Name} has been approved." +
                                      $"\n{currentChore.Points.ToString()} points has been added to your account");

            //Reload ChoresUI
            LoadAmountOfNotifications();
            DisplayChores();
        }
コード例 #3
0
        /// <summary>
        /// Updates overdue chore
        /// </summary>
        private void UpdateOverdue(Model.Concrete chore, Model.ChildUser child)
        {
            //Subtracks the Chore's points from the ChildUser's account and updates DB
            child.Points -= chore.Points;
            child.Update();

            //Sets the Chore to overdue and the ApprovalDate to now. Updates the DB
            chore.Status    = 4;
            chore.FinalDate = DateTime.ParseExact(DateTime.Now.ToString(Properties.Settings.Default.LongDateFormat), Properties.Settings.Default.LongDateFormat, null);
            chore.Update();

            //Creates a notification for the ChildUser
            Model.Notification.Insert(child.ID, $"A chore has gone over due", $"You did not complete {chore.Name} in time.");
        }
コード例 #4
0
        /// <summary>
        /// Completes a Concrete Chore
        /// </summary>
        private void ConcreteChoreDoneButton_Click(object sender, EventArgs e)
        {
            //Set currentChore to the Concrete Chore in clicked button's tag
            Button clickedButton = (Button)sender;

            Model.Concrete currentChore = (Model.Concrete)clickedButton.Tag;

            //Set status to approval pending and update DB
            currentChore.Status = 2;
            currentChore.Update();

            //Create a notification to ParentUser
            Model.Notification.Insert(1, $"{_childrenNames[currentChore.Assignment]} completed a chore.", $"{_childrenNames[currentChore.Assignment]} completed the chore {currentChore.Name}.");

            //Reload ChoreUI
            LoadAmountOfNotifications();
            DisplayChores();
        }