private void Add_Button_Click(object sender, RoutedEventArgs e) { MainWindow main = Application.Current.Windows.OfType <MainWindow>().First(); manual _manual = new manual() { 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?, author = author_Txt.Text, note = note_Txt.Text, address = address_Txt.Text, edition = edition_Txt.Text != "" ? Convert.ToInt32(edition_Txt.Text): null as int?, organization = organization_Txt.Text, entrytype = GetEntryType.GetValueByEnum(GetEntryType.EntryType.Manual) }; bool result = AllFieldEmpty(); if (!result) { _iManualService.Add(_manual); 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 { _iManualService.Add(_manual); SetFieldClear(); main.DataGridMain.ItemsSource = GetEntryType.GetAllByTypes(); UIElement parent = App.Current.MainWindow; parent.IsEnabled = true; this.Close(); //do yes stuff } } }
public void Add(manual entity) { _iConnection.ExecuteScalar <manual>( "INSERT INTO manual (entrytype, bibtexkey, title, author, organization, address, edition, month, year, note)" + " VALUES(@entrytype, @bibtexkey, @title, @author, @organization, @address ,@edition, @month, @year, @note)", new { entity.entrytype, entity.bibtexkey, entity.title, entity.author, entity.organization, entity.address, entity.edition, entity.month, entity.year, entity.note }); }
public void Update(manual entity) { _iConnection.ExecuteScalar <manual>( "UPDATE manual SET entrytype=@entrytype, bibtexkey=@bibtexkey, title=@title, author=@author, organization=@organization," + " address=@address, edition=@edition, month=@month, year=@year, note=@note where ID = @ID", new { entity.entrytype, entity.bibtexkey, entity.title, entity.author, entity.organization, entity.address, entity.edition, entity.month, entity.year, entity.note, entity.ID }); }
public ManualView() { _iManualService = InstanceFactory.GetInstance <DapperManualDal>(); InitializeComponent(); DataContext = new manual(); }