我已经尝试了很多让这个工作。我终于找到了一些代码来创建销售收据,但是当我尝试添加销售收据时出现错误:“'',十六进制值 0x1F,是无效字符。第 1 行,位置 1。”。我正在使用 Visual Web Developer。这是我想出的代码:
realmId = "removed";
accessToken = "removed";
accessTokenSecret = "removed";
consumerKey = ConfigurationManager.AppSettings["consumerKey"];
consumerSecret = ConfigurationManager.AppSettings["consumerSecret"];
dataSourcetype = IntuitServicesType.QBO;
OAuthRequestValidator oauthValidator = new OAuthRequestValidator(accessToken, accessTokenSecret, consumerKey, consumerSecret);
ServiceContext context = new ServiceContext(oauthValidator, realmId, dataSourcetype);
DataServices commonService = new DataServices(context);
Intuit.Ipp.Data.Qbo.SalesReceipt qboSalesReceipt = new Intuit.Ipp.Data.Qbo.SalesReceipt();
//Create Header
Intuit.Ipp.Data.Qbo.SalesReceiptHeader qboSalesReceiptHeader = new Intuit.Ipp.Data.Qbo.SalesReceiptHeader();
qboSalesReceiptHeader.DocNumber = "abc123";
qboSalesReceiptHeader.TxnDate = DateTime.Now;
qboSalesReceiptHeader.TxnDateSpecified = true;
qboSalesReceiptHeader.Note = "Sales Receipt Note";
qboSalesReceiptHeader.CustomerId = new IdType() { idDomain = idDomainEnum.QBO, Value = "49" };
//Set Payment Detail in Header
/*Intuit.Ipp.Data.Qbo.PaymentDetail qboSalesReceiptHeaderPaymentDetail = new Intuit.Ipp.Data.Qbo.PaymentDetail();
qboSalesReceiptHeaderPaymentDetail.Item = new CashPayment { Desc = "Cash Payment Ref #" };
qboSalesReceiptHeader.Detail = qboSalesReceiptHeaderPaymentDetail;*/
//Set Header
qboSalesReceipt.Header = qboSalesReceiptHeader;
//Set Line Item
ItemsChoiceType2[] salesReceiptAttributes = { ItemsChoiceType2.ItemId, ItemsChoiceType2.UnitPrice, ItemsChoiceType2.Qty };
object[] salesReceiptLineValues = { new IdType() { idDomain = idDomainEnum.QBO, Value = "5" }, new decimal(33), new decimal(2) };
var salesReceiptLine = new SalesReceiptLine();
salesReceiptLine.Amount = 66;
salesReceiptLine.AmountSpecified = true;
salesReceiptLine.Desc = "test " + DateTime.Now.ToShortDateString();
salesReceiptLine.ItemsElementName = salesReceiptAttributes;
salesReceiptLine.Items = salesReceiptLineValues;
salesReceiptLine.ServiceDate = DateTime.Now;
salesReceiptLine.ServiceDateSpecified = true;
//Call IDS to Create Sales Receipt
Intuit.Ipp.Data.Qbo.SalesReceipt addedSalesReceipt = commonService.Add(qboSalesReceipt) as SalesReceipt;
//Intuit.Ipp.Data.Qbo.SalesReceipt addedSalesReceipt = commonService.Add(qboSalesReceipt);
string message = "Sales receipt add complete";
ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", message);
无论我做什么,我都无法让它发挥作用。我真的很感谢任何人的帮助。谢谢