/*
 * Author       : sampleapps
 * Generated on : 22-Nov-2009 19:57:42
 * Version      : 3.0
 */
application "Calculate Multi Select Price"
{
    type = public
    date format = "dd-MMM-yyyy"
    time zone = "America/Los_Angeles"
    section Products
    {
        form  Products
        {
            
            Product_Name
            (
                displayname  =  "Product Name"
                type  =  text
            )

            Rate
            (
                type  =  USD
                width  =  20
            )

            actions
            {
                on add
                {
                    Submit
                    (
                        type  =  submit
                        displayname  =  "Submit"
                    )
                    Reset
                    (
                        type  =  reset
                        displayname  =  "Reset"
                    )
                }
                on edit
                {
                    Update
                    (
                        type  =  submit
                        displayname  =  "Update"
                    )
                    Cancel
                    (
                        type  =  cancel
                        displayname  =  "Cancel"
                    )
                }
            }
        }

        list  Products_View
        {
            displayname = "Products View"
            show  all  rows  from  Products 
            (
                Product_Name as "Product Name"
                Rate
            )
            options
            (
                display rows = 100
            )
        }

    }

    section Order
    {
        form  Order_form
        {
            displayname  =  "Order"
            
            Select_Product
            (
                displayname  =  "Select Product"
                type  =  checkboxes
                values  =  Products.Product_Name
            )

            Total_Price
            (
                displayname  =  "Total Price"
                type  =  USD
                private  =  true
                width  =  20
            )

            actions
            {
                on add
                {
                    Submit
                    (
                        type  =  submit
                        displayname  =  "Submit"
                        on success
                        {
                            val = 0.0;
                            for each Select_Product r in Order_form  [ID == input.ID]
                            {
                                val = (val  +  r.Rate);
                            }
                            input.Total_Price = val;
                            success message "Data Added Successfully !";
                        }
                    )
                    Reset
                    (
                        type  =  reset
                        displayname  =  "Reset"
                    )
                }
                on edit
                {
                    Update
                    (
                        type  =  submit
                        displayname  =  "Update"
                    )
                    Cancel
                    (
                        type  =  cancel
                        displayname  =  "Cancel"
                    )
                }
            }
        }

        list  Order_View
        {
            displayname = "Order View"
            show  all  rows  from  Order_form 
            (
                Select_Product as "Select Product"
                Total_Price as "Total Price"
            )
            options
            (
                display rows = 100
            )
        }

    }

}
