private void AddButton_Click(object sender, EventArgs e) { Project project = new Project { Id = Guid.NewGuid(), Active = true }; editDialog.DialogContext = new DialogContext<Project> { SessionContext = this.SessionContext, DataContext = this.dataContext, Item = project }; if (editDialog.ShowDialog(this) == DialogResult.OK) { dataContext.Projects.InsertOnSubmit(project); dataContext.SubmitChanges(); listView.BeginUpdate(); AddListViewItem(project); listView.EndUpdate(); } }
partial void DeleteProject(Project instance);
partial void UpdateProject(Project instance);
partial void InsertProject(Project instance);
private void AddListViewItem(Project project) { var item = new ListViewItem(); SetListViewItem(item, project); listView.Items.Add(item); }
private void SetListViewItem(ListViewItem item, Project project) { item.SubItems.Clear(); item.Text = project.Name; item.SubItems.Add(project.Description); item.SubItems.Add(DatabaseUtilities.BoolToYesNoString(project.Active)); item.SubItems.Add(project.ExternalCode); item.Tag = project; }