使用C#和JScript汇总表

时间:2015-04-16 06:30:34

标签: c# .net jscript

我在C#中编写代码来汇总InvoiceTable的值,并将这些汇总值移到Abbyy FlexiCapture中的GroupTable。该软件相对较新,在运行时不会显示任何错误。

有两组代码要写:

  1. 在TechField中。
  2. 在EventHandlers中。
  3. InvoiceTable包含:

    • TariffNumber
    • ShipQty
    • 金额
    • COO

    GroupTable包含:

    • HSCODE
    • 数量
    • 金额
    • CountryOO

    EventHandlers代码如下(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如下(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);
            }
        }
    }
    

    条件:

    InvoiceTableTariffNumberCOO相等的位置,ShipQty和金额的值应汇总并放入GroupTable

    代码不显示任何错误,但也不提供输出。如果你们中的任何人都可以帮助我,那就太好了。

0 个答案:

没有答案