Пример #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");
 }
Пример #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"));
     }
 }
Пример #3
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);
        }
Пример #4
0
 /**
  * Saveing the docuemt
  *
  * @saveFileDialog: the dialog to open and save the file locally
  * @isSaveAs : to indicate the operation
  * @Document : the document to save
  **/
 public void save(SaveFileDialog saveFileDialog, bool isSaveAs, Document document)
 {
     saveFileDialog.FileName         = tabControl.SelectedTab.Name;
     saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
     saveFileDialog.Filter           = TypesConstants.FILE_TYPES;
     saveFileDialog.Title            = isSaveAs ? "Save As" : "Save";
     if (isSaveAs)
     {
         if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             if (saveFileDialog.FileName.Length > 4)
             {
                 getCurrentDocument.SaveFile(saveFileDialog.FileName, RichTextBoxStreamType.RichText);
                 DocumentDTOImplementation.getInstance().save(document);
             }
         }
     }
     else
     {
         DocumentDTOImplementation.getInstance().update(document, DatabaseConstants.COLUMN_DOCUMENT);
     }
 }
Пример #5
0
 private void btnDeleteNote_Click(object sender, EventArgs e)
 {
     if (noteListView.SelectedItems.Count == 0)
     {
         MessageBox.Show("Please Select a notebook to delete");
     }
     else
     {
         if (MessageBox.Show(UserMessages.ARE_YOU_SURE("Delete , (this cannot be undone) ")
                             , UserMessages.CONFIRMION("Delete"), MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             Note noteTemp;
             bool flag = false;
             foreach (ListViewItem item in noteListView.SelectedItems)
             {
                 noteTemp = noteDTO.getById(item.Text);
                 flag     = DocumentDTOImplementation.getInstance().delete(noteTemp.getDocumentId());
                 flag    &= noteDTO.delete(noteTemp.getId());
                 UserMessages.messageStatus(flag);
             }
         }
     }
 }
Пример #6
0
 private ShareDTOImplementation()
 {
     Logging.singlton(nameof(ShareDTO));
     shareDAO    = ShareDAOImplementation.getInstance();
     documentDTO = DocumentDTOImplementation.getInstance();
 }