private void btnAddStuff_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                notaProdutoDTO                    = new NotaProdutoDTO();
                notaProdutoDTO.Produto            = new ProdutoDTO();
                notaProdutoDTO.Produto            = produtoBLL.ReadName(cbStuff.SelectedValue.ToString())[0];
                notaProdutoDTO.QuantidadeComprada = float.Parse(txtStuffQt.Text.Replace(".", ","));
                notaProdutoDTO.ValorUnitario      = Convert.ToDecimal(txtUnitaryValue.Text.Replace(".", ","));
                notaProdutoDTO.ValorTotal         = (decimal)notaProdutoDTO.QuantidadeComprada * notaProdutoDTO.ValorUnitario;

                newCollection.Add(notaProdutoDTO);
                dataGridAddStuff.ItemsSource = null;
                dataGridAddStuff.ItemsSource = newCollection;
                LiberarRemoveStuff();

                cbStuff.SelectedIndex = -1;
                txtStuffQt.Text       = string.Empty;
                txtUnitaryValue.Text  = string.Empty;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Erro", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void btnRemoveStuff_Click(object sender, RoutedEventArgs e)
        {
            notaProdutoDTO = new NotaProdutoDTO();
            notaProdutoDTO = dataGridAddStuff.SelectedItem as NotaProdutoDTO;

            newCollection.Remove(notaProdutoDTO);
            dataGridAddStuff.ItemsSource = null;
            dataGridAddStuff.ItemsSource = newCollection;
            LiberarRemoveStuff();
        }
        private void btnEditStuff_Click(object sender, RoutedEventArgs e)
        {
            notaProdutoDTO = new NotaProdutoDTO();
            notaProdutoDTO = dataGridAddStuff.SelectedItem as NotaProdutoDTO;

            cbStuff.SelectedItem = notaProdutoDTO.Produto.DescricaoProduto;
            txtStuffQt.Text      = notaProdutoDTO.QuantidadeComprada.ToString().Replace(".", ",");
            txtUnitaryValue.Text = notaProdutoDTO.ValorUnitario.ToString().Replace(".", ",");

            newCollection.Remove(notaProdutoDTO);
            dataGridAddStuff.Items.Refresh();
        }
Пример #4
0
        /// <summary>
        /// Consulta informações de privilegio por nome.
        /// </summary>
        /// <param name="nota">Nome do privilegio que será consultado.</param>
        /// <returns>Informações do privilegio encontrado.</returns>
        public NotaProdutoCollectionDTO ReadInvoice(NotaDTO nota)
        {
            NotaProdutoCollectionDTO notaProdutoCollectionDTO = new NotaProdutoCollectionDTO();

            try
            {
                dataBaseAccess.ClearParameters();
                dataBaseAccess.AddParameters("_idNota", nota.IdNota);

                DataTable dataTable = new DataTable();
                dataTable = dataBaseAccess.Consult(CommandType.StoredProcedure, "sp_nota_produto_nota");

                foreach (DataRow row in dataTable.Rows)
                {
                    NotaProdutoDTO notaProdutoDTO = new NotaProdutoDTO();
                    notaProdutoDTO.Nota               = new NotaDTO();
                    notaProdutoDTO.Nota.IdNota        = Convert.ToInt32(row["IdNota"]);
                    notaProdutoDTO.QuantidadeComprada = float.Parse(row["QuantidadeComprada"].ToString());
                    notaProdutoDTO.ValorUnitario      = Convert.ToDecimal(row["ValorUnitario"]);
                    notaProdutoDTO.ValorTotal         = Convert.ToDecimal(row["ValorTotal"]);

                    notaProdutoDTO.Nota.Filial = new FilialDTO();
                    notaProdutoDTO.Nota.Filial.Pessoa.IdPessoa   = Convert.ToInt32(row["IdPessoaFilial"]);
                    notaProdutoDTO.Nota.Filial.Pessoa.NomePessoa = row["NomeFilial"].ToString();

                    notaProdutoDTO.Nota.Fornecedor = new FornecedorDTO();
                    notaProdutoDTO.Nota.Fornecedor.Pessoa.IdPessoa   = Convert.ToInt32(row["IdPessoaFornecedor"]);
                    notaProdutoDTO.Nota.Fornecedor.Pessoa.NomePessoa = row["NomeFornecedor"].ToString();

                    notaProdutoDTO.Produto                  = new ProdutoDTO();
                    notaProdutoDTO.Produto.IdProduto        = Convert.ToInt32(row["IdProduto"]);
                    notaProdutoDTO.Produto.DescricaoProduto = row["DescricaoProduto"].ToString();

                    notaProdutoDTO.Produto.Unidade              = new UnidadeDTO();
                    notaProdutoDTO.Produto.Unidade.IdUnidade    = Convert.ToInt32(row["IdProduto"]);
                    notaProdutoDTO.Produto.Unidade.SiglaUnidade = row["SiglaUnidade"].ToString();

                    notaProdutoCollectionDTO.Add(notaProdutoDTO);
                }

                return(notaProdutoCollectionDTO);
            }
            catch (Exception ex)
            {
                StringBuilder message = new StringBuilder();
                message.Append("Não foi possível consultar produto por nota:\n\n").Append(ex.Message);
                throw new Exception(message.ToString());
            }
            finally
            {
                dataBaseAccess.ClearParameters();
            }
        }
        private void btnNew_Click(object sender, RoutedEventArgs e)
        {
            buttonApply = EnumApplyAction.Create;

            //Lists
            dataGridInvoice.Visibility = Visibility.Hidden;

            //Buttons
            btnNew.Visibility   = btnEdit.Visibility = btnRemove.Visibility = Visibility.Hidden;
            btnApply.Visibility = btnCancel.Visibility = Visibility.Visible;

            notaProdutoDTO = new NotaProdutoDTO();
            newCollection  = new NotaProdutoCollectionDTO();
        }
Пример #6
0
        /// <summary>
        /// Consulta informações de privilegio por nome.
        /// </summary>
        /// <returns>Informações do privilegio encontrado.</returns>

        public string Create(NotaProdutoDTO notaProduto)
        {
            try
            {
                dataBaseAccess.ClearParameters();
                dataBaseAccess.AddParameters("_idNota", notaProduto.Nota.IdNota);
                dataBaseAccess.AddParameters("_idProduto", notaProduto.Produto.IdProduto);
                dataBaseAccess.AddParameters("_quantidadeComprada", notaProduto.QuantidadeComprada);
                dataBaseAccess.AddParameters("_valorUnitario", notaProduto.ValorUnitario);
                dataBaseAccess.AddParameters("_message", ErrorMessage.MensagemErro);
                return(dataBaseAccess.ExecuteQuery(CommandType.StoredProcedure, "sp_nota_produto_criar"));
            }
            catch (Exception ex)
            {
                StringBuilder message = new StringBuilder();
                message.Append("Não foi possível cadastrar os produtos na nota fiscal: ").Append(ex.Message);
                throw new Exception(message.ToString());
            }
            finally
            {
                dataBaseAccess.ClearParameters();
            }
        }