Example #1
0
        /// <summary>
        /// Inserting new task
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void mainWindow_KeyDown(object sender, KeyEventArgs e)
        {
            #region Insert new task
            if ((e.KeyCode == Keys.Insert) && (tabControl1.SelectedIndex == 0))
            {
                // creating new task
                decimal idTask = 0;
                string idFolder = "0"; // idFolder 0 means root node
                dbrespons = DBOperation.insertNewTask("New task", null, null, false, ref idTask);
                if (dbrespons.result != DBStatus.InsertSuccessful)
                {
                    MessageBox.Show("Error durning inserting new task", "Error",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                // new task into edit mode
                TreeNode newNode = new TreeNode();
                newNode.Name = "T";
                newNode.Tag = idTask.ToString();
                newNode.Text = "New task";
                newNode.ImageIndex = 1;
                newNode.SelectedImageIndex = 1;

                // if node is selected insert new task into folder
                TreeNode selNode = treeView_taskList.SelectedNode;
                if ((selNode != null) && (selNode.Name.Equals("F")))
                {
                    idFolder = selNode.Tag.ToString();
                    selNode.Nodes.Add(newNode);
                }
                else if ((selNode != null) && (selNode.Name.Equals("T")) && (selNode.Parent != null))
                {
                    idFolder = selNode.Parent.Tag.ToString();
                    selNode.Parent.Nodes.Add(newNode);
                }
                else
                {
                    treeView_taskList.Nodes.Add(newNode);
                }

                // inserting task into container
                dbrespons = DBOperation.insertContainerDB(idTask, null, null, idFolder);
                if (dbrespons.result != DBStatus.InsertSuccessful)
                {
                    MessageBox.Show("Error durning inserting new task", "Error",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                // new node is in edit mode
                treeView_taskList.BeginUpdate();
                // selected node
                treeView_taskList.SelectedNode = newNode;
                treeView_taskList.LabelEdit = true;
                newNode.BeginEdit();
                treeView_taskList.EndUpdate();
            }
            #endregion
        }
Example #2
0
        /// <summary>
        /// Making structure of directories
        /// </summary>
        /// <param name="parent">ID parent</param>
        /// <param name="node">node</param>
        public void createFolderTree(string parent, TreeNodeCollection node)
        {
            dbrespons = DBOperation.getFolderByParent(parent, ref folder);
            if (dbrespons.result != DBStatus.SelectSuccessful)
            {
                MessageBox.Show("Error durning creating folders structure", "Information",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            foreach (DataRow item in folder.Rows)
            {
                TreeNode newNode = new TreeNode();
                newNode.ImageIndex = 0; // image
                newNode.SelectedImageIndex = 0;
                newNode.Tag = item["idFolder"].ToString();
                newNode.Name = "F";
                newNode.Text = item["folderName"].ToString();
                node.Add(newNode); // adding new node
                createNewNode(item["idFolder"].ToString(), newNode.Nodes);
            }
        }
Example #3
0
        private void searchForTasks(string idFolder, TreeNodeCollection node)
        {
            DataTable task = new DataTable();
            dbrespons = DBOperation.getTasksFromFolder(idFolder, ref task);
            if (dbrespons.result != DBStatus.SelectSuccessful)
            {
                MessageBox.Show("Error durning creating folders structure", "Information",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            foreach (DataRow item in task.Rows)
            {
                TreeNode nnode = new TreeNode();
                nnode.Name = "T";
                nnode.ImageIndex = 1;
                nnode.SelectedImageIndex = 1;
                nnode.Tag = item["idTasks"].ToString();
                nnode.Text = item["taskDesc"].ToString();
                node.Add(nnode);
            }
        }
Example #4
0
        /// <summary>
        /// Removing folders contains task or other folders
        /// </summary>
        /// <param name="node">Node to remove</param>
        private void removeFolderTaskNode(TreeNode node)
        {
            if (node == null) return; // finish

            // removing node
            if (node.Nodes.Count == 0)
            {
                dbrespons = DBOperation.removingFolder(node.Tag.ToString());
                if (dbrespons.result != DBStatus.DeleteSuccessful)
                {
                    MessageBox.Show("Problem removing folder!", "Error", MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                    return;
                }
                return; // finish
            }

            // removing node nodes
            foreach (TreeNode item in node.Nodes)
            {
                // folder can have subfolders
                if (item.Name.ToString().Equals("F"))
                {
                    if (node.Nodes.Count != 0) // removing deeper levels
                        removeFolderTaskNode(node.Nodes[0]);

                    dbrespons = DBOperation.removingFolder(node.Tag.ToString());
                    if (dbrespons.result != DBStatus.DeleteSuccessful)
                    {
                        MessageBox.Show("Problem removing folder!", "Error", MessageBoxButtons.OK,
                            MessageBoxIcon.Error);
                        return;
                    }
                }
                // tasks can't have subtasks
                else if (item.Name.ToString().Equals("T"))
                {
                    removeTask(node);
                }
            }
        }
Example #5
0
 /// <summary>
 /// Removing task based on node
 /// </summary>
 /// <param name="node"></param>
 public void removeTask(TreeNode node)
 {
     string idTask = node.Tag.ToString();
     dbrespons = DBOperation.removingTask(idTask);
     if (dbrespons.result != DBStatus.DeleteSuccessful)
     {
         MessageBox.Show("Error: deleteing task!", "Error", MessageBoxButtons.OK,
             MessageBoxIcon.Error);
         return;
     }
 }
Example #6
0
 /// <summary>
 /// Removing folder from treeView
 /// </summary>
 /// <param name="node">Node that contains folder</param>
 public void removeFolderTask(TreeNode node)
 {
     if (node != null)
     {
         if (node.Nodes.Count != 0)
         {
             DialogResult result = MessageBox.Show("Removing folder will remove whole contins of folder", "Question",
                 MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
             if (result == DialogResult.OK)
             {
                 removeFolderTaskNode(node);
             }
         }
         else if (node.Nodes.Count == 0)
         {
             dbrespons = DBOperation.removingFolder(node.Tag.ToString());
             if (dbrespons.result != DBStatus.DeleteSuccessful)
             {
                 MessageBox.Show("Problem removing folder!", "Error", MessageBoxButtons.OK,
                     MessageBoxIcon.Error);
                 return;
             }
         }
     }
 }
Example #7
0
        /// <summary>
        /// Moving node or folder one position up
        /// </summary>
        /// <param name="node">Node to move</param>
        public void nodeUp(TreeNode node)
        {
            TreeNode parent = null;
            if ((node != null) && (node.Parent != null) && (node.Parent.Parent != null))
            {
                parent = node.Parent.Parent;
            }

            // Folder1
            //      |---> Folder2
            //      |---> Folder3
            // ------ after operation --------------
            // Folder3
            // Folder1
            //      |---> Folder2
            if (parent != null) // folder on level up
            {
                TreeNode copy = (TreeNode)node.Clone();
                parent.Nodes.Add(copy);
                treeView.SelectedNode = copy;
                node.Remove();

                // information about parent
                string idParent = parent.Tag.ToString(); // parent id
                string idFolder = copy.Tag.ToString(); // idFolder or idTask

                if (node.Name.Equals("F")) // operation on folders
                {
                    dbrespons = DBOperation.updateFolderPosition(idParent, copy.Text, idFolder);
                    if (dbrespons.result != DBStatus.UpdateSuccessful)
                    {
                        MessageBox.Show("Error durning updating folder position!", "Error",
                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                else if (node.Name.Equals("T"))
                {
                    dbrespons = DBOperation.updateTaskPosition(idFolder, idParent);
                    if(dbrespons.result != DBStatus.UpdateSuccessful)
                    {
                        MessageBox.Show("Error durning updating task position!", "Error",
                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
            }
            else if (parent == null) // folder is in root node
            {
                TreeNode copy = (TreeNode)node.Clone();
                treeView.Nodes.Add(copy);
                treeView.SelectedNode = copy;
                node.Remove();

                // information about parent
                string idParent = "0";
                string idFolder = copy.Tag.ToString();

                if (copy.Name.Equals("F")) // moving folder
                {
                    dbrespons = DBOperation.updateFolderPosition(idParent, copy.Text, idFolder);
                    if (dbrespons.result != DBStatus.UpdateSuccessful)
                    {
                        MessageBox.Show("Error durning updating folder position!", "Error",
                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }

                if (copy.Name.Equals("T")) // moving task
                {
                    dbrespons = DBOperation.updateTaskPosition(idFolder, idParent);
                    if(dbrespons.result != DBStatus.UpdateSuccessful)
                    {
                        MessageBox.Show("Error durning updating task position!", "Error",
                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
            }
        }
Example #8
0
        // Moving node up and down throught treeView structure
        // Folder1
        //     |--> Task1
        //     |--> Task2
        // after making node down
        // Folder1
        //     |--> Task1
        // Task2
        public void nodeDown(TreeNode node)
        {
            TreeNode prev = node.PrevNode;
            if ((prev != null) && (node.Name.Equals("F"))) // folder
            {
                TreeNode clone = (TreeNode)node.Clone();
                prev.Nodes.Add(clone);
                treeView.SelectedNode = clone;
                node.Remove();

                // information about parent
                string idParent = clone.Parent.Tag.ToString();
                string idFolder = clone.Tag.ToString();

                dbrespons = DBOperation.updateFolderPosition(idParent, clone.Text, idFolder);
                if (dbrespons.result != DBStatus.UpdateSuccessful)
                {
                    MessageBox.Show("Error durning updating folder position!", "Error",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            if ((prev != null) && (node.Name.Equals("T"))) // operations for task
            {
                TreeNode clone = (TreeNode)node.Clone();
                prev.Nodes.Add(clone);
                treeView.SelectedNode = clone;
                node.Remove();

                // information about parent
                string idParent = clone.Parent.Tag.ToString();
                string idFolder = clone.Tag.ToString();

                // saving data into DB
                dbrespons = DBOperation.updateTaskPosition(idFolder, idParent);
                if(dbrespons.result != DBStatus.UpdateSuccessful)
                {
                    MessageBox.Show("Error durning updating task position!", "Error",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
        }
Example #9
0
        /// <summary>
        /// Method for update task list raised when added,deleted or modify task
        /// </summary>
        private void updateTaskList()
        {
            // Searching of tasks
            dbrespons = DBOperation.getTaskList(ref task);
            if (dbrespons.resultOperation() != DBStatus.SelectSuccessful)
            {
                MessageBox.Show("Error durning searching for tasks " + dbrespons.errorMessage(), "Information",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            todoGridView.DataSource = task;

            // FIXME dosn't work don't know why
            // task finished
            foreach (DataGridViewRow row in todoGridView.Rows)
            {
                if ((bool)row.Cells["finished"].Value)
                {
                    DataGridViewCell cell = row.Cells["taskDesc"];
                    cell.Style = strikedOut;
                }
            }
        }
Example #10
0
        // checking up if node is changed
        private void treeView_taskList_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            if (oldNode == null)
            {
                oldNode = treeView_taskList.SelectedNode;
            }

            // update informations about task
            if (oldNode != treeView_taskList.SelectedNode)
            {
                if (splitContainer.Panel2Collapsed == false) // when panel is visible
                {
                    TreeNode node = e.Node;
                    if (node.Name != "F")
                    {
                        string idTask = node.Tag.ToString();
                        DataTable data = new DataTable(); // contains task information

                        dbrespons = DBOperation.getTaskDate(idTask, ref data);
                        if (dbrespons.result != DBStatus.SelectSuccessful)
                        {
                            MessageBox.Show("Unable read task informaion", "Information",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }

                        // setingup date
                        if (!string.IsNullOrEmpty(data.Rows[1][0].ToString()))
                        {
                            dateTimePickerEnd.Enabled = true;
                            DateTime end = new DateTime();
                            end = DateTime.ParseExact(data.Rows[1][0].ToString(), "yyyy-MM-dd HH:mm:ss", null);
                            dateTimePickerEnd.Value = end;
                        }
                        else
                        {
                            dateTimePickerEnd.Enabled = false;
                        }

                        // start date
                        if (!string.IsNullOrEmpty(data.Rows[1][1].ToString()))
                        {
                            dateTimePickerStart.Enabled = true;
                            DateTime start = new DateTime();
                            start = DateTime.ParseExact(data.Rows[1][1].ToString(), "yyyy-MM-dd HH:mm:ss", null);
                            dateTimePickerEnd.Value = start;
                        }
                        else
                        {
                            dateTimePickerStart.Enabled = false;
                        }
                    }
                }
            }
        }
Example #11
0
        /// <summary>
        /// Updating Folder name
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void treeView_taskList_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
        {
            // updating folder name
            if (e.Node.Name.ToString().Equals("F"))
            {
                string idFolder = e.Node.Tag.ToString();
                string folderName = e.Label;
                if (e.Label == null) return; // return if nothing was been changed

                dbrespons = DBOperation.updateFolderName(idFolder, folderName);
                if (dbrespons.result != DBStatus.UpdateSuccessful)
                {
                    MessageBox.Show("Error when changing folder name", "Error", MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                    return;
                }
            }

            // updating task message
            if (e.Node.Name.ToString().Equals("T"))
            {
                string idTask = e.Node.Tag.ToString();
                if (e.Label == null) return; // preventing ESC when editing node
                string taskDesc = e.Label.ToString();
                dbrespons = DBOperation.updateTaskDescriptionDB(idTask, taskDesc);
                if (dbrespons.result != DBStatus.UpdateSuccessful)
                {
                    MessageBox.Show("Error durning updating task desc", "Error",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                updateTaskList();
                updateTaskBoard();
            }
        }
Example #12
0
        /// <summary>
        /// Creating new node in main node
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolSBCreateFolder_Click(object sender, EventArgs e)
        {
            TreeNode selected_node = treeView_taskList.SelectedNode;
            string idParent = "0";
            if ((selected_node != null) && (selected_node.Parent != null))
            {
                idParent = selected_node.Tag.ToString();
            }

            dbrespons = DBOperation.createNewFolder("New folder", idParent);
            if (dbrespons.result != DBStatus.InsertSuccessful)
            {
                MessageBox.Show("Error when creating new folder!", "Error",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            int row = 0;
            dbrespons = DBOperation.getLastInsertedRowID(ref row);
            if (dbrespons.result != DBStatus.SelectSuccessful)
            {
                MessageBox.Show("Error when getting last row id", "Error",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            createTreeView.createNewFolder("New folder", row.ToString());
        }
Example #13
0
        /// <summary>
        /// Checking if cell is clicked and strikeout finished task
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void todoGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            // if user click on first column
            if ((e.ColumnIndex == 4) && (e.RowIndex != -1))
            {
                int i = e.RowIndex;
                DataGridViewCell cell = todoGridView["taskDesc", i];
                bool finish = (bool)todoGridView["finished", i].Value;

                // checked if is checked
                if (!finish)
                {
                    cell.Style = strikedOut;
                    todoGridView["finished", i].Value = "True";

                    // saving data to DB
                    dbrespons = DBOperation.taskFinished(todoGridView["idTasks", i].Value.ToString(), true);
                    if (dbrespons.result != DBStatus.UpdateSuccessful)
                    {
                        MessageBox.Show("Error durning update task status", "Error",
                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }

                if(finish)
                {
                    cell.Style = regular;
                    todoGridView["finished", i].Value = "False";

                    // saving data to DB
                    dbrespons = DBOperation.taskFinished(todoGridView["idTasks", i].Value.ToString(), true);
                    if (dbrespons.result != DBStatus.UpdateSuccessful)
                    {
                        MessageBox.Show("Error durning update task status", "Error",
                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
            }
        }
Example #14
0
        /// <summary>
        /// Working with SQL
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void mainWindow_Load(object sender, EventArgs e)
        {
            // on start hide panel2
            splitContainer.Panel2Collapsed = true;
            splitContainer.BorderStyle = BorderStyle.FixedSingle;

            // menu for treeView
            showInformation = new MenuItem();
            showInformation.Text = "Show task information";
            showInformation.Click += new EventHandler(showInformation_Click);
            cont_menu.MenuItems.Add(showInformation);

            // Initialization DB
            dbrespons = DBOperation.initDateBase();
            if (dbrespons.resultOperation() != DBStatus.InitDBSuccessful)
            {
                MessageBox.Show("Error durning initialization DB" + dbrespons.errorMessage(), "Information",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //seting up position of task board
            int x = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
            int y = 10;
            x -= (10 + taskBoard.Width);

            taskBoard.StartPosition = FormStartPosition.Manual;
            taskBoard.Location = new Point(x, y);
            taskBoard.Visible = true;

            // creating new tree folder list
            updateTaskList();
            createTreeView.initTreeView();
            updateTaskBoard();
        }