home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 8 / CDACTUAL8.iso / progs / ite / ite10d1.exe / DATA.Z / KBLOOKUP.JFM < prev    next >
Encoding:
Text File  |  1996-09-07  |  10.1 KB  |  390 lines

  1. /****************************************************************************\
  2. *                                                                            *
  3. * KbLookup.jfm  --  Knowledge Base Lookup Table Update Form                  *
  4. *                                                                            *
  5. * KbLookup.jfm is part of the Knowledge Base prebuilt business solution. It  *
  6. * is used to update the two lookup tables, products and categories. It uses  *
  7. * the kblogin form to provide password security. See the header code right   *
  8. * after this comment block to see how the login form is called.              *
  9. *                                                                            *
  10. * Dependencies:  knowbs31.gif                                                *
  11. *                homepg31.gif                                                *
  12. *                paper_22.gif                                                *
  13. *                apps\shared\controls.cc                                     *
  14. *                                                                            *
  15. * Updated 8/27/96 by IntraBuilder Samples Group                              *
  16. * $Revision:   1.3  $                                                       *
  17. *                                                                            *
  18. * Copyright (c) 1996, Borland International, Inc. All rights reserved.       *
  19. *                                                                            *
  20. \****************************************************************************/
  21. #include "security.h"
  22. //
  23. // The code loads the security login form instead of the update form.
  24. // An object reference to the update form is stored as a property of
  25. // the login form. If the login is successful, the login form opens
  26. // this update form.
  27. // 
  28. // First create the update form, but don't open it.
  29. var f = new kblookupForm();
  30. // then create a security object
  31. _sys.scripts.load(SM_CLASS_LOCATION + "security.js");
  32. f.security = new SecurityManager();
  33. // then create the login form
  34. _sys.scripts.load("kblogin.jfm");
  35. var login = new kbloginForm();
  36. // the login form requires two custom properties be set
  37. login.security = f.security;
  38. login.nextForm = f;
  39. // finally, open the login form
  40. login.open();
  41. return;
  42. // {End Header} Do not remove this comment//
  43. // Generated on 08/27/96
  44. //
  45. var f = new kblookupForm();
  46. f.open();
  47. class kblookupForm extends Form {
  48.    _sys.scripts.load(_sys.env.home() + "APPS\\SHARED\\CONTROLS.CC");
  49.    with (this) {
  50.       height = 26.4706;
  51.       left = 3.6667;
  52.       top = 0.6471;
  53.       width = 89.6667;
  54.       title = "Form";
  55.       background = "filename paper_22.gif";
  56.       preRender = class::Form_preRender;
  57.       onServerLoad = class::Form_onServerLoad;
  58.    }
  59.  
  60.  
  61.    with (this.ibapps1 = new Database()){
  62.       left = 21;
  63.       top = 2;
  64.       databaseName = "IBAPPS";
  65.       active = true;
  66.    }
  67.  
  68.  
  69.    with (this.category1 = new Query()){
  70.       left = 36;
  71.       top = 2;
  72.       database = parent.ibapps1;
  73.       sql = "SELECT * FROM kbcat";
  74.       active = true;
  75.    }
  76.  
  77.  
  78.    with (this.category1.rowset) {
  79.  
  80.    }
  81.  
  82.  
  83.    with (this.product1 = new Query()){
  84.       left = 30;
  85.       top = 2;
  86.       database = parent.ibapps1;
  87.       sql = "SELECT * FROM kbprod";
  88.       active = true;
  89.    }
  90.  
  91.  
  92.    with (this.product1.rowset) {
  93.  
  94.    }
  95.  
  96.  
  97.    with (this.rule1 = new Rule(this)){
  98.       left = 1;
  99.       top = 6;
  100.       size = 2;
  101.       right = 70;
  102.       pageno = 0;
  103.    }
  104.  
  105.  
  106.    with (this.rule2 = new Rule(this)){
  107.       left = 1;
  108.       top = 15;
  109.       size = 2;
  110.       right = 71;
  111.    }
  112.  
  113.  
  114.    with (this.rule3 = new Rule(this)){
  115.       left = 1;
  116.       top = 24;
  117.       size = 2;
  118.       right = 70;
  119.       pageno = 0;
  120.    }
  121.  
  122.  
  123.    with (this.rule4 = new Rule(this)){
  124.       left = 1;
  125.       top = 31;
  126.       size = 2;
  127.       right = 70;
  128.    }
  129.  
  130.  
  131.    with (this.kbaseLogoImage = new Image(this)){
  132.       height = 4.8235;
  133.       left = 1;
  134.       top = 0.2353;
  135.       width = 13.6667;
  136.       dataSource = "filename KNOWBS31.GIF";
  137.       alignment = 4;
  138.       pageno = 0;
  139.    }
  140.  
  141.  
  142.    with (this.titleHTML = new HTML(this)){
  143.       height = 2;
  144.       left = 25;
  145.       top = 1.2353;
  146.       width = 44;
  147.       color = "navy";
  148.       text = "<H1>Update Lookup Tables</H1>";
  149.       pageno = 0;
  150.    }
  151.  
  152.  
  153.    with (this.prodHTML = new HTML(this)){
  154.       height = 1;
  155.       left = 1;
  156.       top = 7;
  157.       width = 20;
  158.       color = "black";
  159.       text = "Current Products";
  160.    }
  161.  
  162.  
  163.    with (this.prodSelect = new ListBox(this)){
  164.       height = 6;
  165.       left = 1;
  166.       top = 8;
  167.       width = 20;
  168.    }
  169.  
  170.  
  171.    with (this.prodAddButton = new Button(this)){
  172.       left = 25;
  173.       top = 9;
  174.       width = 10.5;
  175.       text = "Add";
  176.       onServerClick = class::prodAddButton_onServerClick;
  177.    }
  178.  
  179.  
  180.    with (this.prodText = new Text(this)){
  181.       left = 40;
  182.       top = 9;
  183.       width = 30;
  184.       value = "";
  185.    }
  186.  
  187.  
  188.    with (this.prodDeleteButton = new Button(this)){
  189.       left = 25;
  190.       top = 11;
  191.       width = 10.5;
  192.       text = "Delete";
  193.       onServerClick = class::prodDeleteButton_onServerClick;
  194.    }
  195.  
  196.  
  197.    with (this.catHTML = new HTML(this)){
  198.       height = 1;
  199.       left = 1;
  200.       top = 16;
  201.       width = 20;
  202.       color = "black";
  203.       text = "Current Categories";
  204.    }
  205.  
  206.  
  207.    with (this.catSelect = new ListBox(this)){
  208.       height = 6;
  209.       left = 1;
  210.       top = 17;
  211.       width = 20;
  212.    }
  213.  
  214.  
  215.    with (this.catAddButton = new Button(this)){
  216.       left = 25;
  217.       top = 18;
  218.       width = 10.5;
  219.       text = "Add";
  220.       onServerClick = class::catAddButton_onServerClick;
  221.    }
  222.  
  223.  
  224.    with (this.catText = new Text(this)){
  225.       left = 40;
  226.       top = 18;
  227.       width = 30;
  228.       value = "";
  229.    }
  230.  
  231.  
  232.    with (this.catDeleteButton = new Button(this)){
  233.       left = 25;
  234.       top = 20;
  235.       width = 10.5;
  236.       text = "Delete";
  237.       onServerClick = class::catDeleteButton_onServerClick;
  238.    }
  239.  
  240.  
  241.    with (this.HomePageLinkImage = new Image(this)){
  242.       height = 4.8235;
  243.       left = 1;
  244.       top = 25;
  245.       width = 13.6667;
  246.       dataSource = "filename HOMEPG31.GIF";
  247.       alignment = 4;
  248.       pageno = 0;
  249.       onImageClick = class::link_to_home_page;
  250.    }
  251.  
  252.  
  253.    with (this.HomePageLinkHTML = new HTML(this)){
  254.       height = 1;
  255.       left = 25;
  256.       top = 25;
  257.       width = 45;
  258.       color = "black";
  259.       fontBold = false;
  260.       text = "<A HREF='/ibapps/index.htm'>Return to Home Page</A>";
  261.       pageno = 0;
  262.    }
  263.  
  264.  
  265.    with (this.GeneratedHTML1 = new GeneratedHTML(this)){
  266.       height = 1;
  267.       left = 1;
  268.       top = 32;
  269.       width = 68;
  270.       pageno = 0;
  271.    }
  272.  
  273.  
  274.    with (this.errorHTML = new HTML(this)){
  275.       height = 4;
  276.       left = 1;
  277.       top = 7;
  278.       width = 68;
  279.       color = "black";
  280.       text = "HTML1";
  281.       pageno = 2;
  282.    }
  283.  
  284.  
  285.    function Form_onServerLoad()
  286.    {
  287.       try{
  288.          if (!this.security.hasAccessTo("kbupdate")) {
  289.             this.errorHTML.text = "Insufficient rights to update lookup tables";
  290.             this.pageno = 2;
  291.          }
  292.       }
  293.       catch (Exception e) {
  294.          this.errorHTML.text = "Error opening lookup form. " + 
  295.                        e.message + " (" + e.code + ")";
  296.          this.pageno = 2;
  297.       }
  298.    }
  299.  
  300.    function Form_preRender(notForm, formRef)
  301.    {
  302.       // 
  303.       // generate array from KbProd for the listbox
  304.       //
  305.       form = notForm ? formRef : this;
  306.       form.prodArray = new Array();
  307.       form.product1.rowset.first();
  308.       while(!form.product1.rowset.endOfSet) {
  309.          form.prodArray.add(form.product1.rowset.fields["ProdDescript"].value);
  310.          form.product1.rowset.next();
  311.       }
  312.       form.prodArray.sort();
  313.       form.prodSelect.options = 'array form.prodArray';
  314.       // 
  315.       // generate array from KbCat for the listbox
  316.       //
  317.       form = notForm ? formRef : this;
  318.       form.catArray = new Array();
  319.       form.category1.rowset.first();
  320.       while(!form.category1.rowset.endOfSet) {
  321.          form.catArray.add(form.category1.rowset.fields["CatDescript"].value);
  322.          form.category1.rowset.next();
  323.       }
  324.       form.catArray.sort();
  325.       form.catSelect.options = 'array form.catArray';
  326.    }
  327.  
  328.    function prodAddButton_onServerClick()
  329.    {
  330.       var prod = new StringEx(this.form.prodText.value);
  331.       prod = new StringEx(prod.rightTrim());
  332.       prod = prod.leftTrim();
  333.       if (prod.length > 0) {
  334.          this.form.product1.rowset.beginAppend();
  335.          this.form.product1.rowset.fields["ProdDescript"].value = prod;
  336.          this.form.product1.rowset.save();
  337.          // blank out the text
  338.          this.form.prodText.value = "";
  339.          // re-render the form
  340.          this.form.Form_preRender(true, this.form);
  341.       }
  342.    }
  343.  
  344.    function prodDeleteButton_onServerClick()
  345.    {
  346.       var prod = new StringEx(this.form.prodSelect.value);
  347.       prod = new StringEx(prod.rightTrim());
  348.       prod = prod.leftTrim();
  349.       if (prod.length > 0) {
  350.          if (this.form.product1.rowset.applyLocate('ProdDescript = prod'))
  351.             this.form.product1.rowset.delete();
  352.          this.form.Form_preRender(true, this.form);
  353.       }
  354.    }
  355.  
  356.    function catAddButton_onServerClick()
  357.    {
  358.       var cat = new StringEx(this.form.catText.value);
  359.       cat = new StringEx(cat.rightTrim());
  360.       cat = cat.leftTrim();
  361.       if (cat.length > 0) {
  362.          this.form.category1.rowset.beginAppend();
  363.          this.form.category1.rowset.fields["CatDescript"].value = cat;
  364.          this.form.category1.rowset.save();
  365.          // blank out the text
  366.          this.form.catText.value = "";
  367.          // re-render the form
  368.          this.form.Form_preRender(true, this.form);
  369.       }
  370.    }
  371.  
  372.    function catDeleteButton_onServerClick()
  373.    {
  374.       var cat = new StringEx(this.form.catSelect.value);
  375.       cat = new StringEx(cat.rightTrim());
  376.       cat = cat.leftTrim();
  377.       if (cat.length > 0) {
  378.          if (this.form.category1.rowset.applyLocate('CatDescript = cat'))
  379.             this.form.category1.rowset.delete();
  380.          this.form.Form_preRender(true, this.form);
  381.       }
  382.    }
  383.  
  384.    function link_to_home_page()
  385.    {
  386.       location.href="/ibapps/index.htm";
  387.    }
  388.  
  389. }
  390.