/// <summary> /// Deletes a Chore from DB /// </summary> private void DeleteChoreButton_Click(object sender, System.EventArgs e) { //Casts clicked button to a Button Button clickedButton = (Button)sender; //Displays messagebox for user to confirm delete var confirmDelete = MessageBox.Show("Are you sure you want to delete this chore?", "Confirm Deletion", MessageBoxButtons.YesNo); if (confirmDelete == DialogResult.Yes) { try { //Casts button's tag to a Chore and deletes it Model.Chore selectedChore = (Model.Chore)clickedButton.Tag; selectedChore.Delete(); //Reloads ChoreUI DisplayChores(); } catch { MessageBox.Show("Could not delete selected chore: Conversion failed", "Error"); } } }
/// <summary> /// Creates a edit button /// </summary> private Control AddDeleteChoreButton(int locationX, int locationY, Model.Chore chore) { //Creates a standard button from library var deleteChoreButton = TechnicalPlatform.UILibrary.StandardElements.AddImageButton(new Point(locationX, locationY - 15), chore, global::ChoreApplication.Properties.Resources.delete); //Adds event handler deleteChoreButton.Click += new EventHandler(DeleteChoreButton_Click); return(deleteChoreButton); }
public ChoreDTO(Model.Chore chore) { Id = chore.Id; Title = chore.Title; Description = chore.Description; Assignee = chore.AssignedUser.Id; //need to map a user object back to an id DueDate = chore.DueDate; Completed = chore.Completed; Recurring = chore.Recurring; }
/// <summary> /// Creates a panel for a single Chore /// </summary> /// <param name="chore">Chore being displayed</param> /// <param name="location">Relative location of panel</param> /// <param name="points">Points earned by completing the Chore</param> /// <param name="label1">Type specific label</param> /// <param name="label2">Type specific label</param> /// <returns>Panel with Chore info</returns> private Panel LoadChore(Model.Chore chore, Point location, int points, string label1, string label2) { //Sets starting location for labels. Updated with each label displayed int yLoc = 5; int labelDist = 0; //Sets label texts var choreName = chore.Name; var choreDescription = "Description: " + chore.Description; var chorePoints = "Points: " + points.ToString(); //Creates labels and updates location var choreNameLabel = TechnicalPlatform.UILibrary.StandardElements.AddLabel(choreName, true, new Point(5, yLoc)); yLoc += choreNameLabel.Height + labelDist; var choreDescriptionLabel = TechnicalPlatform.UILibrary.StandardElements.AddLabel(choreDescription, false, new Point(10, yLoc)); yLoc += choreNameLabel.Height + labelDist; var chorePointsLabel = TechnicalPlatform.UILibrary.StandardElements.AddLabel(chorePoints, false, new Point(10, yLoc)); yLoc += choreNameLabel.Height + labelDist; var choreLimitLabel = TechnicalPlatform.UILibrary.StandardElements.AddLabel(label1, false, new Point(10, yLoc)); yLoc += choreNameLabel.Height + labelDist; var choreCompletionsLabel = TechnicalPlatform.UILibrary.StandardElements.AddLabel(label2, false, new Point(10, yLoc)); var panelHeight = choreNameLabel.Height + chorePointsLabel.Height + choreDescriptionLabel.Height + choreLimitLabel.Height + choreCompletionsLabel.Height; //Creates standard panel from library var individualChorePanel = TechnicalPlatform.UILibrary.StandardElements.AddPanel(location, chorePanel.Width - 25, panelHeight); //Adds labels to panel individualChorePanel.Controls.Add(choreNameLabel); individualChorePanel.Controls.Add(chorePointsLabel); individualChorePanel.Controls.Add(choreDescriptionLabel); individualChorePanel.Controls.Add(choreLimitLabel); individualChorePanel.Controls.Add(choreCompletionsLabel); return(individualChorePanel); }
/// <summary> /// Creates the panel with the Chore. Name, assignment, status and type are displayed for all chores. /// </summary> /// <param name="chore">Chore to be displayed</param> /// <param name="width">Width of the panel</param> /// <param name="yLocation">Location in chorePanel</param> /// <param name="status">Status of the chore</param> /// <param name="type">Chore type</param> /// <returns>Panel with labes for each info</returns> private Panel LoadChore(Model.Chore chore, int width, int yLocation, string status, string type) { //Sets stating location for labels and distance between int yLoc = 5; int LabelDistance = 0; //Sets the 4 info texts string choreName = chore.Name; string choreAssignment = "Assigned to: " + _childrenNames[chore.Assignment]; string choreStatus = "Status: " + status; string choreType = "Type: " + type; //Creates the labels and updates yLoc for each var choreNameLabel = TechnicalPlatform.UILibrary.StandardElements.AddLabel(choreName, true, new Point(5, yLoc)); yLoc += choreNameLabel.Height + LabelDistance; var choreAssignmentLabel = TechnicalPlatform.UILibrary.StandardElements.AddLabel(choreAssignment, false, new Point(10, yLoc)); yLoc += choreNameLabel.Height + LabelDistance; var choreStatusLabel = TechnicalPlatform.UILibrary.StandardElements.AddLabel(choreStatus, false, new Point(10, yLoc)); yLoc += choreNameLabel.Height + LabelDistance; var choreTypeLabel = TechnicalPlatform.UILibrary.StandardElements.AddLabel(choreType, false, new Point(10, yLoc)); yLoc += choreNameLabel.Height + LabelDistance; var panelHeight = choreNameLabel.Height + choreAssignmentLabel.Height + choreStatusLabel.Height + choreTypeLabel.Height; //Creates panel to return var currentPanel = TechnicalPlatform.UILibrary.StandardElements.AddPanel(new Point(1, yLocation), width, panelHeight); //Adds labels to panel currentPanel.Controls.Add(choreNameLabel); currentPanel.Controls.Add(choreAssignmentLabel); currentPanel.Controls.Add(choreStatusLabel); currentPanel.Controls.Add(choreTypeLabel); return(currentPanel); }