public EstoqueMovimentacaoColecao ConsultarPorFilial(int filial)
        {
            try
            {
                EstoqueMovimentacaoColecao estoqueMovimentacaoColecao = new EstoqueMovimentacaoColecao();
                conexao.LimparParametros();

                conexao.AdicionarParametros("@Filial", filial);

                DataTable dataTable = conexao.ExecutarConsulta(CommandType.StoredProcedure, "uspEstoqueMovimentacaoConsultarPorFilial");

                foreach (DataRow dataRow in dataTable.Rows)
                {
                    EstoqueMovimentacao estoque = new EstoqueMovimentacao();
                    estoque.IDFilial     = Convert.ToInt32(dataRow["IDFilial"]);
                    estoque.IDProduto    = Convert.ToInt32(dataRow["IDProduto"]);
                    estoque.Quantidade   = Convert.ToInt32(dataRow["Quantidade"]);
                    estoque.EntradaSaida = Convert.ToString(dataRow["EntradaSaida"]);
                    estoque.DataHora     = Convert.ToDateTime(dataRow["DataHora"]);

                    estoqueMovimentacaoColecao.Add(estoque);
                }

                return(estoqueMovimentacaoColecao);
            }
            catch (Exception ex)
            {
                throw new Exception("Erro ao consultar movimentação do estoque. Detalhes: " + ex.Message);
            }
        }
Esempio n. 2
0
        public override async Task <EstoqueMovimentacao> DomainOrchestration(EstoqueMovimentacao entity, EstoqueMovimentacao entityOld)
        {
            await this.AtualizaQuantidadeNoEstoque(entity);

            await this.AtualizaEstoqueColaborador(entity);

            return(entity);
        }
Esempio n. 3
0
        protected override EstoqueMovimentacao AddDefault(EstoqueMovimentacao estoquemovimentacao)
        {
            if (estoquemovimentacao.Estoque.IsNotNull())
            {
                _repEstoque.Update(estoquemovimentacao.Estoque);
            }

            return(base.AddDefault(estoquemovimentacao));
        }
Esempio n. 4
0
        private async Task AtualizaQuantidadeNoEstoque(EstoqueMovimentacao entity)
        {
            var estoque = await _repEstoque.GetById(new EstoqueFilter()
            {
                EstoqueId = entity.EstoqueId
            });

            estoque.AtualizarQuantidade(entity.Quantidade, entity.Entrada);
            entity.Estoque = estoque;
        }
Esempio n. 5
0
 private async Task AtualizaEstoqueColaborador(EstoqueMovimentacao entity)
 {
     await Task.Run(() =>
     {
         if (entity.AtualizaEstoqueColaborador)
         {
             var estoqueMovimentacaoColaborador = new EstoqueMovimentacaoColaborador(0, entity.ResponsavelId, entity.EstoqueMovimentacaoId, !entity.Entrada, entity.Quantidade);
             entity.CollectionEstoqueMovimentacaoColaborador = new List <EstoqueMovimentacaoColaborador>()
             {
                 estoqueMovimentacaoColaborador
             };
         }
     });
 }
        private EstoqueMovimentacao CarregarItem(DataRow item)
        {
            EstoqueMovimentacao estoque = new EstoqueMovimentacao();
            VMDataRow           dtRow   = new VMDataRow(item);

            estoque.IDMovimentacao = dtRow.GetInt("IDMovimentacao");
            estoque.Data           = dtRow.GetDat("Data");
            estoque.Quantidade     = dtRow.GetDec("Quantidade");
            estoque.Operacao       = dtRow.GetStr("Operacao");
            estoque.Produto        = new Produto
            {
                IDProduto  = dtRow.GetInt("IDProduto"),
                Descricao  = dtRow.GetStr("Descricao"),
                Quantidade = dtRow.GetDec("Estoque")
            };

            return(estoque);
        }
Esempio n. 7
0
 public EstoqueMovimentacao GetByModel(EstoqueMovimentacao model)
 {
     return(this.GetAll().Where(_ => _.EstoqueMovimentacaoId == model.EstoqueMovimentacaoId).SingleOrDefault());
 }
Esempio n. 8
0
        private void AtualizarGrid(EstoqueMovimentacao EstoqueMovimentacao, bool booExcluir)
        {
            try
            {
                object FiltroExcluir = null;

                if (booExcluir)
                {
                    FiltroExcluir         = (LocalizarFiltroExcluir(dgwColecao) as EstoqueMovimentacao).GetChavePrimaria();
                    dgwColecao.DataSource = null;
                    estoqueMovimentacaoCollection.Remove(EstoqueMovimentacao);
                }
                else
                {
                    if (EstoqueMovimentacao != null)
                    {
                        var Item = from p in estoqueMovimentacaoCollection
                                   where p.GetChavePrimaria() == EstoqueMovimentacao.GetChavePrimaria()
                                   select p;

                        if (Item.Count() == 1)
                        {
                            EstoqueMovimentacao EstoqueMovimentacaoSelecionado = Item.First();
                            EstoqueMovimentacaoSelecionado = EstoqueMovimentacao;
                        }
                        else
                        {
                            estoqueMovimentacaoCollection.Add(EstoqueMovimentacao);
                        }
                    }
                    else
                    {
                        while (backgroundWorker1.IsBusy)
                        {
                            Application.DoEvents();
                        }
                        object[] args = new object[5];
                        args[0] = "ConsultarEstoqueMovimentacao";
                        args[1] = dtpInicial.Value;
                        args[2] = dtpFinal.Value;
                        args[3] = (txtProdutoPesquisar.VMPesquisaValor as Produto) == null ? (int?)null: (txtProdutoPesquisar.VMPesquisaValor as Produto).IDProduto;
                        backgroundWorker1.RunWorkerAsync(args);
                        while (backgroundWorker1.IsBusy)
                        {
                            Application.DoEvents();
                        }
                    }
                }

                dgwColecao.DataSource = null;
                if (estoqueMovimentacaoCollection.Count() > 0)
                {
                    dgwColecao.DataSource = estoqueMovimentacaoCollection.ToList <EstoqueMovimentacao>();
                }

                txtRegistro.Text = dgwColecao.Rows.Count.ToString();
                txtDebito.Text   = estoqueMovimentacaoCollection.Where(o => o.Operacao == "D").Count().ToString();
                txtCredito.Text  = estoqueMovimentacaoCollection.Where(o => o.Operacao == "C").Count().ToString();


                //if (objEstoqueMovimentacao != null)
                //    LocalizarIndexLinha(dgwColecao, FiltroExcluir == null ? objEstoqueMovimentacao.GetChavePrimaria() : FiltroExcluir);

                dgwColecao.Update();
                dgwColecao.Refresh();

                if (dgwColecao.RowCount > 0)
                {
                    dgwColecao.Focus();
                }
            }
            catch (Exception ex)
            {
                Exceptionerro(ex);
            }
        }