Example #1
0
 ///<summary>Throws exception if any child tasklists or tasks.</summary>
 public static void Delete(TaskList tlist)
 {
     if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
         Meth.GetVoid(MethodBase.GetCurrentMethod(),tlist);
         return;
     }
     string command="SELECT COUNT(*) FROM tasklist WHERE Parent="+POut.Long(tlist.TaskListNum);
     DataTable table=Db.GetTable(command);
     if(table.Rows[0][0].ToString()!="0"){
         throw new Exception(Lans.g("TaskLists","Not allowed to delete task list because it still has child lists attached."));
     }
     command="SELECT COUNT(*) FROM task WHERE TaskListNum="+POut.Long(tlist.TaskListNum);
     table=Db.GetTable(command);
     if(table.Rows[0][0].ToString()!="0"){
         throw new Exception(Lans.g("TaskLists","Not allowed to delete task list because it still has child tasks attached."));
     }
     command="SELECT COUNT(*) FROM userod WHERE TaskListInBox="+POut.Long(tlist.TaskListNum);
     table=Db.GetTable(command);
     if(table.Rows[0][0].ToString()!="0"){
         throw new Exception(Lans.g("TaskLists","Not allowed to delete task list because it is attached to a user inbox."));
     }
     command= "DELETE from tasklist WHERE TaskListNum = '"
         +POut.Long(tlist.TaskListNum)+"'";
      			Db.NonQ(command);
 }
Example #2
0
		///<summary></summary>
		public FormTaskListEdit(TaskList cur)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			Cur=cur;
			Lan.F(this);
		}
Example #3
0
        ///<summary>Build the full path to the passed in task list.  Returns the string in the standard Windows path format.</summary>
        public static string GetFullPath(long tasklistNum, List <TaskList> listTaskLists = null)
        {
            //No need to check RemotingRole; no call to db.
            StringBuilder taskListPath = new StringBuilder();
            TaskList      curTaskList  = null;

            if (listTaskLists != null)
            {
                curTaskList = listTaskLists.FirstOrDefault(x => x.TaskListNum == tasklistNum);
            }
            else
            {
                curTaskList = GetOne(tasklistNum);
            }
            if (curTaskList == null)
            {
                return("");
            }
            taskListPath.Append(curTaskList.Descript);
            while (curTaskList.Parent != 0)
            {
                if (listTaskLists != null)
                {
                    curTaskList = listTaskLists.FirstOrDefault(x => x.TaskListNum == curTaskList.Parent);
                }
                else
                {
                    curTaskList = GetOne(curTaskList.Parent);
                }
                if (curTaskList == null)
                {
                    break;
                }
                taskListPath.Insert(0, curTaskList.Descript + "/");
            }
            return(taskListPath.ToString());
        }
Example #4
0
        public static string GetChangesDescription(TaskHist taskCur, TaskHist taskNext)
        {
            if (taskCur.Descript.StartsWith("This task was cut from task list ") || taskCur.Descript.StartsWith("This task was copied from task "))
            {
                return(taskCur.Descript);
            }
            if (taskCur.DateTimeEntry == DateTime.MinValue)
            {
                return(Lans.g("TaskHists", "New task."));
            }
            StringBuilder strb = new StringBuilder();

            strb.Append("");
            if (taskNext.TaskListNum != taskCur.TaskListNum)
            {
                string   descOne  = Lans.g("TaskHists", "(DELETED)");
                string   descTwo  = Lans.g("TaskHists", "(DELETED)");
                TaskList taskList = TaskLists.GetOne(taskCur.TaskListNum);
                if (taskList != null)
                {
                    descOne = taskList.Descript;
                }
                taskList = TaskLists.GetOne(taskNext.TaskListNum);
                if (taskList != null)
                {
                    descTwo = taskList.Descript;
                }
                strb.Append(Lans.g("TaskHists", "Task list changed from") + " " + descOne + " " + Lans.g("TaskHists", "to") + " " + descTwo + ".\r\n");
            }
            if (taskNext.ObjectType != taskCur.ObjectType)
            {
                strb.Append(Lans.g("TaskHists", "Task attachment changed from") + " "
                            + taskCur.ObjectType.ToString() + " " + Lans.g("TaskHists", "to") + " " + taskNext.ObjectType.ToString() + ".\r\n");
            }
            if (taskNext.KeyNum != taskCur.KeyNum)
            {
                strb.Append(Lans.g("TaskHists", "Task account attachment changed.") + "\r\n");
            }
            if (taskNext.Descript != taskCur.Descript && !taskNext.Descript.StartsWith("This task was cut from task list ") &&
                !taskNext.Descript.StartsWith("This task was copied from task "))
            {
                //We change the description of a task when it is cut/copied.
                //This prevents the history grid from showing a description changed when it wasn't changed by the user.
                strb.Append(Lans.g("TaskHists", "Task description changed.") + "\r\n");
            }
            if (taskNext.TaskStatus != taskCur.TaskStatus)
            {
                strb.Append(Lans.g("TaskHists", "Task status changed from") + " "
                            + taskCur.TaskStatus.ToString() + " " + Lans.g("TaskHists", "to") + " " + taskNext.TaskStatus.ToString() + ".\r\n");
            }
            if (taskNext.DateTimeEntry != taskCur.DateTimeEntry)
            {
                strb.Append(Lans.g("TaskHists", "Task date added changed from") + " "
                            + taskCur.DateTimeEntry.ToString()
                            + " " + Lans.g("TaskHists", "to") + " "
                            + taskNext.DateTimeEntry.ToString() + ".\r\n");
            }
            if (taskNext.UserNum != taskCur.UserNum)
            {
                strb.Append(Lans.g("TaskHists", "Task author changed from ")
                            + Userods.GetUser(taskCur.UserNum).UserName
                            + " " + Lans.g("TaskHists", "to") + " "
                            + Userods.GetUser(taskNext.UserNum).UserName + ".\r\n");
            }
            if (taskNext.DateTimeFinished != taskCur.DateTimeFinished)
            {
                strb.Append(Lans.g("TaskHists", "Task date finished changed from") + " "
                            + taskCur.DateTimeFinished.ToString()
                            + " " + Lans.g("TaskHists", "to") + " "
                            + taskNext.DateTimeFinished.ToString() + ".\r\n");
            }
            if (taskNext.PriorityDefNum != taskCur.PriorityDefNum)
            {
                strb.Append(Lans.g("TaskHists", "Task priority changed from") + " "
                            + Defs.GetDef(DefCat.TaskPriorities, taskCur.PriorityDefNum).ItemName
                            + " " + Lans.g("TaskHists", "to") + " "
                            + Defs.GetDef(DefCat.TaskPriorities, taskNext.PriorityDefNum).ItemName + ".\r\n");
            }
            if (taskCur.IsNoteChange)              //Using taskOld because the notes changed from the old one to the new one.
            {
                strb.Append(Lans.g("TaskHists", "Task notes changed."));
            }
            return(strb.ToString());
        }
Example #5
0
		///<summary>Task gets inserted ahead of time, then frequently altered before passing in here.  The taskOld that is passed in should be the task as it is in the database.  When saving, taskOld will be compared with db to make sure no changes.</summary>
		public FormTaskEdit(Task taskCur,Task taskOld) {
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			TaskCur=taskCur;
			TaskOld=taskOld;
			TaskListCur=TaskLists.GetOne(taskCur.TaskListNum);
			Lan.F(this);
		}
Example #6
0
		///<summary>Send to another user.</summary>
		private void butSend_Click(object sender,EventArgs e) {
			//This button is always present.
			if(OwnedForms.Length>0) {
				MsgBox.Show(this,"One or more task note edit windows are open and must be closed.");
				return;
			}
			if(listObjectType.SelectedIndex==(int)TaskObjectType.Patient) {
				FormTaskListSelect FormT=new FormTaskListSelect(TaskObjectType.Patient);
				FormT.ShowDialog();
				if(FormT.DialogResult!=DialogResult.OK) {
					return;
				}
				TaskCur.TaskListNum=FormT.SelectedTaskListNum;
				TaskListCur=TaskLists.GetOne(TaskCur.TaskListNum);
				textTaskList.Text=TaskListCur.Descript;
				if(!SaveCur()) {
					return;
				}
				DataValid.SetInvalidTask(TaskCur.TaskNum,true);//popup
			}
			else {//to an in-box
				FormTaskSendUser FormT=new FormTaskSendUser();
				FormT.ShowDialog();
				if(FormT.DialogResult!=DialogResult.OK) {
					return;
				}
				TaskCur.TaskListNum=FormT.TaskListNum;
				TaskListCur=TaskLists.GetOne(TaskCur.TaskListNum);
				textTaskList.Text=TaskListCur.Descript;
				if(!SaveCur()) {
					return;
				}
				DataValid.SetInvalidTask(TaskCur.TaskNum,true);//popup
			}
			DialogResult=DialogResult.OK;
			Close();
		}
Example #7
0
 ///<summary>Send to another user.</summary>
 private void butSend_Click(object sender,EventArgs e)
 {
     //This button is always present.
     if(listObjectType.SelectedIndex==(int)TaskObjectType.Patient) {
         FormTaskListSelect FormT=new FormTaskListSelect(TaskObjectType.Patient);
         FormT.ShowDialog();
         if(FormT.DialogResult!=DialogResult.OK) {
             return;
         }
         TaskCur.TaskListNum=FormT.SelectedTaskListNum;
         TaskListCur=TaskLists.GetOne(TaskCur.TaskListNum);
         textTaskList.Text=TaskListCur.Descript;
         if(!SaveCur()) {
             return;
         }
         DataValid.SetInvalidTask(TaskCur.TaskNum,true);//popup
     }
     else {//to an in-box
         FormTaskSendUser FormT=new FormTaskSendUser();
         FormT.ShowDialog();
         if(FormT.DialogResult!=DialogResult.OK) {
             return;
         }
         TaskCur.TaskListNum=FormT.TaskListNum;
         TaskListCur=TaskLists.GetOne(TaskCur.TaskListNum);
         textTaskList.Text=TaskListCur.Descript;
         if(!SaveCur()) {
             return;
         }
         DataValid.SetInvalidTask(TaskCur.TaskNum,true);//popup
     }
     DialogResult=DialogResult.OK;
     Close();
 }
Example #8
0
		///<summary></summary>
		public static long Insert(TaskList tlist) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				tlist.TaskListNum=Meth.GetLong(MethodBase.GetCurrentMethod(),tlist);
				return tlist.TaskListNum;
			}
			if(tlist.IsRepeating && tlist.DateTL.Year>1880) {
				throw new Exception(Lans.g("TaskLists","TaskList cannot be tagged repeating and also have a date."));
			}
			if(tlist.Parent==0 && tlist.DateTL.Year>1880 && tlist.DateType==TaskDateType.None) {//it would not show anywhere, so it would be 'lost'
				throw new Exception(Lans.g("TaskLists","A TaskList with a date must also have a type selected."));
			}
			if(tlist.IsRepeating && tlist.Parent!=0 && tlist.DateType!=TaskDateType.None) {//In repeating, children not allowed to repeat.
				throw new Exception(Lans.g("TaskLists","In repeating tasklists, only the main parents can have a task status."));
			}
			return Crud.TaskListCrud.Insert(tlist);
		}
Example #9
0
 /// <summary>False if taskList has no parent, all of taskList's ancestors are not archived, or taskList ancestor can't be found.</summary>
 public static bool IsAncestorTaskListArchived(ref Dictionary <long, TaskList> dictAllTaskLists, TaskList taskList, bool isDictionaryRefreshed = false)
 {
     //No need to check RemotingRole; no call to db.
     if (taskList.Parent == 0)           //If list has no parent return false.
     {
         return(false);
     }
     if (dictAllTaskLists.ContainsKey(taskList.Parent))                                       //If list parent is in dictionary
     {
         if (dictAllTaskLists[taskList.Parent].TaskListStatus == TaskListStatusEnum.Archived) //and parent is archived return true
         {
             return(true);
         }
         //Check if grandparent is archived with current value of isDictionaryRefreshed
         return(IsAncestorTaskListArchived(ref dictAllTaskLists, dictAllTaskLists[taskList.Parent], isDictionaryRefreshed));
     }
     if (!isDictionaryRefreshed)             //Refresh dictionary once in recursion if parent is missing from dictionary and try again with current list
     {
         dictAllTaskLists = GetAll().ToDictionary(x => x.TaskListNum);
         return(IsAncestorTaskListArchived(ref dictAllTaskLists, taskList, true));
     }
     return(false);           //List was refreshed and parent couldn't be found.
 }
Example #10
0
		private void Copy_Clicked() {
			if(clickedI < TaskListsList.Count) {//is list
				ClipTaskList=TaskListsList[clickedI].Copy();
				ClipTask=null;
			}
			else {//task
				ClipTaskList=null;
				ClipTask=TasksList[clickedI-TaskListsList.Count].Copy();
			}
			WasCut=false;
		}
Example #11
0
		private void AddList_Clicked() {
			if(tabContr.SelectedTab==tabUser && TreeHistory.Count==0) {//trunk of user tab
				MsgBox.Show(this,"Not allowed to add a task list to the trunk of the user tab.  Either use the subscription feature, or add it to a child list.");
				return;
			}
			if(tabContr.SelectedTab==tabNew) {//new tab
				MsgBox.Show(this,"Not allowed to add items to the 'New' tab.");
				return;
			}
			TaskList cur=new TaskList();
			//if this is a child of any other taskList
			if(TreeHistory.Count>0) {
				cur.Parent=TreeHistory[TreeHistory.Count-1].TaskListNum;
			}
			else {
				cur.Parent=0;
				if(tabContr.SelectedTab==tabDate) {
					cur.DateTL=cal.SelectionStart;
					cur.DateType=TaskDateType.Day;
				}
				else if(tabContr.SelectedTab==tabWeek) {
					cur.DateTL=cal.SelectionStart;
					cur.DateType=TaskDateType.Week;
				}
				else if(tabContr.SelectedTab==tabMonth) {
					cur.DateTL=cal.SelectionStart;
					cur.DateType=TaskDateType.Month;
				}
			}
			if(tabContr.SelectedTab==tabRepeating) {
				cur.IsRepeating=true;
			}
			FormTaskListEdit FormT=new FormTaskListEdit(cur);
			FormT.IsNew=true;
			FormT.ShowDialog();
			FillGrid();
		}
Example #12
0
		///<summary>A recursive function that checks every child in a list IsFromRepeating.  If any are marked complete, then it returns true, signifying that this list should be immune from being deleted since it's already in use.</summary>
		private bool AnyAreMarkedComplete(TaskList list) {
			//get all children:
			List<TaskList> childLists=TaskLists.RefreshChildren(list.TaskListNum,Security.CurUser.UserNum,0);
			List<Task> childTasks=Tasks.RefreshChildren(list.TaskListNum,true,DateTime.MinValue,Security.CurUser.UserNum,0);
			for(int i=0;i<childLists.Count;i++) {
				if(AnyAreMarkedComplete(childLists[i])) {
					return true;
				}
			}
			for(int i=0;i<childTasks.Count;i++) {
				if(childTasks[i].TaskStatus==TaskStatusEnum.Done) {
					return true;
				}
			}
			return false;
		}
Example #13
0
		///<summary>A recursive function that deletes the specified list and all children.</summary>
		private void DeleteEntireList(TaskList list) {
			//get all children:
			List<TaskList> childLists=TaskLists.RefreshChildren(list.TaskListNum,Security.CurUser.UserNum,0);
			List<Task> childTasks=Tasks.RefreshChildren(list.TaskListNum,true,DateTime.MinValue,Security.CurUser.UserNum,0);
			for(int i=0;i<childLists.Count;i++) {
				DeleteEntireList(childLists[i]);
			}
			for(int i=0;i<childTasks.Count;i++) {
				Tasks.Delete(childTasks[i].TaskNum);
			}
			try {
				TaskLists.Delete(list);
			}
			catch(Exception e) {
				MessageBox.Show(e.Message);
			}
		}
Example #14
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.  Sending null in for oldList will cause all existing subscriptions to the old list to be deleted.  In order for the new list to have the same subscriptions as the old list (as in a Cut/Paste), send in the old task list.</summary>
		private void DuplicateExistingList(TaskList newList,TaskList oldList,bool isInMainOrUser) {
			//get all children:
			List<TaskList> childLists=TaskLists.RefreshChildren(newList.TaskListNum,Security.CurUser.UserNum,0);
			List<Task> childTasks=Tasks.RefreshChildren(newList.TaskListNum,true,DateTime.MinValue,Security.CurUser.UserNum,0);
			TaskLists.Insert(newList);
			if(oldList!=null) {
				TaskSubscriptions.UpdateAllSubs(oldList.TaskListNum,newList.TaskListNum);
			}
			//now we have a new taskListNum to work with
			for(int i=0;i<childLists.Count;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(!isInMainOrUser) {
					childLists[i].DateTL=DateTime.MinValue;
					childLists[i].DateType=TaskDateType.None;
				}
				if(oldList==null) {
					DuplicateExistingList(childLists[i],null,isInMainOrUser);//delete any existing subscriptions
				}
				else {
					DuplicateExistingList(childLists[i],childLists[i],isInMainOrUser);
				}
			}
			for(int i=0;i<childTasks.Count;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(!isInMainOrUser) {
					childTasks[i].DateTask=DateTime.MinValue;
					childTasks[i].DateType=TaskDateType.None;
				}
				List<TaskNote> noteList=TaskNotes.GetForTask(childTasks[i].TaskNum);
				long newTaskNum=Tasks.Insert(childTasks[i]);
				for(int t=0;t<noteList.Count;t++) {
					noteList[t].TaskNum=newTaskNum;
					TaskNotes.Insert(noteList[t]);//Creates the new note with the current datetime stamp.
					TaskNotes.Update(noteList[t]);//Restores the historical datetime for the note.
				}
			}
		}
Example #15
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 isInMainOrUser)
 {
     //get all children:
     List<TaskList> childLists=TaskLists.RefreshChildren(newList.TaskListNum,Security.CurUser.UserNum,0);
     List<Task> childTasks=Tasks.RefreshChildren(newList.TaskListNum,true,DateTime.MinValue,Security.CurUser.UserNum,0);
     TaskLists.Insert(newList);
     //now we have a new taskListNum to work with
     for(int i=0;i<childLists.Count;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(!isInMainOrUser) {
             childLists[i].DateTL=DateTime.MinValue;
             childLists[i].DateType=TaskDateType.None;
         }
         DuplicateExistingList(childLists[i],isInMainOrUser);
     }
     for(int i=0;i<childTasks.Count;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(!isInMainOrUser) {
             childTasks[i].DateTask=DateTime.MinValue;
             childTasks[i].DateType=TaskDateType.None;
         }
         List<TaskNote> noteList=TaskNotes.GetForTask(childTasks[i].TaskNum);
         long newTaskNum=Tasks.Insert(childTasks[i]);
         for(int t=0;t<noteList.Count;t++) {
             noteList[t].TaskNum=newTaskNum;
             TaskNotes.Insert(noteList[t]);
         }
     }
 }