Exemplo n.º 1
0
        private void chkIsCompleted_Click(object sender, RoutedEventArgs e)
        {
            if (chkIsCompleted.IsChecked == true)
            {
                if (MessageBox.Show("Are you sure this task is completed? It cannot be undone! ",
                "Confirm task completion...",
                MessageBoxButton.YesNoCancel, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {

                    TasksHelper client = new TasksHelper();
                    try
                    {
                        var textRange = new TextRange(txtDesc.Document.ContentStart, txtDesc.Document.ContentEnd);
                        Task task = (Task)lstTask.SelectedItem;

                        TaskAssignment assn = client.GetTaskAssignment(task.TaskID, event_.EventID,
                            int.Parse(cboRole.SelectedValue.ToString()));

                        client.SetTaskCompleted(task, assn.AssignedRoleID, textRange.Text.Trim());

                        MessageBox.Show("Operation Succeeded");
                        chkIsCompleted.IsEnabled = false;
                        txtRemark.IsReadOnly = true;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("An Error have occured: " + ex.Message, "Error",
                            MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    client.Close();
                }
                else
                {
                    chkIsCompleted.IsChecked = false;
                }
            }
        }
Exemplo n.º 2
0
        private void lstTask_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (lstTask.SelectedIndex == -1)
            {
                return;
            }
            txtDesc.Document.Blocks.Clear();
            txtRemark.Document.Blocks.Clear();

            Task task = (Task)lstTask.SelectedItem;

            txtTaskName.Text = task.TaskName;
            txtDesc.AppendText(task.TaskDesc);
            dtpDueDate.SelectedDateTime = task.DueDate;

            TasksHelper client = new TasksHelper();

            TaskAssignment assn = client.GetTaskAssignment(task.TaskID, event_.EventID,
                int.Parse(cboRole.SelectedValue.ToString()));

            txtRemark.AppendText(assn.Remarks);
             chkIsCompleted.IsChecked = this.txtRemark.IsReadOnly = assn.IsCompleted;

            chkIsCompleted.IsEnabled = !assn.IsCompleted;

            if (!assn.IsRead)
            {
                client.SetTaskRead(task, int.Parse(cboRole.SelectedValue.ToString()));
            }
            client.Close();
        }