0

之前,我有这个程序工作。但是,我不确定我是否删除了某些内容,或者我忘记添加某些内容,但是我看的越多,它看起来的错误就越少。

也许我只需要一双新鲜的眼睛来看待它,但据我所知,这是 100% 正确的,断点告诉我一切都是正确的。

这不会增加快速书的库存,我不知道为什么,这没有意义。

        public void ProductAdd(IMsgSetRequest requestMsgSet)
    {
        IItemInventoryAdd itemInventoryAddRq = requestMsgSet.AppendItemInventoryAddRq();

        #region ADD PRODUCT INFORMATION
        for (int i = 0; i <= this.Form.productsList.Items.Count - 1; i++)
        {

            itemInventoryAddRq.Name.SetValue(Form.productID[i].ToString());
            itemInventoryAddRq.SalesDesc.SetValue(Form.productsList.Items[i].ToString().ToUpper());
            itemInventoryAddRq.PurchaseDesc.SetValue(Form.productsList.Items[i].ToString().ToUpper());
            itemInventoryAddRq.SalesPrice.SetValue(Form.QBprice[i]);
            itemInventoryAddRq.AssetAccountRef.FullName.SetValue("Inventory Asset");
            itemInventoryAddRq.COGSAccountRef.FullName.SetValue("Cost of Goods Sold");
            itemInventoryAddRq.ManufacturerPartNumber.SetValue(Form.QBsku[i].ToString().ToUpper());

            IMsgSetResponse responseMsgSet = sessionManager.DoRequests(requestMsgSet);
        }

        #endregion
    }
4

1 回答 1

0

当我在循环之外有附加请求时,我往往会出现奇怪的行为。尽管它应该每次都创建一个项目,但 SessionManager.DoRequests 似乎并不总是像你所拥有的那样工作。我会像这样重写循环:

public void ProductAdd(IMsgSetRequest requestMsgSet)
{
    #region ADD PRODUCT INFORMATION
    for (int i = 0; i <= this.Form.productsList.Items.Count - 1; i++)
    {

        IItemInventoryAdd itemInventoryAddRq = requestMsgSet.AppendItemInventoryAddRq();

        itemInventoryAddRq.Name.SetValue(Form.productID[i].ToString());
        itemInventoryAddRq.SalesDesc.SetValue(Form.productsList.Items[i].ToString().ToUpper());
        itemInventoryAddRq.PurchaseDesc.SetValue(Form.productsList.Items[i].ToString().ToUpper());
        itemInventoryAddRq.SalesPrice.SetValue(Form.QBprice[i]);
        itemInventoryAddRq.AssetAccountRef.FullName.SetValue("Inventory Asset");
        itemInventoryAddRq.COGSAccountRef.FullName.SetValue("Cost of Goods Sold");
        itemInventoryAddRq.ManufacturerPartNumber.SetValue(Form.QBsku[i].ToString().ToUpper());

    }

    IMsgSetResponse responseMsgSet = sessionManager.DoRequests(requestMsgSet);
    #endregion
}
于 2013-09-20T18:17:36.893 回答