How we install VSTA.
- Go to Control Panel | add/remove programs | Change office 2007 | Click on add or remove Features
- Go to Microsoft infopath option |.net programability support | .net programability support from .net 2.0 version
- right click on visual studio tools for applications | run from my computer
- click on continue and VSTA has been install
How we write the Code
- Go to Tool Menu | Form option | programming | language
- select Security and trust option | Full trust and check the option of sign this form template |Certificate | OK.
- Go to Tools menu | programming |Microsoft visual studion tools application.
- Copy and Paste the Code.
using Microsoft.Office.InfoPath;
using System;
using System.Windows.Forms;
using System.Xml;
using System.Xml.XPath;
using mshtml;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
namespace Publicutilities
{
public partial class FormCode
{
//Make the object of webservices
Publicutilities.@in.disnic.services.PublicUtility_Services ObjService = new Publicutilities.@in.disnic.services.PublicUtility_Services();
// NOTE: The following procedure is required by Microsoft Office InfoPath.
// It can be modified using Microsoft Office InfoPath.
public void InternalStartup()
{
((ButtonEvent)EventManager.ControlEvents["btnSubmit"]).Clicked += new ClickedEventHandler(btnSubmit_Clicked);
EventManager.FormEvents.Submit += new SubmitEventHandler(FormEvents_Submit);
}
///
/// Method to Submit UserData in CategoryData Table;For submitting Data we have Used a [webMethod]
/// that will accept 3 parameters as Array Object as AvailabilityStatus,ObjectDistanceCode,Code.
public void btnSubmit_Clicked(object sender, ClickedEventArgs e)
{
// Write your code here.
int[] ObjectDistanceCode = new int[4];
XPathNavigator root = this.MainDataSource.CreateNavigator();
XPathNavigator field = root.SelectSingleNode("/my:myFields/my:CodeIH",
this.NamespaceManager);
if (field.Value != "")
ObjectDistanceCode[0] = Convert.ToInt16(field.Value);
XPathNavigator field2 = root.SelectSingleNode("/my:myFields/my:CodeNh",
this.NamespaceManager);
if (field2.Value != "")
ObjectDistanceCode[1] = Convert.ToInt16(field2.Value);
XPathNavigator field3 = root.SelectSingleNode("/my:myFields/my:CodeSh",
this.NamespaceManager);
if (field3.Value != "")
ObjectDistanceCode[2] = Convert.ToInt16(field3.Value);
XPathNavigator field4 = root.SelectSingleNode("/my:myFields/my:CodeMD",
this.NamespaceManager);
if (field4.Value != "")
ObjectDistanceCode[3] = Convert.ToInt16(field4.Value);
XPathNavigator field5 = root.SelectSingleNode("/my:myFields/my:CodeOD",
this.NamespaceManager);
//Define An Array to Store Avalability Status for CheckBoxes
int[] AvailabilityStatus = new int[4];
XPathNavigator Field1 = root.SelectSingleNode("/my:myFields/my:catIH",
this.NamespaceManager);
if (Field1.Value == "true")
AvailabilityStatus[0] = 1;
else
AvailabilityStatus[0] = 0;
XPathNavigator Field2 = root.SelectSingleNode("/my:myFields/my:CatNH",
this.NamespaceManager);
if (Field2.Value == "true")
AvailabilityStatus[1] = 1;
else
AvailabilityStatus[1] = 0;
XPathNavigator Field3 = root.SelectSingleNode("/my:myFields/my:CatSH",
this.NamespaceManager);
if (Field3.Value == "true")
AvailabilityStatus[2] = 1;
else
AvailabilityStatus[2] = 0;
XPathNavigator Field4 = root.SelectSingleNode("/my:myFields/my:CatMD",
this.NamespaceManager);
if (Field4.Value == "true")
AvailabilityStatus[3] = 1;
else
AvailabilityStatus[3] = 0;
//InsertDistanceData is a [web method] used to store user information.
ObjService.InsertDistanceData(ObjectDistanceCode, AvailabilityStatus);
}
public void FormEvents_Submit(object sender, SubmitEventArgs e)
{
// If the submit operation is successful, set
e.CancelableArgs.Cancel = false;
// Write your code here.
}
}
}
After writing the code publish the infopath form.u can check the following link.
if any infopath form have code then u can check the 2nd option of publishing.
Publish a Infopath Form
0 comments:
Post a Comment