Saving using custom code -- error - InfoPath Dev
in

InfoPath Dev

Saving using custom code -- error

Last post 05-13-2009 08:52 AM by geoffc. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 05-13-2009 08:52 AM

    Saving using custom code -- error

    Every now and then when I go to save my form, I will get an error saying something to the extent of "an error was found while saving, this form cannot be saved." Other times the form will save perfectly. I added code to the save event to check for certain things and I am wondering if that is causing the problem. Can someone please look at my code and let me know if there are any glaring mistakes? I am still new at c# so i'm not sure what might be wrong.

    public void FormEvents_Save(object sender, SaveEventArgs e)

    {

    XPathNavigator mainData = MainDataSource.CreateNavigator();

    string approved = mainData.SelectSingleNode("/dfs:myFields/my:examInfo/my:initialApproval", NamespaceManager).Value.ToUpper(); string finalapproval = mainData.SelectSingleNode("/dfs:myFields/my:examInfo/my:finalApproval", NamespaceManager).Value.ToUpper();

    string flag = mainData.SelectSingleNode("/dfs:myFields/my:risk_flag2", NamespaceManager).Value.ToUpper();

    if (finalapproval.Equals("APPROVED"))

    {

    e.PerformSaveOperation();

    e.CancelableArgs.Cancel =
    false;

    }

    else if (flag.Equals("Y"))

    {

    e.CancelableArgs.Message = "Please click the \"Update\" button before trying to save.";

    }

    else if (approved.Equals("APPROVED"))

    {

    try

    {

    this.Submit();MessageBox.Show("Your changes have been successfully submitted to the database.");

    e.PerformSaveOperation();

    e.CancelableArgs.Cancel =
    false;

    }

    catch

    {

    e.PerformSaveOperation();

    e.CancelableArgs.Cancel =
    false;

    }

    }

    else

    {

    e.PerformSaveOperation();

    e.CancelableArgs.Cancel =
    false;

    }

    }

     

     

Page 1 of 1 (1 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.