The magnets used in the current study consists of a mother and daughter magnets. An 8-Fr nasogastric tube is tightly fixed with the mother magnet, which will be used for bile or pancreatic drainage before formation of anastomoses. The outside diameter (OD) of the magnets ranges from 5mm to 15mm. In fact, for biliojejunostomy, larger magnets are applied, whereas for pancreaticojejunostomy, smaller magnets are routinely used. This study is a single-center, parallel controlled trial to evaluate the safety and effectiveness of magnetic compression technique for biliojejunostomy and pancreaticojejunostomy, versus traditional hand-sewn techniques on the postoperative morbidity of the patients. And also how to avoid mutual attraction of the two pairs of magnets, formation of bilio-/pancreaticojejunostomy time, discharge rule of the magnets will be all evaluated in the current study.