acumatica
코드를 통한 연락처 및 주소 정보 수정
수색…
소개
이 항목에서는 Acumatica 내의 여러 화면 코드를 통해 연락처 및 주소 정보를 수정하는 방법에 대해 알아 봅니다.
새 직원에 대한 연락처 및 주소 정보 지정
Employee에 대한 연락처 및 주소 정보를 지정하려면 필드 값을 지정하기 전에 Contact 및 Address 데이터 뷰에서 항상 Select()
메서드를 호출해야합니다. 또한 연락처 및 주소 데이터보기의 현재 속성에 Select()
메서드의 결과를 할당하여 코드가 Contact 및 Address PXCache의 현재 레코드를 각각 수정하도록하는 것이 좋습니다.
EmployeeMaint employeeMaintGraph = PXGraph.CreateInstance<EmployeeMaint>();
EPEmployee epEmployeeRow = new EPEmployee();
epEmployeeRow.AcctCD = "EMPLOYEE1";
epEmployeeRow = employeeMaintGraph.Employee.Insert(epEmployeeRow);
Contact contactRow = employeeMaintGraph.Contact.Current = employeeMaintGraph.Contact.Select();
contactRow.FirstName = "John";
contactRow.LastName = "Green";
employeeMaintGraph.Contact.Update(contactRow);
Address addressRow = employeeMaintGraph.Address.Current = employeeMaintGraph.Address.Select();
addressRow.CountryID = "US";
addressRow = employeeMaintGraph.Address.Update(addressRow);
addressRow.State = "DC";
employeeMaintGraph.Address.Update(addressRow);
epEmployeeRow.VendorClassID = "EMPSTAND";
epEmployeeRow.DepartmentID = "FINANCE";
employeeMaintGraph.Employee.Update(epEmployeeRow);
employeeMaintGraph.Actions.PressSave();
새 Employee를 삽입 할 때 employeeMaintGraph.Contact.Current
는 연락처 레코드가 캐시에 자동으로 삽입되고 따라서 PXCache / Data View의 Current 속성을 통해 사용할 수있게되므로 주 연락처 레코드를 항상 반환합니다. Select()
메서드는 새로운 Employee를 삽입하거나 기존 Employee를 업데이트해야하는 모든 가능한 시나리오에서 작동하므로 좀 더 일반적입니다.
고객의 청구서 수신 주소 및 청구 지 주소 정보 무시
고객에 대한 청구서 수신 주소 및 청구 지 주소 정보를 재정의해야 할 때 가장 먼저 수행해야 할 단계는 고객 DAC의 IsBillContSameAsMain 및 IsBillSameAsMain 속성에 대한 올바른 값을 설정하는 것 입니다. 캐시에 현재 Same as Main 필드 값을 커밋하도록 IsBillContSameAsMain 또는 IsBillSameAsMain 속성을 업데이트 한 직후에 Customer 캐시에서 Update()
메서드를 호출하는 것을 잊지 마십시오.
다음 단계는 필드 값을 지정하기 전에 BillContact 및 BillAddress 데이터 뷰에서 Select()
메서드를 호출하는 것입니다. 또한 Select()
메서드의 결과를 BillContact 및 BillAddress 데이터보기의 Current 속성에 할당하여 코드가 Contact 및 Address PXCache의 현재 레코드를 각각 수정하도록하는 것이 좋습니다.
public class CustomerMaintExt : PXGraphExtension<CustomerMaint>
{
public PXAction<Customer> UpdateBillingAddress;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "Update Bill-To Info")]
protected void updateBillingAddress()
{
Customer currentCustomer = Base.BAccount.Current;
if (currentCustomer.IsBillContSameAsMain != true)
{
currentCustomer.IsBillContSameAsMain = true;
Base.BAccount.Update(currentCustomer);
}
else
{
currentCustomer.IsBillContSameAsMain = false;
Base.BAccount.Update(currentCustomer);
Contact billContact = Base.BillContact.Current = Base.BillContact.Select();
billContact.FullName = "ABC Holdings Inc";
billContact.Phone1 = "+1 (212) 532-9574";
Base.BillContact.Update(billContact);
}
if (currentCustomer.IsBillSameAsMain != true)
{
currentCustomer.IsBillSameAsMain = true;
Base.CurrentCustomer.Update(currentCustomer);
}
else
{
currentCustomer.IsBillSameAsMain = false;
Base.CurrentCustomer.Update(currentCustomer);
Address billAddress = Base.BillAddress.Current = Base.BillAddress.Select();
billAddress.AddressLine1 = "65 Broadway";
billAddress.AddressLine2 = "Office Suite 187";
billAddress.City = "New York";
billAddress.CountryID = "US";
billAddress = Base.BillAddress.Update(billAddress);
billAddress.State = "NY";
billAddress.PostalCode = "10004";
Base.BillAddress.Update(billAddress);
}
Base.Actions.PressSave();
}
}
판매 주문의 청구서 수신 주소 및 청구 지 주소 정보 무시
판매 주문에 대한 청구 지 주소 및 청구 지 주소 정보를 지정하려면 필드 값을 지정하기 전에 항상 Billing_Contact 및 Billing_Address 데이터보기에서 Select()
메소드를 호출해야합니다. 또한 Select()
메서드의 결과를 Billing_Contact 및 Billing_Address 데이터보기의 Current 속성에 할당하여 코드가 SOBillingContact 및 SOBillingAddress PXCache의 현재 레코드를 각각 수정하도록하는 것이 좋습니다.
재정의 할 필요가있을 때 빌-하려면 연락처와 판매 주문에 대한 정보를 주소의 SOBillingContact DAC와 SOBillingAddress DAC에 OverrideContact 및 OverrideAddress 속성에 대한 올바른 값을 설정합니다. OverrideContact 및 OverrideAddress 속성을 업데이트 한 후에 SOBillingContact 및 SOBillingAddress 캐시에서 Update()
메서드를 호출하여 변경 내용을 적용해야합니다. 완료되면 판매 주문에 대한 청구서 수신 주소 및 주소 정보를 지정할 수 있습니다.
public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
public PXAction<SOOrder> UpdateBillingAddress;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "Update Bill-To Info")]
protected void updateBillingAddress()
{
SOBillingContact contact = Base.Billing_Contact.Current = Base.Billing_Contact.Select();
if (contact.OverrideContact == true)
{
contact.OverrideContact = false;
Base.Billing_Contact.Update(contact);
}
else
{
contact.OverrideContact = true;
contact = Base.Billing_Contact.Update(contact);
if (contact == null)
{
contact = Base.Billing_Contact.Current;
}
contact.Phone1 = "+1 (908) 643-0281";
contact.Email = "[email protected]";
Base.Billing_Contact.Update(contact);
}
SOBillingAddress address = Base.Billing_Address.Current = Base.Billing_Address.Select();
if (address.OverrideAddress == true)
{
address.OverrideAddress = false;
Base.Billing_Address.Update(address);
}
else
{
address.OverrideAddress = true;
address = Base.Billing_Address.Update(address);
if (address == null)
{
address = Base.Billing_Address.Current;
}
address.AddressLine1 = "201 Lower Notch Rd";
address.AddressLine2 = "Office Suite 1936";
address.City = "Little Falls";
address.CountryID = "US";
address = Base.Billing_Address.Update(address);
address.State = "NJ";
address.PostalCode = "07425";
Base.Billing_Address.Update(address);
}
Base.Actions.PressSave();
}
}