Esempio n. 1
0
        private void ResetarAgua(object sender, RoutedEventArgs e)
        {
            //  if (pegaAgua.Text == "" && copoml == 0 && totalml == 0 || pegaAgua.Text != "" && copoml == 0 && totalml == 0 || pegaAgua.Text != ""
            //  && copoml != 0 && totalml != 0 && contador == 0)
            //   {
            // MessageBox.Show("Defina as Configurações Primeiro!!!", "BebaAguaAPP", MessageBoxButton.OK, MessageBoxImage.Information);
            //   }
            // else {
            try
            {
                DadosAgua dad = new DadosAgua();

                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));
                }

                dad.Id            = lastID;
                dad.Contador      = "0";
                dad.PegaAguaValor = "0";

                DalHelper.Update2(dad);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro : " + ex.Message);
            }


            contador          = 0;
            textContador.Text = "0";
            carinha.Source    = (ImageSource)Resources["triste"];
        }
Esempio n. 2
0
        public void PegarAgua(object sender, RoutedEventArgs e)
        {
            //if (pegaAgua.Text == "" ||  copoml == 0 && totalml == 0)
            //  {
            //     MessageBox.Show("Defina as Configurações Primeiro!!!", "BebaAguaAPP", MessageBoxButton.OK, MessageBoxImage.Information);
            //  }
            //  else
            //  {
            // Pegaaguavalor = int.Parse(this.pegaAgua.Text) + Pegaaguavalor;
            contador          = contador + copoml;
            textContador.Text = contador.ToString();

            try
            {
                DadosAgua dad = new DadosAgua();

                dad.Contador   = contador.ToString();
                dad.ValorCopo  = copoml.ToString();
                dad.ValorTotal = totalml.ToString();
                dad.carinha    = "triste";
                dad.Data       = getData;
                dad.Hora       = getHora;

                DalHelper.Add(dad);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro : " + ex.Message);
            }

            if (contador < totalml / 2)
            {
                carinha.Source = (ImageSource)Resources["triste"];
                DadosAgua dad = new DadosAgua();
                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));
                }

                dad.Id      = lastID;
                dad.carinha = "triste";


                DalHelper.Update3(dad);
                Notifica(mensagem2);
            }

            if (contador == totalml / 2)
            {
                carinha.Source = (ImageSource)Resources["zen1"];

                DadosAgua dad = new DadosAgua();
                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));
                }

                dad.Id      = lastID;
                dad.carinha = "zen1";

                DalHelper.Update3(dad);
                Notifica(mensagem3);
            }

            if (contador > totalml / 2 && contador < totalml)
            {
                carinha.Source = (ImageSource)Resources["zen2"];

                DadosAgua dad = new DadosAgua();
                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));
                }

                dad.Id      = lastID;
                dad.carinha = "zen2";

                DalHelper.Update3(dad);

                Notifica(mensagem4);
            }

            if (contador >= totalml && contador < totalml * 2)
            {
                carinha.Source = (ImageSource)Resources["haha"];

                DadosAgua dad = new DadosAgua();
                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));
                }

                dad.Id      = lastID;
                dad.carinha = "haha";

                DalHelper.Update3(dad);
                Notifica(mensagem5);
            }


            if (contador >= totalml * 2)
            {
                carinha.Source = (ImageSource)Resources["wow"];

                DadosAgua dad = new DadosAgua();
                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));
                }

                dad.Id      = lastID;
                dad.carinha = "wow";

                DalHelper.Update3(dad);
                Notifica(mensagem6);
            }

            if (contador >= 10000)
            {
                contador = 10000;

                try
                {
                    DadosAgua dad = new DadosAgua();

                    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));
                    }

                    dad.Id       = lastID;
                    dad.Contador = "10000";


                    DalHelper.Update2(dad);

                    dad.carinha = "wow";
                    DalHelper.Update3(dad);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Erro : " + ex.Message);
                }

                textContador.Text = "10000";
                carinha.Source    = (ImageSource)Resources["wow"];
            }
        }