コード例 #1
0
        private void okCancelControl_ButtonOKClick(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            WorkEntry entry = new WorkEntry
            {
                Id = Guid.NewGuid(),
                User = sessionContext.UserId,
                Start = DateTime.Now,
                Text = comboBoxText.Text
            };
            dataContext.AddWorkEntry(entry);
            dataContext.SubmitChanges();
            DialogResult = System.Windows.Forms.DialogResult.OK;
            Close();
        }
コード例 #2
0
 private void buttonOk_Click(object sender, RoutedEventArgs e)
 {
     using (new BusyScope(this, buttonOk, buttonCancel))
     {
         WorkEntry entry = new WorkEntry
         {
             Id = Guid.NewGuid(),
             User = sessionContext.UserId,
             Start = DateTime.Now,
             Text = comboBoxText.Text
         };
         dataContext.AddWorkEntry(entry);
         dataContext.SubmitChanges();
         Close();
     }
 }
コード例 #3
0
ファイル: WorkEntriesEditView.cs プロジェクト: helgihaf/Alpha
        private void SetListViewItem(ListViewItem item, WorkEntry entry)
        {
            item.SubItems.Clear();
            item.Text = entry.Start.ToString("T");
            string endString = string.Empty;
            if (entry.End.HasValue)
            {
                if (entry.Start.Date <= entry.End.Value.Date)
                {
                    endString = entry.End.Value.ToString("T");
                }
                else
                {
                    endString = entry.End.Value.ToString();
                }
            }
            item.SubItems.Add(endString);

            string projectString = string.Empty;
            if (entry.ProjectEntity != null)
            {
                projectString = entry.ProjectEntity.Name;
            }
            item.SubItems.Add(projectString);

            string activityString = string.Empty;
            if (entry.ActivityEntity != null)
            {
                activityString = entry.ActivityEntity.Name;
            }
            item.SubItems.Add(activityString);

            item.SubItems.Add(entry.Text);

            item.Tag = entry;
        }
コード例 #4
0
ファイル: WorkTrack.cs プロジェクト: helgihaf/Alpha
        /// <summary>
        /// Adds a new work entry, closing any open work entries for the user. Data is not submitted.
        /// </summary>
        /// <param name="entry"></param>
        public void AddWorkEntry(WorkEntry entry)
        {
            if (entry == null)
            {
                throw new ArgumentNullException("entry");
            }

            if (entry.Id == default(Guid))
            {
                throw new ArgumentException("Invalid user ID on entry");
            }

            if (entry.User == default(Guid))
            {
                throw new ArgumentException("Invalid user ID on entry");
            }

            if (entry.Start == default(DateTime))
            {
                throw new ArgumentException("Invalid start DateTime on entry");
            }

            // Close all open entries
            var openEntries =
                from openEntry in this.WorkEntries
                where openEntry.User == entry.User && openEntry.End == null
                select openEntry;

            foreach (var openEntry in openEntries)
            {
                openEntry.End = entry.Start;
            }

            // Add the new one
            this.WorkEntries.InsertOnSubmit(entry);
        }
コード例 #5
0
ファイル: WorkTrack.designer.cs プロジェクト: helgihaf/Alpha
 partial void DeleteWorkEntry(WorkEntry instance);
コード例 #6
0
ファイル: WorkTrack.designer.cs プロジェクト: helgihaf/Alpha
 partial void UpdateWorkEntry(WorkEntry instance);
コード例 #7
0
ファイル: WorkTrack.designer.cs プロジェクト: helgihaf/Alpha
 partial void InsertWorkEntry(WorkEntry instance);
コード例 #8
0
ファイル: TrackWorkDialog.cs プロジェクト: helgihaf/Alpha
        private void okCancelControl_ButtonOKClick(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            WorkEntry entry = new WorkEntry
            {
                Id = Guid.NewGuid(),
                User = sessionContext.UserId,
                Start = dateTimeStart.Value,
                Text = comboBoxText.Text
            };
            var project = GetSelection(comboBoxProject) as Project;
            if (project != null)
            {
                entry.Project = project.Id;
            }
            var activity = GetSelection(comboBoxActivity) as Activity;
            if (activity != null)
            {
                entry.Activity = activity.Id;
            }
            if (checkBoxEnd.Checked)
            {
                entry.End = dateTimeEnd.Value;
            }
            dataContext.AddWorkEntry(entry);
            dataContext.SubmitChanges();
            DialogResult = System.Windows.Forms.DialogResult.OK;
            Hide();
        }