Esempio n. 1
0
        private void ReturnAgua(object sender, RoutedEventArgs e)
        {
            sqliteConnection = new SQLiteConnection("Data Source=.\\dados\\DadosAgua.db; Version=3;");
            sqliteConnection.Open();

            SQLiteCommand    cmd = new SQLiteCommand("Select * from DadosAgua", sqliteConnection);
            SQLiteDataReader da  = cmd.ExecuteReader();

            while (da.Read())
            {
                lastID            = Convert.ToInt32(da.GetValue(0));
                textContador.Text = da.GetValue(3).ToString();
            }

            sqliteConnection.Close();

            DalHelper.Delete(lastID);

            sqliteConnection = new SQLiteConnection("Data Source=.\\dados\\DadosAgua.db; Version=3;");
            sqliteConnection.Open();

            SQLiteCommand    cmd2 = new SQLiteCommand("Select * from DadosAgua", sqliteConnection);
            SQLiteDataReader da2  = cmd2.ExecuteReader();

            while (da2.Read())
            {
                textContador.Text = da2.GetValue(3).ToString();
            }

            sqliteConnection.Close();

            //falta o metodo atualizadados() separado

            MessageBox.Show("Entrada Excluída com Sucesso!!!", "BebaAguaAPP", MessageBoxButton.OK, MessageBoxImage.Information);
        }
        public void BtnExcluirDados(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(txtID.Text))
            {
                MessageBox.Show("Informe o ID da entrada a ser Excluída");
                return;
            }

            try
            {
                int codigo = Convert.ToInt32(txtID.Text);
                DalHelper.Delete(codigo);
                ExibirDados();
                LimpaDados();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro : " + ex.Message);
            }
        }