private void butOK_Click(object sender, System.EventArgs e)
 {
     if (textDateTL.errorProvider1.GetError(textDateTL) != ""
         )
     {
         MessageBox.Show(Lan.g(this, "Please fix data entry errors first."));
         return;
     }
     Cur.Descript = textDescript.Text;
     Cur.DateTL   = PIn.PDate(textDateTL.Text);
     Cur.DateType = (TaskDateType)listDateType.SelectedIndex;
     if (!checkFromNum.Checked)            //user unchecked the box
     {
         Cur.FromNum = 0;
     }
     Cur.ObjectType = (TaskObjectType)listObjectType.SelectedIndex;
     try{
         TaskLists.InsertOrUpdate(Cur, IsNew);
     }
     catch (Exception ex) {
         MessageBox.Show(ex.Message);
         return;
     }
     DialogResult = DialogResult.OK;
 }
Example #2
0
 ///<summary>A recursive function that duplicates an entire existing TaskList.  For the initial loop, make changes to the original taskList before passing it in.  That way, Date and type are only set in initial loop.  All children preserve original dates and types.  The isRepeating value will be applied in all loops.  Also, make sure to change the parent num to the new one before calling this function.  The taskListNum will always change, because we are inserting new record into database.</summary>
 private void DuplicateExistingList(TaskList newList, bool isInMain)
 {
     //get all children:
     TaskList[] childLists = TaskLists.Refresh(newList.TaskListNum, DateTime.MinValue, TaskDateType.None, newList.IsRepeating);
     Task[]     childTasks = Tasks.Refresh(newList.TaskListNum, DateTime.MinValue, TaskDateType.None, newList.IsRepeating);
     TaskLists.InsertOrUpdate(newList, true);
     //now we have a new taskListNum to work with
     for (int i = 0; i < childLists.Length; i++)
     {
         childLists[i].Parent = newList.TaskListNum;
         if (newList.IsRepeating)
         {
             childLists[i].IsRepeating = true;
             childLists[i].DateTL      = DateTime.MinValue;             //never a date
         }
         else
         {
             childLists[i].IsRepeating = false;
         }
         childLists[i].FromNum = 0;
         if (!isInMain)
         {
             childLists[i].DateTL   = DateTime.MinValue;
             childLists[i].DateType = TaskDateType.None;
         }
         DuplicateExistingList(childLists[i], isInMain);
     }
     for (int i = 0; i < childTasks.Length; i++)
     {
         childTasks[i].TaskListNum = newList.TaskListNum;
         if (newList.IsRepeating)
         {
             childTasks[i].IsRepeating = true;
             childTasks[i].DateTask    = DateTime.MinValue;               //never a date
         }
         else
         {
             childTasks[i].IsRepeating = false;
         }
         childTasks[i].FromNum = 0;
         if (!isInMain)
         {
             childTasks[i].DateTask = DateTime.MinValue;
             childTasks[i].DateType = TaskDateType.None;
         }
         Tasks.InsertOrUpdate(childTasks[i], true);
     }
 }