//Opens View Task Window for Selected Task
        private void ViewTaskButtonClick(object sender, RoutedEventArgs e)
        {
            DataStructures.TaskRowStruct selectedTask = new DataStructures.TaskRowStruct();

            if ((sender as Button).Name.Equals(ViewTaskButton.Name))
            {
                selectedTask = (DataStructures.TaskRowStruct)TaskList2.SelectedItems[0];
            }
            else if ((sender as Button).Name.Equals(ViewTaskButton_ByYou.Name))
            {
                selectedTask = (DataStructures.TaskRowStruct)AssignedByYouList.SelectedItems[0];
            }
            else if ((sender as Button).Name.Equals(ViewTaskButton_ToYou.Name))
            {
                selectedTask = (DataStructures.TaskRowStruct)AssignedToYouList.SelectedItems[0];
            }
            else
            {
                MessageBox.Show("Please select a task");
            }

            try
            {
                if (selectedTask != null)
                {
                    ViewTaskWindow viewTaskWindow = new ViewTaskWindow(selectedTask);
                    viewTaskWindow.Show();
                }
            }
            catch (ArgumentOutOfRangeException)
            {
                MessageBox.Show("Please select a task");
            }
        }
예제 #2
0
        public EditTaskWindow(DataStructures.TaskRowStruct task)
        {
            InitializeComponent();
            AssignToComboBox.ItemsSource = Properties.Settings.Default.UsersStringCollection;
            StatusComboBox.ItemsSource   = (StringCollection)Application.Current.Resources["MainWorkflow"];

            selectedTask = task;

            TaskNameTextBox.Text          = selectedTask.taskName;
            StartDatePicker.SelectedDate  = selectedTask.startDate;
            DeadlinePicker.SelectedDate   = selectedTask.deadline;
            AssignToComboBox.SelectedItem = selectedTask.assignedTo;
            StatusComboBox.SelectedItem   = selectedTask.taskStatus;
            TaskDetailsTextBox.Text       = selectedTask.details;
        }
예제 #3
0
        //Loads tasks from database into app (only some details)
        public static void GetTasks()
        {
            using (SqlConnection sqlConn = new SqlConnection(Properties.Settings.Default.PDMDatabaseConnectionString))
            {
                SqlCommand getTasks = new SqlCommand("SELECT TaskName, StartDate, Deadline, AssignedTo, TaskStatus, LastEdited FROM dbo.Tasks", sqlConn);

                sqlConn.Open();



                SqlDataReader reader = getTasks.ExecuteReader();

                foreach (Window window in Application.Current.Windows)
                {
                    if (window.GetType() == typeof(MainWindow))
                    {
                        (window as MainWindow).TaskList2.ItemsSource = null;
                    }
                }

                DataStructures.taskRows.Clear();

                while (reader.Read())
                {
                    DataStructures.TaskRowStruct taskRow = new DataStructures.TaskRowStruct();
                    taskRow.taskName   = reader.GetString(0);
                    taskRow.startDate  = reader.GetDateTime(1);
                    taskRow.deadline   = reader.GetDateTime(2);
                    taskRow.assignedTo = (string)reader.GetString(3);
                    taskRow.taskStatus = (string)reader.GetString(4);
                    taskRow.lastEdited = reader.GetDateTime(5);

                    DataStructures.taskRows.Add(taskRow);
                }

                reader.Close();
                sqlConn.Close();
            }

            foreach (Window window in Application.Current.Windows)
            {
                if (window.GetType() == typeof(MainWindow))
                {
                    (window as MainWindow).TaskList2.ItemsSource = DataStructures.taskRows;
                }
            }
        }
예제 #4
0
        public static void UpdateTask(DataStructures.TaskRowStruct selectedTask)
        {
            int taskID = GetTaskID(selectedTask.taskName, selectedTask.details);

            if (selectedTask.notifyUsers.Contains(Application.Current.Properties["username"].ToString()) != true)
            {
                selectedTask.notifyUsers.Add(Application.Current.Properties["username"].ToString());
            }

            string[] notifyUsersArray = selectedTask.notifyUsers.ToArray();
            string   notifyUserString = string.Join(",", notifyUsersArray);

            using (SqlConnection sqlConn = new SqlConnection(Properties.Settings.Default.PDMDatabaseConnectionString))
            {
                SqlCommand updateTaskComm = new SqlCommand("UpdateTaskSP", sqlConn);
                updateTaskComm.CommandType = CommandType.StoredProcedure;
                updateTaskComm.Parameters.AddWithValue("@taskID", taskID);
                updateTaskComm.Parameters.AddWithValue("@taskName", selectedTask.taskName);
                updateTaskComm.Parameters.AddWithValue("@startdate", selectedTask.startDate);
                updateTaskComm.Parameters.AddWithValue("@deadline", selectedTask.deadline);
                updateTaskComm.Parameters.AddWithValue("@details", selectedTask.details);
                updateTaskComm.Parameters.AddWithValue("@tasklistfiletabledir", selectedTask.taskListFileTableDir);
                updateTaskComm.Parameters.AddWithValue("@assignedby", selectedTask.assignedBy);
                updateTaskComm.Parameters.AddWithValue("@assignedto", selectedTask.assignedTo);
                updateTaskComm.Parameters.AddWithValue("@taskstatus", selectedTask.taskStatus);
                updateTaskComm.Parameters.AddWithValue("@lastedited", DateTime.Now);
                updateTaskComm.Parameters.AddWithValue("@lasteditedby", System.Windows.Application.Current.Properties["username"]);

                if (selectedTask.taskFiles == null)
                {
                    selectedTask.taskFiles = new List <string>();
                }

                string[] taskFilesArray = selectedTask.taskFiles.ToArray();
                string   taskFiles      = string.Join(",", taskFilesArray);

                updateTaskComm.Parameters.AddWithValue("@taskFiles", taskFiles);

                updateTaskComm.Parameters.AddWithValue("@notifyUsers", notifyUserString);

                sqlConn.Open();
                int i = updateTaskComm.ExecuteNonQuery();
                sqlConn.Close();
            }
        }
        public ViewTaskWindow(DataStructures.TaskRowStruct task)
        {
            InitializeComponent();

            selectedTask              = task;
            TaskNameLabel.Content     = selectedTask.taskName;
            StartDateLabel.Content    = StartDateLabel.Content.ToString() + " " + selectedTask.startDate.ToString("dd/MM/yyyy");
            DeadlineLabel.Content     = DeadlineLabel.Content.ToString() + " " + selectedTask.deadline.ToString("dd/MM/yyyy");
            AssignToLabel.Content     = AssignToLabel.Content.ToString() + " " + selectedTask.assignedTo;
            StatusLabel.Content       = StatusLabel.Content.ToString() + " " + selectedTask.taskStatus;
            LastEditedLabel.Content   = LastEditedLabel.Content.ToString() + " " + selectedTask.lastEdited.ToString("HH:mm dd/MM/yyyy");
            DetailsTextBlock.Text     = selectedTask.details;
            LastEditedByLabel.Content = LastEditedByLabel.Content.ToString() + " " + selectedTask.lastEditedBy;


            InitUpdateRows();
            InitAddUpdateRow();
        }
        //Opens View Task Window for Selected Task
        private void MouseDoubleClickItem(object sender, RoutedEventArgs e)
        {
            DataStructures.TaskRowStruct selectedTask = new DataStructures.TaskRowStruct();

            selectedTask = ((FrameworkElement)e.OriginalSource).DataContext as DataStructures.TaskRowStruct;

            if (selectedTask == null)
            {
                //MessageBox.Show("Please select a task");
            }

            try
            {
                if (selectedTask != null)
                {
                    ViewTaskWindow viewTaskWindow = new ViewTaskWindow(selectedTask);
                    viewTaskWindow.Show();
                }
            }
            catch (ArgumentOutOfRangeException)
            {
                //MessageBox.Show("Please select a task");
            }
        }
예제 #7
0
        //Loads tasks from database into app (all details)
        public static void GetTasksFull()
        {
            using (SqlConnection sqlConn = new SqlConnection(Properties.Settings.Default.PDMDatabaseConnectionString))
            {
                SqlCommand getTasks = new SqlCommand("SELECT TaskID, TaskName, StartDate, Deadline, Details, TaskListFileTableDir, AssignedBy, AssignedTo, TaskStatus, " +
                                                     "LastEdited, LastEditedBy, TaskFiles, NotifyUsers FROM dbo.Tasks", sqlConn);

                sqlConn.Open();

                SqlDataReader reader = getTasks.ExecuteReader();

                foreach (Window window in Application.Current.Windows)
                {
                    if (window.GetType() == typeof(MainWindow))
                    {
                        (window as MainWindow).TaskList2.ItemsSource         = null;
                        (window as MainWindow).AssignedByYouList.ItemsSource = null;
                        (window as MainWindow).AssignedToYouList.ItemsSource = null;
                    }
                }

                DataStructures.taskRows.Clear();
                DataStructures.assignedByTaskRows.Clear();
                DataStructures.assignedToTaskRows.Clear();
                DataStructures.taskNames.Clear();

                while (reader.Read())
                {
                    DataStructures.TaskRowStruct taskRow = new DataStructures.TaskRowStruct();
                    taskRow.taskID               = reader.GetInt32(0);
                    taskRow.taskName             = reader.GetString(1);
                    taskRow.startDate            = reader.GetDateTime(2);
                    taskRow.deadline             = reader.GetDateTime(3);
                    taskRow.details              = reader.GetString(4);
                    taskRow.taskListFileTableDir = reader.GetString(5);
                    taskRow.assignedBy           = reader.GetString(6);
                    taskRow.assignedTo           = (string)reader.GetString(7);
                    taskRow.taskStatus           = (string)reader.GetString(8);
                    taskRow.lastEdited           = reader.GetDateTime(9);
                    taskRow.lastEditedBy         = reader.GetString(10);
                    string taskFilesString   = reader.GetString(11);
                    string notifyUsersString = reader.GetString(12);

                    if (taskFilesString != "")
                    {
                        string[] taskFilesArray = taskFilesString.Split(',');

                        foreach (string s in taskFilesArray)
                        {
                            if (taskRow.taskFiles == null)
                            {
                                taskRow.taskFiles = new List <string>();
                                taskRow.taskFiles.Add(s);
                            }
                            else
                            {
                                if (taskRow.taskFiles.Contains(s) == false)
                                {
                                    taskRow.taskFiles.Add(s);
                                }
                            }
                        }
                    }

                    string[] notifyUsersArray = notifyUsersString.Split(',');

                    if (taskRow.notifyUsers == null)
                    {
                        taskRow.notifyUsers = new List <string>();
                    }

                    foreach (string user in notifyUsersArray)
                    {
                        taskRow.notifyUsers.Add(user);
                    }


                    DataStructures.taskRows.Add(taskRow);
                }

                reader.Close();
                sqlConn.Close();
            }

            foreach (DataStructures.TaskRowStruct task in DataStructures.taskRows)
            {
                if (task.assignedBy.Equals(Application.Current.Properties["username"].ToString()))
                {
                    DataStructures.assignedByTaskRows.Add(task);
                }

                if (task.assignedTo.Equals(Application.Current.Properties["username"].ToString()))
                {
                    DataStructures.assignedToTaskRows.Add(task);
                }

                DataStructures.taskNames.Add(task.taskName);
            }

            foreach (DataStructures.TaskRowStruct task in DataStructures.taskRows)
            {
                /*
                 * if (task.assignedTo.Equals(Application.Current.Properties["username"].ToString()))
                 * {
                 *  DataStructures.assignedToTaskRows.Add(task);
                 * }
                 */
            }



            foreach (Window window in Application.Current.Windows)
            {
                if (window.GetType() == typeof(MainWindow))
                {
                    (window as MainWindow).TaskList2.ItemsSource         = DataStructures.taskRows;
                    (window as MainWindow).AssignedByYouList.ItemsSource = DataStructures.assignedByTaskRows;
                    (window as MainWindow).AssignedToYouList.ItemsSource = DataStructures.assignedToTaskRows;


                    (window as MainWindow).taskListView = (CollectionView)CollectionViewSource.GetDefaultView((window as MainWindow).TaskList2.ItemsSource);
                    (window as MainWindow).taskListView.SortDescriptions.Add(new SortDescription("lastEdited", ListSortDirection.Descending));
                    (window as MainWindow).assignedByListView = (CollectionView)CollectionViewSource.GetDefaultView((window as MainWindow).AssignedByYouList.ItemsSource);
                    (window as MainWindow).assignedByListView.SortDescriptions.Add(new SortDescription("lastEdited", ListSortDirection.Descending));
                    (window as MainWindow).assignedToListView = (CollectionView)CollectionViewSource.GetDefaultView((window as MainWindow).AssignedToYouList.ItemsSource);
                    (window as MainWindow).assignedToListView.SortDescriptions.Add(new SortDescription("lastEdited", ListSortDirection.Descending));
                }
            }
        }
예제 #8
0
        public static string AddTaskFiles(DataStructures.TaskRowStruct selectedTask, OpenFileDialog selectFiles)
        {
            string taskFilesUpdateString = "Added File(s): ";
            int    noOfFiles             = 0;

            foreach (string filename in selectFiles.FileNames)
            {
                FileInfo fileInfo = new FileInfo(filename);


                try
                {
                    if (selectedTask.taskFiles == null)
                    {
                        selectedTask.taskFiles = new List <string>();

                        selectedTask.taskFiles.Add(fileInfo.Name);
                        File.Copy(filename, Properties.Settings.Default.FileDirectory + selectedTask.taskListFileTableDir + @"\" + fileInfo.Name);

                        if (noOfFiles < selectFiles.FileNames.Length)
                        {
                            taskFilesUpdateString += fileInfo.Name + ", ";
                        }
                        else
                        {
                            taskFilesUpdateString += fileInfo.Name;
                        }
                    }
                    else
                    {
                        if (selectedTask.taskFiles.Contains(fileInfo.Name) == false)
                        {
                            selectedTask.taskFiles.Add(fileInfo.Name);
                        }

                        File.Copy(filename, Properties.Settings.Default.FileDirectory + selectedTask.taskListFileTableDir + @"\" + fileInfo.Name);

                        if (noOfFiles < selectFiles.FileNames.Length)
                        {
                            taskFilesUpdateString += fileInfo.Name + ", ";
                        }
                        else
                        {
                            taskFilesUpdateString += fileInfo.Name;
                        }
                    }
                }
                catch (IOException ioe)
                {
                    File.Delete(Properties.Settings.Default.FileDirectory + selectedTask.taskListFileTableDir + @"\" + fileInfo.Name);
                    File.Copy(filename, Properties.Settings.Default.FileDirectory + selectedTask.taskListFileTableDir + @"\" + fileInfo.Name);

                    if (noOfFiles < selectFiles.FileNames.Length)
                    {
                        taskFilesUpdateString += fileInfo.Name + " (replaced existing), ";
                    }
                    else
                    {
                        taskFilesUpdateString += fileInfo.Name + " (replaced existing)";
                    }
                }

                noOfFiles++;
            }

            string[] taskFilesArray = selectedTask.taskFiles.ToArray();
            string   taskFiles      = String.Join(",", taskFilesArray);

            DataHandling.UpdateTask(selectedTask);

            return(taskFilesUpdateString);
        }