Пример #1
0
        private void butOK_Click(object sender, EventArgs e)
        {
            if (textNote.Text == "")
            {
                MsgBox.Show(this, "Please enter a note, or delete this entry.");
                return;
            }
            //We need the old datetime to check if the user made any changes.  We overrite TaskNoteCur's date time below so need to get it here.
            DateTime dateTimeNoteOld = TaskNoteCur.DateTimeNote;

            try {
                TaskNoteCur.DateTimeNote = DateTime.Parse(textDateTime.Text);
            }
            catch {
                MsgBox.Show(this, "Please fix date.");
                return;
            }
            if (TaskNoteCur.IsNew)
            {
                TaskNoteCur.Note = textNote.Text;
                TaskNotes.Insert(TaskNoteCur);
                Tasks.TaskEditCreateLog(Permissions.TaskNoteEdit, Lan.g(this, "Added task note"), Tasks.GetOne(TaskNoteCur.TaskNum));
                //This refreshes "new" status for the task as appropriate.
                DataValid.SetInvalidTask(TaskNoteCur.TaskNum, true);               //popup
                DialogResult = DialogResult.OK;
                OnEditComplete();
            }
            else if (TaskNoteCur.Note != textNote.Text || dateTimeNoteOld != TaskNoteCur.DateTimeNote)
            {
                //This refreshes "new" status for the task as appropriate.
                DataValid.SetInvalidTask(TaskNoteCur.TaskNum, true);               //popup
                TaskNoteCur.Note = textNote.Text;
                TaskNotes.Update(TaskNoteCur);
                Tasks.TaskEditCreateLog(Permissions.TaskNoteEdit, Lan.g(this, "Task note changed"), Tasks.GetOne(TaskNoteCur.TaskNum));
                DialogResult = DialogResult.OK;
                OnEditComplete();
            }
            else
            {
                //Intentionally blank, user opened an existing task note and did not change the note but clicked OK.
                //This is effectively equivilent to a Cancel click
                DialogResult = DialogResult.Cancel;
            }
            Close();            //Needed because the window is called as a non-modal window.
        }
Пример #2
0
 private void butDelete_Click(object sender, EventArgs e)
 {
     if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Delete?"))
     {
         return;
     }
     if (TaskNoteCur.IsNew)
     {
         DialogResult = DialogResult.Cancel;
         Close();                //Needed because the window is called as a non-modal window.
         return;
     }
     TaskNotes.Delete(TaskNoteCur.TaskNoteNum);
     DataValid.SetInvalidTask(TaskNoteCur.TaskNum, true);           //popup
     DialogResult = DialogResult.OK;
     OnEditComplete();
     Tasks.TaskEditCreateLog(Permissions.TaskNoteEdit, Lan.g(this, "Deleted note from task"), Tasks.GetOne(TaskNoteCur.TaskNum));
     Close();            //Needed because the window is called as a non-modal window.
 }