C# Can';t在Quickbooks桌面中更新SalesReceive
我正在使用来自的QuickBooks Integrator与QuickBooks桌面集成 我正在尝试更新发票,但没有收到任何错误,但当我签入QuickBooks时,我发现没有任何更改,实际上也没有得到更新 首先,我尝试根据RefNumber查找发票,如果它找到了发票,那么我尝试替换行项目,然后像下面这样调用update方法C# Can';t在Quickbooks桌面中更新SalesReceive,c#,quickbooks,nsoftware,C#,Quickbooks,Nsoftware,我正在使用来自的QuickBooks Integrator与QuickBooks桌面集成 我正在尝试更新发票,但没有收到任何错误,但当我签入QuickBooks时,我发现没有任何更改,实际上也没有得到更新 首先,我尝试根据RefNumber查找发票,如果它找到了发票,那么我尝试替换行项目,然后像下面这样调用update方法existingInvoice.update() 以下是我的代码示例: public static List<Invoice> FindInvoice(st
existingInvoice.update()代码>
以下是我的代码示例:
public static List<Invoice> FindInvoice(string refNumber)
{
var invoicesSearch = new Objsearch
{
QueryType = ObjsearchQueryTypes.qtInvoiceSearch,
RuntimeLicense = "MYLICENSEKEY",
QBConnectionString = "MYCONNECTIONSTRINGTOREMOTECONNECTOR",
SearchCriteria = new SearchCriteria
{
RefNumberContains = refNumber
},
};
invoicesSearch.Search();
var qbInvoiceList = invoicesSearch.Results.ToList();
var invoiceObjList = new List<Invoice>();
foreach (var inv in qbInvoiceList)
{
var newInv = new Invoice();
newInv.QBResponseAggregate = inv.Aggregate;
invoiceObjList.Add(newInv);
}
return invoiceObjList.FirstOrDefault();
}
public static void PutInvoice(Invoice invoice)
{
var existingInvoice = FindInvoice(invoice.RefNumber);
if (existingInvoice != null)
{
existingInvoice.LineItems.Clear();
existingInvoice.LineItems.AddRange(invoice.LineItems);
existingInvoice.QBConnectionString = "MYCONNECTIONSTRINGTOREMOTECONNECTOR";
existingInvoice.RuntimeLicense = RuntimeLicense;
existingInvoice.QBXMLVersion = "12.0";
existingInvoice.Update(); //this line
}
}
公共静态列表FindInvoice(字符串引用号)
{
var invoicesSearch=新对象搜索
{
QueryType=ObjsearchQueryTypes.qtInvoiceSearch,
RuntimeLicense=“MYLICENSEKEY”,
QBConnectionString=“MYCONNECTIONSTRINGTOREMOTECONNECTOR”,
SearchCriteria=新的SearchCriteria
{
RefNumberContains=refNumber
},
};
invoicesSearch.Search();
var qbInvoiceList=invoicesSearch.Results.ToList();
var invoiceObjList=新列表();
foreach(qbInvoiceList中的var inv)
{
var newInv=新发票();
newInv.QBResponseAggregate=投资总额;
invoiceObjList.Add(新投资);
}
return invoiceObjList.FirstOrDefault();
}
公共发票(发票)
{
var existingInvoice=FindInvoice(invoice.RefNumber);
如果(现有发票!=null)
{
现有Invoice.LineItems.Clear();
现有invoice.LineItems.AddRange(invoice.LineItems);
existingInvoice.QBConnectionString=“MYCONNECTIONSTRINGTOREMOTECONNECTOR”;
existingInvoice.RuntimeLicense=RuntimeLicense;
现有的invoice.QBXMLVersion=“12.0”;
existingInvoice.Update();//此行
}
}
好的,问题是我在更新之前最后一件事就是设置了QBXMLVersion
要使Update()
成功处理,首先需要设置QBXMLVersion
下面是一个更新的工作示例:
public static void PutInvoice(Invoice invoice)
{
var existingInvoice = FindInvoice(invoice.RefNumber);
if (existingInvoice != null)
{
existingInvoice.QBXMLVersion = "12.0";
existingInvoice.RuntimeLicense = "MyRuntimeLicenseKey";
existingInvoice.QBConnectionString = "MYCONNECTIONSTRINGTOREMOTECONNECTOR";
existingInvoice.LineItems.Clear();
existingInvoice.LineItems.AddRange(invoice.LineItems);
existingInvoice.Update();
}
}
如果您使用调试器单步执行此代码,您在什么时候首先得到意外结果?@Crowcoder我没有得到任何错误或意外结果。它只是通过没有任何问题。这是有趣的部分。