Beispiel #1
0
        private void btnUpdate_Click(object sender, RoutedEventArgs e)
        {
            if (TaskData == null)
            {
                TaskData = new NoteDto()
                {
                    TaskId = cmTask.Id,
                    Note   = txtNote.Text
                };
            }
            else
            {
                TaskData.Note = txtNote.Text;
            }

            CMCUDResult opResult;

            if (TaskData.Id == 0)
            {
                opResult = NoteExtensions.NoteDataProvider.Insert(TaskData);
            }
            else
            {
                opResult = NoteExtensions.NoteDataProvider.Update(TaskData);
            }

            if (opResult.Errors.Any())
            {
                MessageBox.Show(opResult.ErrorsCombined);
            }
            else
            {
                MessageBox.Show("Updated");
            }
        }
        internal static void Note_CreateTaskDataInstance(CMTaskDto cmTaskTemplate, CMTaskDto cmTaskInstance)
        {
            // The task data (template) to clone
            var taskDataTemplate = NoteDataProvider.Get_ForTaskId(cmTaskTemplate.Id);

            // If there was no task data template defined then just return without creating data for the instance
            if (taskDataTemplate == null)
            {
                return;
            }

            // Now we can create new task data note
            var taskData = new NoteDto()
            {
                TaskId = cmTaskInstance.Id,
                Note   = taskDataTemplate.Note
            };

            var opResult = NoteDataProvider.Insert(taskData);

            if (opResult.Errors.Any())
            {
                throw new Exception(opResult.ErrorsCombined);
            }
        }
Beispiel #3
0
        private void UserControl_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            TaskData = NoteExtensions.NoteDataProvider.Get_ForTaskId(cmTask.Id);

            if (TaskData != null)
            {
                try
                {
                    txtNote.Text = TaskData.Note;
                }
                catch
                {
                    MessageBox.Show("Error reading task data.");
                }
            }
        }