Esempio n. 1
0
        private void btnVoltar(object sender, RoutedEventArgs e)
        {
            var telaListarPeca = new ListarPecas();

            this.Close();
            telaListarPeca.Show();
        }
Esempio n. 2
0
        private void btnSalvar(object sender, RoutedEventArgs e)
        {
            Peca   novaPeca   = new Peca();
            string nome       = textNomePec.Text.Trim();
            int    quantidade = int.Parse(textQtdePec.Text);
            double teste      = 1000.22;

            Console.WriteLine("Valor teste" + teste);
            double valor = double.Parse(textValorPec.Text.Replace("$", "").Replace(",", ""), CultureInfo.InvariantCulture);

            Console.WriteLine("Valor alterado" + valor);
            if (isName(nome) && isValue(textValorPec.Text))
            {
                novaPeca.NomePec  = nome;
                novaPeca.QtdePeca = quantidade;
                novaPeca.ValPec   = valor;

                DAOPeca peca = new DAOPeca();
                peca.inserir(novaPeca);
                var alerta = new Alerta();
                alerta.conteudo.Content = "Peça cadastrada com sucesso";
                alerta.ShowDialog();
                var telaListarPeca = new ListarPecas();
                this.Close();
                telaListarPeca.Show();
            }
            else
            {
                if (!isName(nome))
                {
                    lblNomeIncorreto.Visibility = Visibility.Visible;
                }
                if (!isValue(textValorPec.Text))
                {
                    lblValorIncorreto.Visibility = Visibility.Visible;
                }

                var alerta = new Alerta();
                alerta.conteudo.Content = "Preencha os campos corretamente!";
                alerta.ShowDialog();
            }
        }