private void newRecordToolStripMenuItem_Click(object sender, EventArgs e) { ToolStripItem menu = sender as ToolStripItem; if (menu != null) { ContextMenuStrip popup = menu.Owner as ContextMenuStrip; if (popup != null) { Control src = popup.SourceControl; DataGridView grid = src as DataGridView; if (grid == dgvMaster) { MasterNote master = (MasterNote)masterNoteBindingSource.AddNew(); masterNoteBindingSource.EndEdit(); _dbContext.SaveChanges(); _dbContext.Entry(master).GetDatabaseValues(); } if (grid == dgvDetail) { DetailNote detail = (DetailNote)detailNotesBindingSource.AddNew(); detailNotesBindingSource.EndEdit(); _dbContext.SaveChanges(); _dbContext.Entry(detail).GetDatabaseValues(); } } } }
private void detailNotesBindingSource_AddingNew(object sender, AddingNewEventArgs e) { DetailNote detail = new DetailNote(); detail.IsCompleted = false; detail.StartDate = DateTime.Now; detail.Description = "Enter your notes here"; e.NewObject = detail; }
public void AddDetailNotes(DetailNote detailNote) { if(Sections == null) return; var detail = (from sh in Sections where sh.Items != null from s in sh.Items where s.Details != null from dh in s.Details where dh.Items != null from d in dh.Items where d.Id == detailNote.SectionDetailId select d).SingleOrDefault(); if (detail == null) return; detail.DetailNote = detailNote; }