Example #1
0
 private void saveTask()
 {
     if (note != null)
     {
         updateTask();
     }
     else
     {
         Document document = new Document();
         document.setOwner(user.getUsername());
         document.setDocument(txtNote.Text);
         DocumentDTOImplementation.getInstance().save(document);
         Note noteTemp = new Note();
         noteTemp.setAuthor(user.getFullName());
         noteTemp.setDocumentId(document.getId());
         noteTemp.setLastModified(DateTime.Now);
         noteTemp.setTitle(txtTitle.Text);
         NoteDTOImplementation.getInstance().save(noteTemp);
         TaskNote task = new TaskNote();
         task.status   = (Status)Enum.Parse(typeof(Status), statusComboBox.SelectedItem.ToString());
         task.priority = (Priority)Enum.Parse(typeof(Priority), priorityComboBox.SelectedItem.ToString());
         task.noteId   = noteTemp.getId();
         task.dueDate  = dueDatePicker.Value;
         TaskDTOImplementation.getInstance().save(task);
         if (notebook != null)
         {
             notebook.addNote(noteTemp.getId());
             NotebookDTOImplementation.getInstance().update(notebook, DatabaseConstants.COLUMN_NOTESID);
         }
     }
     MessageBox.Show("Task and Note were added succesfully", "Task Added Successfully");
 }
Example #2
0
 private void btnDeleteTask_Click(object sender, EventArgs e)
 {
     if (taskData.SelectedRows.Count > 0)
     {
         if (MessageBox.Show(UserMessages.ARE_YOU_SURE("Delete"), UserMessages.CONFIRMION("Delete"), MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             lastId -= taskData.SelectedRows.Count;
             if (lastId < 0)
             {
                 lastId = 1;
             }
             TaskNote task;
             bool     flag = false;
             foreach (DataGridViewRow row in taskData.SelectedRows)
             {
                 task            = (TaskNote)row.DataBoundItem;
                 undoBufferIndex = (undoBufferIndex + 1) % bufferSize;
                 flag            = taskDTO.delete(task.id);
                 Note noteTemp = NoteDTOImplementation.getInstance().getById(task.noteId);
                 flag &= noteTemp != null;
                 flag &= NoteDTOImplementation.getInstance().delete(task.noteId);
                 flag &= DocumentDTOImplementation.getInstance().delete(noteTemp.getDocumentId());
                 undoBuffer[undoBufferIndex] = task;
                 tasks.Remove(task);
                 UserMessages.messageStatus(flag);
             }
             refreshTaskData();
         }
     }
     else
     {
         MessageBox.Show(UserMessages.EMPTY_OPERATION("Delete"));
     }
 }
 /**
  * Getting the task note by the taskId
  *
  * @taskId : the taskId to search for in the database
  *
  * return a note o if it was found and an null otherwise
  **/
 public Note getNote(String taskId)
 {
     try {
         return(NoteDTOImplementation.getInstance().getById(taskDAO.findNote(taskId)));
     } catch (Exception e) {
         Logging.logInfo(true, e.Message);
         return(new Note());
     }
 }
Example #4
0
 private void refreshTaskData()
 {
     tasks.UnionWith(taskDTO.getAllTasks(lastId.ToString()));
     foreach (TaskNote task in tasks)
     {
         if (String.IsNullOrEmpty(task.document))
         {
             task.document = NoteDTOImplementation.getInstance().getNoteDocument(task.noteId).getDocumentContent();
         }
         if (int.Parse(task.id) > lastId)
         {
             lastId = int.Parse(task.id);
         }
     }
     ++lastId;
     taskData.DataSource = tasks.ToList();
 }
Example #5
0
        private void updateTask()
        {
            Document document = DocumentDTOImplementation.getInstance().getById(note.getDocumentId());

            document.setDocument(txtNote.Text);
            DocumentDTOImplementation.getInstance().update(document, DatabaseConstants.COLUMN_DOCUMENT);
            Note noteTemp = new Note();

            noteTemp.setDocumentId(document.getId());
            noteTemp.setLastModified(DateTime.Now);
            noteTemp.setTitle(txtTitle.Text);
            NoteDTOImplementation.getInstance().update(noteTemp, DatabaseConstants.COLUMN_LASTMODIFIED, DatabaseConstants.COLUMN_TITLE);
            TaskNote task = new TaskNote {
                status   = (Status)Enum.Parse(typeof(Status), statusComboBox.SelectedItem.ToString()),
                priority = (Priority)Enum.Parse(typeof(Priority), priorityComboBox.SelectedItem.ToString()),
                dueDate  = dueDatePicker.Value
            };

            TaskDTOImplementation.getInstance().update(task, DatabaseConstants.COLUMN_STATUS, DatabaseConstants.COLUMN_PRIORITY, DatabaseConstants.COLUMN_DUEDATE);
        }