/* Filename:    J006_SimpleInv6.js
 * Description: Simple Inventory Application
 * Copyright:   2006 The Code Corporation. Please see http://www.codecorp.com/jsLicensing.html for information regarding copyright and grant of license.
 * $Revision: 118 $
 * $Date: 2006-12-05 16:26:51 -0700 (Tue, 05 Dec 2006) $
 */
 
//Adding functionality to the ok/cancel actions


//form event handlers

function inventoryOnCancel()
{
    // clear the form
    itemEdit.text = "";
    quantEdit.text = "";
}

function inventoryOnOk()
{
    // write the data to inventory.dat file

    gui.statusText = "Saving...";
    
    var ok = storage.append("inventory.dat", quantEdit.text + " of item " + itemEdit.text + "\n");
    
    gui.statusText = ok? "Saved": "Save failed!";
    
    // clear the form (to start another)
    inventoryOnCancel();
}

// Create the form and edit controls
var inventory = new gui.Form(inventoryOnOk, inventoryOnCancel);
var itemEdit = new gui.Edit();
var quantEdit = new gui.Edit();

// add Label and Edit boxes to the form
inventory.append(new gui.Label("Item #:"));
inventory.append(itemEdit);
inventory.append(new gui.Label("Quantity:"));
inventory.append(quantEdit);

// add caption text
inventory.caption = "Inventory";

// show the form
gui.showForm(inventory);


//EOF
