Exemplo n.º 1
0
        private void listar(string nome)
        {
            Produto_Helper_CRUD phc = new Produto_Helper_CRUD(App.ligacaoBD);

            if (nome == "")
            {
                _contentor = new ObservableCollection <Produto>(phc.list());
            }
            else
            {
                _contentor = new ObservableCollection <Produto>(phc.list(nome));
            }

            ListViewProducts.ItemsSource = _contentor;
        }
Exemplo n.º 2
0
        private void BtnAttStk_Click(object sender, RoutedEventArgs e)
        {
            if (txtStock.Text != "")
            {
                Produto_Helper_CRUD phc = new Produto_Helper_CRUD(App.ligacaoBD);
                Produto             p;

                if (_editProduto == null)
                {
                    p = new Produto();
                }
                else
                {
                    p = _editProduto;
                }
                p.Nome      = txtName.Text;
                p.Categoria = txtCat.Text;
                p.Preco     = Convert.ToDecimal(txtPreco.Text);
                try
                {
                    p.Stock = Convert.ToInt32(txtStock.Text);
                }
                catch
                {
                    p.Stock = 0;
                }
                string status = phc.atualizar(p);
                if (status != "")
                {
                    MessageBox.Show("Erro: " + status);
                }
                else
                {
                    resetForm();
                    nome = "";
                    listar(nome);
                }
            }
            else
            {
                MessageBox.Show("Todos os campos devem ser preenchidos!!");
            }
        }