If the par value of the common stock is 5 dollars and is sold at market for 10 dollars does the company get the extra $5? Also how is the company affected by the market value going up and down?
If existing shares are sold, then the transaction does not involve the company -it is between the old shareholder and the new shareholder. The only thing that the company gets, is a new shareholder.
If on the other hand this is issuance of new stock, then the new shareholder gets the paper and the company the green paper -the whole of it.
Your second question ("how the company is affected...") is too broad and unclear to be easy to answer. Is this in the short-run? Long-run? In relation to its operations? In relation to its competitive position? As regards its credit rating?