2013-05-20 3 views
0

MS Dynamics GP에서 고객을 생성하려고합니다.고객 생성 주소 없음 - Dynamics GP

public void CreateGPCustomer(JMAOrder jd) 
    { 
     Customer cu = new Customer(); 
     cu.ModifiedDate = DateTime.Now; 
     cu.IsActive = true; 
     cu.Name = "Joseph Jones"; 
     cu.Shortname = "Joe"; 
     cu.StatementName = cu.Name; 
     CustomerAddress cad = new CustomerAddress(); 
     cad.City = "Waltham"; 
     cad.ContactPerson = cu.Name; 
     cad.CountryRegion = "US"; 
     cad.CreatedDate = DateTime.Now; 
     cad.LastModifiedDate = DateTime.Now; 
     cad.Line1 = "123 Main St"; 
     cad.Line2 = "12"; 
     PhoneNumber ph = new PhoneNumber(); 
     ph.CountryCode = "1"; 
     ph.Value = "7811234567"; 
     cad.Phone1 = ph; 
     cad.PostalCode = "02452"; 
     cad.State = "MA"; 
     cu.Key = MakeCustomerKey("Joseph", "Jones"); 
     Policy p = wsDynamicsGP.GetPolicyByOperation("CreateCustomer", context); 
     wsDynamicsGP.CreateCustomer(cu, context, p); 
    } 

내가 주소가 추가되지 않은 참조 :

enter image description here

내가 놓친 게 무엇 코드 여기 내 코드는?

답변

1

고객 주소 만들기는 고객 생성과는 별도로 이루어집니다. Dynamics GP 웹 서비스 참조에서 CreateCustomerAddress 메서드를 참조하십시오.

 CompanyKey companyKey; 
     Context context; 
     CustomerKey customerKey; 
     CustomerAddressKey customerAddressKey; 
     CustomerAddress customerAddress; 
     Policy customerAddressCreatePolicy; 

     // Create an instance of the service 
     DynamicsGPClient wsDynamicsGP = new DynamicsGPClient(); 

     // Create a context with which to call the service 
     context = new Context(); 

     // Specify which company to use (sample company) 
     companyKey = new CompanyKey(); 
     companyKey.Id = (-1); 

     // Set up the context object 
     context.OrganizationKey = (OrganizationKey)companyKey; 

     // Create a customer key to specify the customer 
     customerKey = new CustomerKey(); 
     customerKey.Id = "AARONFIT0001"; 

     // Create a customer address key 
     customerAddressKey = new CustomerAddressKey(); 
     customerAddressKey.CustomerKey = customerKey; 
     customerAddressKey.Id = "BILLING"; 

     // Create a customer address object 
     customerAddress = new CustomerAddress(); 
     customerAddress.Key = customerAddressKey; 

     // Populate properties with address information 
     customerAddress.Line1 = "11403 45 St. South"; 
     customerAddress.Line2 = "Billing Dept."; 
     customerAddress.City = "Chicago"; 
     customerAddress.State = "IL"; 
     customerAddress.CountryRegion = "USA"; 

     // Get the create policy for the customer address 
     customerAddressCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateCustomerAddress", 
     context); 

     // Create the customer address 
     wsDynamicsGP.CreateCustomerAddress(customerAddress, context, customerAddressCreatePolicy); 

     // Close the service 
     if(wsDynamicsGP.State != CommunicationState.Faulted) 
     { 
      wsDynamicsGP.Close(); 
     }