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(); }
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(); } }
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; }
/// <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); }
partial void DeleteWorkEntry(WorkEntry instance);
partial void UpdateWorkEntry(WorkEntry instance);
partial void InsertWorkEntry(WorkEntry instance);
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(); }