Exemplo n.º 1
0
        private void Add_Button_Click(object sender, RoutedEventArgs e)
        {
            MainWindow main    = Application.Current.Windows.OfType <MainWindow>().First();
            inbook     _inbook = new inbook()
            {
                bibtexkey = bibtexKey_Txt.Text,
                title     = title_Txt.Text,
                year      = year_Txt.Text != "" ? Convert.ToInt32(year_Txt.Text) : null as int?,
                chapter   = chapter_Txt.Text != "" ? Convert.ToInt32(chapter_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?,
                author    = author_Txt.Text,
                address   = address_Txt.Text,
                edition   = edition_Txt.Text != "" ? Convert.ToInt32(edition_Txt.Text) : null as int?,
                note      = note_Txt.Text,
                publisher = publisher_Txt.Text,
                series    = series_Txt.Text != "" ? Convert.ToInt32(series_Txt.Text) : null as int?,
                type      = type_Txt.Text,
                entrytype = GetEntryType.GetValueByEnum(GetEntryType.EntryType.InBook)
            };


            bool result = AllFieldEmpty();

            if (!result)
            {
                _inBookService.Add(_inbook);
                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
                {
                    _inBookService.Add(_inbook);
                    SetFieldClear();
                    main.DataGridMain.ItemsSource = GetEntryType.GetAllByTypes();
                    UIElement parent = App.Current.MainWindow;
                    parent.IsEnabled = true;
                    this.Close();
                    //do yes stuff
                }
            }
        }
Exemplo n.º 2
0
 public void Add(inbook entity)
 {
     _iConnection.ExecuteScalar <inbook>(
         "INSERT INTO inbook (chapter, author, month, note, title, volume, year, address, type," +
         " bibtexkey, entrytype ,publisher, series, edition) VALUES( @chapter, @author, @month, @note, @title," +
         " @volume, @year, @address, @type, @bibtexkey, @entrytype, @publisher, @series, @edition)", 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
     });
 }
Exemplo n.º 3
0
 public void Update(inbook entity)
 {
     _iConnection.ExecuteScalar <inbook>(
         "UPDATE inbook SET author=@author, entrytype=@entrytype, bibtexkey=@bibtexkey, " +
         " month=@month, note=@note, chapter=@chapter, publisher=@publisher, series=@series, type=@type," +
         "title=@title, 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
     });
 }
Exemplo n.º 4
0
 public InBookView()
 {
     _inBookService = InstanceFactory.GetInstance <DapperInbookDal>();
     InitializeComponent();
     DataContext = new inbook();
 }