Example #1
0
        public void Editar(Projeto obj)
        {
            FbCommand sqlCommand = new FbCommand();

            try
            {
                sqlCommand.Connection = this._conexao;
                sqlCommand.CommandText = "UPDATE PROJETOS SET CLIENTE = @CLIENTE, DESCRICAO = @DESCRICAO, EMPRESA = @EMPRESA, FILIAL = @FILIAL, " +
                                         "HORASGERENTE = @HORAGERENTE, HORASCONSULTOR = @HORACONSULTOR, HORASCOORDENADOR = @HORACOORDENADOR, " +
                                         "META = @META " +
                                         "WHERE CODIGO = @CODIGO";

                sqlCommand.Parameters.AddRange(this.ParametrizarComando(obj));
                sqlCommand.ExecuteNonQuery();
            }
            catch (FbException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                sqlCommand.Dispose();
            }
        }
Example #2
0
        public void Cadastrar(Projeto obj)
        {
            FbCommand sqlCommand = new FbCommand();

            try
            {
                sqlCommand.Connection = this._conexao;
                sqlCommand.CommandText = "INSERT INTO PROJETOS (CLIENTE, EMPRESA, FILIAL, HORASGERENTE, HORASCONSULTOR, HORASCOORDENADOR, DESCRICAO, META) " +
                                         "VALUES (@CLIENTE, @EMPRESA, @FILIAL, @HORAGERENTE, @HORACONSULTOR, @HORACOORDENADOR, @DESCRICAO, @META)";

                sqlCommand.Parameters.AddRange(this.ParametrizarComando(obj));
                sqlCommand.ExecuteNonQuery();
            }
            catch (FbException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                sqlCommand.Dispose();
            }
        }
Example #3
0
 public void TestaCadastroProjeto()
 {
     this.CriaInstancia();
     Empresa emp = new Empresa();
     emp.Codigo = "**";
     Filial fil = new Filial();
     fil.Codigo = "**";
     IProjetoNegocio umProjetoNegocio = new ProjetoBUS(Conexao.Instacia, emp, fil);
     Projeto umProjeto = new Projeto();
     umProjeto.Empresa = emp;
     umProjeto.Filial = fil;
     umProjeto.Cliente = new Cliente();
     umProjeto.Cliente.Codigo = 1;
     umProjeto.HorasConsultor = "100";
     umProjeto.HorasCoordenador = "100";
     umProjeto.HorasGerente = "100";
     umProjeto.Meta = new Meta();
     umProjeto.Meta.Codigo = 4;
     umProjetoNegocio.Cadastrar(umProjeto);
 }
Example #4
0
        public void Editar(Projeto obj)
        {
            obj = this.ConfigurarCompartilhamentoDeTabelas(obj);
            IProjetoRepositorio umProjetoDAO = new ProjetoDAO(this._conexao);
            umProjetoDAO.Editar(obj);

            if (obj.Meta != null)
            {
                int i = 0;
                IMetaNegocio umaMetaBus = new MetaBUS(this._conexao, this._empresa, this._filial);
                IPeriodoNegocio umPeriodoNegocio = new PeriodoBUS(Conexao.Instacia, this._empresa, this._filial);
                Meta umaMeta = umaMetaBus.Consultar(obj.Meta.Codigo);

                foreach (var periodo in umaMeta.Periodos)
                {
                    periodo.Meta = umaMeta;
                    periodo.Realizado = umaMetaBus.ApurarMetasPorMes(periodo.Ano, periodo.Mes, umaMeta.Funcionario, obj, umaMeta.Indicador);
                    umPeriodoNegocio.Editar(periodo);
                }
            }
        }
Example #5
0
 public List<Meta> Listar(Projeto projeto)
 {
     IMetaRepositorio umaMetaRepositorio = new MetaDAO(this._conexao);
     return umaMetaRepositorio.Listar(this._empresa.Codigo, this._filial.Codigo, projeto);
 }
Example #6
0
 public void TestaExclusaoProjeto()
 {
     this.CriaInstancia();
     Empresa emp = new Empresa();
     emp.Codigo = "**";
     Filial fil = new Filial();
     fil.Codigo = "**";
     IProjetoNegocio umProjetoNegocio = new ProjetoBUS(Conexao.Instacia, emp, fil);
     Projeto umProjeto = new Projeto();
     umProjeto.Empresa = emp;
     umProjeto.Filial = fil;
     umProjeto.Codigo = 1;
     umProjetoNegocio.Excluir(umProjeto);
 }
Example #7
0
        protected Projeto ConfigurarCompartilhamentoDeTabelas(Projeto obj)
        {
            bool empresa = false;
            bool filial = false;

            ProprietarioEntidade.VerificaProprietario("Projeto", this._conexao, ref empresa, ref filial);

            obj.Empresa = new Empresa();
            obj.Empresa.Codigo = "**";

            if (empresa)
            {
                obj.Empresa.Codigo = this._empresa.Codigo;
            }

            obj.Filial = new Filial();
            obj.Filial.Codigo = "**";

            if (filial)
            {
                obj.Filial.Codigo = this._filial.Codigo;
            }

            return obj;
        }
Example #8
0
 public void Excluir(Projeto obj)
 {
     IProjetoRepositorio umProjetoDAO = new ProjetoDAO(this._conexao);
     umProjetoDAO.Excluir(obj);
 }
Example #9
0
        public void Excluir(Projeto obj)
        {
            FbCommand sqlCommand = new FbCommand();

            try
            {
                sqlCommand.Connection = this._conexao;
                sqlCommand.CommandText = "DELETE FROM PROJETOS WHERE CODIGO = @CODIGO";
                sqlCommand.Parameters.AddWithValue("@CODIGO", obj.Codigo);
                sqlCommand.ExecuteNonQuery();
            }
            catch (FbException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                sqlCommand.Dispose();
            }
        }
Example #10
0
 public void Cadastrar(Projeto obj)
 {
     obj = this.ConfigurarCompartilhamentoDeTabelas(obj);
     IProjetoRepositorio umProjetoDAO = new ProjetoDAO(this._conexao);
     umProjetoDAO.Cadastrar(obj);
 }
Example #11
0
        public double ApurarMetasPorMes(int ano, int mes, Funcionario funcionario, Projeto projeto, Indicador indicador)
        {
            OrdemServico ordemFiltro = new OrdemServico();
            ordemFiltro.DataDe = "01/" + mes + "/" + ano;
            ordemFiltro.DataAte = new DateTime(ano, mes, DateTime.DaysInMonth(ano, mes)).ToString("dd/MM/yyy");
            ordemFiltro.Projeto = projeto;
            ordemFiltro.Funcionario = funcionario;
            ordemFiltro.Cliente = new Cliente();

            OrdemServicoBUS umaOrdemServicoBUS = new OrdemServicoBUS(this._conexao, this._empresa, this._filial);
            List<OrdemServico> listaOrdens = umaOrdemServicoBUS.Pesquisar(ordemFiltro);

            double total = 0;

            switch (indicador.Codigo)
            {
                case 1: //HORA
                    foreach (var os in listaOrdens)
                    {
                        double horas = 0;

                        if ((os.Inicio == "00:00") && (os.Fim == "00:00"))
                        {
                            OrdemServicoRemoto osr = new OrdemServicoRemotoBUS(this._conexao, this._empresa, this._filial).Consultar(os.Codigo);
                            DateTime horasAcimaDeCem = new DateTime();
                            horasAcimaDeCem = horasAcimaDeCem.AddHours(Convert.ToInt32(osr.Total.Split(':')[0]));
                            horasAcimaDeCem = horasAcimaDeCem.AddMinutes(Convert.ToInt32(osr.Total.Split(':')[1]));
                            TimeSpan ticks = new TimeSpan(horasAcimaDeCem.Ticks);
                            total += ticks.TotalHours;
                        }
                        else
                        {
                            horas = TimeSpan.Parse(os.Total).TotalHours;
                        }
                        total += horas;
                    }
                    break;
                case 2: //PROSPECÇÕES                              
                    total = listaOrdens.Count;
                    break;
            }

            return total;
        }
 public ActionResult Delete(int id, Projeto projeto)
 {
     try
     {
         Conexao.Ativar(true);
         Usuario umUsuario = (Usuario)Session["UsuarioLogado"];
         IProjetoNegocio umProjetoNegocio = new ProjetoBUS(Conexao.Instacia, umUsuario.Funcionario.Empresa, umUsuario.Funcionario.Filial);
         projeto.Empresa = umUsuario.Funcionario.Empresa;
         projeto.Filial = umUsuario.Funcionario.Filial;
         projeto.Codigo = id;
         umProjetoNegocio.Excluir(projeto);
         return RedirectToAction("Index", new { st = "ok" });
     }
     catch (Exception ex)
     {
         return RedirectToAction("Index", new { st = "er" });
     }
     finally
     {
         Conexao.Ativar(false);
     }
 }
Example #13
0
        protected IEnumerable<Projeto> ConverteDataTableEmList(DataTable dt)
        {
            int indexCodigo = dt.Columns["CODIGO"].Ordinal;
            int indexDescricao = dt.Columns["DESCRICAO"].Ordinal;
            int indexHorasGerente = dt.Columns["HORASGERENTE"].Ordinal;
            int indexHorasCoordenador = dt.Columns["HORASCOORDENADOR"].Ordinal;
            int indexHorasConsultor = dt.Columns["HORASCONSULTOR"].Ordinal;
            int indexCodCliente = dt.Columns["CODCLIENTE"].Ordinal;
            int indexNomeCliente = dt.Columns["NOMECLIENTE"].Ordinal;
            int indexCodEmpresa = dt.Columns["CODEMPRESA"].Ordinal;
            int indexNomeEmpresa = dt.Columns["NOMEEMPRESA"].Ordinal;
            int indexCodFilial = dt.Columns["CODFILIAL"].Ordinal;
            int indexNomeFilial = dt.Columns["NOMEFILIAL"].Ordinal;
            int indexCodMeta = dt.Columns["CODMETA"].Ordinal;
            int indexDescMeta = dt.Columns["DESCMETA"].Ordinal;

            foreach (DataRow linha in dt.Rows)
            {
                Projeto umProjeto = new Projeto();
                umProjeto.Codigo = Convert.ToInt32(linha[indexCodigo].ToString());
                umProjeto.Descricao = linha[indexDescricao].ToString();
                umProjeto.HorasConsultor = linha[indexHorasConsultor].ToString().Insert(linha[indexHorasConsultor].ToString().Length - 2, ":");
                umProjeto.HorasCoordenador = linha[indexHorasCoordenador].ToString().Insert(linha[indexHorasCoordenador].ToString().Length - 2, ":");
                umProjeto.HorasGerente = linha[indexHorasGerente].ToString().Insert(linha[indexHorasGerente].ToString().Length - 2, ":");
                umProjeto.Cliente = new Cliente();
                umProjeto.Cliente.Codigo = Convert.ToInt32(linha[indexCodCliente].ToString());
                umProjeto.Cliente.Nome = linha[indexNomeCliente].ToString();
                umProjeto.Empresa = new Empresa();
                umProjeto.Empresa.Codigo = linha[indexCodEmpresa].ToString();
                umProjeto.Empresa.Nome = linha[indexNomeCliente].ToString();
                umProjeto.Filial = new Filial();
                umProjeto.Filial.Codigo = linha[indexCodFilial].ToString();
                umProjeto.Filial.Nome = linha[indexNomeFilial].ToString();
                umProjeto.Meta = new Meta();
                umProjeto.Meta.Codigo = linha[indexCodMeta].ToString() != "" ? Convert.ToInt32(linha[indexCodMeta].ToString()) : 0;
                umProjeto.Meta.Descricao = linha[indexDescMeta].ToString();
                yield return umProjeto;
            }
        }
Example #14
0
        protected List<FbParameter> ParametrizarComando(Projeto obj)
        {
            List<FbParameter> lista = new List<FbParameter>();

            FbParameter sqlpEmpresa = new FbParameter();
            sqlpEmpresa.ParameterName = "@EMPRESA";
            sqlpEmpresa.Value = obj.Empresa.Codigo;
            lista.Add(sqlpEmpresa);

            FbParameter sqlpFilial = new FbParameter();
            sqlpFilial.ParameterName = "@FILIAL";
            sqlpFilial.Value = obj.Filial.Codigo;
            lista.Add(sqlpFilial);

            FbParameter sqlpCliente = new FbParameter();
            sqlpCliente.ParameterName = "@CLIENTE";
            sqlpCliente.Value = obj.Cliente.Codigo;
            lista.Add(sqlpCliente);

            FbParameter sqlpHoraGerente = new FbParameter();
            sqlpHoraGerente.ParameterName = "@HORAGERENTE";
            sqlpHoraGerente.Value = obj.HorasGerente.Replace(":", "");
            lista.Add(sqlpHoraGerente);

            FbParameter sqlpHoraConsultor = new FbParameter();
            sqlpHoraConsultor.ParameterName = "@HORACONSULTOR";
            sqlpHoraConsultor.Value = obj.HorasConsultor.Replace(":", "");
            lista.Add(sqlpHoraConsultor);

            FbParameter sqlpHoraCoordenador = new FbParameter();
            sqlpHoraCoordenador.ParameterName = "@HORACOORDENADOR";
            sqlpHoraCoordenador.Value = obj.HorasCoordenador.Replace(":", "");
            lista.Add(sqlpHoraCoordenador);

            FbParameter sqlpDescricao = new FbParameter();
            sqlpDescricao.ParameterName = "@DESCRICAO";
            sqlpDescricao.Value = obj.Descricao;
            lista.Add(sqlpDescricao);

            if (obj.Codigo != 0)
            {
                FbParameter sqlpCodigo = new FbParameter();
                sqlpCodigo.ParameterName = "@CODIGO";
                sqlpCodigo.Value = obj.Codigo;
                lista.Add(sqlpCodigo);
            }


            FbParameter sqlpMeta = new FbParameter();
            sqlpMeta.ParameterName = "@META";

            if ((obj.Meta != null) && (obj.Meta.Codigo != 0))
            {
                sqlpMeta.Value = obj.Meta.Codigo;
            }
            else
            {
                sqlpMeta.Value = null;
            }

            lista.Add(sqlpMeta);

            return lista;
        }
Example #15
0
        public Projeto Consultar(string empresa, string filial, int id)
        {
            FbCommand comando = new FbCommand();

            try
            {
                comando.Connection = this._conexao;
                comando.CommandText = "SELECT PROJETOS.CODIGO, PROJETOS.HORASGERENTE, PROJETOS.DESCRICAO, PROJETOS.HORASCOORDENADOR, PROJETOS.HORASCONSULTOR, " +
                                        "CLIENTES.CODIGO AS CODCLIENTE, CLIENTES.REDUZIDO AS NOMECLIENTE, " +
                                        "META.CODIGO AS CODMETA, META.DESCRICAO AS DESCMETA, " +
                                        "SYS_COMPANY.EMPRESA AS CODEMPRESA, SYS_COMPANY.NOME AS NOMEEMPRESA, " +
                                        "SYS_BRANCH.FILIAL AS CODFILIAL, SYS_BRANCH.NOME AS NOMEFILIAL " +
                                        "FROM PROJETOS " +
                                        "INNER JOIN CLIENTES ON CLIENTES.CODIGO = PROJETOS.CLIENTE " +
                                        "LEFT JOIN META ON META.CODIGO = PROJETOS.META " +
                                        "LEFT JOIN SYS_COMPANY ON SYS_COMPANY.EMPRESA = PROJETOS.EMPRESA " +
                                        "LEFT JOIN SYS_BRANCH ON SYS_BRANCH.FILIAL = PROJETOS.FILIAL " +
                                        "WHERE ((PROJETOS.EMPRESA = @EMPRESA) OR (PROJETOS.EMPRESA = '**') ) " +
                                        "AND ((PROJETOS.FILIAL = @FILIAL) OR (PROJETOS.FILIAL = '**')) " +
                                        "AND PROJETOS.CODIGO = @CODIGO";

                comando.Parameters.AddWithValue("@EMPRESA", empresa);
                comando.Parameters.AddWithValue("@FILIAL", filial);
                comando.Parameters.AddWithValue("@CODIGO", id);

                FbDataReader reader = comando.ExecuteReader();

                int indexCodigo = reader.GetOrdinal("CODIGO");
                int indexDescricao = reader.GetOrdinal("DESCRICAO");
                int indexHorasGerente = reader.GetOrdinal("HORASGERENTE");
                int indexHorasCoordenador = reader.GetOrdinal("HORASCOORDENADOR");
                int indexHorasConsultor = reader.GetOrdinal("HORASCONSULTOR");
                int indexCodCliente = reader.GetOrdinal("CODCLIENTE");
                int indexNomeCliente = reader.GetOrdinal("NOMECLIENTE");
                int indexCodEmpresa = reader.GetOrdinal("CODEMPRESA");
                int indexNomeEmpresa = reader.GetOrdinal("NOMEEMPRESA");
                int indexCodFilial = reader.GetOrdinal("CODFILIAL");
                int indexNomeFilial = reader.GetOrdinal("NOMEFILIAL");
                int indexCodMeta = reader.GetOrdinal("CODMETA");
                int indexDescMeta = reader.GetOrdinal("DESCMETA");

                Projeto umProjeto = new Projeto();

                while (reader.Read())
                {
                    umProjeto.Codigo = reader.GetInt32(indexCodigo);
                    umProjeto.Descricao = reader.GetString(indexDescricao);
                    umProjeto.HorasGerente = reader.GetString(indexHorasGerente).Insert(reader.GetString(indexHorasGerente).Length - 2, ":");
                    umProjeto.HorasCoordenador = reader.GetString(indexHorasCoordenador).Insert(reader.GetString(indexHorasCoordenador).Length - 2, ":");
                    umProjeto.HorasConsultor = reader.GetString(indexHorasConsultor).Insert(reader.GetString(indexHorasConsultor).Length - 2, ":");
                    umProjeto.Cliente = new Cliente();
                    umProjeto.Cliente.Codigo = reader.GetInt32(indexCodCliente);
                    umProjeto.Cliente.Nome = reader.GetString(indexNomeCliente);
                    umProjeto.Empresa = new Empresa();
                    umProjeto.Empresa.Codigo = reader.GetString(indexCodEmpresa);
                    umProjeto.Empresa.Nome = reader.GetString(indexNomeEmpresa);
                    umProjeto.Filial = new Filial();
                    umProjeto.Filial.Codigo = reader.GetString(indexCodFilial);
                    umProjeto.Filial.Nome = reader.GetString(indexNomeFilial);
                    umProjeto.Meta = new Meta();
                    umProjeto.Meta.Codigo = reader[indexCodMeta] != DBNull.Value ? reader.GetInt32(indexCodMeta) : 0;
                    umProjeto.Meta.Descricao = reader[indexDescMeta] != DBNull.Value? reader.GetString(indexDescMeta):"";
                }

                return umProjeto;
            }
            catch (FbException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                comando.Dispose();
            }
        }
Example #16
0
        public List<Meta> Listar(string empresa, string filial, Projeto projeto)
        {
            FbCommand sqlCommand = new FbCommand();

            try
            {
                sqlCommand.Connection = this._conexao;
                sqlCommand.CommandText = "SELECT META.EMPRESA, META.FILIAL, META.CODIGO, META.DESCRICAO, META.DATACADASTRO, " +
                                            "INDICADOR.CODIGO AS CODINDICADOR, INDICADOR.DESCRICAO AS DESCINDICADOR, " +
                                            "FUNCIONARIOS.CODIGO AS CODFUNC, FUNCIONARIOS.NOME AS NOMEFUNC, " +
                                            "PROJETOS.CODIGO AS CODPROJETO, PROJETOS.DESCRICAO AS DESCPROJETO " +
                                            "FROM META " +
                                            "INNER JOIN INDICADOR ON INDICADOR.CODIGO = META.INDICADOR " +
                                            "INNER JOIN FUNCIONARIOS ON FUNCIONARIOS.CODIGO = META.FUNCIONARIO " +
                                            "LEFT JOIN PROJETOS ON PROJETOS.META = META.CODIGO " +
                                            "LEFT JOIN SYS_COMPANY ON SYS_COMPANY.EMPRESA = META.EMPRESA " +
                                            "LEFT JOIN SYS_BRANCH ON SYS_BRANCH.FILIAL = META.FILIAL " +
                                            "WHERE ((META.EMPRESA = @EMPRESA) OR (META.EMPRESA = '**')) AND " +
                                            "((META.FILIAL = @FILIAL) OR (META.FILIAL = '**')) AND PROJETOS.CODIGO = @PROJETO";

                sqlCommand.Parameters.AddWithValue("@EMPRESA", empresa);
                sqlCommand.Parameters.AddWithValue("@FILIAL", filial);
                sqlCommand.Parameters.AddWithValue("@PROJETO", projeto.Codigo);

                FbDataAdapter sqlAdapter = new FbDataAdapter();
                sqlAdapter.SelectCommand = sqlCommand;

                DataTable dtMeta = new DataTable();
                sqlAdapter.Fill(dtMeta);
                return this.ColetarPeriodos(this.ConverteDataTableEmList(dtMeta).ToList());
            }
            catch (FbException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                sqlCommand.Dispose();
            }
        }
        public ActionResult Create(Projeto projeto)
        {
            try
            {
                Conexao.Ativar(true);

                Usuario umUsuario = (Usuario)Session["UsuarioLogado"];
                IProjetoNegocio umProjetoBUS = new ProjetoBUS(Conexao.Instacia, umUsuario.Funcionario.Empresa, umUsuario.Funcionario.Filial);
                projeto.Empresa = umUsuario.Funcionario.Empresa;
                projeto.Filial = umUsuario.Funcionario.Filial;
                umProjetoBUS.Cadastrar(projeto);
                return RedirectToAction("Index", new { st = "ok" });
            }
            catch
            {
                return RedirectToAction("Index", new { st = "er" });
            }
            finally
            {
                Conexao.Ativar(false);
            }
        }