public void Add(incollection entity) { _iConnection.ExecuteScalar <incollection>( "INSERT INTO incollection (chapter, author, month, note, title, volume, year, address, type," + " bibtexkey, entrytype ,publisher, series, edition, booktitle, editor, pages) VALUES( @chapter, @author, @month, @note, @title," + " @volume, @year, @address, @type, @bibtexkey, @entrytype, @publisher, @series, @edition, @booktitle, @editor, @pages)", new { entity.entrytype, entity.bibtexkey, entity.author, entity.address, entity.chapter, entity.publisher, entity.series, entity.type, entity.title, entity.month, entity.note, entity.volume, entity.edition, entity.year, entity.ID, entity.booktitle, entity.editor, entity.pages, }); }
public void Update(incollection entity) { _iConnection.ExecuteScalar <incollection>( "UPDATE incollection SET author=@author, entrytype=@entrytype, bibtexkey=@bibtexkey, booktitle=@booktitle, " + " month=@month, note=@note, chapter@chapter, pages=@pages, publisher=@publisher, series=@series, type=@type, " + "title=@title, editor=@editor, address=@address, edition=@edition, volume=@volume, year=@year where ID = @ID", new { entity.entrytype, entity.bibtexkey, entity.author, entity.address, entity.chapter, entity.publisher, entity.series, entity.type, entity.title, entity.month, entity.note, entity.volume, entity.edition, entity.year, entity.ID, entity.booktitle, entity.editor, entity.pages, }); }
private void Add_Button_Click(object sender, RoutedEventArgs e) { MainWindow main = Application.Current.Windows.OfType <MainWindow>().First(); incollection _incollection = new incollection() { bibtexkey = bibtexkey_Txt.Text, title = title_Txt.Text, year = year_Txt.Text != "" ? Convert.ToInt32(year_Txt.Text) : null as int?, month = month_Txt.Text != "" ? Convert.ToInt32(month_Txt.Text) : null as int?, volume = volume_Txt.Text != "" ? Convert.ToInt32(volume_Txt.Text) : null as int?, address = address_Txt.Text, booktitle = booktitle_Txt.Text, chapter = chapter_Txt.Text != "" ? Convert.ToInt32(chapter_Txt.Text) : null as int?, edition = edition_Txt.Text != "" ? Convert.ToInt32(edition_Txt.Text) : null as int?, editor = editor_Txt.Text, publisher = publisher_Txt.Text, series = series_Txt.Text != "" ? Convert.ToInt32(series_Txt.Text):null as int?, type = type_Txt.Text, author = author_Txt.Text, pages = pages_Txt.Text, note = note_Txt.Text, entrytype = GetEntryType.GetValueByEnum(GetEntryType.EntryType.InCollection) }; bool result = AllFieldEmpty(); if (!result) { _iInCollectionService.Add(_incollection); SetFieldClear(); UIElement parent = App.Current.MainWindow; parent.IsEnabled = true; main.DataGridMain.ItemsSource = GetEntryType.GetAllByTypes(); this.Close(); } else { if (MessageBox.Show("Are you Sure to create a empty .bib", "Question", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No) { //do no stuff return; } else { _iInCollectionService.Add(_incollection); SetFieldClear(); main.DataGridMain.ItemsSource = GetEntryType.GetAllByTypes(); UIElement parent = App.Current.MainWindow; parent.IsEnabled = true; this.Close(); //do yes stuff } } }
public InCollectionView() { _iInCollectionService = InstanceFactory.GetInstance <DapperIncollectionDal>(); InitializeComponent(); DataContext = new incollection(); }