之前,我有这个程序在工作。但是,我不确定我是否删除了某些内容,或者我忘了添加内容,但是我看的越多,它看起来就越少错误。
也许我只需要一双新眼睛来看它,但从我所知道的,这是100%正确的,断点告诉我一切都是正确的。
这不是添加到quickbooks库存,我不知道为什么,它没有意义。
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
}
答案 0 :(得分: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
}