Hello,
I'm quite new to the world of InfoPath and SharePoint so my apologies if this question sounds a little bit "newbie" !
I'm making a form that will be integrated to our MOSS 2007 solution. Outside MOSS, in the InfoPath client preview, everything's alright and act like expected. But when I publish/upload my form into MOSS, the event of having modified (change) a datetime form field seems to be not recognized. Here's the code :
using Microsoft.Office.InfoPath;
using System;
using System.Xml;
using System.Xml.XPath;
using System.Collections.Generic;
using System.Text;
using System.Globalization;
namespace Demande_Conge
{
public partial class FormCode
{
public void InternalStartup()
{
EventManager.FormEvents.Loading += new LoadingEventHandler(FormEvents_Loading);
EventManager.XmlEvents["/my:DemandeConge/my:Conges/my:DateFin"].Changed += new XmlChangedEventHandler(DateFin_Changed); <== this event is not recognized as the "DateFin_Changed" function isn't executed.
}
public void FormEvents_Loading(object sender, LoadingEventArgs e)
{
XPathNavigator MainData = MainDataSource.CreateNavigator();
MainData.SelectSingleNode("/my:DemandeConge/my:IDDemande", NamespaceManager).SetValue(
MainData.SelectSingleNode("/my:DemandeConge/my:Employe", NamespaceManager).Value + "_" + DateTime.Now.ToShortDateString());
}
public void DateFin_Changed(object sender, XmlEventArgs e)
{
XPathNavigator MainData2 = MainDataSource.CreateNavigator();
DateTime dt1 = MainData2.SelectSingleNode("/my:DemandeConge/my:Conges/my:DateDebut", NamespaceManager).ValueAsDateTime;
DateTime dt2 = MainData2.SelectSingleNode("/my:DemandeConge/my:Conges/my:DateFin", NamespaceManager).ValueAsDateTime;
System.TimeSpan span = dt2.Subtract(dt1);
double final = span.TotalDays;
string final2 = final.ToString();
MainData2.SelectSingleNode("/my:DemandeConge/my:Conges/my:Total", NamespaceManager).SetValue(final2);
}
}
}
So what's wrong in this code ? What annoys me is that it works perfectly outside MOSS... :'(
Thanks a lot for your help.
David from Belgium.