private void register_current() { if (String.IsNullOrEmpty(TB_title.Text)) { return; } ChapterSong cs = new ChapterSong(); cs.Id = ics; ics++; cs.Title = TB_title.Text; parent.shortslist.Add(cs); AuthorChapter ac = make_authorchapter(TB_author.Text, cs.Id); if (ac != null) { parent.shortsauthorlist.Add(ac); } foreach (string s in LB_coauthor.Items) { AuthorChapter acc = make_authorchapter(s, cs.Id); if (acc != null) { parent.shortsauthorlist.Add(acc); } } }
private AuthorChapter make_authorchapter(string author, int csid) { AuthorChapter ac = new AuthorChapter(); ac.Id = iac; iac++; ac.ChapterSong = csid; Author au = (from c in db.Author where c.Name == author select c).FirstOrDefault(); if (au == null) { int authorid = authorclass.NewAuthor(db, author); if (authorid > 0) { ac.Author = authorid; return(ac); } return(null); } else { ac.Author = au.Id; return(ac); } }