public Funcionario(Nome nome, CPF cCPF, CTPS cCTPS, PIS pis, Data dataNasc, Email email) { Nome = nome; CPF = cCPF; CTPS = cCTPS; PIS = pis; DataNasc = dataNasc; Email = email; }
public List <Afiliado> ListaAfiliado(string cpf, int id = 0) { try { var lista = new List <Afiliado>(); var query = "SELECT " + "A.Nome " + ",A.Email " + ",A.DataNascimento " + ",A.Cargo " + ",A.CONSIR " + ",A.CPF " + ",A.CTPS_Num " + ",A.CTPS_Serie " + ",A.ID " + ",A.NomeMae " + ",A.NomePai " + ",A.PIS " + ",A.RG " + ",A.Pagamento " + ",A.Contribuicao " + ",E.Rua " + ",E.Numero " + ",E.Complemento " + ",E.Bairro " + ",E.Cidade " + ",E.CEP " + ",E.UF " + ",E.Pais " + ",EP.CNPJ EmpresaCNPJ " + ",EP.Nome EmpresaNome " + " FROM Afiliado A " + " LEFT JOIN Afiliado_Endereco E " + " ON E.IdAfiliado = A.ID " + " AND E.D_E_L_E_T_ = 0 " + " AND A.D_E_L_E_T_ = 0 " + " LEFT JOIN Afiliado_Empresa EP " + " ON EP.IdAfiliado = A.ID " + " AND EP.D_E_L_E_T_ = 0 " + " WHERE A.D_E_L_E_T_=0 "; if (cpf.Trim() != "") { query += " AND A.CPF='" + cpf + "'"; } if (id > 0) { query += " AND A.ID='" + id + "'"; } var dataTable = _contexto.Consultar(query); foreach (DataRow linha in dataTable.Rows) { var obj = new Afiliado { ID = Convert.ToInt32(linha["ID"]), Nome = linha["Nome"].ToString().ToUpper(), RG = linha["RG"].ToString().ToUpper(), CPF = linha["CPF"].ToString().ToUpper(), Email = linha["Email"].ToString().ToUpper(), Cargo = linha["Cargo"].ToString().ToUpper(), Consir = linha["Consir"].ToString().ToUpper(), CNPJ = linha["EmpresaCNPJ"].ToString().ToUpper(), Empresa = linha["EmpresaNome"].ToString().ToUpper(), DataNascimento = Convert.ToDateTime(linha["DataNascimento"].ToString()), NomeMae = linha["NomeMae"].ToString().ToUpper(), NomePai = linha["NomePai"].ToString().ToUpper(), ContribuicaoID = Convert.ToInt32(linha["Contribuicao"].ToString()), PagamentoID = Convert.ToInt32(linha["Pagamento"].ToString()) }; //OBJETO CTPS var ctps = new CTPS { Numero = linha["CTPS_Num"].ToString().ToUpper(), Serie = linha["CTPS_Serie"].ToString().ToUpper(), PIS = linha["PIS"].ToString().ToUpper() }; obj.CTPS = ctps; //OBJETO ENDEREÇO var endereco = new Endereco { Logradouro = linha["RUA"].ToString().ToUpper(), Numero = linha["Numero"].ToString().ToUpper(), Complemento = linha["Complemento"].ToString().ToUpper(), Bairro = linha["Bairro"].ToString().ToUpper(), CEP = linha["CEP"].ToString(), Cidade = linha["Cidade"].ToString().ToUpper(), Pais = linha["Pais"].ToString().ToUpper(), UF = linha["UF"].ToString().ToUpper() }; obj.Endereco = endereco; lista.Add(obj); } return(lista); } catch (Exception) { throw; } }