示例#1
0
 private bool SaveCur()
 {
     if (textDateTask.errorProvider1.GetError(textDateTask) != ""
         )
     {
         MessageBox.Show(Lan.g(this, "Please fix data entry errors first."));
         return(false);
     }
     Cur.TaskStatus    = checkTaskStatus.Checked;
     Cur.DateTimeEntry = PIn.PDateT(textDateTimeEntry.Text);
     Cur.Descript      = textDescript.Text;
     Cur.DateTask      = PIn.PDate(textDateTask.Text);
     Cur.DateType      = (TaskDateType)listDateType.SelectedIndex;
     if (!checkFromNum.Checked)            //user unchecked the box. Never allowed to check if initially unchecked
     {
         Cur.FromNum = 0;
     }
     //ObjectType already handled
     //Cur.KeyNum already handled
     try{
         Tasks.InsertOrUpdate(Cur, IsNew);
     }
     catch (Exception ex) {
         MessageBox.Show(ex.Message);
         return(false);
     }
     return(true);
 }
示例#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);
     }
 }
示例#3
0
        private void listMain_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            ListViewItem ClickedItem = listMain.GetItemAt(e.X, e.Y);

            if (ClickedItem == null)
            {
                return;
            }
            clickedI = ClickedItem.Index;
            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            if (clickedI < TaskListsList.Length)             //is list
            {
                TreeHistory.Add(TaskListsList[clickedI]);
                FillTree();
                FillMain();
                return;
            }
            //check tasks off
            if (e.X > 16)
            {
                return;
            }
            Task task = TasksList[clickedI - TaskListsList.Length].Copy();

            task.TaskStatus = !task.TaskStatus;
            try {
                Tasks.InsertOrUpdate(task, false);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
                return;
            }
            FillMain();
        }
示例#4
0
        private void OnPaste_Click()
        {
            if (ClipTaskList != null)           //a taskList is on the clipboard
            {
                TaskList newTL = ClipTaskList.Copy();
                if (TreeHistory.Count > 0)               //not on main trunk
                {
                    newTL.Parent = ((TaskList)TreeHistory[TreeHistory.Count - 1]).TaskListNum;
                    switch (tabContr.SelectedIndex)
                    {
                    case 0:                            //main
                        //even though usually only trunks are dated, we will leave the date alone in main
                        //category since user may wish to preserve it. All other children get date cleared.
                        break;

                    case 1:                               //repeating
                        newTL.DateTL = DateTime.MinValue; //never a date
                        //leave dateType alone, since that affects how it repeats
                        break;

                    case 2:                                 //day
                    case 3:                                 //week
                    case 4:                                 //month
                        newTL.DateTL   = DateTime.MinValue; //children do not get dated
                        newTL.DateType = TaskDateType.None; //this doesn't matter either for children
                        break;
                    }
                }
                else                  //one of the main trunks
                {
                    newTL.Parent = 0;
                    switch (tabContr.SelectedIndex)
                    {
                    case 0:                            //main
                        newTL.DateTL   = DateTime.MinValue;
                        newTL.DateType = TaskDateType.None;
                        break;

                    case 1:                               //repeating
                        newTL.DateTL = DateTime.MinValue; //never a date
                        //newTL.DateType=TaskDateType.None;//leave alone
                        break;

                    case 2:                            //day
                        newTL.DateTL   = cal.SelectionStart;
                        newTL.DateType = TaskDateType.Day;
                        break;

                    case 3:                            //week
                        newTL.DateTL   = cal.SelectionStart;
                        newTL.DateType = TaskDateType.Week;
                        break;

                    case 4:                            //month
                        newTL.DateTL   = cal.SelectionStart;
                        newTL.DateType = TaskDateType.Month;
                        break;
                    }
                }
                if (tabContr.SelectedIndex == 1)               //repeating
                {
                    newTL.IsRepeating = true;
                }
                else
                {
                    newTL.IsRepeating = false;
                }
                newTL.FromNum = 0;              //always
                if (tabContr.SelectedIndex == 0)
                {
                    DuplicateExistingList(newTL, true);
                }
                else
                {
                    DuplicateExistingList(newTL, false);
                }
            }
            if (ClipTask != null)           //a task is on the clipboard
            {
                Task newT = ClipTask.Copy();
                if (TreeHistory.Count > 0)               //not on main trunk
                {
                    newT.TaskListNum = ((TaskList)TreeHistory[TreeHistory.Count - 1]).TaskListNum;
                    switch (tabContr.SelectedIndex)
                    {
                    case 0:                            //main
                        //even though usually only trunks are dated, we will leave the date alone in main
                        //category since user may wish to preserve it. All other children get date cleared.
                        break;

                    case 1:                                //repeating
                        newT.DateTask = DateTime.MinValue; //never a date
                        //leave dateType alone, since that affects how it repeats
                        break;

                    case 2:                                //day
                    case 3:                                //week
                    case 4:                                //month
                        newT.DateTask = DateTime.MinValue; //children do not get dated
                        newT.DateType = TaskDateType.None; //this doesn't matter either for children
                        break;
                    }
                }
                else                  //one of the main trunks
                {
                    newT.TaskListNum = 0;
                    switch (tabContr.SelectedIndex)
                    {
                    case 0:                            //main
                        newT.DateTask = DateTime.MinValue;
                        newT.DateType = TaskDateType.None;
                        break;

                    case 1:                                //repeating
                        newT.DateTask = DateTime.MinValue; //never a date
                        //newTL.DateType=TaskDateType.None;//leave alone
                        break;

                    case 2:                            //day
                        newT.DateTask = cal.SelectionStart;
                        newT.DateType = TaskDateType.Day;
                        break;

                    case 3:                            //week
                        newT.DateTask = cal.SelectionStart;
                        newT.DateType = TaskDateType.Week;
                        break;

                    case 4:                            //month
                        newT.DateTask = cal.SelectionStart;
                        newT.DateType = TaskDateType.Month;
                        break;
                    }
                }
                if (tabContr.SelectedIndex == 1)               //repeating
                {
                    newT.IsRepeating = true;
                }
                else
                {
                    newT.IsRepeating = false;
                }
                newT.FromNum = 0;              //always
                Tasks.InsertOrUpdate(newT, true);
            }
            if (WasCut)
            {
                if (ClipTaskList != null)
                {
                    DeleteEntireList(ClipTaskList);
                }
                else if (ClipTask != null)
                {
                    Tasks.Delete(ClipTask);
                }
            }
            FillMain();
        }
示例#5
0
        private void FillMain()
        {
            int      parent;
            DateTime date;

            if (TreeHistory.Count > 0)           //not on main trunk
            {
                parent = ((TaskList)TreeHistory[TreeHistory.Count - 1]).TaskListNum;
                date   = DateTime.MinValue;
            }
            else              //one of the main trunks
            {
                parent = 0;
                date   = cal.SelectionStart;
            }
            RefreshMainLists(parent, date);
            if (TreeHistory.Count == 0 &&      //main trunk
                (tabContr.SelectedIndex == 2 || tabContr.SelectedIndex == 3 || tabContr.SelectedIndex == 4))               //any of the dated groups
            {
                //clear any lists which are derived from a repeating list and which do not have any itmes checked off
                bool changeMade = false;
                for (int i = 0; i < TaskListsList.Length; i++)
                {
                    if (TaskListsList[i].FromNum == 0)                   //ignore because not derived from a repeating list
                    {
                        continue;
                    }
                    if (!AnyAreMarkedComplete(TaskListsList[i]))
                    {
                        DeleteEntireList(TaskListsList[i]);
                        changeMade = true;
                    }
                }
                //clear any tasks which are derived from a repeating tast and which are not checked off
                for (int i = 0; i < TasksList.Length; i++)
                {
                    if (TasksList[i].FromNum == 0)
                    {
                        continue;
                    }
                    if (!TasksList[i].TaskStatus)
                    {
                        Tasks.Delete(TasksList[i]);
                        changeMade = true;
                    }
                }
                if (changeMade)
                {
                    RefreshMainLists(parent, date);
                }
                //now add back any repeating lists and tasks that meet the criteria
                //Get lists of all repeating lists and tasks of one type.  We will pick items from these two lists.
                TaskList[] repeatingLists = new TaskList[0];
                Task[]     repeatingTasks = new Task[0];
                switch (tabContr.SelectedIndex)
                {
                case 2:
                    repeatingLists = TaskLists.Refresh(-1, DateTime.MinValue, TaskDateType.Day, true);
                    repeatingTasks = Tasks.Refresh(-1, DateTime.MinValue, TaskDateType.Day, true);
                    break;

                case 3:
                    repeatingLists = TaskLists.Refresh(-1, DateTime.MinValue, TaskDateType.Week, true);
                    repeatingTasks = Tasks.Refresh(-1, DateTime.MinValue, TaskDateType.Week, true);
                    break;

                case 4:
                    repeatingLists = TaskLists.Refresh(-1, DateTime.MinValue, TaskDateType.Month, true);
                    repeatingTasks = Tasks.Refresh(-1, DateTime.MinValue, TaskDateType.Month, true);
                    break;
                }
                //loop through list and add back any that meet criteria.
                changeMade = false;
                bool alreadyExists;
                for (int i = 0; i < repeatingLists.Length; i++)
                {
                    //if already exists, skip
                    alreadyExists = false;
                    for (int j = 0; j < TaskListsList.Length; j++)               //loop through Main list
                    {
                        if (TaskListsList[j].FromNum == repeatingLists[i].TaskListNum)
                        {
                            alreadyExists = true;
                            break;
                        }
                    }
                    if (alreadyExists)
                    {
                        continue;
                    }
                    //otherwise, duplicate the list
                    repeatingLists[i].DateTL      = date;
                    repeatingLists[i].FromNum     = repeatingLists[i].TaskListNum;
                    repeatingLists[i].IsRepeating = false;
                    repeatingLists[i].Parent      = 0;
                    repeatingLists[i].ObjectType  = 0;                 //user will have to set explicitly
                    DuplicateExistingList(repeatingLists[i], true);
                    changeMade = true;
                }
                for (int i = 0; i < repeatingTasks.Length; i++)
                {
                    //if already exists, skip
                    alreadyExists = false;
                    for (int j = 0; j < TasksList.Length; j++)               //loop through Main list
                    {
                        if (TasksList[j].FromNum == repeatingTasks[i].TaskNum)
                        {
                            alreadyExists = true;
                            break;
                        }
                    }
                    if (alreadyExists)
                    {
                        continue;
                    }
                    //otherwise, duplicate the task
                    repeatingTasks[i].DateTask    = date;
                    repeatingTasks[i].FromNum     = repeatingTasks[i].TaskNum;
                    repeatingTasks[i].IsRepeating = false;
                    repeatingTasks[i].TaskListNum = 0;
                    Tasks.InsertOrUpdate(repeatingTasks[i], true);
                    changeMade = true;
                }
                if (changeMade)
                {
                    RefreshMainLists(parent, date);
                }
            }            //if main trunk on dated group
            listMain.Items.Clear();
            ListViewItem item;
            string       dateStr = "";

            for (int i = 0; i < TaskListsList.Length; i++)
            {
                dateStr = "";
                if (TaskListsList[i].DateTL.Year > 1880 &&
                    tabContr.SelectedIndex == 0)                     //main
                {
                    //dateStr=TaskListsList[i].DateTL.ToShortDateString()+" - ";
                    if (TaskListsList[i].DateType == TaskDateType.Day)
                    {
                        dateStr = TaskListsList[i].DateTL.ToShortDateString() + " - ";
                    }
                    else if (TaskListsList[i].DateType == TaskDateType.Week)
                    {
                        dateStr = Lan.g(this, "Week of") + " " + TaskListsList[i].DateTL.ToShortDateString() + " - ";
                    }
                    else if (TaskListsList[i].DateType == TaskDateType.Month)
                    {
                        dateStr = TaskListsList[i].DateTL.ToString("MMMM") + " - ";
                    }
                }
                item             = new ListViewItem(dateStr + TaskListsList[i].Descript, 0);
                item.ToolTipText = item.Text;
                listMain.Items.Add(item);
            }
            string objDesc = "";

            for (int i = 0; i < TasksList.Length; i++)
            {
                //checked=1, unchecked=2
                dateStr = "";
                if (tabContr.SelectedIndex == 0)               //main
                {
                    if (TasksList[i].DateTask.Year > 1880)
                    {
                        if (TasksList[i].DateType == TaskDateType.Day)
                        {
                            dateStr = TasksList[i].DateTask.ToShortDateString() + " - ";
                        }
                        else if (TasksList[i].DateType == TaskDateType.Week)
                        {
                            dateStr = Lan.g(this, "Week of") + " " + TasksList[i].DateTask.ToShortDateString() + " - ";
                        }
                        else if (TasksList[i].DateType == TaskDateType.Month)
                        {
                            dateStr = TasksList[i].DateTask.ToString("MMMM") + " - ";
                        }
                    }
                    else if (TasksList[i].DateTimeEntry.Year > 1880)
                    {
                        dateStr = TasksList[i].DateTimeEntry.ToShortDateString() + " - ";
                    }
                }
                objDesc = "";
                if (TasksList[i].ObjectType == TaskObjectType.Patient)
                {
                    if (TasksList[i].KeyNum != 0)
                    {
                        objDesc = Patients.GetPat(TasksList[i].KeyNum).GetNameLF() + " - ";
                    }
                }
                else if (TasksList[i].ObjectType == TaskObjectType.Appointment)
                {
                    if (TasksList[i].KeyNum != 0)
                    {
                        Appointment AptCur = Appointments.GetOneApt(TasksList[i].KeyNum);
                        if (AptCur != null)
                        {
                            objDesc = Patients.GetPat(AptCur.PatNum).GetNameLF()
                                      + "  " + AptCur.AptDateTime.ToString()
                                      + "  " + AptCur.ProcDescript
                                      + "  " + AptCur.Note
                                      + " - ";
                        }
                    }
                }
                if (TasksList[i].TaskStatus)                 //complete
                {
                    item = new ListViewItem(dateStr + objDesc + TasksList[i].Descript, 1);
                }
                else
                {
                    item = new ListViewItem(dateStr + objDesc + TasksList[i].Descript, 2);
                }
                item.ToolTipText = item.Text;
                listMain.Items.Add(item);
            }
        }