private void buttonQuery_Click(object sender, EventArgs e) { StringBuilder sb = new StringBuilder(); var key_word = textBoxKey.Text; if (string.IsNullOrEmpty(key_word)) { return; } DBUtil <Note> dBUtil = new DBUtil <Note>(); var notes = dBUtil.GetAllWithOrRestrictionsStringInsentiveLike("Name", key_word); if (notes.Count > 0) { foreach (var note in notes) { sb.AppendLine(note.ToString()); } } DBUtil <Person> dBUtilPerson = new DBUtil <Person>(); var people = dBUtilPerson.GetAllWithOrRestrictionsStringInsentiveLike("Name", key_word); if (people.Count > 0) { foreach (var person in people) { sb.AppendLine(person.ToString()); } } DBUtil <Place> dBUtilPlace = new DBUtil <Place>(); var places = dBUtilPlace.GetAllWithOrRestrictionsStringInsentiveLike("Name", key_word); if (places.Count > 0) { foreach (var place in places) { sb.AppendLine(place.ToString()); } } textBox3.Text = sb.ToString(); }
private void button1_Click(object sender, EventArgs e) { var name = textBoxName.Text; var bookName = "Inferno"; if (textBoxBook.Text == "2") { bookName = "Purgatorio"; } if (textBoxBook.Text == "3") { bookName = "Paridiso"; } Note note = new Note { Name = name, Commentary = textBoxCommentary.Text }; note.Loc = new Loc { Book = bookName, Canto = int.Parse(textBoxCanto.Text), Start = int.Parse(textBoxStart.Text), End = int.Parse(textBoxEnd.Text), }; if (checkBoxTerm.Checked == true) { var terms = _dBUtilTerm.GetAllWithOrRestrictionsStringInsentiveLike("Name", name, "Alias"); if (terms == null || terms.Count == 0) { var itemType = (string)comboBoxTermItemType.SelectedItem; var term = new Term { Name = name }; if (!string.IsNullOrEmpty(itemType)) { if (itemType == "Item") { itemType = "Metaphor"; } ; term.SetMetaphorItem(itemType, ""); switch (itemType) { case "Place": { var placeUtil = new DBUtil <Place>(); var places = placeUtil.GetAllWithOrRestrictionsStringInsentiveLike("Name", name, "Alias"); if (places == null || places.Count == 0) { var place = new Place { Name = name }; placeUtil.save(place); } } break; case "Politician": { var placeUtil = new DBUtil <Politician>(); var places = placeUtil.GetAllWithOrRestrictionsStringInsentiveLike("Name", name, "Alias"); if (places == null || places.Count == 0) { var place = new Politician { Name = name }; placeUtil.save(place); } } break; case "Poet": { var placeUtil = new DBUtil <Poet>(); var places = placeUtil.GetAllWithOrRestrictionsStringInsentiveLike("Name", name, "Alias"); if (places == null || places.Count == 0) { var place = new Poet { Name = name }; placeUtil.save(place); } } break; case "Character": { var placeUtil = new DBUtil <Character>(); var places = placeUtil.GetAllWithOrRestrictionsStringInsentiveLike("Name", name, "Alias"); if (places == null || places.Count == 0) { var place = new Character { Name = name }; placeUtil.save(place); } } break; case "Person": { var personUtil = new DBUtil <Person>(); var people = personUtil.GetAllWithOrRestrictionsStringInsentiveLike("Name", name, "Alias"); if (people == null || people.Count == 0) { var person = new Person { Name = name }; personUtil.save(person); } } break; } } term.AddNote(note); _dBUtilTerm.save(term); } else { var term = terms[0]; term.AddNote(note); _dBUtilTerm.save(term); } } _dBUtilNote.save(note); }