home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************\
- * *
- * KbLookup.jfm -- Knowledge Base Lookup Table Update Form *
- * *
- * KbLookup.jfm is part of the Knowledge Base prebuilt business solution. It *
- * is used to update the two lookup tables, products and categories. It uses *
- * the kblogin form to provide password security. See the header code right *
- * after this comment block to see how the login form is called. *
- * *
- * Dependencies: knowbs31.gif *
- * homepg31.gif *
- * paper_22.gif *
- * apps\shared\controls.cc *
- * *
- * Updated 8/27/96 by IntraBuilder Samples Group *
- * $Revision: 1.3 $ *
- * *
- * Copyright (c) 1996, Borland International, Inc. All rights reserved. *
- * *
- \****************************************************************************/
- #include "security.h"
- //
- // The code loads the security login form instead of the update form.
- // An object reference to the update form is stored as a property of
- // the login form. If the login is successful, the login form opens
- // this update form.
- //
- // First create the update form, but don't open it.
- var f = new kblookupForm();
- // then create a security object
- _sys.scripts.load(SM_CLASS_LOCATION + "security.js");
- f.security = new SecurityManager();
- // then create the login form
- _sys.scripts.load("kblogin.jfm");
- var login = new kbloginForm();
- // the login form requires two custom properties be set
- login.security = f.security;
- login.nextForm = f;
- // finally, open the login form
- login.open();
- return;
- // {End Header} Do not remove this comment//
- // Generated on 08/27/96
- //
- var f = new kblookupForm();
- f.open();
- class kblookupForm extends Form {
- _sys.scripts.load(_sys.env.home() + "APPS\\SHARED\\CONTROLS.CC");
- with (this) {
- height = 26.4706;
- left = 3.6667;
- top = 0.6471;
- width = 89.6667;
- title = "Form";
- background = "filename paper_22.gif";
- preRender = class::Form_preRender;
- onServerLoad = class::Form_onServerLoad;
- }
-
-
- with (this.ibapps1 = new Database()){
- left = 21;
- top = 2;
- databaseName = "IBAPPS";
- active = true;
- }
-
-
- with (this.category1 = new Query()){
- left = 36;
- top = 2;
- database = parent.ibapps1;
- sql = "SELECT * FROM kbcat";
- active = true;
- }
-
-
- with (this.category1.rowset) {
-
- }
-
-
- with (this.product1 = new Query()){
- left = 30;
- top = 2;
- database = parent.ibapps1;
- sql = "SELECT * FROM kbprod";
- active = true;
- }
-
-
- with (this.product1.rowset) {
-
- }
-
-
- with (this.rule1 = new Rule(this)){
- left = 1;
- top = 6;
- size = 2;
- right = 70;
- pageno = 0;
- }
-
-
- with (this.rule2 = new Rule(this)){
- left = 1;
- top = 15;
- size = 2;
- right = 71;
- }
-
-
- with (this.rule3 = new Rule(this)){
- left = 1;
- top = 24;
- size = 2;
- right = 70;
- pageno = 0;
- }
-
-
- with (this.rule4 = new Rule(this)){
- left = 1;
- top = 31;
- size = 2;
- right = 70;
- }
-
-
- with (this.kbaseLogoImage = new Image(this)){
- height = 4.8235;
- left = 1;
- top = 0.2353;
- width = 13.6667;
- dataSource = "filename KNOWBS31.GIF";
- alignment = 4;
- pageno = 0;
- }
-
-
- with (this.titleHTML = new HTML(this)){
- height = 2;
- left = 25;
- top = 1.2353;
- width = 44;
- color = "navy";
- text = "<H1>Update Lookup Tables</H1>";
- pageno = 0;
- }
-
-
- with (this.prodHTML = new HTML(this)){
- height = 1;
- left = 1;
- top = 7;
- width = 20;
- color = "black";
- text = "Current Products";
- }
-
-
- with (this.prodSelect = new ListBox(this)){
- height = 6;
- left = 1;
- top = 8;
- width = 20;
- }
-
-
- with (this.prodAddButton = new Button(this)){
- left = 25;
- top = 9;
- width = 10.5;
- text = "Add";
- onServerClick = class::prodAddButton_onServerClick;
- }
-
-
- with (this.prodText = new Text(this)){
- left = 40;
- top = 9;
- width = 30;
- value = "";
- }
-
-
- with (this.prodDeleteButton = new Button(this)){
- left = 25;
- top = 11;
- width = 10.5;
- text = "Delete";
- onServerClick = class::prodDeleteButton_onServerClick;
- }
-
-
- with (this.catHTML = new HTML(this)){
- height = 1;
- left = 1;
- top = 16;
- width = 20;
- color = "black";
- text = "Current Categories";
- }
-
-
- with (this.catSelect = new ListBox(this)){
- height = 6;
- left = 1;
- top = 17;
- width = 20;
- }
-
-
- with (this.catAddButton = new Button(this)){
- left = 25;
- top = 18;
- width = 10.5;
- text = "Add";
- onServerClick = class::catAddButton_onServerClick;
- }
-
-
- with (this.catText = new Text(this)){
- left = 40;
- top = 18;
- width = 30;
- value = "";
- }
-
-
- with (this.catDeleteButton = new Button(this)){
- left = 25;
- top = 20;
- width = 10.5;
- text = "Delete";
- onServerClick = class::catDeleteButton_onServerClick;
- }
-
-
- with (this.HomePageLinkImage = new Image(this)){
- height = 4.8235;
- left = 1;
- top = 25;
- width = 13.6667;
- dataSource = "filename HOMEPG31.GIF";
- alignment = 4;
- pageno = 0;
- onImageClick = class::link_to_home_page;
- }
-
-
- with (this.HomePageLinkHTML = new HTML(this)){
- height = 1;
- left = 25;
- top = 25;
- width = 45;
- color = "black";
- fontBold = false;
- text = "<A HREF='/ibapps/index.htm'>Return to Home Page</A>";
- pageno = 0;
- }
-
-
- with (this.GeneratedHTML1 = new GeneratedHTML(this)){
- height = 1;
- left = 1;
- top = 32;
- width = 68;
- pageno = 0;
- }
-
-
- with (this.errorHTML = new HTML(this)){
- height = 4;
- left = 1;
- top = 7;
- width = 68;
- color = "black";
- text = "HTML1";
- pageno = 2;
- }
-
-
- function Form_onServerLoad()
- {
- try{
- if (!this.security.hasAccessTo("kbupdate")) {
- this.errorHTML.text = "Insufficient rights to update lookup tables";
- this.pageno = 2;
- }
- }
- catch (Exception e) {
- this.errorHTML.text = "Error opening lookup form. " +
- e.message + " (" + e.code + ")";
- this.pageno = 2;
- }
- }
-
- function Form_preRender(notForm, formRef)
- {
- //
- // generate array from KbProd for the listbox
- //
- form = notForm ? formRef : this;
- form.prodArray = new Array();
- form.product1.rowset.first();
- while(!form.product1.rowset.endOfSet) {
- form.prodArray.add(form.product1.rowset.fields["ProdDescript"].value);
- form.product1.rowset.next();
- }
- form.prodArray.sort();
- form.prodSelect.options = 'array form.prodArray';
- //
- // generate array from KbCat for the listbox
- //
- form = notForm ? formRef : this;
- form.catArray = new Array();
- form.category1.rowset.first();
- while(!form.category1.rowset.endOfSet) {
- form.catArray.add(form.category1.rowset.fields["CatDescript"].value);
- form.category1.rowset.next();
- }
- form.catArray.sort();
- form.catSelect.options = 'array form.catArray';
- }
-
- function prodAddButton_onServerClick()
- {
- var prod = new StringEx(this.form.prodText.value);
- prod = new StringEx(prod.rightTrim());
- prod = prod.leftTrim();
- if (prod.length > 0) {
- this.form.product1.rowset.beginAppend();
- this.form.product1.rowset.fields["ProdDescript"].value = prod;
- this.form.product1.rowset.save();
- // blank out the text
- this.form.prodText.value = "";
- // re-render the form
- this.form.Form_preRender(true, this.form);
- }
- }
-
- function prodDeleteButton_onServerClick()
- {
- var prod = new StringEx(this.form.prodSelect.value);
- prod = new StringEx(prod.rightTrim());
- prod = prod.leftTrim();
- if (prod.length > 0) {
- if (this.form.product1.rowset.applyLocate('ProdDescript = prod'))
- this.form.product1.rowset.delete();
- this.form.Form_preRender(true, this.form);
- }
- }
-
- function catAddButton_onServerClick()
- {
- var cat = new StringEx(this.form.catText.value);
- cat = new StringEx(cat.rightTrim());
- cat = cat.leftTrim();
- if (cat.length > 0) {
- this.form.category1.rowset.beginAppend();
- this.form.category1.rowset.fields["CatDescript"].value = cat;
- this.form.category1.rowset.save();
- // blank out the text
- this.form.catText.value = "";
- // re-render the form
- this.form.Form_preRender(true, this.form);
- }
- }
-
- function catDeleteButton_onServerClick()
- {
- var cat = new StringEx(this.form.catSelect.value);
- cat = new StringEx(cat.rightTrim());
- cat = cat.leftTrim();
- if (cat.length > 0) {
- if (this.form.category1.rowset.applyLocate('CatDescript = cat'))
- this.form.category1.rowset.delete();
- this.form.Form_preRender(true, this.form);
- }
- }
-
- function link_to_home_page()
- {
- location.href="/ibapps/index.htm";
- }
-
- }
-