The Details of the Selected Order

Top  Previous  Next

Steps:

1.Create a new page and name it as "OrderDetails".
2.Place "Tutorial > OrderTracking > Title" element into the upper part of the page.
3.Place "Tutorial > OrderTracking > OrderForm" element below the title.
4.Place "Tutorial > OrderTracking > OrderedProducts" element below the form.

 

The "OrderForm" Element

OrderForm

 

The "OrderForm" element is a process form that contains a process block "OrderBlock" and ExecuteCommand elements "DeleteOrder" and "ChangeStatus". The "Repeat | For Each" property of "OrderBlock" is defined as "/order/item".

"order" Element properties:

Name

order

Connection Name

SuperStore

Query

SELECT

  c.NAME AS CUSTNAME, c.EMAIL,

  e.NAME AS EMPLNAME,

  o.ID, o.ORDER_DATE, o.STATUS

FROM

  customers c,

  employees e,

  orders o

WHERE

  o.ID = @vof(i:ID) AND

  o.CUSTOMER_ID = c.ID AND

  o.EMPLOYEE_ID = e.ID;

This SQL statement joins 3 tables (orders, customers, and employees) and returns the date of the order, the name of the customer, the email of the customer, the name of the employee and the status of the selected order.

Please note that the "ID" parameter, that is used in  "@vof(i:ID)" definition, was included in the hyperlink with definition
"display.doms?pg=OrderDetails&ID=$vof(ID)&_rand=" in the "Orders" page.
 
The "OrderBlock" contains three process definitions which are "DeleteOrderProcess", "ChangeStatusProcess" and "NotifyCustomerProcess". The "HiddenBox" elements in the "OrderBlock" are the "ID" to identify the order to delete or to change its status, the "CUSTNAME" and the "EMAIL" to be used in the properties of the "NotifyCustomerProcess" Element.

Delete Order Process

The aim of this process is to delete the currently displayed order from the database. The properties of the "DeleteOrderProcess" were set as follows:

Name

DeleteOrderProcess

Connection Name

SuperStore

Update Query (SQL)

DELETE FROM orders WHERE ID = @vof(ID);

DELETE FROM orderdetails WHERE ORDER_ID = @vof(ID);

The SQL contains two statements; one deletes the order record from the "orders" table and the other one deletes all the records of the products that were included in the order from the "orderdetails" table.

Change Status Process

This process is used to change the status of the order being displayed. When the value of the STATUS ComboBox is changed and [Change Status] button is clicked, we change the value of the "STATUS" field in the "orders" table and we will notify the customer with the status change of his order with an e-mail.

Name

ChangeStatusProcess

Connection Name

SuperStore

Update Query (SQL)

UPDATE orders SET 

  STATUS = '@vof(STATUS)' 

WHERE ID = @vof(ID)

The "OrderedProducts" Element

OrderedProducts
The products that were included in the selected order will be listed with this element. It contains a header, a repeating panel and a summary section.

The "Repeat | For Each" property of the repeating panel is set to "/order_details/item". The properties of "order_details" data source element are as follows:

Name

order_details

Connection Name

SuperStore

Query

SELECT

  p.NAME, d.UNIT_PRICE,

  d.PRODUCT_ID, d.QUANTITY,

  d.QUANTITY * d.UNIT_PRICE AS LINETOT

FROM

  orderdetails d, products p

WHERE

  ORDER_ID = @vof(i:ID) AND

  d.PRODUCT_ID = p.ID

 

 

This SQL query will return all the products that were included in the selected order. The selected order, again, is specified with "@vof(i:ID)" definition.