예제 #1
0
        public static decimal TotalEntradaCompProduto(int compId, int prodId)
        {
            strSQL   = new StringBuilder();
            crud     = new BDCrud();
            decTotal = new decimal();

            strSQL.Append("SELECT SUM(VW.Valor_Total) ");
            strSQL.Append("FROM VW_Estoque VW ");
            strSQL.Append("WHERE VW.Id_Competecia = @Id_Competecia AND VW.Tipo_Es = 'E' AND " +
                          "VW.Id_Produto = @Id_Produto");

            try
            {
                crud.LimparParametros();
                crud.AdicionarParametro("Id_Competecia", compId);
                crud.AdicionarParametro("Id_Produto", prodId);
                string strVerificar = crud.Executar(CommandType.Text, strSQL.ToString()).ToString();
                if (strVerificar == "")
                {
                    return(0);
                }
                else
                {
                    return(decTotal = decimal.Parse(crud.Executar(CommandType.Text, strSQL.ToString()).ToString()));
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #2
0
        public static decimal TotalSaidaPerProduto(DateTime dataInicio, DateTime dataFinal, int prodId)
        {
            strSQL   = new StringBuilder();
            crud     = new BDCrud();
            decTotal = new decimal();

            strSQL.Append("SELECT SUM(VW.Valor_Total) ");
            strSQL.Append("FROM VW_Estoque VW ");
            strSQL.Append("WHERE VW.Data_Cadastro BETWEEN @dataInicio AND @dataFinal AND VW.Tipo_Es = 'S' AND " +
                          "VW.Id_Produto = @Id_Produto");

            try
            {
                crud.LimparParametros();
                crud.AdicionarParametro("dataInicio", dataInicio);
                crud.AdicionarParametro("dataFinal", dataFinal);
                crud.AdicionarParametro("Id_Produto", prodId);
                string strVerificar = crud.Executar(CommandType.Text, strSQL.ToString()).ToString();
                if (strVerificar == "")
                {
                    return(0);
                }
                else
                {
                    return(decTotal = decimal.Parse(crud.Executar(CommandType.Text, strSQL.ToString()).ToString()));
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #3
0
        public static decimal TotalSaidaMarca(int marcaId)
        {
            strSQL   = new StringBuilder();
            crud     = new BDCrud();
            decTotal = new decimal();

            strSQL.Append("SELECT SUM(VW.Valor_Total) ");
            strSQL.Append("FROM VW_Estoque VW ");
            strSQL.Append("WHERE VW.Id_Marca = @Id_Marca AND VW.Tipo_Es = 'S' ");

            try
            {
                crud.LimparParametros();
                crud.AdicionarParametro("Id_Marca", marcaId);

                string strVerificar = crud.Executar(CommandType.Text, strSQL.ToString()).ToString();
                if (strVerificar == "")
                {
                    return(0);
                }
                else
                {
                    return(decTotal = decimal.Parse(crud.Executar(CommandType.Text, strSQL.ToString()).ToString()));
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #4
0
        public int Id(DateTime competencia)
        {
            strSQL = new StringBuilder();
            crud   = new BDCrud();
            int id;

            strSQL.Append("SELECT Id ");
            strSQL.Append("FROM Competencia ");
            strSQL.Append("WHERE Data_Competencia = @Data_Competencia");

            try
            {
                crud.LimparParametros();
                crud.AdicionarParametro("Data_Competencia", competencia);
                if (crud.Executar(CommandType.Text, strSQL.ToString()) is null)
                {
                    return(0);
                }
                else
                {
                    return(id = int.Parse(crud.Executar(CommandType.Text, strSQL.ToString()).ToString()));
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #5
0
        public DateTime CompetenciaAtiva()
        {
            strSQL = new StringBuilder();
            crud   = new BDCrud();
            DateTime competencia;

            strSQL.Append("SELECT Data_Competencia ");
            strSQL.Append("FROM Competencia ");
            strSQL.Append("WHERE Ativo = 'S'");

            try
            {
                crud.LimparParametros();

                if (crud.Executar(CommandType.Text, strSQL.ToString()) is null)
                {
                    return(competencia = new DateTime());
                }
                else
                {
                    return(competencia = DateTime.Parse(crud.Executar(CommandType.Text, strSQL.ToString()).ToString()));
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #6
0
        public bool Inserir(ModEstoque estoque)
        {
            strSQL = new StringBuilder();
            crud   = new BDCrud();

            strSQL.Append("INSERT INTO Estoque (Tipo_ES, Data_Cadastro, Qtd_Produto, Valor_Unitario, Id_Produto, Id_Competencia) ");
            strSQL.Append("VALUES(@Tipo_ES, @Data_Cadastro, @Qtd_Produto, @Valor_Unitario, @Id_Produto, @Id_Competencia)");

            try
            {
                crud.LimparParametros();
                crud.AdicionarParametro("Tipo_ES", estoque.TipoES);
                crud.AdicionarParametro("Data_Cadastro", estoque.DataCadastro);
                crud.AdicionarParametro("Qtd_Produto", estoque.QtdProduto);
                crud.AdicionarParametro("Valor_Unitario", estoque.ValorProduto);
                crud.AdicionarParametro("Id_Produto", estoque.Produto.Id);
                crud.AdicionarParametro("Id_Competencia", estoque.Competencia.Id);
                crud.Executar(CommandType.Text, strSQL.ToString());
                return(true);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #7
0
        public bool Atualizar(ModProduto produto)
        {
            strSQL = new StringBuilder();
            crud   = new BDCrud();

            strSQL.Append("UPDATE Produto ");
            strSQL.Append("SET Descricao = @Descricao, Ativo = @Ativo, Id_Marca = @Id_Marca ");
            strSQL.Append("WHERE Id = @Id");

            try
            {
                crud.LimparParametros();
                crud.AdicionarParametro("Descricao", produto.Descricao);
                crud.AdicionarParametro("Ativo", produto.Ativo);
                crud.AdicionarParametro("Id_Marca", produto.Marca.Id);
                crud.AdicionarParametro("Id", produto.Id);
                crud.Executar(CommandType.Text, strSQL.ToString());

                return(true);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #8
0
        public bool Atualizar(ModEstoque estoque)
        {
            strSQL = new StringBuilder();
            crud   = new BDCrud();

            strSQL.Append("UPDATE Estoque ");
            strSQL.Append("SET Tipo_ES = @Tipo_ES, Data_Cadastro = @Data_Cadastro, Qtd_Produto = @Qtd_Produto, " +
                          "Valor_Unitario = @Valor_Unitario, Id_Produto = @Id_Produto ");
            strSQL.Append("WHERE Id = @Id");

            try
            {
                crud.LimparParametros();
                crud.AdicionarParametro("Tipo_ES", estoque.TipoES);
                crud.AdicionarParametro("Data_Cadastro", estoque.DataCadastro);
                crud.AdicionarParametro("Qtd_Produto", estoque.QtdProduto);
                crud.AdicionarParametro("Valor_Unitario", estoque.ValorProduto);
                crud.AdicionarParametro("Id_Produto", estoque.Produto.Id);
                crud.AdicionarParametro("Id", estoque.Id);
                crud.Executar(CommandType.Text, strSQL.ToString());

                return(true);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #9
0
        public bool Excluir(ModEstoque estoque)
        {
            strSQL = new StringBuilder();
            crud   = new BDCrud();

            strSQL.Append("DELETE FROM Estoque ");
            strSQL.Append("WHERE Id = @Id");

            try
            {
                crud.LimparParametros();
                crud.AdicionarParametro("Id", estoque.Id);
                crud.Executar(CommandType.Text, strSQL.ToString());
                return(true);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #10
0
        public bool Inserir(ModCompetencia competencia)
        {
            strSQL = new StringBuilder();
            crud   = new BDCrud();

            strSQL.Append("INSERT INTO Competencia (Data_Competencia, Ativo) ");
            strSQL.Append("VALUES(@Data_Competencia, @Ativo)");

            try
            {
                crud.LimparParametros();
                crud.AdicionarParametro("Data_Competencia", competencia.Competencia);
                crud.AdicionarParametro("Ativo", competencia.Ativo);
                crud.Executar(CommandType.Text, strSQL.ToString());
                return(true);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #11
0
        public int CompetenciaQtdAtiva()
        {
            strSQL = new StringBuilder();
            crud   = new BDCrud();
            int competenciaQtd;

            strSQL.Append("SELECT COUNT(*) ");
            strSQL.Append("FROM Competencia ");
            strSQL.Append("WHERE Ativo = 'S'");

            try
            {
                crud.LimparParametros();
                competenciaQtd = int.Parse(crud.Executar(CommandType.Text, strSQL.ToString()).ToString());
                return(competenciaQtd);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #12
0
        public bool Inserir(ModMarca marca)
        {
            strSQL = new StringBuilder();
            crud   = new BDCrud();

            strSQL.Append("INSERT INTO Marca (Descricao, Ativo) ");
            strSQL.Append("VALUES(@Descricao, @Ativo)");

            try
            {
                crud.LimparParametros();
                crud.AdicionarParametro("Descricao", marca.Descricao);
                crud.AdicionarParametro("Ativo", marca.Ativo);
                crud.Executar(CommandType.Text, strSQL.ToString());
                return(true);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #13
0
        public DateTime Competencia(int compId)
        {
            strSQL = new StringBuilder();
            crud   = new BDCrud();
            DateTime competencia;

            strSQL.Append("SELECT Data_Competencia ");
            strSQL.Append("FROM Competencia ");
            strSQL.Append("WHERE Id = @Id");

            try
            {
                crud.LimparParametros();
                crud.AdicionarParametro("Id", compId);
                competencia = DateTime.Parse(crud.Executar(CommandType.Text, strSQL.ToString()).ToString());
                return(competencia);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #14
0
        public char Status(int compId)
        {
            strSQL = new StringBuilder();
            crud   = new BDCrud();
            char status;

            strSQL.Append("SELECT Ativo ");
            strSQL.Append("FROM Competencia ");
            strSQL.Append("WHERE Id = @Id");

            try
            {
                crud.LimparParametros();
                crud.AdicionarParametro("Id", compId);
                status = char.Parse(crud.Executar(CommandType.Text, strSQL.ToString()).ToString());
                return(status);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #15
0
        public bool AtualizarStatus(ModCompetencia competencia)
        {
            strSQL = new StringBuilder();
            crud   = new BDCrud();

            strSQL.Append("UPDATE Competencia ");
            strSQL.Append("SET Ativo = @Ativo ");
            strSQL.Append("WHERE Id = @Id");

            try
            {
                crud.LimparParametros();
                crud.AdicionarParametro("Ativo", competencia.Ativo);
                crud.AdicionarParametro("Id", competencia.Id);
                crud.Executar(CommandType.Text, strSQL.ToString());

                return(true);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }