Ejemplo n.º 1
0
 /// <summary>
 /// Fills an List of tasks with a full hierarchy.
 /// </summary>
 /// <param name="parent">Parent task</param>
 /// <param name="tasks">List of tasks, already initialized</param>
 private static void CollectHierarchy(Task parent, List <Task> tasks)
 {
     if (tasks != null)
     {
         tasks.Add(parent);
     }
     foreach (Task child in Todomoo.GetChildrenTasks(parent))
     {
         CollectHierarchy(child, tasks);
     }
 }
Ejemplo n.º 2
0
        void PopulatePaymentCombo()
        {
            ArrayList payment_types = Todomoo.GetPaymentTypes();

            foreach (string payment_type in payment_types)
            {
                cmbPaymentType.Items.Add(payment_type);
            }
            if (cmbPaymentType.Items.Count > 0)
            {
                cmbPaymentType.SelectedIndex = 0;
            }
        }
Ejemplo n.º 3
0
        void BtnSumTimersClick(object sender, EventArgs e)
        {
            int timer = 0;

            foreach (Task t in Todomoo.GetChildrenTasks(task))
            {
                try {
                    timer += t.Timer;
                } catch { }
            }
            try {
                numTimerS.Value = timer % 60;
                numTimerM.Value = ((timer - numTimerS.Value) / 60) % 60;
                numTimerH.Value = (timer - numTimerS.Value - numTimerM.Value * 60) / (60 * 60);
            } catch { }
        }
Ejemplo n.º 4
0
        void BtnSumPriceClick(object sender, EventArgs e)
        {
            float    sum  = 0;
            DateTime last = DateTime.MinValue;

            foreach (Task t in Todomoo.GetChildrenTasks(task))
            {
                try {
                    sum += t.Price;
                    if (t.Paid > last)
                    {
                        last = t.Paid;
                    }
                } catch { }
            }
            numPrice.Value = (Decimal)sum;
            if (last != DateTime.MinValue)
            {
                dtPaid.Value = last;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Update properties of the Task object.
        /// </summary>
        public bool Save()
        {
            // Check compulsory fields
            if (txtName.Text == "")
            {
                Utils.MsgDialog.Warning(Lang.Get("invalid_entry"), Lang.Get("warning"));
                tabs.SelectedTab = tabGeneral;
                txtName.Focus();
                return(false);
            }

            // Check if there is no category
            if (cmbCategory.Enabled == false)
            {
                Utils.MsgDialog.Warning(Lang.Get("category_must_create"), Lang.Get("warning"));
                tabs.SelectedTab = tabGeneral;
                if (btnAddCategory.Visible && btnAddCategory.Enabled)
                {
                    btnAddCategory.Focus();
                }
                return(false);
            }

            // Update fields from the GUI (General)
            task.Name = txtName.Text;
            if (txtDescription.Text != "")
            {
                task.Description = txtDescription.Text;
            }
            else
            {
                task.RemoveDescription();
            }
            task.Colour   = (Color)(((ImageComboItem)cmbColour.SelectedItem).Tag);
            task.Priority = cmbPriority.SelectedIndex;

            // Category switch
            if (task.IsRoot())
            {
                int newCategory = (int)(((ImageComboItem)cmbCategory.SelectedItem).Tag);
                if (newCategory != task.CategoryId)
                {
                    Todomoo.ChangeCategoryToHierarchy(task, newCategory);
                }
            }

            // Update fields from the GUI (Dates and time)
            task.CreationDate = dtCreationDate.Value;
            if (!chkDueDateNot.Checked)
            {
                task.DueDate = dtDueDate.Value;
            }
            else
            {
                task.RemoveDueDate();
            }
            if (!chkCompletedNot.Checked)
            {
                task.Completed = dtCompleted.Value;
            }
            else
            {
                task.RemoveCompleted();
            }
            if (!task.IsTimerRunning())
            {
                if (chkUseTimer.Checked)
                {
                    task.Timer = (int)numTimerS.Value + (int)numTimerM.Value * 60 + (int)numTimerH.Value * 60 * 60;
                }
                else
                {
                    task.RemoveTimer();
                }
            }

            // Update fields from the GUI (Payment)
            if (!chkPriceNot.Checked)
            {
                task.PricingByHour = chkPerHour.Checked;
                if (task.PricingByHour)
                {
                    task.PriceByHour = (float)numPrice.Value;
                }
                else
                {
                    task.Price = (float)numPrice.Value;
                }
            }
            else
            {
                task.RemovePrice();
            }
            if ((!chkPaidNot.Checked) && (!chkPriceNot.Checked))
            {
                task.Paid = dtPaid.Value;
            }
            else
            {
                task.RemovePaid();
            }
            if ((!chkPaidNot.Checked) && (!chkPriceNot.Checked))
            {
                task.Payment = cmbPaymentType.Text;
            }
            else
            {
                task.RemovePayment();
            }
            if (txtPaymentNote.Text != "")
            {
                task.PaymentNote = txtPaymentNote.Text;
            }
            else
            {
                task.RemovePaymentNote();
            }

            // Say to the task object the notes to update
            ArrayList pending_notes = new ArrayList();

            foreach (Control item in accordion.Controls)
            {
                if (item is AccordionItem)
                {
                    try { pending_notes.Add((Note)item.Tag); } catch { }
                }
            }
            task.SetUnsavedNotes(pending_notes);

            return(true);
        }