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

  1. /****************************************************************************\
  2. *                                                                            *
  3. * Update.jfm  --  Employee Phone Book Update Form                            *
  4. *                                                                            *
  5. * Update.jfm is part of the Phone Book solution application. It is used      *
  6. * to modify the employee table. It can also be used to add and delete        *
  7. * employee records.                                                          *
  8. *                                                                            *
  9. * Dependencies:  phonbk31.gif                                                *
  10. *                apps\shared\controls.cc                                     *
  11. *                                                                            *
  12. * Links to:      ibapps/index.htm                                            *
  13. *                svr/intrasrv.isv?apps/phone/phonedep.jrp                    *
  14. *                svr/intrasrv.isv?apps/phone/phoneemp.jrp                    *
  15. *                svr/intrasrv.isv?apps/phone/update.jfm                      *
  16. *                                                                            *
  17. * Updated 8/27/96 by IntraBuilder Samples Group                              *
  18. * $Revision:   1.22  $                                                       *
  19. *                                                                            *
  20. * Copyright (c) 1996, Borland International, Inc. All rights reserved.       *
  21. *                                                                            *
  22. \****************************************************************************/
  23. #include "intra.h"
  24. #include "security.h"
  25. //
  26. // This header code is executed when the form is run. The return
  27. // prevents the designer generated startup code from executing.
  28. // 
  29. // The code loads the security login form instead of the update form.
  30. // An object reference to the update form is stored as a property of
  31. // the login form. If the login is successful, the login form opens
  32. // this update form.
  33. // 
  34. // First create the update form, but don't open it.
  35. var f = new updateForm();
  36. f.argv = UPDATE.arguments;
  37. // then create a security object
  38. _sys.scripts.load(SM_CLASS_LOCATION + "security.js");
  39. f.security = new SecurityManager();
  40. // then create the login form
  41. _sys.scripts.load("emplogin.jfm");
  42. var login = new emploginForm();
  43. // the login form requires two custom properties be set
  44. login.security = f.security;
  45. login.nextForm = f;
  46. // finally, open the login form
  47. login.open();
  48. return;
  49. // {End Header} Do not remove this comment//
  50. // Generated on 08/27/1996
  51. //
  52. var f = new updateForm();
  53. f.open();
  54. class updateForm extends Form {
  55.    _sys.scripts.load(_sys.env.home() + "APPS\\SHARED\\CONTROLS.CC")
  56.    with (this) {
  57.       color = "4a95b5";
  58.       height = 28.4118;
  59.       left = 1.3333;
  60.       top = 0.1765;
  61.       width = 85.1667;
  62.       title = "Update Employee";
  63.       preRender = class::Form_preRender;
  64.       onServerLoad = class::Form_onServerLoad;
  65.    }
  66.  
  67.  
  68.    with (this.ibapps1 = new Database()){
  69.       left = 21;
  70.       top = 3;
  71.       databaseName = "IBAPPS";
  72.       active = true;
  73.    }
  74.  
  75.  
  76.    with (this.employee1 = new Query()){
  77.       left = 27;
  78.       top = 3;
  79.       database = parent.ibapps1;
  80.       sql = "SELECT * FROM employee";
  81.       active = true;
  82.    }
  83.  
  84.  
  85.    with (this.employee1.rowset) {
  86.  
  87.    }
  88.  
  89.  
  90.    with (this.department1 = new Query()){
  91.       left = 33;
  92.       top = 3;
  93.       database = parent.ibapps1;
  94.       sql = "select * from departmt";
  95.       active = true;
  96.    }
  97.  
  98.  
  99.    with (this.department1.rowset) {
  100.  
  101.    }
  102.  
  103.  
  104.    with (this.rule1 = new Rule(this)){
  105.       left = 1;
  106.       top = 6;
  107.       size = 2;
  108.       right = 80;
  109.       pageno = 0;
  110.    }
  111.  
  112.  
  113.    with (this.rule2 = new Rule(this)){
  114.       left = 1;
  115.       top = 28;
  116.       size = 2;
  117.       right = 80;
  118.       pageno = 0;
  119.    }
  120.  
  121.  
  122.    with (this.PhoneBookLogo = new Image(this)){
  123.       height = 4.8235;
  124.       left = 1;
  125.       top = 0.2353;
  126.       width = 13.6667;
  127.       dataSource = "filename PHONBK31.GIF";
  128.       alignment = 4;
  129.       pageno = 0;
  130.    }
  131.  
  132.  
  133.    with (this.HeadingHTML = new HTML(this)){
  134.       height = 2;
  135.       left = 21;
  136.       top = 0.2353;
  137.       width = 59;
  138.       color = "853a1a";
  139.       text = "<H1>Update Employee Data</H1>";
  140.       pageno = 0;
  141.    }
  142.  
  143.  
  144.    with (this.navImage = new Image(this)){
  145.       visible = false;
  146.       height = 1.3529;
  147.       left = 1;
  148.       top = 6.4706;
  149.       width = 17.3333;
  150.       dataSource = "filename EXPINAVH.GIF";
  151.       alignment = 4;
  152.       onImageServerClick = class::navImage_onImageServerClick;
  153.    }
  154.  
  155.  
  156.    with (this.editImage = new Image(this)){
  157.       visible = false;
  158.       height = 1.3529;
  159.       left = 21;
  160.       top = 6.4706;
  161.       width = 29;
  162.       dataSource = "filename EXPIROWH.GIF";
  163.       alignment = 4;
  164.       onImageServerClick = class::editImage_onImageServerClick;
  165.    }
  166.  
  167.  
  168.    with (this.profileButton = new Button(this)){
  169.       visible = false;
  170.       left = 59;
  171.       top = 6.4706;
  172.       width = 21;
  173.       text = "Security Profile";
  174.       onServerClick = class::profileButton_onServerClick;
  175.    }
  176.  
  177.  
  178.    with (this.nameHTML = new HTML(this)){
  179.       height = 1;
  180.       left = 1;
  181.       top = 8.4706;
  182.       width = 17.1667;
  183.       color = "black";
  184.       text = "Full Name";
  185.    }
  186.  
  187.  
  188.    with (this.nameText = new Text(this)){
  189.       left = 21;
  190.       top = 8.4706;
  191.       width = 37;
  192.       dataLink = parent.employee1.rowset.fields["Full Name"];
  193.    }
  194.  
  195.  
  196.    with (this.empidHTML = new HTML(this)){
  197.       height = 1;
  198.       left = 1;
  199.       top = 9.4706;
  200.       width = 17.1667;
  201.       color = "black";
  202.       text = "Employee ID";
  203.    }
  204.  
  205.  
  206.    with (this.employeeIDHTML = new HTML(this)){
  207.       height = 1;
  208.       left = 21;
  209.       top = 9.4706;
  210.       width = 19;
  211.       color = "black";
  212.       text = {||this.parent.rowset.state==STATE_LOCATE ? "(locating)" : this.parent.rowset.state==STATE_FILTER ? "(filtering)" : this.parent.rowset.state==STATE_APPEND ? "(appending)" : (this.parent.rowset.endOfSet ? "(end of set)" : parseInt(this.parent.rowset.fields["Employee ID"].value))};
  213.    }
  214.  
  215.  
  216.    with (this.secIDHTML = new HTML(this)){
  217.       height = 1;
  218.       left = 48;
  219.       top = 9.4706;
  220.       width = 10;
  221.       color = "black";
  222.       text = "Security ID";
  223.    }
  224.  
  225.  
  226.    with (this.securityIDText = new Text(this)){
  227.       left = 59;
  228.       top = 9.4706;
  229.       width = 21;
  230.       dataLink = parent.employee1.rowset.fields["Security ID"];
  231.    }
  232.  
  233.  
  234.    with (this.securityIDHTML = new HTML(this)){
  235.       height = 1;
  236.       left = 59;
  237.       top = 9.4706;
  238.       width = 21;
  239.       color = "black";
  240.       text = {||this.parent.employee1.rowset.fields["Security ID"].value};
  241.    }
  242.  
  243.  
  244.    with (this.deptHTML = new HTML(this)){
  245.       height = 1;
  246.       left = 1;
  247.       top = 11;
  248.       width = 17.1667;
  249.       color = "black";
  250.       text = "Department";
  251.    }
  252.  
  253.  
  254.    with (this.titleHTML = new HTML(this)){
  255.       height = 1;
  256.       left = 1;
  257.       top = 12.4706;
  258.       width = 17.1667;
  259.       color = "black";
  260.       text = "Title";
  261.    }
  262.  
  263.  
  264.    with (this.titleText = new Text(this)){
  265.       left = 21;
  266.       top = 12.4706;
  267.       width = 37;
  268.       dataLink = parent.employee1.rowset.fields["Title"];
  269.    }
  270.  
  271.  
  272.    with (this.phoneHTML = new HTML(this)){
  273.       height = 1;
  274.       left = 1;
  275.       top = 14;
  276.       width = 17.1667;
  277.       color = "black";
  278.       text = "Phone";
  279.    }
  280.  
  281.  
  282.    with (this.phoneText = new Text(this)){
  283.       left = 21;
  284.       top = 14;
  285.       width = 11;
  286.       dataLink = parent.employee1.rowset.fields["Phone"];
  287.    }
  288.  
  289.  
  290.    with (this.locationHTML = new HTML(this)){
  291.       height = 1;
  292.       left = 49;
  293.       top = 14;
  294.       width = 9;
  295.       color = "black";
  296.       text = "Location";
  297.    }
  298.  
  299.  
  300.    with (this.locationText = new Text(this)){
  301.       left = 59;
  302.       top = 14;
  303.       width = 9;
  304.       dataLink = parent.employee1.rowset.fields["Location"];
  305.    }
  306.  
  307.  
  308.    with (this.homepageHTML = new HTML(this)){
  309.       height = 1;
  310.       left = 1;
  311.       top = 15;
  312.       width = 17.1667;
  313.       color = "black";
  314.       text = "Homepage URL";
  315.    }
  316.  
  317.  
  318.    with (this.homepageText = new Text(this)){
  319.       left = 21;
  320.       top = 15;
  321.       width = 59;
  322.       dataLink = parent.employee1.rowset.fields["Homepage"];
  323.    }
  324.  
  325.  
  326.    with (this.noteHTML = new HTML(this)){
  327.       height = 1;
  328.       left = 1;
  329.       top = 16;
  330.       width = 17.1667;
  331.       color = "black";
  332.       text = "Phone Note";
  333.    }
  334.  
  335.  
  336.    with (this.noteText = new Text(this)){
  337.       left = 21;
  338.       top = 16;
  339.       width = 59;
  340.       dataLink = parent.employee1.rowset.fields["Phone Note"];
  341.    }
  342.  
  343.  
  344.    with (this.homeAddressHTML = new HTML(this)){
  345.       height = 1;
  346.       left = 1;
  347.       top = 18;
  348.       width = 17.1667;
  349.       color = "black";
  350.       text = "Home address";
  351.    }
  352.  
  353.  
  354.    with (this.addr1Text = new Text(this)){
  355.       left = 21;
  356.       top = 18;
  357.       width = 41;
  358.       dataLink = parent.employee1.rowset.fields["Home Address1"];
  359.    }
  360.  
  361.  
  362.    with (this.addr2Text = new Text(this)){
  363.       left = 21;
  364.       top = 19;
  365.       width = 41;
  366.       dataLink = parent.employee1.rowset.fields["Home Address2"];
  367.    }
  368.  
  369.  
  370.    with (this.cityText = new Text(this)){
  371.       left = 21;
  372.       top = 20;
  373.       width = 20;
  374.       dataLink = parent.employee1.rowset.fields["Home City"];
  375.    }
  376.  
  377.  
  378.    with (this.stateText = new Text(this)){
  379.       left = 43;
  380.       top = 20;
  381.       width = 5;
  382.       dataLink = parent.employee1.rowset.fields["Home State"];
  383.    }
  384.  
  385.  
  386.    with (this.zipText = new Text(this)){
  387.       left = 49;
  388.       top = 20;
  389.       width = 9;
  390.       dataLink = parent.employee1.rowset.fields["Home Zip"];
  391.    }
  392.  
  393.  
  394.    with (this.homePhoneHTML = new HTML(this)){
  395.       height = 1;
  396.       left = 1;
  397.       top = 21;
  398.       width = 17.1667;
  399.       color = "black";
  400.       text = "Home phone";
  401.    }
  402.  
  403.  
  404.    with (this.homePhoneText = new Text(this)){
  405.       left = 21;
  406.       top = 21;
  407.       width = 18;
  408.       dataLink = parent.employee1.rowset.fields["Home Phone"];
  409.    }
  410.  
  411.  
  412.    with (this.contactNameHTML = new HTML(this)){
  413.       height = 1;
  414.       left = 1;
  415.       top = 23;
  416.       width = 17.1667;
  417.       color = "black";
  418.       text = "Contact Name";
  419.    }
  420.  
  421.  
  422.    with (this.contactText = new Text(this)){
  423.       left = 21;
  424.       top = 23;
  425.       width = 33;
  426.       dataLink = parent.employee1.rowset.fields["Contact"];
  427.    }
  428.  
  429.  
  430.    with (this.contactPhoneHTML = new HTML(this)){
  431.       height = 1;
  432.       left = 1;
  433.       top = 24;
  434.       width = 17.1667;
  435.       color = "black";
  436.       text = "Contact Phone";
  437.    }
  438.  
  439.  
  440.    with (this.contactPhoneText = new Text(this)){
  441.       left = 21;
  442.       top = 24;
  443.       width = 18;
  444.       dataLink = parent.employee1.rowset.fields["Contact Phone"];
  445.    }
  446.  
  447.  
  448.    with (this.saveButton = new Button(this)){
  449.       visible = false;
  450.       left = 21;
  451.       top = 6.4706;
  452.       width = 21;
  453.       text = "Save Updates";
  454.       onServerClick = class::saveButton_onServerClick;
  455.    }
  456.  
  457.  
  458.    with (this.errorHTML = new HTML(this)){
  459.       height = 3;
  460.       left = 1;
  461.       top = 7;
  462.       width = 79;
  463.       color = "black";
  464.       text = "error";
  465.       pageno = 2;
  466.    }
  467.  
  468.  
  469.    with (this.deptSelect = new FieldSelect(this)){
  470.       left = 21;
  471.       top = 11;
  472.       width = 37;
  473.       options = "array {'departmt','department'}";
  474.    }
  475.  
  476.  
  477.    with (this.deptButton = new Button(this)){
  478.       left = 59;
  479.       top = 11;
  480.       width = 21;
  481.       text = "Update Departments";
  482.       onServerClick = class::deptButton_onServerClick;
  483.    }
  484.  
  485.  
  486.    with (this.LinksHTML = new HTML(this)){
  487.       height = 1;
  488.       left = 1;
  489.       top = 26;
  490.       width = 78;
  491.       color = "black";
  492.       text = {||'<A HREF="/ibapps/index.htm">[Home]</A> <A HREF="/svr/intrasrv.isv?apps/phone/phoneemp.jrp">[List]</A> <A HREF="/svr/intrasrv.isv?apps/phone/phonedep.jrp">[Department]</A>'};
  493.    }
  494.  
  495.    with (this.GeneratedHTML1 = new GeneratedHTML(this)){
  496.       height = 1;
  497.       left = 1;
  498.       top = 29;
  499.       width = 79;
  500.       pageno = 0;
  501.    }
  502.  
  503.    this.rowset = this.employee1.rowset;
  504.  
  505.    function Form_onServerLoad()
  506.    {
  507.       var form = this;
  508.       // check for error conditions
  509.       var error = new Exception();
  510.       error.code = 0;
  511.       try {
  512.          // move to the requested record
  513.          if (form.argv.length == 1) {
  514.             if (!form.rowset.applyLocate('"Employee ID"=' + form.argv[0])){
  515.                error.message = "Invalid Employee ID - " + form.argv[0];
  516.                throw error;
  517.             }
  518.          }
  519.          if (form.security.hasAccessTo("Phone Update")) {
  520.             form.navImage.visible = true;
  521.             form.editImage.visible = true;
  522.             form.deptButton.visible = true;
  523.             form.saveButton.visible = false;
  524.             form.securityIDText.visible = true;
  525.             form.securityIDHTML.visible = false;
  526.          }
  527.          else {
  528.             var name = form.security.getUserName();
  529.             if (form.rowset.applyLocate('"Security ID"=name')){
  530.                form.navImage.visible = false;
  531.                form.editImage.visible = false;
  532.                form.deptButton.visible = false;
  533.                form.saveButton.visible = true;
  534.                form.securityIDText.visible = false;
  535.                form.securityIDHTML.visible = true;
  536.             }
  537.             else {
  538.                error.message = "Insufficient rights to update data";
  539.                throw error;
  540.             }
  541.          }
  542.       }
  543.       catch (Exception e) {
  544.          form.errorHTML.text = "Error loading update form: " + e.message +
  545.                                " (" + e.code + ")"
  546.          form.pageno = 2;
  547.       }
  548.       //
  549.       // set the field events for the department field
  550.       //
  551.       // This allows the Select control to show values from the lookup table
  552.       //
  553.       this.employee1.rowset.fields["Department"].canChange = 
  554.          {| d |; var dept = this.parent.parent.parent.parent.department1 ;dept.rowset.applyLocate('Department = d') ;this.value = dept.rowset.fields["Department ID"].value; return false}
  555.       this.employee1.rowset.fields["Department"].beforeGetValue = 
  556.          {; var dept = this.parent.parent.parent.parent.department1 ;dept.rowset.applyLocate('"Department ID" = ' + (this.value==null?0:this.value)) ;return (dept.rowset.endOfSet?"":dept.rowset.fields["Department"].value)};
  557.       this.deptSelect.dataLink = this.employee1.rowset.fields["Department"];
  558.       this.deptSelect.value = this.employee1.rowset.fields["Department"].value;
  559.    }
  560.  
  561.    function Form_preRender(notForm, formRef)
  562.    {
  563.       var form = (notForm ? formRef : this);
  564.       if (form.pageno == 1 && !form.rowset.endOfSet) {
  565.          // determine if the update profile button should be enabled
  566.          form.profileButton.visible = (form.security.getUserName() == form.rowset.fields["Security ID"].value);
  567.          form.employeeIDHTML.text = form.employeeIDHTML.text;
  568.          form.securityIDHTML.text = form.securityIDHTML.text;
  569.       }
  570.    }
  571.  
  572.    function navImage_onImageServerClick(nLeft, nTop) {
  573.       if (nLeft >= 26*0 && nLeft < 26*1)
  574.          form.rowset.first();
  575.       else if (nLeft >= 26*1 && nLeft < 26*2) {
  576.          if (!form.rowset.next(-1)) 
  577.             form.rowset.next();
  578.       }
  579.       else if (nLeft >= 26*2 && nLeft < 26*3) {
  580.          if (!form.rowset.next()) 
  581.             form.rowset.next(-1);
  582.       }
  583.       else
  584.          form.rowset.last();
  585.       // re-render the form
  586.       this.form.Form_preRender(true, this.form);
  587.    }
  588.  
  589.    function editImage_onImageServerClick(nLeft, nTop) {
  590.       if (nLeft >= 26*0 && nLeft < 26*1)
  591.          form.rowset.beginAppend();
  592.       else if (nLeft >= 26*1 && nLeft < 26*2)
  593.          form.rowset.delete();
  594.       else if (nLeft >= 26*2 && nLeft < 26*3)
  595.          form.rowset.save();
  596.       else if (nLeft >= 26*3 && nLeft < 26*4)
  597.          form.rowset.abandon();
  598.       else if (nLeft >= 26*4 && nLeft < 26*5)
  599.          form.rowset.beginEdit();
  600.       else if (nLeft >= 26*5 && nLeft < 26*6) {
  601.          with(this) {
  602.             if (form.rowset.state==STATE_LOCATE) {
  603.                text="New Query";
  604.                form.rowset.applyLocate();
  605.             } 
  606.             else {
  607.                text="Run Query";
  608.                form.rowset.beginLocate();
  609.             }
  610.          }
  611.       }
  612.       else {
  613.          with(this) {
  614.             if (form.rowset.state==STATE_FILTER) {
  615.                text="New Filter";
  616.                form.rowset.applyFilter();
  617.             } 
  618.             else {
  619.                text="Run Filter";
  620.                form.rowset.beginFilter();
  621.             }
  622.          }
  623.       }
  624.       // re-render the form
  625.       this.form.Form_preRender(true, this.form);
  626.    }
  627.  
  628.    function saveButton_onServerClick()
  629.    {
  630.       this.form.rowset.save();
  631.       this.form.Form_preRender(true, this.form);
  632.    }
  633.  
  634.    function profileButton_onServerClick()
  635.    {
  636.       _sys.scripts.load("empprof.jfm");
  637.       var f = new empprofForm();
  638.       f.security = this.form.security;
  639.       f.callingForm = this.form;
  640.       f.changeForm  = "empchang.jfm";
  641.       f.changeFormClass = "empchangForm";
  642.       f.open();
  643.    }
  644.  
  645.    function deptButton_onServerClick()
  646.    {
  647.       _sys.forms.run("departmt.jfm");
  648.    }
  649.  
  650. }
  651.