private void Button_Click(object sender, RoutedEventArgs e) { CafeDAO cdao = new CafeDAO(); Cafe cafe = new Cafe() { Nome = txtNome.Text, Sabor = txtSabor.Text, Valor = Convert.ToDecimal(txtValor.Text), Descricao = txtDesc.Text }; cdao.inserir(cafe); MessageBox.Show("Cafe inserido com sucesso!"); }
private void BtnDialog_Click(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "JSON files (*.json) | *.json"; if (openFileDialog.ShowDialog() == true) { Relatorio relatorio = new Relatorio(); CafeDAO cDao = new CafeDAO(); foreach (Cafe cafe in relatorio.lerJson(openFileDialog.FileName)) { cDao.inserir(cafe); } } }