Well, there are several options.
1. Go to Hangzhou East railway station (http://f.amap.com/4dPIn_0263hq5) by metro, bus, taxi, etc. Then take a high speed train to Shanghai Hongqiao railway station. Follow the guideposts on the ceiling to Metro line 2 after you go downstairs and pass through the gate machine. Then buy a metro ticket at a ticket machine. Follow the guideposts which says Line 2 To Pudong International Airport. You have to get off the train at Guanglan Road Station and take the train at the opposite platform heading to Pudong airport.
The total time from Hangzhou East railway station to Pudong airport is around 2.5 to 3 hours, but you'd better buy a train ticket online before departure at http://www.12306.cn rather than buy it at the train station.
Cost is about ￥81.
2. Go to Wulinmen bus station (http://f.amap.com/3hdhj_05A3hmR) and buy a ticket to Pudong airport. Then take a bus.... The total time is about 3.5 hours from Wulinmen to Pudong airport. Cost is about ￥110.
For the return trip, I am sorry to tell you that both of the options above are not available at 2 am. You may find an airport hotel or simply sleep in airport... The first bus departs at Pudong airport at 8:40 am, but the first metro from airport departs at 6:00 am which is much earlier.
My English is not too good, if you cannot understand or have any questions, you may contact me privately.