Introduction
This knowledge base article will assist developers on how to handle iVend Retail Business Objects when using various events exposed in the iVend Management Console and the iVend POS.
Purpose
As an example, a developer can use iVend Retail Business Objects to create/delete customers or products on the bases of an Id.
There are two types of iVend Business Objects:
· Master Type Business Objects (Customer, Product, etc.)
· Transaction Type Business Objects (TransactionDTO, PaymentDTO, PurchaseOrderDTO, etc).
Code Sample for Handling iVend Retail Business Objects (e.g. Customer)
In this example we are going to use the following code snippet to delete a customer, load an existing customer and create new customer:
//Deleting customer on the basis of ID.
private void DeleteCustomer()
{
Customer cust = CustomerSubSystem.Instance.LoadById("C0003");
CustomerSubSystem.Instance.Delete(cust);
MessageBox.Show("Customer deleted,ID:" + cust.Id.ToString());
}
//Loading existing customer based on ID
private void LoadCustomer()
{
Customer cust = CustomerSubSystem.Instance.LoadById("C0003");
MessageBox.Show("Customer Loaded,Name:" + cust.Name.ToString());
}
//Create new Customer
private void CreateCustomer()
{
Customer cust = CustomerSubSystem.Instance.Create();
cust.FirstName = "TestCustomer1";
cust.CustomerGroup = CustomerGroupSubSystem.Instance.LoadByKey(10000000000000001);
CustomerSubSystem.Instance.Commit(cust);//saving customer in DB.
MessageBox.Show("Customer created,ID:" + cust.Id.ToString());
}