コード例 #1
0
        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!");
        }
コード例 #2
0
        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);
                }
            }
        }