示例#1
0
        public List <ColaboradorModel> ListarTodosColaboradores()
        {
            List <ColaboradorModel> lista = new List <ColaboradorModel>();
            ColaboradorModel        item;
            DAL    objDAL = new DAL();
            string sql    = "select c.id, u.nome as usuario, e.nome_fantasia as empresa, u.cpf_cnpj as Cpf, u.email, u.senha, u.tipo, u.status " +
                            "from Colaborador c inner join usuario u on u.id = c.id_usuario " +
                            "inner join empresa e on e.id = u.id_empresa order by u.nome asc";
            DataTable dt = objDAL.RetDataTable(sql);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                item = new ColaboradorModel
                {
                    Id         = dt.Rows[i]["Id"].ToString(),
                    Nome       = dt.Rows[i]["Usuario"].ToString(),
                    Usuario_Id = dt.Rows[i]["Usuario"].ToString(),
                    Empresa_Id = dt.Rows[i]["Empresa"].ToString(),
                    CPF        = dt.Rows[i]["Cpf"].ToString(),
                    Email      = dt.Rows[i]["Email"].ToString(),
                    Senha      = dt.Rows[i]["Senha"].ToString(),
                    Tipo       = dt.Rows[i]["Tipo"].ToString(),
                    Status     = dt.Rows[i]["Status"].ToString()
                };
                lista.Add(item);
            }

            return(lista);
        }
示例#2
0
        public ColaboradorModel RetornarColaborador(int?id)
        {
            List <ColaboradorModel> lista = new List <ColaboradorModel>();
            ColaboradorModel        item;
            DAL    objDAL = new DAL();
            string sql    = "select c.id, u.nome as usuario, e.nome_fantasia as empresa, u.cpf_cnpj as Cpf, u.email, u.senha, u.tipo, u.status " +
                            "from Colaborador c inner join usuario u on u.id = c.id_usuario " +
                            $"inner join empresa e on e.id = u.id_empresa where c.id = '{id}' order by u.nome asc";
            DataTable dt   = objDAL.RetDataTable(sql);
            var       tipo = dt.Rows[0]["Tipo"].ToString();

            item = new ColaboradorModel
            {
                Id         = dt.Rows[0]["Id"].ToString(),
                Nome       = dt.Rows[0]["Usuario"].ToString(),
                Usuario_Id = dt.Rows[0]["Usuario"].ToString(),
                Empresa_Id = dt.Rows[0]["Empresa"].ToString(),
                CPF        = dt.Rows[0]["Cpf"].ToString(),
                Email      = dt.Rows[0]["Email"].ToString(),
                Senha      = dt.Rows[0]["Senha"].ToString()
            };

            return(item);
        }