/// <summary>
 /// initialize elements
 /// </summary>
 public override void InitElements()
 {
     Form          = new EditTaskForm(itemTypeForm, ControlPrefix);
     Form.Parent   = this;
     Detail        = new EditTaskDetail(ControlPrefix);
     Detail.Parent = this;
 }
예제 #2
0
        private void EditTaskBtn_Click(object sender, EventArgs e)
        {
            try
            {
                EditTask EditTaskForm;
                if (SelectedProject.Project_ID != null)
                {
                    EditTaskForm = new EditTask(SelectedProject.Project_ID, SelectedTask.Task_Id);
                }
                else
                {
                    MessageBox.Show("Select a task to edit first, and then click in the edit button");
                    return;
                }

                EditTaskForm.BoolRegisteredChangedE += new EventHandler <BoolEvent>(EditTaskForm_BoolRegisteredChangedE);

                EditTaskForm.ShowDialog();

                EditTaskForm.BoolRegisteredChangedE -= EditTaskForm_BoolRegisteredChangedE;

                EditTaskForm.Dispose();

                EditTaskForm = null;
            }
            catch (Exception)
            {
                MessageBox.Show("Failed to edit, try later");
            }
        }
예제 #3
0
        public bool EditTask(int id, EditTaskForm form)
        {
            using (var organizerContext = new OrganizerDBEntities())
            {
                // fetching a task we will edit
                var query = from task in organizerContext.Tasks
                            where task.Id == id
                            select task;
                Task taskToEdit = query.First();

                // assigning new values for the task
                taskToEdit.IsFinished  = form.cbFinish.IsChecked;
                taskToEdit.Title       = form.txtTitle.Text;
                taskToEdit.Description = form.txtDescription.Text;
                taskToEdit.Location    = form.txtLocation.Text;
                taskToEdit.Start       = (DateTime)form.dpStart.SelectedDate;
                taskToEdit.Finish      = (DateTime)form.dpEnd.DisplayDate;

                // chech if task with the same title exists for this date
                var queryCheck = from tsk in organizerContext.Tasks
                                 where tsk.Title == taskToEdit.Title && tsk.Start == taskToEdit.Start && tsk.Id != taskToEdit.Id
                                 select tsk;
                if (queryCheck.Count() > 0)
                {
                    // Configure the message box to be displayed
                    string messageBoxText = "Task with the same title is already created for this day!\n" +
                                            "Do you want to create a task with a different title?";
                    string           caption = "Task already exists";
                    MessageBoxButton button  = MessageBoxButton.YesNo;
                    MessageBoxImage  icon    = MessageBoxImage.Warning;
                    // Display message box
                    MessageBoxResult result = MessageBox.Show(messageBoxText, caption, button, icon);
                    if (result == MessageBoxResult.Yes)
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
                else
                {
                    // saving changes
                    organizerContext.SaveChanges();
                    return(true);
                }
            }
        }
예제 #4
0
 public ActionResult Edit(EditTaskForm editTaskForm)
 {
    return HandleForm(editTaskForm)
        .WithSuccessResult(this.RedirectToAction(x => x.Index()));
 }
예제 #5
0
        private void InitControls()
        {
            // visible controls
            _stickyNote = new TodoHoverableButtonImage()
            {
                Image_Normal  = Properties.Resources.sticky_note_normal,
                Image_Hovered = Properties.Resources.sticky_note_hovered,
                Location      = new Point(191, 0),
                Size          = new Size(31, 36)
            };

            _checkBox = new TodoCheckBox()
            {
                Location = new Point(321, 0),
                Size     = new Size(31, 36),
                Checked  = _desc.Done
            };

            // help/on-click controls
            _helpTT = new ToolTip()
            {
                AutoPopDelay = 60000,
                ToolTipIcon  = ToolTipIcon.Info
            };

            DescriptionChanged();

            _contextMenuStrip = new ContextMenuStrip();
            _contextMenuStrip.Items.Add("Modifier");
            _contextMenuStrip.Items.Add("Supprimer");

            _contextMenuStrip.ItemClicked += (object sender, ToolStripItemClickedEventArgs e) =>
            {
                switch (e.ClickedItem.Text)
                {
                case "Modifier":
                    using (var form = new EditTaskForm(_desc))
                    {
                        if (form.ShowDialog() == DialogResult.OK)
                        {
                            _desc.Title       = form.NewTitle;
                            _desc.Description = form.NewDescription;
                            DescriptionChanged();
                            Refresh();
                        }
                    }
                    break;

                case "Supprimer":
                    var parent = (PlanningPanel)Parent;
                    parent.RemoveTask(this);
                    break;
                }
            };

            // events
            _checkBox.Click += (object sender, EventArgs e) =>
            {
                _desc.Done = !_desc.Done;
                Refresh();
            };

            // // //

            Controls.AddRange(new Control[]
            {
                _stickyNote,
                _checkBox
            });

            ContextMenuStrip = _contextMenuStrip;
        }
        public IActionResult editTask([FromForm] EditTaskForm editTaskForm)
        {
            DatabaseService.editTask(editTaskForm.id, editTaskForm.title, editTaskForm.description, editTaskForm.week, editTaskForm.weekDay, HttpContext.Session.GetString("username"));

            return(RedirectToPage("/todo"));
        }