Summarize table using C# and JScript

好久不见. 提交于 2019-12-01 10:12:42

问题


I've written code in C# to summarize values of InvoiceTable and move those summarized values to to GroupTable in Abbyy FlexiCapture. The Software is comparatively new and does not show any error when I run it.

There are two sets of code to be written:

  1. In TechField.
  2. In EventHandlers.

InvoiceTable consists of:

  • TariffNumber
  • ShipQty
  • Amount
  • COO

GroupTable consists of:

  • HSCode
  • Qty
  • Amt
  • CountryOO

EventHandlers code is as follows (C#):

if (ChangedStates.Has(7)) {
    int currentRow = 0;
    int i;
    for (i = 0; i < Document.Field("Invoice2\\InvoiceTable").Items.Count; i++) {
        if (Document.Field("Invoice2\\InvoiceTable").Cell("TariffNumber", i).Value == "") {
            Document.Field("Invoice2\\GroupTable").Cell("HSCode", currentRow).Value = Document.Field("Invoice2\\InvoiceTable").Cell("TariffNumber", i).Value;
            Document.Field("Invoice2\\GroupTable").Cell("Amt", currentRow).Value = Document.Field("Invoice2\\InvoiceTable").Cell("Amount", i).Value;
            Document.Field("Invoice2\\GroupTable").Cell("Qty", currentRow).Value = Document.Field("Invoice2\\InvoiceTable").Cell("ShipQty", i).Value;
            currentRow++;
        }
    }
}

TechField is as follows (JScript):

for (i = 0; i < Field("ShipQty").Items.Count - 1; i++) {
    for (j = i + 1; j < Field("ShipQty").Items.Count; j++) {
        // if same new items are found
        if (Field("TariffNumber").Items(i).Value == Field("TariffNumber").Items(j).Value && Field("CoO").Items(i).Value == Field("CoO").Items(j).Value)
        {
            // summarise quantities
            Field("ShipQty").Items(i).Value = parseInt(Field("ShipQty").Items(i).Value) + parseInt(Field("ShipQty").Items(j).Value);

            // and weights
            Field("Amount").Items(i).Value = parseFloat(Field("Amount").Items(i).Value) + parseFloat(Field("Amount").Items(j).Value);
        }
    }
}

Condition:

In the InvoiceTable, where ever TariffNumber and COO are equal, values of ShipQty and Amount should be summarized and put into GroupTable.

The code does not show any errors but does not give the output as well. Would be great if anyone of you can help me out on this.

来源:https://stackoverflow.com/questions/29666948/summarize-table-using-c-sharp-and-jscript

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!