Is there any legislation preventing members of congress (/the president) from being a CEO/director of a company at the same time as they are elected?
For a paid job as a CEO or a board member, a federal statute provides that:
A Member or an officer or employee who is a noncareer officer or employee and who occupies a position classified above GS–15 of the General Schedule or, in the case of positions not under the General Schedule, for which the rate of basic pay is equal to or greater than 120 percent of the minimum rate of basic pay payable for GS–15 of the General Schedule shall not—
receive compensation for affiliating with or being employed by a firm, partnership, association, corporation, or other entity which provides professional services involving a fiduciary relationship;
permit that Member’s, officer’s, or employee’s name to be used by any such firm, partnership, association, corporation, or other entity;
receive compensation for practicing a profession which involves a fiduciary relationship;
serve for compensation as an officer or member of the board of any association, corporation, or other entity; or
receive compensation for teaching, without the prior notification and approval of the appropriate entity referred to in section 503.
"Member" in this context means "member of Congress;" I don't see anything in the law which says that the President is not included in "officer or employee," but it's conceivable that he isn't. In any event, the most important consequence a President could face for violating this is impeachment, in which case Congress decides if the statute applies to him (and impeachment doesn't have to be based on a federal statute anyway). That also means that even an unpaid post could cause issues -- the Presidency is a full-time job if ever there was one, and questions would be raised whether or not the President is a) slacking off or b) using his official position for the benefit of his company. With that said, Vice President Cheney's financial disclosure forms indicate that he served on the boards of several nonprofits while he was the VP.
The statute only applies to someone serving for financial compensation, and does not apply to uncompensated service. Each House of Congress has ethics rules, and the House of Representatives mirrors the statute. Representatives may serve as board members if they aren't being paid. I can't find anything about unpaid CEOs being banned, in which case it'd be like board members: you can do it, but you still have to abide by general conflict-of-interest ethics rules.
The Senate has stricter rules. In addition to the ban on paid officership or board membership, Senators can't serve as officers for or on the board of a publicly-held or publicly-regulated company even if unpaid. There are three exceptions: they can do it for a 501(c) nonprofit; they can do it for an organization that primarily serves Senators, Senate staff, and their families; and they can stay on a board if they had been continuously on it for at least the 2 years before they were sworn in as Senators, it takes up a minimal amount of their time, and they aren't on any committee that has jurisdiction over a government agency regulating that company.