Yes. In the Designer, you can double click on the button control and choose Edit Form code. This will bring up the script editor. To add .NET code, you'll want to create a project in Visual Studio using the InfoPath template. This is covered in Chapter 2 of our book.
Patrick Halstead [InfoPath MVP]
InfoPathDev
Patrick Halstead
Project Manager at Qdabra