【问题标题】:error while trying to create a new customer using .net DevKit 2.0尝试使用 .net DevKit 2.0 创建新客户时出错
【发布时间】:2013-02-06 21:27:07
【问题描述】:

当我尝试在 Quickbooks Desktop 中创建新客户时遇到错误。

错误: 对象引用未设置为对象的实例。

当我尝试为客户创建地址时出现错误。

 Customer qbdCustomer = new Customer();
                qbdCustomer.Name = txtCompany.Text;
                qbdCustomer.GivenName = txtFName.Text;
                qbdCustomer.FamilyName = txtLName.Text;                    
                qbdCustomer.Address[0].Line1 = txtAddress.Text;
                qbdCustomer.Address[0].Line2 = txtAddress2.Text;
                qbdCustomer.Address[0].City = txtCity.Text;
                qbdCustomer.Address[0].CountrySubDivisionCode = drpState.SelectedItem.Value;
                qbdCustomer.Address[0].PostalCode = txtZip.Text;
                qbdCustomer.Phone[0].FreeFormNumber = txtPhone.Text;
                qbdCustomer.Email[0].Address = txtEmail.Text;
                Customer customerAdded = (new DataServices(context)).Add(qbdCustomer);

就像我说的那样,当它到达第一个地址行时就会发生错误。 Name、GivenName 和 FamilyName 字段有效,因此它必须与地址数组有关。 我已经坚持了几天,任何帮助将不胜感激。

【问题讨论】:

    标签: c# intuit-partner-platform intuit


    【解决方案1】:

    创建一个 PhysicalAddress 对象并将其分配回 Customer Address 属性:

    Intuit.Ipp.Data.Qbd.PhysicalAddress customerAddress = new Intuit.Ipp.Data.Qbd.PhysicalAddress();
    customerAddress.Line1 = txtAddress.Text;
    customerAddress.Line2 = txtAddress2.Text;
    customerAddress.City = txtCity.Text;
    customerAddress.CountrySubDivisionCode = drpState.SelectedItem.Value;
    customerAddress.PostalCode = txtZip.Text;
    qbdCustomer.Address = new Intuit.Ipp.Data.Qbd.PhysicalAddress[]{ customerAddress };
    

    这同样适用于电话和电子邮件属性。

    【讨论】:

      猜你喜欢
      • 2017-11-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-30
      • 2018-02-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多