Populating a Repeating Table - InfoPath Dev
in

InfoPath Dev

Populating a Repeating Table

Last post 05-17-2011 06:20 AM by Pcheru. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 05-17-2011 06:20 AM

    Populating a Repeating Table

    Hi,

    I am trying to populate 'Summary' details table based on 'Market'details table.

    Summary Details has 'Marketvalue' and 'Quantity' 

    Market Details has 'Marketvalue' ; 'Quantity' ; 'Count' etc., fields

    The logic: Add the quantity fields in the 'Summary' Details table if the same Marketvalue repeats in 'Market'Details table.

    Issue: It is populating only the first row of Market Details into Summary details.

    Can somebody please help me.

    Also,let me know a way to attach the .xsn file also

    The code I am using is pasted below:

    using Microsoft.Office.InfoPath;

    using System;

    using System.Xml;

    using System.Web;

    using System.Xml.XPath;

    using System.Diagnostics;

    using System.Threading;

    using System.Collections;

    using System.ComponentModel;

    using System.IO;

    namespace Populate

    {

    public partial class FormCode

    {

    // Member variables are not supported in browser-enabled forms.

    // Instead, write and read these values from the FormState

    // dictionary using code such as the following:

    //

    // private object _memberVariable

    // {

    // get

    // {

    // return FormState["_memberVariable"];

    // }

    // set

    // {

    // FormState["_memberVariable"] = value;

    // }

    // }

    // NOTE: The following procedure is required by Microsoft Office InfoPath.

    // It can be modified using Microsoft Office InfoPath.

    public void InternalStartup()

    {

    ((ButtonEvent)EventManager.ControlEvents["Populate"]).Clicked += new ClickedEventHandler(Populate_Clicked);

    }

     

    private void getSummary(string strKey, string strType)

    {

    XPathNavigator mainNavigator = this.MainDataSource.CreateNavigator();

     

    XPathNodeIterator market_n = mainNavigator.Select("/my:myFields/my:Market_Details/my:market_details_repeating/my:Market", NamespaceManager);

    XPathNodeIterator qty_n = mainNavigator.Select("/my:myFields/my:Market_Details/my:market_details_repeating/my:qty", NamespaceManager);

    XPathNodeIterator counter_n = mainNavigator.Select("/my:myFields/my:Market_Details/my:market_details_repeating/my:counter", NamespaceManager);

    XPathNodeIterator max_counter_n = mainNavigator.Select("/my:myFields/my:Market_Details/my:max_value", NamespaceManager);

    XPathNodeIterator summ_marketvalue_n = mainNavigator.Select("/my:myFields/my:Summary_Details/my:summary_details_repeating/my:summ_marketvalue", NamespaceManager);

    XPathNodeIterator summ_qty_n = mainNavigator.Select("/my:myFields/my:Summary_Details/my:summary_details_repeating/my:summ_qty", NamespaceManager);

     

    XPathNodeIterator house_nodes = this.MainDataSource.CreateNavigator().Select("/my:myFields/my:Summary_Details/my:summary_details_repeating", NamespaceManager);

    XPathNodeIterator house_nodes1 = this.MainDataSource.CreateNavigator().Select("/my:myFields/my:Market_Details/my:market_details_repeating", NamespaceManager);

    max_counter_n.MoveNext();

    int test = Convert.ToInt32(max_counter_n.Current.Value);

    for (int x = 1; x <= test; x++)

    {

    house_nodes1.MoveNext();

    house_nodes.MoveNext();

    string corp;

    string num;

    XPathNavigator xcur1 = house_nodes1.Current;

    xcur1.MoveToChild("Market", NamespaceManager.LookupNamespace("my"));

    corp = xcur1.InnerXml;

    xcur1.MoveToParent();

    xcur1.MoveToChild("qty", NamespaceManager.LookupNamespace("my"));

    num = xcur1.InnerXml;

    xcur1.MoveToParent();

    while (market_n.MoveNext())

    {

    string corp_val;

    string corp_num;

    XPathNavigator xcur = house_nodes.Current;

    xcur.MoveToChild("summary_details_repeating", NamespaceManager.LookupNamespace("my"));

    if (xcur.InnerXml != "")

    {

    xcur.SetValue("");

    }

    xcur.MoveToChild("summ_marketvalue", NamespaceManager.LookupNamespace("my"));

    corp_val = xcur.InnerXml;

    xcur.MoveToParent();

    xcur.MoveToChild("summary_details_repeating", NamespaceManager.LookupNamespace("my"));

    xcur.MoveToChild("summ_qty", NamespaceManager.LookupNamespace("my"));

    corp_num = xcur.InnerXml;

    xcur.MoveToParent();

    xcur.MoveToChild("summary_details_repeating", NamespaceManager.LookupNamespace("my"));

    if (corp_val != corp)

    {

    xcur.AppendChildElement("my", "summ_marketvalue", NamespaceManager.LookupNamespace("my"), corp);

    xcur.AppendChildElement("my", "summ_qty", NamespaceManager.LookupNamespace("my"), num);

    }

    else

    {

    int parse = Int32.Parse(num);

    int res1 = Convert.ToInt32(num);

    int parse2 = Int32.Parse(corp_num);

    int res2 = Convert.ToInt32(corp_num);

    int result = res1 + res2;

    string final = Convert.ToString(result);

    summ_qty_n.MoveNext();

    summ_qty_n.Current.SetValue(final);

    }

    summ_marketvalue_n.MoveNext();

    summ_qty_n.MoveNext();

    }

    }

    }

    public void Populate_Clicked(object sender, ClickedEventArgs e)

    {

    getSummary("", "");

    // Write your code here.

    }

    }

    }

    Thank you,

    Priyanka

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