public ComprovanteCedido PegaCedido(int id)
        {
            string conexao = _iconfiguration.GetSection("ConnectionStrings").GetSection("DefaultConnection").Value;

            DAO.ConsultaDados dados  = new DAO.ConsultaDados();
            ComprovanteCedido cedido = dados.PegarDadosCedido(id, conexao);

            return(cedido);
        }
        public ComprovanteCedido PegarDadosCedido(int iCodigo, string conexao)
        {
            ComprovanteCedido comprovante = new ComprovanteCedido();


            string sQuery = "";


            if (iCodigo > 0)
            {
                try
                {
                    sQuery = "select "
                             + " sCNPJEmpCed as cnpj_emp_ced, "
                             + " sMatriculaTrab as matricula, "
                             + " case "
                             + " 	when dtAdmissao is not null then CONVERT(char,dtAdmissao,103) else '' "
                             + " end as data_admissao, "
                             + " case "
                             + " 	when iTipoRegTrab = 1 then 'CLT(celetista)' "
                             + " 	when iTipoRegTrab = 2 then 'ESTATUTÁRIO' "
                             + " end as tipo_reg_trab, "
                             + " case "
                             + " 	when iTipoRegPrev = 1 then 'RGPS' "
                             + " 	when iTipoRegPrev = 2 then 'RPPS' "
                             + " 	when iTipoRegPrev = 3 then 'Regime de Previdência Social no Exterior' "
                             + " end as tipo_reg_prev, "
                             + " case "
                             + " 	when iOnusCessReq = 1 then 'RGPS' "
                             + " 	when iOnusCessReq = 2 then 'RPPS' "
                             + " 	when iOnusCessReq = 3 then 'Regime de Previdência Social no Exterior' "
                             + " end as onus_cess_req, "
                             + " case "
                             + " 	when iCategoria = 101 then 'Empregado Geral inclusive emprego público p/CLT' "
                             + " 	when iCategoria = 301 then 'Servidor Público Titular de Cargo Efetivo' "
                             + " 	when iCategoria = 302 then 'Servidor Ocupante de cargo exclusivo em comissão' "
                             + " 	when iCategoria = 306 then 'Servidor Público Temporário, sujeito a regime adm. especial' "
                             + " end as categoria "
                             + " from tblCedido "
                             + " where iCodTrabalhador = @iCodigo";

                    SqlConnection sqlConnection1 = new SqlConnection(conexao);
                    SqlCommand    cmd            = new SqlCommand();
                    SqlDataReader reader;

                    cmd.CommandText = sQuery;
                    cmd.Parameters.AddWithValue("@iCodigo", iCodigo);
                    cmd.CommandType = CommandType.Text;
                    cmd.Connection  = sqlConnection1;

                    sqlConnection1.Open();

                    reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        comprovante.sCNPJEmpCed    = reader["cnpj_emp_ced"].ToString();
                        comprovante.sMatriculaTrab = reader["matricula"].ToString();
                        comprovante.dtAdmissao     = (reader["data_admissao"].ToString());
                        comprovante.sTipoRegTrab   = reader["tipo_reg_trab"].ToString();
                        comprovante.sTipoRegPrev   = reader["tipo_reg_prev"].ToString();
                        comprovante.sOnusCessReq   = reader["onus_cess_req"].ToString();
                        comprovante.sCategoria     = reader["categoria"].ToString();
                    }
                    sqlConnection1.Close();
                }
                catch { }
            }

            return(comprovante);
        }