private void Add_Button_Click(object sender, RoutedEventArgs e) { MainWindow main = Application.Current.Windows.OfType <MainWindow>().First(); booklet _booklet = new booklet() { bibtexkey = bibtexKey_Txt.Text, title = title_Txt.Text, address = address_Txt.Text, author = author_Txt.Text, entrytype = GetEntryType.GetValueByEnum(GetEntryType.EntryType.Booklet), howpublished = howpublished_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?, note = note_Txt.Text }; bool result = AllFieldEmpty(); if (!result) { _iBookletService.Add(_booklet); 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 { _iBookletService.Add(_booklet); SetFieldClear(); main.DataGridMain.ItemsSource = GetEntryType.GetAllByTypes(); UIElement parent = App.Current.MainWindow; parent.IsEnabled = true; this.Close(); //do yes stuff } } }
public void Add(booklet entity) { _iConnection.ExecuteScalar <booklet>( "INSERT INTO booklet (author, month, note, title, howpublished, " + "year, address, bibtexkey, entrytype) VALUES( @author, @month, @note," + " @title, @howpublished, @year, @address, @bibtexkey, @entrytype)", new { entity.title, entity.author, entity.howpublished, entity.address, entity.month, entity.note, entity.year, entity.bibtexkey, entity.entrytype }); }
public void Update(booklet entity) { _iConnection.ExecuteScalar <booklet>( "UPDATE booklet SET author=@author, entrytype=@entrytype, bibtexkey=@bibtexkey, month=@month, " + "note=@note, title=@title, year=@year, howpublished=@howpublished, address=@address where ID = @ID", new { entity.title, entity.author, entity.howpublished, entity.address, entity.month, entity.note, entity.year, entity.bibtexkey, entity.entrytype, entity.ID }); }
public BookletView() { _iBookletService = InstanceFactory.GetInstance <DapperBookletDal>(); InitializeComponent(); DataContext = new booklet(); }