Ejemplo n.º 1
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            TasksLocalShare.Task task = new TasksLocalShare.Task();
            //dont need id on save... ***********************
            task.LastEditBy   = Environment.UserName;
            task.LastEditDate = DateTime.Now;
            task.TaskDetails  = textBoxNotes.Text;
            task.TaskStatus   = (TasksLocalShare.TaskStatus)comboBoxStatus.SelectedItem;
            task.TaskTitle    = textBoxTitle.Text;
            TasksLocalShare.AddTask(task);

            this.Close();
        }
Ejemplo n.º 2
0
        private void toolStripButton13_Click(object sender, EventArgs e)
        {
            //delete item
            if (dataGridView1.SelectedRows.Count > 0)
            {
                TasksLocalShare.Task task = (TasksLocalShare.Task)dataGridView1.SelectedRows[0].Tag;

                int index = dataGridView1.SelectedRows[0].Index - 1;

                dataGridView1.Rows.Remove(dataGridView1.SelectedRows[0]);
                //dataGridView1.Rows[0].Selected = true;
                //now delete from xml and refresh
                TasksLocalShare.DeleteTask(task.TaskId);

                textBoxContent.Text = "";

                SetGridSelect();

                refreshTasks();
            }
        }
Ejemplo n.º 3
0
        private void SetGridSelect(int selected = 0)
        {
            if (selected > 0)
            {
                dataGridView1.Rows[selected].Selected = true;
            }
            else if (dataGridView1.SelectedRows == null & dataGridView1.Rows.Count > 0)
            {
                dataGridView1.Rows[0].Selected = true;
            }

            if (dataGridView1.SelectedRows.Count > 0)
            {
                //bring task direct from file here
                TasksLocalShare.Task task = (TasksLocalShare.Task)dataGridView1.SelectedRows[0].Tag;
                textBoxContent.Text         = task.TaskDetails;
                textBoxContent.Tag          = task;
                labelEditDate.Text          = task.LastEditDate.ToString();
                comboBoxStatus.SelectedItem = (object)task.TaskStatus;
            }
        }
Ejemplo n.º 4
0
        private void button3_Click(object sender, EventArgs e)
        {
            //first check the file has not changed by someone else in the meantime

            TasksLocalShare.Task task = (TasksLocalShare.Task)textBoxContent.Tag;

            bool            letsSave           = true;
            Nullable <bool> hasTaskBeenChanged = TasksChecker.LocalTaskChanged(task);
            bool            hasValue           = hasTaskBeenChanged.HasValue;

            if (hasValue)
            {
                if (hasTaskBeenChanged.Value)
                {
                    if (MessageBox.Show("This task has been changed since loading. Do you want to save anyway?", "This task has been changed since loading", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No)
                    {
                        letsSave = false;
                    }
                }
            }
            else
            {
                //has been delted - offer to save as new
                letsSave = false;
                MessageBox.Show("This task has been deleted while you where editing it", "This task has been deleted while you where editing it", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if (letsSave)
            {
                task.TaskStatus   = (TasksLocalShare.TaskStatus)comboBoxStatus.SelectedItem;
                task.TaskDetails  = textBoxContent.Text;
                task.LastEditDate = DateTime.Now;
                task.LastEditBy   = Environment.UserName;
                TasksLocalShare.UpdateTask(task);
            }

            refreshTasks(dataGridView1.SelectedRows[0].Index);
        }
Ejemplo n.º 5
0
        //when user clicks the save then check the source task file for that item
        //if it is diff than what you have in the currentTasks list
        //then warn/load the current document.
        public static Nullable <bool> LocalTaskChanged(TasksLocalShare.Task Task)
        {
            //now check against currenttasks in the last loaded list...

            List <TasksLocalShare.Task> sourceTasks = TasksLocalShare.LoadTaskList(); //from source

            //find from list check taskStatus and taskDetails

            TasksLocalShare.Task t = sourceTasks.Find(s => s.TaskId == Task.TaskId);

            if (t == null)
            {
                return(null); //been deleted
            }
            if (t.TaskDetails == Task.TaskDetails & t.TaskStatus == Task.TaskStatus & t.LastEditBy == Task.LastEditBy)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }