Hi D.Tiwary
You can achieve it without using code,try the following steps:
1、
Insert a Button named Submit.
2、
Right-Click->General->Action(Submit)->Submit Option->Send form data to a single destination(Sharepoint document library)->Choose
a data connection for submit(your library connection)->Advance->After submit(close the form)
Thanks,
Lhan Han