<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title></title>

<SCRIPT language=JavaScript type="text/javascript" SRC="jcl/System.js"></SCRIPT>
<SCRIPT language=JavaScript type="text/javascript" SRC="jcl/DataSet.js"></SCRIPT>
<SCRIPT language=JavaScript type="text/javascript" SRC="jcl/Control.js"></SCRIPT>
<SCRIPT language=JavaScript type="text/javascript" SRC="jcl/DBControl.js"></SCRIPT>
<SCRIPT language=JavaScript type="text/javascript" SRC="jcl/DBNavigator.js"></SCRIPT>
<SCRIPT language=JavaScript type="text/javascript" SRC="jcl/DBPageNavigator.js"></SCRIPT>
<SCRIPT language=JavaScript type="text/javascript" SRC="jcl/DBGrid.js"></SCRIPT>
<SCRIPT language=JavaScript type="text/javascript" SRC="jcl/DateTimeInput.js"></SCRIPT>

</head>
<BODY onload='afterload();'>
</BODY>
</html>

<SCRIPT language=JavaScript type="text/javascript">

function afterload(){
    init();
    createPopupMenu();
}
function createPopupMenu() {
     var m1=new MenuItem();
     PopupMenu1.Items.Add(m1);
     m1.Text.innerHTML='Add Record';
     m1.OnClick=function(sender,event) {
       DataSet2.Append(); 
     };
     var m2=new MenuItem();
     PopupMenu1.Items.Add(m2);
     m2.Text.innerHTML='Delete Record';
     m2.OnClick=function(sender,event) {
       DataSet2.Delete(); 
     };
}

function init(){
    window.DataSet1=new DataSet();
    var Field2 = new Field("SALE_ID","INTEGER");
    var Field3 = new Field("SALE_CLIENT_ID","VARCHAR");
    var Field4 = new Field("SALE_SELLER_ID","VARCHAR");
    var Field5 = new Field("SALE_DATE","DATETIME");
    var Field6 = new Field("SALE_TYPE","VARCHAR");
    var Field7 = new Field("SALE_NOTE","VARCHAR");
    var Field1 = new Field("DataSet2","NESTED");
    window.DataSet2=new DataSet(DataSet1);
    var Field8 = new Field("ITEM_ID","INTEGER");
    var Field9 = new Field("ITEM_PRODUCT_ID","VARCHAR");
    var Field10 = new Field("ITEM_PRICE","REAL");
    var Field11 = new Field("ITEM_AMOUNT","INTEGER");
    var Field16 = new Field("PPRODUCT_NAME","LOOKUP");
    window.Div1=new Div();
    window.Span1=new Span(Div1);
    window.DBGrid2=new DBGrid(Div1);
    var Column1 = new Column();
    var Column2 = new Column();
    var Column3 = new Column();
    var Column4 = new Column();
    window.Span2=new Span(Div1);
    window.Edit1=new Edit(Div1);
    window.Button1=new Button(Div1);
    window.Button2=new Button(Div1);
    window.Button3=new Button(Div1);
    window.Button4=new Button(Div1);
    window.Button5=new Button(Div1);
    window.Span3=new Span(Div1);
    window.Span4=new Span(Div1);
    window.Span5=new Span(Div1);
    window.DBEdit1=new DBEdit(Div1);
    window.DBEdit3=new DBEdit(Div1);
    window.DBPageNavigator1=new DBPageNavigator(Div1);
    window.Button6=new Button(Div1);
    window.Button7=new Button(Div1);
    window.DBDateInput1=new DBDateInput(Div1);
    window.Span6=new Span(Div1);
    window.DBLookupSelect1=new DBLookupSelect(Div1);
    window.Span7=new Span(Div1);
    window.DBLookupSelect2=new DBLookupSelect(Div1);
    window.DBMemo1=new DBMemo(Div1);
    window.Span8=new Span(Div1);
    window.Button8=new Button(Div1);
    window.Button9=new Button(Div1);
    window.Button10=new Button(Div1);
    window.Button11=new Button(Div1);
    window.DS_Product=new DataSet();
    var Field12 = new Field("PRODUCT_ID","VARCHAR");
    var Field13 = new Field("PRODUCT_NAME","VARCHAR");
    var Field14 = new Field("PRODUCT_PRICE","REAL");
    var Field15 = new Field("PRODUCT_AREA","VARCHAR");
    window.DS_Seller=new DataSet();
    var Field17 = new Field("SELLER_ID","VARCHAR");
    var Field18 = new Field("SELLER_NAME","VARCHAR");
    window.DS_Client=new DataSet();
    var Field19 = new Field("CLIENT_ID","VARCHAR");
    var Field20 = new Field("CLIENT_NAME","VARCHAR");
    window.PopupMenu1=new PopupMenu();
    DataSet1.Name='DataSet1';
    DataSet1.Fields.Add(Field2);
    DataSet1.Fields.Add(Field3);
    DataSet1.Fields.Add(Field4);
    DataSet1.Fields.Add(Field5);
    DataSet1.Fields.Add(Field6);
    DataSet1.Fields.Add(Field7);
    DataSet1.Fields.Add(Field1);
    DataSet1.Fields.Auto = false;
    DataSet1.MaxRows=5;
    DataSet1.DataSource='demo.MasterDetail';
    Field2.Name='Field2';
    Field2.Type='INTEGER';
    Field2.FieldName='SALE_ID';
    Field3.Name='Field3';
    Field3.Type='VARCHAR';
    Field3.FieldName='SALE_CLIENT_ID';
    Field4.Name='Field4';
    Field4.Type='VARCHAR';
    Field4.FieldName='SALE_SELLER_ID';
    Field5.Name='Field5';
    Field5.Type='DATETIME';
    Field5.FieldName='SALE_DATE';
    Field6.Name='Field6';
    Field6.Type='VARCHAR';
    Field6.FieldName='SALE_TYPE';
    Field7.Name='Field7';
    Field7.Type='VARCHAR';
    Field7.FieldName='SALE_NOTE';
    Field1.Name='Field1';
    Field1.Type='NESTED';
    Field1.FieldName='DataSet2';
    DataSet2.Name='DataSet2';
    DataSet2.Fields.Add(Field8);
    DataSet2.Fields.Add(Field9);
    DataSet2.Fields.Add(Field10);
    DataSet2.Fields.Add(Field11);
    DataSet2.Fields.Add(Field16);
    DataSet2.Fields.Auto = false;
    DataSet2.MaxRows=-1;
    DataSet2.MasterLink=DataSet1;
    DataSet2.MasterFields='SALE_ID';
    DataSet2.DetailFields='ITEM_ID';
    Field8.Name='Field8';
    Field8.Type='INTEGER';
    Field8.FieldName='ITEM_ID';
    Field9.Name='Field9';
    Field9.Type='VARCHAR';
    Field9.FieldName='ITEM_PRODUCT_ID';
    Field10.Name='Field10';
    Field10.Type='REAL';
    Field10.FieldName='ITEM_PRICE';
    Field10.DisplayFormat='$0.00';
    Field11.Name='Field11';
    Field11.Type='INTEGER';
    Field11.FieldName='ITEM_AMOUNT';
    Field16.Name='Field16';
    Field16.Type='LOOKUP';
    Field16.FieldName='PPRODUCT_NAME';
    Field16.LookupDataSet=DS_Product;
    Field16.KeyField='ITEM_PRODUCT_ID';
    Field16.LookupKeyField='PRODUCT_ID';
    Field16.LookupResultField='PRODUCT_NAME';
    Field16.DisplayLabel='PPRODUCT_NAME';
    Div1.Name='Div1';
    Div1.style.height='666';
    Div1.style.width='679';
    Div1.style.position='absolute';
    Div1.style.left='11';
    Div1.style.top='17';
    Span1.Name='Span1';
    Span1.innerText='Bill Example';
    Span1.style.height='24';
    Span1.style.width='247';
    Span1.style.position='absolute';
    Span1.style.left='237';
    Span1.style.top='4';
    Span1.style.fontSize='18';
    DBGrid2.Name='DBGrid2';
    DBGrid2.style.height='184';
    DBGrid2.style.width='586';
    DBGrid2.style.position='absolute';
    DBGrid2.style.left='22';
    DBGrid2.style.top='244';
    DBGrid2.Columns.Add(Column1);
    DBGrid2.Columns.Add(Column2);
    DBGrid2.Columns.Add(Column3);
    DBGrid2.Columns.Add(Column4);
    DBGrid2.Columns.Auto = false;
    DBGrid2.DataSet=DataSet2;
    DBGrid2.PopupMenu=PopupMenu1;
    Column1.Name='Column1';
    Column1.DataField='ITEM_PRODUCT_ID';
    Column1.Caption='ITEM_ID';
    Column2.Name='Column2';
    Column2.Caption='PPRODUCT_NAME';
    Column2.DataField='PPRODUCT_NAME';
    Column2.CtlType='LOOKUP';
    Column2.width=200;
    Column3.Name='Column3';
    Column3.DataField='ITEM_PRICE';
    Column3.Caption='ITEM_PRICE';
    Column4.Name='Column4';
    Column4.DataField='ITEM_AMOUNT';
    Column4.Caption='ITEM_AMOUNT';
    Span2.Name='Span2';
    Span2.innerText='No.';
    Span2.style.height='21';
    Span2.style.width='36';
    Span2.style.position='absolute';
    Span2.style.left='21';
    Span2.style.top='49';
    Edit1.Name='Edit1';
    Edit1.style.height='21';
    Edit1.style.width='113';
    Edit1.style.position='absolute';
    Edit1.style.left='80';
    Edit1.style.top='47';
    Button1.Name='Button1';
    Button1.value='Search';
    Button1.style.height='21';
    Button1.style.width='75';
    Button1.style.position='absolute';
    Button1.style.left='203';
    Button1.style.top='45';
    Button2.Name='Button2';
    Button2.value='Add';
    Button2.style.height='21';
    Button2.style.width='75';
    Button2.style.position='absolute';
    Button2.style.left='288';
    Button2.style.top='45';
    Button3.Name='Button3';
    Button3.value='Delete';
    Button3.style.height='21';
    Button3.style.width='75';
    Button3.style.position='absolute';
    Button3.style.left='371';
    Button3.style.top='45';
    Button4.Name='Button4';
    Button4.value='Save';
    Button4.style.height='21';
    Button4.style.width='75';
    Button4.style.position='absolute';
    Button4.style.left='452';
    Button4.style.top='45';
    Button5.Name='Button5';
    Button5.value='Cancel';
    Button5.style.height='21';
    Button5.style.width='75';
    Button5.style.position='absolute';
    Button5.style.left='540';
    Button5.style.top='45';
    Span3.Name='Span3';
    Span3.innerText='No.:';
    Span3.style.height='21';
    Span3.style.width='75';
    Span3.style.position='absolute';
    Span3.style.left='21';
    Span3.style.top='88';
    Span4.Name='Span4';
    Span4.innerText='Customer:';
    Span4.style.height='21';
    Span4.style.width='75';
    Span4.style.position='absolute';
    Span4.style.left='21';
    Span4.style.top='124';
    Span5.Name='Span5';
    Span5.innerText='Price:';
    Span5.style.height='21';
    Span5.style.width='75';
    Span5.style.position='absolute';
    Span5.style.left='21';
    Span5.style.top='159';
    DBEdit1.Name='DBEdit1';
    DBEdit1.value='DBEdit1';
    DBEdit1.style.height='21';
    DBEdit1.style.width='166';
    DBEdit1.style.position='absolute';
    DBEdit1.style.left='80';
    DBEdit1.style.top='86';
    DBEdit1.DataSet=DataSet1;
    DBEdit1.DataField='SALE_ID';
    DBEdit3.Name='DBEdit3';
    DBEdit3.value='DBEdit1';
    DBEdit3.style.height='21';
    DBEdit3.style.width='167';
    DBEdit3.style.position='absolute';
    DBEdit3.style.left='81';
    DBEdit3.style.top='156';
    DBEdit3.DataSet=DataSet1;
    DBEdit3.DataField='SALE_TYPE';
    DBPageNavigator1.Name='DBPageNavigator1';
    DBPageNavigator1.style.height='31';
    DBPageNavigator1.style.width='527';
    DBPageNavigator1.style.position='absolute';
    DBPageNavigator1.style.left='24';
    DBPageNavigator1.style.top='483';
    DBPageNavigator1.DataSet=DataSet1;
    Button6.Name='Button6';
    Button6.value='Add';
    Button6.style.height='21';
    Button6.style.width='75';
    Button6.style.position='absolute';
    Button6.style.left='21';
    Button6.style.top='437';
    Button7.Name='Button7';
    Button7.value='Delete';
    Button7.style.height='21';
    Button7.style.width='75';
    Button7.style.position='absolute';
    Button7.style.left='102';
    Button7.style.top='437';
    DBDateInput1.Name='DBDateInput1';
    DBDateInput1.value='DBDateInput1';
    DBDateInput1.style.height='21';
    DBDateInput1.style.width='166';
    DBDateInput1.style.position='absolute';
    DBDateInput1.style.left='443';
    DBDateInput1.style.top='158';
    DBDateInput1.DataSet=DataSet1;
    DBDateInput1.DataField='SALE_DATE';
    Span6.Name='Span6';
    Span6.innerText='Date:';
    Span6.style.height='21';
    Span6.style.width='37';
    Span6.style.position='absolute';
    Span6.style.left='382';
    Span6.style.top='159';
    DBLookupSelect1.Name='DBLookupSelect1';
    DBLookupSelect1.style.height='21';
    DBLookupSelect1.style.width='169';
    DBLookupSelect1.style.position='absolute';
    DBLookupSelect1.style.left='80';
    DBLookupSelect1.style.top='121';
    DBLookupSelect1.DataSet=DataSet1;
    DBLookupSelect1.ListDataSet=DS_Client;
    DBLookupSelect1.KeyField='CLIENT_ID';
    DBLookupSelect1.DataField='SALE_CLIENT_ID';
    DBLookupSelect1.ListField='CLIENT_NAME';
    Span7.Name='Span7';
    Span7.innerText='Seller:';
    Span7.style.height='21';
    Span7.style.width='75';
    Span7.style.position='absolute';
    Span7.style.left='384';
    Span7.style.top='124';
    DBLookupSelect2.Name='DBLookupSelect2';
    DBLookupSelect2.style.height='21';
    DBLookupSelect2.style.width='169';
    DBLookupSelect2.style.position='absolute';
    DBLookupSelect2.style.left='443';
    DBLookupSelect2.style.top='123';
    DBLookupSelect2.DataSet=DataSet1;
    DBLookupSelect2.ListDataSet=DS_Seller;
    DBLookupSelect2.KeyField='SELLER_ID';
    DBLookupSelect2.DataField='SALE_SELLER_ID';
    DBLookupSelect2.ListField='SELLER_NAME';
    DBMemo1.Name='DBMemo1';
    DBMemo1.value='DBMemo1';
    DBMemo1.style.height='39';
    DBMemo1.style.width='165';
    DBMemo1.style.position='absolute';
    DBMemo1.style.left='81';
    DBMemo1.style.top='197';
    DBMemo1.DataSet=DataSet1;
    DBMemo1.DataField='SALE_NOTE';
    Span8.Name='Span8';
    Span8.innerText='Note:';
    Span8.style.height='21';
    Span8.style.width='41';
    Span8.style.position='absolute';
    Span8.style.left='23';
    Span8.style.top='200';
    Button8.Name='Button8';
    Button8.value='|<';
    Button8.style.height='21';
    Button8.style.width='20';
    Button8.style.position='absolute';
    Button8.style.left='23';
    Button8.style.top='7';
    Button8.title='First';
    Button9.Name='Button9';
    Button9.value='<';
    Button9.style.height='21';
    Button9.style.width='20';
    Button9.style.position='absolute';
    Button9.style.left='42';
    Button9.style.top='7';
    Button9.title='Previous';
    Button10.Name='Button10';
    Button10.value='>';
    Button10.style.height='21';
    Button10.style.width='20';
    Button10.style.position='absolute';
    Button10.style.left='61';
    Button10.style.top='7';
    Button10.title='Next';
    Button11.Name='Button11';
    Button11.value='>|';
    Button11.style.height='21';
    Button11.style.width='20';
    Button11.style.position='absolute';
    Button11.style.left='80';
    Button11.style.top='7';
    Button11.title='Last';
    DS_Product.Name='DS_Product';
    DS_Product.Fields.Add(Field12);
    DS_Product.Fields.Add(Field13);
    DS_Product.Fields.Add(Field14);
    DS_Product.Fields.Add(Field15);
    DS_Product.Fields.Auto = false;
    DS_Product.MaxRows=-1;
    DS_Product.DataSource='demo.Simple';
    Field12.Name='Field12';
    Field12.Type='VARCHAR';
    Field12.FieldName='PRODUCT_ID';
    Field13.Name='Field13';
    Field13.Type='VARCHAR';
    Field13.FieldName='PRODUCT_NAME';
    Field14.Name='Field14';
    Field14.Type='REAL';
    Field14.FieldName='PRODUCT_PRICE';
    Field15.Name='Field15';
    Field15.Type='VARCHAR';
    Field15.FieldName='PRODUCT_AREA';
    DS_Seller.Name='DS_Seller';
    DS_Seller.Fields.Add(Field17);
    DS_Seller.Fields.Add(Field18);
    DS_Seller.Fields.Auto = false;
    DS_Seller.MaxRows=-1;
    DS_Seller.DataSource='demo.Seller';
    Field17.Name='Field17';
    Field17.Type='VARCHAR';
    Field17.FieldName='SELLER_ID';
    Field18.Name='Field18';
    Field18.Type='VARCHAR';
    Field18.FieldName='SELLER_NAME';
    DS_Client.Name='DS_Client';
    DS_Client.Fields.Add(Field19);
    DS_Client.Fields.Add(Field20);
    DS_Client.Fields.Auto = false;
    DS_Client.MaxRows=-1;
    DS_Client.DataSource='demo.Client';
    Field19.Name='Field19';
    Field19.Type='VARCHAR';
    Field19.FieldName='CLIENT_ID';
    Field20.Name='Field20';
    Field20.Type='VARCHAR';
    Field20.FieldName='CLIENT_NAME';
    PopupMenu1.Name='PopupMenu1';
    Button1.onclick=Button1onclick;
    Button2.onclick=Button2onclick;
    Button3.onclick=Button3onclick;
    Button4.onclick=Button4onclick;
    Button5.onclick=Button5onclick;
    Button6.onclick=Button6onclick;
    Button7.onclick=Button7onclick;
    Button8.onclick=Button8onclick;
    Button9.onclick=Button9onclick;
    Button10.onclick=Button10onclick;
    Button11.onclick=Button11onclick;
    DataSet1.Open();
}
//search by sale_id
function Button1onclick() {
    DataSet1.Close();
    DataSet1.Params.Clear();
    if(Edit1.value) {
        DataSet1.Params.Add(new Param('SALE_ID',Edit1.value,'int'));
    }
    DataSet1.Open();
}
function Button2onclick() {
    DataSet1.Append();
}
function Button3onclick() {
    DataSet1.Delete();
}
function Button4onclick() {
    DataSet1.Apply();
}
function Button5onclick() {
    DataSet1.Cancel();
}
function Button6onclick() {
    DataSet2.Append();
}
function Button7onclick() {
    DataSet2.Delete();
}
function Button8onclick() {
    DataSet1.First();
}
function Button9onclick() {
    DataSet1.Prev();
}
function Button10onclick() {
    DataSet1.Next();
}
function Button11onclick() {
    DataSet1.Last();
}
</SCRIPT>
