Пример #1
0
 /// <summary>
 /// Creates and displays elements in the designer.
 /// Sets _child and edits label texts.
 /// </summary>
 public EditChildUI(Model.ChildUser child)
 {
     InitializeComponent();
     _child = child;
     childFirstNameTextbox.Text = child.FirstName;
     childPincodeTextBox.Text   = child.Pincode;
     welcomeLabel.Text          = "Editing " + child.FirstName;
 }
Пример #2
0
        /// <summary>
        /// Creates a button to delete a ChildUser
        /// </summary>
        private Control AddDeleteChildButton(int locationX, int locationY, Model.ChildUser childUser)
        {
            //Creates a standard button from library
            var deleteChildButton = TechnicalPlatform.UILibrary.StandardElements.AddImageButton(new Point(locationX, locationY - 15), childUser, global::ChoreApplication.Properties.Resources.delete);

            //Adds event handler
            deleteChildButton.Click += new EventHandler(DeleteChildButton_Click);
            return(deleteChildButton);
        }
Пример #3
0
        /// <summary>
        /// Displays a ChildUser in a panel
        /// </summary>
        private Panel LoadChild(Model.ChildUser child, int yLocation)
        {
            //Creates a panel with User info
            var individualUserPanel = LoadUser(child, yLocation);

            //Adds edit and delete button
            individualUserPanel.Controls.Add(AddEditChildButton(330, individualUserPanel.Height / 2, child));
            individualUserPanel.Controls.Add(AddDeleteChildButton(365, individualUserPanel.Height / 2, child));
            return(individualUserPanel);
        }
Пример #4
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.");
        }
Пример #5
0
        /// <summary>
        /// Deletes ChildUser from button tag in DB.
        /// </summary>
        private void DeleteChildButton_Click(object sender, System.EventArgs e)
        {
            //Sets selectedUser to the ChildUser in button tag
            Button clickedButton = (Button)sender;

            Model.ChildUser selectedUser = (Model.ChildUser)clickedButton.Tag;

            //Displays message box for user to confirm deleting
            var confirmDelete = MessageBox.Show("Are you sure you want to delete this user?", "Confirm Deletion", MessageBoxButtons.YesNo);

            //Deletes ChildUser and reloads UI if yes
            if (confirmDelete == DialogResult.Yes)
            {
                selectedUser.Delete();
                UsersUI();
            }
        }
Пример #6
0
        /// <summary>
        /// Creates and displays elements in the designer.
        /// Initializes helpers and sets UI to ChoresUI by default.
        /// </summary>
        public ChildMenu(Model.ChildUser child)
        {
            //Creates session
            _session = child;

            //Creates and displays elements in designer
            InitializeComponent();

            //Initializes _statusValues and _childrenNames dictionary
            InitializeDictionaries();

            //Loads and displays amount of points the ChildUser has
            LoadPoints();

            //Displays amount of notifications for _session
            LoadAmountOfNotifications();

            //Loads ChoresUI
            ChoresUI();
        }
Пример #7
0
        /// <summary>
        /// Sends user to EditChildUI to edit chosen User
        /// </summary>
        private void EditChildButton_Click(object sender, System.EventArgs e)
        {
            //Disable ParentMenu
            this.Enabled = false;

            Button clickedButton = (Button)sender;

            try
            {
                //Sets selectedChild to ChildUser from clicked button's tag
                Model.ChildUser selectedChild = (Model.ChildUser)clickedButton.Tag;

                //Opens EditChildUI
                var editSelectedChildUI = new EditChildUI(selectedChild);
                editSelectedChildUI.Show();

                //Enables ParentMenu on close
                editSelectedChildUI.FormClosing += UsersNavigationButton_Click;
            }
            catch
            {
                MessageBox.Show("Could not edit child: Child not found", "Error");
            }
        }