home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************\
- * *
- * KBUpdate.jfm -- Knowledge Base Update Form *
- * *
- * KBUpdate.jfm is part of the Knowledge Base solution application. It is *
- * used to update the documents in the Knowledge Base. You can edit, add, *
- * delete, query and filter the documents. *
- * *
- * Dependencies: knowbs31.gif *
- * homepg31.gif *
- * paper_22.gif *
- * expinavh.gif *
- * expirowh.gif *
- * database.cc *
- * apps\shared\controls.cc *
- * *
- * Links to: ibapps/index.htm *
- * svr/intrasrv.isv?apps/kbase_ib/kbsearch.jfm *
- * *
- * Updated 11/13/96 by IntraBuilder Samples Group *
- * $Revision: 1.30 $ *
- * *
- * Copyright (c) 1996, Borland International, Inc. All rights reserved. *
- * *
- \****************************************************************************/
- #include "intra.h"
- #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.
- _sys.scripts.load(_sys.env.home() + "APPS\\SHARED\\STRING.JS");
- var f = new kbupdateForm();
- // 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 11/13/96
- //
- var f = new kbupdateForm();
- f.open();
- class kbupdateForm extends Form {
- _sys.scripts.load(_sys.env.home() + "APPS\\SHARED\\CONTROLS.CC")
- _sys.scripts.load("DATABASE.CC")
- with (this) {
- color = "ffffc4";
- height = 14;
- left = 0;
- top = 0;
- width = 76;
- title = "Knowledge Base Updates";
- background = "filename PAPER_22.GIF";
- onServerLoad = class::form_onServerLoad;
- }
-
-
- with (this.ibapps1 = new KbaseDatabase()){
- left = 45;
- top = 0;
- active = true;
- }
-
-
- with (this.category1 = new Query()){
- left = 64;
- top = 0;
- database = parent.ibapps1;
- sql = "SELECT * FROM kbcat";
- active = true;
- }
-
-
- with (this.category1.rowset) {
-
- }
-
-
- with (this.kbase1 = new Query()){
- left = 52;
- top = 0;
- database = parent.ibapps1;
- sql = "SELECT * FROM kbase";
- active = true;
- }
-
-
- with (this.kbase1.rowset) {
- filterOptions = 3;
- locateOptions = 3;
- onAppend = class::Rowset_onAppend;
- onNavigate = class::Rowset_onNavigate;
- }
-
-
- with (this.product1 = new Query()){
- left = 58;
- top = 0;
- database = parent.ibapps1;
- sql = "SELECT * FROM kbprod";
- active = true;
- }
-
-
- with (this.product1.rowset) {
- }
-
-
- with (this.rule1 = new Rule(this)){
- top = 4;
- size = 2;
- right = 74;
- pageno = 0;
- }
-
-
- with (this.rule2 = new Rule(this)){
- top = 29;
- size = 2;
- right = 74;
- pageno = 0;
- }
-
-
- with (this.rule3 = new Rule(this)){
- top = 20.5;
- size = 2;
- right = 74;
- pageno = 0;
- }
-
-
- with (this.KnowledgeBaseLogo = new Image(this)){
- height = 3.4167;
- width = 10.25;
- dataSource = "filename KNOWBS31.GIF";
- alignment = 4;
- pageno = 0;
- }
-
-
- with (this.HeadingHTML = new HTML(this)){
- height = 2;
- left = 12;
- width = 62;
- color = "navy";
- text = {||'<H1><FONT SIZE="+4"><FONT COLOR="maroon">K</FONT></FONT>nowledge <FONT SIZE="+4"><FONT COLOR="maroon">B</FONT></FONT>ase <FONT SIZE="+4"><FONT COLOR="maroon">U</FONT></FONT>pdate</H1>'};
- pageno = 0;
- }
-
-
- with (this.DocumentIdHtml = new HTML(this)){
- height = 1;
- top = 5;
- width = 16;
- color = "black";
- fontBold = true;
- text = "Document ID";
- }
-
-
- with (this.DocumentIdFieldHTML = new HTML(this)){
- height = 1;
- left = 16;
- top = 5;
- width = 44;
- color = "black";
- fontBold = true;
- text = {||this.parent.rowset.state==3 ? "(appending)" : (this.parent.rowset.endOfSet ? "(end of set)" : parseInt(this.parent.kbase1.rowset.fields["DocumentID"].value))};
- }
-
-
- with (this.TitleHTML = new HTML(this)){
- height = 1;
- top = 6;
- width = 16;
- color = "black";
- fontBold = true;
- text = "Title";
- pageno = 0;
- }
-
-
- with (this.TitleText = new Text(this)){
- left = 16;
- top = 6;
- width = 44;
- dataLink = parent.kbase1.rowset.fields["Title"];
- pageno = 0;
- }
-
-
- with (this.ProductHTML = new HTML(this)){
- height = 1;
- top = 7;
- width = 16;
- color = "black";
- fontBold = true;
- text = "Product";
- pageno = 0;
- }
-
-
- with (this.ProductSelect = new FieldSelect(this)){
- left = 16;
- top = 7;
- width = 44;
- options = "array {'kbprod','ProdDescript'}";
- pageno = 0;
- }
-
-
- with (this.CategoryHTML = new HTML(this)){
- height = 1;
- top = 8;
- width = 16;
- color = "black";
- fontBold = true;
- text = "Category";
- pageno = 0;
- }
-
-
- with (this.CategorySelect = new FieldSelect(this)){
- left = 16;
- top = 8;
- width = 44;
- options = "array {'kbcat','CatDescript'}";
- pageno = 0;
- }
-
-
- with (this.KeywordHTML = new HTML(this)){
- height = 1;
- top = 9;
- width = 16;
- color = "black";
- fontBold = true;
- text = "Keywords";
- pageno = 0;
- }
-
-
- with (this.KeywordText = new Text(this)){
- left = 16;
- top = 9;
- width = 44;
- dataLink = parent.kbase1.rowset.fields["Keyword"];
- pageno = 0;
- }
-
-
- with (this.ReformatCheck = new CheckBox(this)){
- height = 1;
- left = 16;
- top = 10;
- width = 52;
- text = "Allow HTML formatting of this document";
- color = "";
- fontBold = true;
- }
-
-
- with (this.DocumentTextArea = new TextArea(this)){
- height = 9;
- top = 11;
- width = 70;
- dataLink = parent.kbase1.rowset.fields["Document"];
- pageno = 0;
- }
-
-
- with (this.HomePageLinkImage = new Image(this)){
- onImageClick = class::link_to_home_page;
- height = 3.4167;
- top = 21;
- width = 10.25;
- dataSource = "filename HOMEPG31.GIF";
- alignment = 4;
- pageno = 0;
- }
-
-
- with (this.HomePageLinkHTML = new HTML(this)){
- height = 1;
- left = 12;
- top = 21;
- width = 62;
- color = "black";
- text = "<A HREF='/ibapps/index.htm'>Return to Home Page</A>";
- pageno = 0;
- }
-
-
- with (this.SearchLinkImage = new Image(this)){
- onImageClick = class::link_to_search_page;
- height = 3.4167;
- top = 25;
- width = 10.25;
- dataSource = "filename KNOWBS31.GIF";
- alignment = 4;
- pageno = 0;
- }
-
-
- with (this.SearchLinkHTML = new HTML(this)){
- height = 1;
- left = 12;
- top = 25;
- width = 62;
- color = "black";
- text = "<A HREF='/svr/intrasrv.isv?apps/kbase_ib/kbsearch.jfm'>Start a new search</A>";
- pageno = 0;
- }
-
-
- with (this.GeneratedHTML = new GeneratedHTML(this)){
- height = 1;
- top = 29.5;
- width = 74;
- pageno = 0;
- }
-
-
- with (this.FilterCriteriaHTML = new HTML(this)){
- height = 1;
- top = 4.5;
- width = 50;
- color = "maroon";
- text = "<H2>Enter filter criteria below</H2>";
- pageno = 2;
- }
-
-
- with (this.ApplyFilterButton = new Button(this)){
- onServerClick = class::ApplyFilterButton_onServerClick;
- left = 12;
- top = 2;
- width = 17;
- text = "Apply Filter";
- pageno = 2;
- }
-
-
- with (this.AbandonFilterButton = new Button(this)){
- onServerClick = class::AbandonFilterButton_onServerClic;
- left = 33;
- top = 2;
- width = 17;
- text = "Abandon Filter";
- pageno = 2;
- }
-
-
- with (this.QueryCriteriaHTML = new HTML(this)){
- height = 1;
- top = 4.5;
- width = 50;
- color = "maroon";
- text = "<H2>Enter query criteria below</H2>";
- pageno = 3;
- }
-
-
- with (this.ApplyQueryButton = new Button(this)){
- onServerClick = class::ApplyQueryButton_onServerClick;
- left = 12;
- top = 2;
- width = 17;
- text = "Apply Query";
- pageno = 3;
- }
-
-
- with (this.AbandonQueryButton = new Button(this)){
- onServerClick = class::AbandonQueryButton_onServerClick;
- left = 33;
- top = 2;
- width = 17;
- text = "Abandon Query";
- pageno = 3;
- }
-
-
- with (this.NavImage = new Image(this)){
- onImageServerClick = {|nLeft, nTop|;if (nLeft >= 26*0 && nLeft < 26*1){form.rowset.first()}else if (nLeft >= 26*1 && nLeft < 26*2){if (!form.rowset.next(-1)) form.rowset.next();}else if (nLeft >= 26*2 && nLeft < 26*3){if (!form.rowset.next()) form.rowset.next(-1);}else{form.rowset.last()}};
- height = 0.9583;
- left = 12;
- top = 2;
- width = 13;
- dataSource = "filename EXPINAVH.GIF";
- alignment = 4;
- }
-
-
- with (this.OtherImage = new Image(this)){
- onImageServerClick = class::OtherImage_OnImageServerClick;
- height = 0.9583;
- left = 28;
- top = 2;
- width = 22.75;
- dataSource = "filename EXPIROWH.GIF";
- alignment = 4;
- }
-
- this.rowset = this.kbase1.rowset;
-
- function form_onServerLoad()
- {
- // Make sure the logged in user has access to the kbupdate form
- if (!this.security.hasAccessTo("KBUPDATE")) {
- _sys.forms.run("kberror.jfm");
- this.close();
- this.release();
- }
- //
- // set the document id value
- //
- this.refreshID(this);
- //
- // set the field events for the product field
- //
- this.kbase1.rowset.fields["Product"].canChange =
- {| p |; var prod = this.parent.parent.parent.parent.product1 ;prod.rowset.applyLocate("ProdDescript = '" + escapeChar(p,"'") + "'") ;this.value = prod.rowset.fields["Product"].value; return false}
- this.kbase1.rowset.fields["Product"].beforeGetValue =
- {; var prod = this.parent.parent.parent.parent.product1 ;prod.rowset.applyLocate('Product = ' + (this.value==null?0:this.value)) ;return (prod.rowset.endOfSet?"":prod.rowset.fields["ProdDescript"].value)};
- this.ProductSelect.dataLink = this.kbase1.rowset.fields["Product"];
- //
- // set the field events for the category field
- //
- this.kbase1.rowset.fields["Category"].canChange =
- {| c |; var cat = this.parent.parent.parent.parent.category1 ;cat.rowset.applyLocate("CatDescript = '" + escapeChar(c,"'") + "'") ;this.value = cat.rowset.fields["Category"].value; return false}
- this.kbase1.rowset.fields["Category"].beforeGetValue =
- {; var cat = this.parent.parent.parent.parent.category1 ;cat.rowset.applyLocate('Category = ' + (this.value==null?0:this.value)) ;return (cat.rowset.endOfSet?"":cat.rowset.fields["CatDescript"].value)};
- this.CategorySelect.dataLink = this.kbase1.rowset.fields["Category"];
- //
- // set the field events for the reformat field
- // (this is only necessary in the InterBase version of the Knowledge Base
- // since there are no boolean type fields in InterBase.)
- //
- this.kbase1.rowset.fields["Reformat"].canChange =
- {| r |; this.value = (r ? 1 : 0); return false};
- this.kbase1.rowset.fields["Reformat"].beforeGetValue =
- {; return this.parent.parent.endOfSet ? false : (this.value == 1)};
- this.ReformatCheck.dataLink = this.kbase1.rowset.fields["Reformat"];
- }
-
- function ApplyFilterButton_onServerClick()
- {
- if (this.form.rowset.state == STATE_FILTER) {
- this.form.rowset.applyFilter();
- this.form.rowset.first();
- }
- this.form.pageno = 1;
- }
-
- function AbandonFilterButton_onServerClick()
- {
- this.form.rowset.abandon();
- this.form.pageno = 1;
- }
-
- function ApplyQueryButton_onServerClick()
- {
- if (this.form.rowset.state == STATE_LOCATE) {
- if (!this.form.rowset.applyLocate())
- this.form.rowset.first();
- }
- this.form.pageno = 1;
- }
-
- function AbandonQueryButton_onServerClick()
- {
- this.form.rowset.abandon();
- this.form.pageno = 1;
- }
-
- function OtherImage_OnImageServerClick( nLeft, nTop )
- {
- try {
- if (nLeft >= 26*0 && nLeft < 26*1)
- form.rowset.beginAppend();
- else if (nLeft >= 26*1 && nLeft < 26*2) {
- if (!form.rowset.endOfSet) {
- form.rowset.delete();
- if (form.rowset.endOfSet)
- form.rowset.last();
- }
- }
- else if (nLeft >= 26*2 && nLeft < 26*3) {
- form.rowset.modified = true;
- form.rowset.save();
- }
- else if (nLeft >= 26*3 && nLeft < 26*4) {
- form.rowset.abandon();
- if (form.rowset.endOfSet)
- form.rowset.last();
- }
- else if (nLeft >= 26*4 && nLeft < 26*5)
- form.rowset.beginEdit();
- else if (nLeft >= 26*5 && nLeft < 26*6) {
- with(this) {
- if (form.rowset.state==STATE_LOCATE) {
- form.rowset.applyLocate();
- }
- else {
- form.rowset.beginLocate();
- form.pageno = 3;
- }
- }
- }
- else {
- with(this) {
- if (form.rowset.state==STATE_FILTER) {
- form.rowset.applyFilter();
- }
- else {
- form.rowset.beginFilter();
- form.pageno = 2;
- }
- }
- }
- form.refreshID(form);
- }
- catch (DbException e) {
- if (e.message.indexOf("TITLE") > 0)
- var error = "The Title field must not be blank.<p>" +
- e.message + " (" + e.code + ")<p>";
- else
- var error = e.message + " (" + e.code + ")<p>";
- error += "<u>Server Errors:</u><p>";
- for (var i = 0; i<e.errors.length; i++)
- error += e.errors[i].message + " (" + e.errors[i].context + ")<br>";
- _sys.scripts.load("kberror.jfm");
- var f = new kberrorForm();
- f.setError(error);
- f.enableBackButton();
- f.open();
- }
- catch (Exception e) {
- _sys.scripts.load("kberror.jfm");
- var f = new kberrorForm();
- f.setError(e.message + " (" + e.code + ")");
- f.enableBackButton();
- f.open();
- }
- }
-
- function NaveImage_onServerClick (nLeft, nTop)
- {
- try {
- if (this.form.rowset.modified) {
- this.form.rowset.save();
- }
- if (nLeft >= 26*0 && nLeft < 26*1) {
- form.rowset.first()
- }
- else if (nLeft >= 26*1 && nLeft < 26*2) {
- if (!form.rowset.next(-1))
- form.rowset.next();
- }
- else if (nLeft >= 26*2 && nLeft < 26*3) {
- if (!form.rowset.next())
- form.rowset.next(-1);
- }
- else {
- form.rowset.last();
- }
- }
- catch (DbException e) {
- if (e.message.indexOf("TITLE") > 0)
- var error = "The Title field must not be blank.<p>" +
- e.message + " (" + e.code + ")<p>";
- else
- var error = e.message + " (" + e.code + ")<p>";
- error += "<u>Server Errors:</u><p>";
- for (var i = 0; i<e.errors.length; i++)
- error += e.errors[i].message + " (" + e.errors[i].context + ")<br>";
- _sys.scripts.load("kberror.jfm");
- var f = new kberrorForm();
- f.setError(error);
- f.enableBackButton();
- f.open();
- }
- catch (Exception e) {
- _sys.scripts.load("kberror.jfm");
- var f = new kberrorForm();
- f.setError(e.message + " (" + e.code + ")");
- f.enableBackButton();
- f.open();
- }
- }
-
- function Rowset_onAppend()
- {
- var s = new StoredProc();
- s.database = this.parent.database;
- s.procedureName = "GET_DOC_ID";
- s.active=true;
- this.fields["DocumentID"].value = s.params["NEW_ID"].value;
- }
-
- function Rowset_onNavigate()
- {
- this.parent.parent.refreshID(this.parent.parent);
- }
-
- function refreshID( frm ) {
- frm.DocumentIdFieldHTML.text = frm.DocumentIdFieldHTML.text;
- }
-
- function link_to_home_page()
- {
- location.href="/ibapps/index.htm";
- }
-
- function link_to_search_page()
- {
- location.href="/svr/intrasrv.isv?apps/kbase_ib/kbsearch.jfm";
- }
-
- }
-
-