예제 #1
0
        private void newCommonTaskToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmTimeEntry form = new frmTimeEntry(Settings.CurrentSettings.NextCommonTask);

            if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Settings.CurrentSettings.CommonTasks.Add(form.Value);
            }
            RefreshCommonTasks();
        }
예제 #2
0
        private void editCommonTaskToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TimeEntry task = (sender as ToolStripMenuItem).Tag as TimeEntry;

            frmTimeEntry form = new frmTimeEntry(task);

            if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Settings.CurrentSettings.CommonTasks.Remove(task);
                Settings.CurrentSettings.CommonTasks.Add(form.Value);
            }
            RefreshCommonTasks();
        }
예제 #3
0
        private bool EditEntry(TimeEntry temp)
        {
            frmTimeEntry form = new frmTimeEntry(temp);

            if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Settings.CurrentSettings.TimeEntries.Remove(temp);
                TimeEntry newValue = form.Value;
                AddTimeEntry(newValue);
                return(true);
            }
            return(false);
        }
예제 #4
0
        private void addToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Tuple <bool, DateTime> closeResult = CloseCurrentTask();

            if (Settings.CurrentSettings.TimeEntries.Count == 0 || closeResult.Item1)
            {
                frmTimeEntry form = new frmTimeEntry();
                form.Start = closeResult.Item2;
                form.Text  = "Starting a new task...";
                DialogResult result = form.ShowDialog();
                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    TimeEntry newValue = form.Value;
                    AddTimeEntry(newValue);
                }
            }
        }
예제 #5
0
        private Tuple <bool, DateTime> CloseCurrentTask()
        {
            TimeEntry lastTask = Settings.CurrentSettings.LastUnclosedTask;

            if (Settings.CurrentSettings.TimeEntries.Count > 0 && lastTask != null)
            {
                TimeEntry temp = new TimeEntry(lastTask);
                temp.Stop = DateTime.Now;
                frmTimeEntry form = new frmTimeEntry(temp, true);
                form.Text = "Closing " + temp.ToString();
                if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    Settings.CurrentSettings.TimeEntries.Remove(lastTask);
                    TimeEntry newValue = form.Value;
                    AddTimeEntry(newValue);
                    return(new Tuple <bool, DateTime>(true, newValue.Stop));
                }
                return(new Tuple <bool, DateTime>(false, DateTime.Now));
            }
            return(new Tuple <bool, DateTime>(true, DateTime.Now));
        }