Contents Index Write code to synchronize the database Write code for navigation and data manipulation

UltraLite ActiveX User's Guide
  Tutorial: An UltraLite Application for Pocket IE
    Lesson 5: Write the JScript sample code

Write code to display order information


When main.htm loads, the following functions run to obtain and display the order information.

For more information about the GetTable method, see GetTable method.

function OpenGetOrder() {
 var conn = top.Connection;
 var cs = top.CS;
 var empid;
 if ( conn == null ) {
    alert("Not yet connected!");
  return;
 }
 conn.AutoCommit = false;
 var table = conn.GetTable("ULIdentifyEmployee_nosync");
 table.Open();
 if ( table.RowCount == 0 ) {
    empid = window.prompt("Enter employee ID #: ", "50");
    table.InsertBegin();
    table.Columns("emp_id").value = empid;
    table.Insert();
    conn.Commit();
 }
 table.MoveFirst();
 cs.SetEmployeeID( table.Columns("emp_id").value );
 table.Close();
 ProductList = conn.GetTable("ULProduct");
 ProductList.Open();
 CustomerList = conn.GetTable("ULCustomer");
 CustomerList.Open();
 OrderList = conn.GetTable("ULOrder");
 OrderList.Open();
 SetOrderData();
 SkipToValidOrder();
}
function UpdateForm() {
 var cs = top.CS;
 if ( cs.GetNoOrder() ) { 
    txt_Custname.value = "";
    txt_Prodname.value = "";
    txt_Quant.value = "";
    txt_Price.value = "";
    txt_Discount.value = "";
    txt_Status.value = "";
    txt_Notes.value = "";
  return;
 }
 txt_Custname.value = cs.GetCustName();
 txt_Prodname.value = cs.GetProdName();
 txt_Quant.value = cs.GetQuantity();
 txt_Price.value = cs.GetPrice();
 txt_Discount.value = cs.GetDiscount();
 txt_Status.value = cs.GetStatus();
 txt_Notes.value = cs.GetNotes();
 if ( cs.FirstOrder() == cs.GetOrderID() ) {
    SetStatus("First Order");
 } else if ( cs.LastOrder() == cs.GetOrderID() ) {
    SetStatus("Last Order");
 }
}

Contents Index Write code to synchronize the database Write code for navigation and data manipulation