コード例 #1
0
        private void btnSalvar_Click(object sender, RoutedEventArgs e)
        {
            var result = MessageBox.Show("Deseja realmente salvar?", "Atenção", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                TreinaWebWPFEntities entities = new TreinaWebWPFEntities();

                if (cursoAtual.twc_id != 0)
                {
                    entities.Entry(cursoAtual).State = System.Data.Entity.EntityState.Modified;
                }
                else
                {
                    entities.Entry(cursoAtual).State = System.Data.Entity.EntityState.Added;
                }

                entities.SaveChanges();
            }
        }
コード例 #2
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            TreinaWebWPFEntities entities = new TreinaWebWPFEntities();

            dgCursos.ItemsSource = entities.twc_cursos.OrderBy(c => c.twc_nome).ToList();
        }