コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: Guisantos94/Cookie
        private void BtnArquivo_Importar_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "JSON files (*.json) | *.json";
            if (openFileDialog.ShowDialog() == true)
            {
                Arquivo   relatorio = new Arquivo();
                CookieDAO dao       = new CookieDAO();
                foreach (CookieClass cafe in relatorio.lerJson(openFileDialog.FileName))
                {
                    dao.inserirCookie(cafe);
                }
            }
        }
コード例 #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            CookieClass cookie = new CookieClass()
            {
                Sabor = txtSabor.Text,
                Valor = Convert.ToDecimal(txtValor.Text)
            };

            CookieDAO dao = new CookieDAO();

            dao.inserirCookie(cookie);
            MessageBox.Show("cookie cadastrado com sucesso!!");
            txtSabor.Clear();
            txtValor.Clear();
        }