private void btnGravar_Click(object sender, RoutedEventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(txtProcedimento.Text))
     {
         procedimento = new Procedimento
         {
             NomeProcedimento = txtProcedimento.Text,
             Valor            = Convert.ToDouble(txtValor.Text)
         };
         if (ProcedimentoDAO.Cadastrar(procedimento))
         {
             MessageBox.Show("Procedimento cadastrado!", "Vendas WPF",
                             MessageBoxButton.OK, MessageBoxImage.Information);
             LimparFormulario();
         }
         else
         {
             MessageBox.Show("Esse Procedimento já existe!", "Vendas WPF",
                             MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
     else
     {
         MessageBox.Show("Preencha o campo Procedimento!!!", "Vendas WPF",
                         MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
        public ObservableCollection <KeyValuePair <int, string> > CarregarProcedimentos()
        {
            var             chavesValoresProcedimentos = new ObservableCollection <KeyValuePair <int, string> >();
            ProcedimentoDAO procedimentoDAO            = new ProcedimentoDAO();
            var             procedimentos = procedimentoDAO.Listar();

            foreach (ProcedimentoModel item in procedimentos)
            {
                chavesValoresProcedimentos.Add(new KeyValuePair <int, string>(item.Id, item.Nome));
            }
            return(chavesValoresProcedimentos);
        }
Exemple #3
0
 public ProcedimentoViewModel()
 {
     LimparUsuarioAtual();
     _procedimentoDAO = new ProcedimentoDAO();
     AtualizarLista();
 }