home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************\
- * *
- * Update.jfm -- Employee Phone Book Update Form *
- * *
- * Update.jfm is part of the Phone Book solution application. It is used *
- * to modify the employee table. It can also be used to add and delete *
- * employee records. *
- * *
- * Dependencies: phonbk31.gif *
- * apps\shared\controls.cc *
- * *
- * Links to: ibapps/index.htm *
- * svr/intrasrv.isv?apps/phone/phonedep.jrp *
- * svr/intrasrv.isv?apps/phone/phoneemp.jrp *
- * svr/intrasrv.isv?apps/phone/update.jfm *
- * *
- * Updated 8/27/96 by IntraBuilder Samples Group *
- * $Revision: 1.22 $ *
- * *
- * Copyright (c) 1996, Borland International, Inc. All rights reserved. *
- * *
- \****************************************************************************/
- #include "intra.h"
- #include "security.h"
- //
- // This header code is executed when the form is run. The return
- // prevents the designer generated startup code from executing.
- //
- // 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 updateForm();
- f.argv = UPDATE.arguments;
- // 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("emplogin.jfm");
- var login = new emploginForm();
- // 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/1996
- //
- var f = new updateForm();
- f.open();
- class updateForm extends Form {
- _sys.scripts.load(_sys.env.home() + "APPS\\SHARED\\CONTROLS.CC")
- with (this) {
- color = "4a95b5";
- height = 28.4118;
- left = 1.3333;
- top = 0.1765;
- width = 85.1667;
- title = "Update Employee";
- preRender = class::Form_preRender;
- onServerLoad = class::Form_onServerLoad;
- }
-
-
- with (this.ibapps1 = new Database()){
- left = 21;
- top = 3;
- databaseName = "IBAPPS";
- active = true;
- }
-
-
- with (this.employee1 = new Query()){
- left = 27;
- top = 3;
- database = parent.ibapps1;
- sql = "SELECT * FROM employee";
- active = true;
- }
-
-
- with (this.employee1.rowset) {
-
- }
-
-
- with (this.department1 = new Query()){
- left = 33;
- top = 3;
- database = parent.ibapps1;
- sql = "select * from departmt";
- active = true;
- }
-
-
- with (this.department1.rowset) {
-
- }
-
-
- with (this.rule1 = new Rule(this)){
- left = 1;
- top = 6;
- size = 2;
- right = 80;
- pageno = 0;
- }
-
-
- with (this.rule2 = new Rule(this)){
- left = 1;
- top = 28;
- size = 2;
- right = 80;
- pageno = 0;
- }
-
-
- with (this.PhoneBookLogo = new Image(this)){
- height = 4.8235;
- left = 1;
- top = 0.2353;
- width = 13.6667;
- dataSource = "filename PHONBK31.GIF";
- alignment = 4;
- pageno = 0;
- }
-
-
- with (this.HeadingHTML = new HTML(this)){
- height = 2;
- left = 21;
- top = 0.2353;
- width = 59;
- color = "853a1a";
- text = "<H1>Update Employee Data</H1>";
- pageno = 0;
- }
-
-
- with (this.navImage = new Image(this)){
- visible = false;
- height = 1.3529;
- left = 1;
- top = 6.4706;
- width = 17.3333;
- dataSource = "filename EXPINAVH.GIF";
- alignment = 4;
- onImageServerClick = class::navImage_onImageServerClick;
- }
-
-
- with (this.editImage = new Image(this)){
- visible = false;
- height = 1.3529;
- left = 21;
- top = 6.4706;
- width = 29;
- dataSource = "filename EXPIROWH.GIF";
- alignment = 4;
- onImageServerClick = class::editImage_onImageServerClick;
- }
-
-
- with (this.profileButton = new Button(this)){
- visible = false;
- left = 59;
- top = 6.4706;
- width = 21;
- text = "Security Profile";
- onServerClick = class::profileButton_onServerClick;
- }
-
-
- with (this.nameHTML = new HTML(this)){
- height = 1;
- left = 1;
- top = 8.4706;
- width = 17.1667;
- color = "black";
- text = "Full Name";
- }
-
-
- with (this.nameText = new Text(this)){
- left = 21;
- top = 8.4706;
- width = 37;
- dataLink = parent.employee1.rowset.fields["Full Name"];
- }
-
-
- with (this.empidHTML = new HTML(this)){
- height = 1;
- left = 1;
- top = 9.4706;
- width = 17.1667;
- color = "black";
- text = "Employee ID";
- }
-
-
- with (this.employeeIDHTML = new HTML(this)){
- height = 1;
- left = 21;
- top = 9.4706;
- width = 19;
- color = "black";
- 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))};
- }
-
-
- with (this.secIDHTML = new HTML(this)){
- height = 1;
- left = 48;
- top = 9.4706;
- width = 10;
- color = "black";
- text = "Security ID";
- }
-
-
- with (this.securityIDText = new Text(this)){
- left = 59;
- top = 9.4706;
- width = 21;
- dataLink = parent.employee1.rowset.fields["Security ID"];
- }
-
-
- with (this.securityIDHTML = new HTML(this)){
- height = 1;
- left = 59;
- top = 9.4706;
- width = 21;
- color = "black";
- text = {||this.parent.employee1.rowset.fields["Security ID"].value};
- }
-
-
- with (this.deptHTML = new HTML(this)){
- height = 1;
- left = 1;
- top = 11;
- width = 17.1667;
- color = "black";
- text = "Department";
- }
-
-
- with (this.titleHTML = new HTML(this)){
- height = 1;
- left = 1;
- top = 12.4706;
- width = 17.1667;
- color = "black";
- text = "Title";
- }
-
-
- with (this.titleText = new Text(this)){
- left = 21;
- top = 12.4706;
- width = 37;
- dataLink = parent.employee1.rowset.fields["Title"];
- }
-
-
- with (this.phoneHTML = new HTML(this)){
- height = 1;
- left = 1;
- top = 14;
- width = 17.1667;
- color = "black";
- text = "Phone";
- }
-
-
- with (this.phoneText = new Text(this)){
- left = 21;
- top = 14;
- width = 11;
- dataLink = parent.employee1.rowset.fields["Phone"];
- }
-
-
- with (this.locationHTML = new HTML(this)){
- height = 1;
- left = 49;
- top = 14;
- width = 9;
- color = "black";
- text = "Location";
- }
-
-
- with (this.locationText = new Text(this)){
- left = 59;
- top = 14;
- width = 9;
- dataLink = parent.employee1.rowset.fields["Location"];
- }
-
-
- with (this.homepageHTML = new HTML(this)){
- height = 1;
- left = 1;
- top = 15;
- width = 17.1667;
- color = "black";
- text = "Homepage URL";
- }
-
-
- with (this.homepageText = new Text(this)){
- left = 21;
- top = 15;
- width = 59;
- dataLink = parent.employee1.rowset.fields["Homepage"];
- }
-
-
- with (this.noteHTML = new HTML(this)){
- height = 1;
- left = 1;
- top = 16;
- width = 17.1667;
- color = "black";
- text = "Phone Note";
- }
-
-
- with (this.noteText = new Text(this)){
- left = 21;
- top = 16;
- width = 59;
- dataLink = parent.employee1.rowset.fields["Phone Note"];
- }
-
-
- with (this.homeAddressHTML = new HTML(this)){
- height = 1;
- left = 1;
- top = 18;
- width = 17.1667;
- color = "black";
- text = "Home address";
- }
-
-
- with (this.addr1Text = new Text(this)){
- left = 21;
- top = 18;
- width = 41;
- dataLink = parent.employee1.rowset.fields["Home Address1"];
- }
-
-
- with (this.addr2Text = new Text(this)){
- left = 21;
- top = 19;
- width = 41;
- dataLink = parent.employee1.rowset.fields["Home Address2"];
- }
-
-
- with (this.cityText = new Text(this)){
- left = 21;
- top = 20;
- width = 20;
- dataLink = parent.employee1.rowset.fields["Home City"];
- }
-
-
- with (this.stateText = new Text(this)){
- left = 43;
- top = 20;
- width = 5;
- dataLink = parent.employee1.rowset.fields["Home State"];
- }
-
-
- with (this.zipText = new Text(this)){
- left = 49;
- top = 20;
- width = 9;
- dataLink = parent.employee1.rowset.fields["Home Zip"];
- }
-
-
- with (this.homePhoneHTML = new HTML(this)){
- height = 1;
- left = 1;
- top = 21;
- width = 17.1667;
- color = "black";
- text = "Home phone";
- }
-
-
- with (this.homePhoneText = new Text(this)){
- left = 21;
- top = 21;
- width = 18;
- dataLink = parent.employee1.rowset.fields["Home Phone"];
- }
-
-
- with (this.contactNameHTML = new HTML(this)){
- height = 1;
- left = 1;
- top = 23;
- width = 17.1667;
- color = "black";
- text = "Contact Name";
- }
-
-
- with (this.contactText = new Text(this)){
- left = 21;
- top = 23;
- width = 33;
- dataLink = parent.employee1.rowset.fields["Contact"];
- }
-
-
- with (this.contactPhoneHTML = new HTML(this)){
- height = 1;
- left = 1;
- top = 24;
- width = 17.1667;
- color = "black";
- text = "Contact Phone";
- }
-
-
- with (this.contactPhoneText = new Text(this)){
- left = 21;
- top = 24;
- width = 18;
- dataLink = parent.employee1.rowset.fields["Contact Phone"];
- }
-
-
- with (this.saveButton = new Button(this)){
- visible = false;
- left = 21;
- top = 6.4706;
- width = 21;
- text = "Save Updates";
- onServerClick = class::saveButton_onServerClick;
- }
-
-
- with (this.errorHTML = new HTML(this)){
- height = 3;
- left = 1;
- top = 7;
- width = 79;
- color = "black";
- text = "error";
- pageno = 2;
- }
-
-
- with (this.deptSelect = new FieldSelect(this)){
- left = 21;
- top = 11;
- width = 37;
- options = "array {'departmt','department'}";
- }
-
-
- with (this.deptButton = new Button(this)){
- left = 59;
- top = 11;
- width = 21;
- text = "Update Departments";
- onServerClick = class::deptButton_onServerClick;
- }
-
-
- with (this.LinksHTML = new HTML(this)){
- height = 1;
- left = 1;
- top = 26;
- width = 78;
- color = "black";
- 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>'};
- }
-
- with (this.GeneratedHTML1 = new GeneratedHTML(this)){
- height = 1;
- left = 1;
- top = 29;
- width = 79;
- pageno = 0;
- }
-
- this.rowset = this.employee1.rowset;
-
- function Form_onServerLoad()
- {
- var form = this;
- // check for error conditions
- var error = new Exception();
- error.code = 0;
- try {
- // move to the requested record
- if (form.argv.length == 1) {
- if (!form.rowset.applyLocate('"Employee ID"=' + form.argv[0])){
- error.message = "Invalid Employee ID - " + form.argv[0];
- throw error;
- }
- }
- if (form.security.hasAccessTo("Phone Update")) {
- form.navImage.visible = true;
- form.editImage.visible = true;
- form.deptButton.visible = true;
- form.saveButton.visible = false;
- form.securityIDText.visible = true;
- form.securityIDHTML.visible = false;
- }
- else {
- var name = form.security.getUserName();
- if (form.rowset.applyLocate('"Security ID"=name')){
- form.navImage.visible = false;
- form.editImage.visible = false;
- form.deptButton.visible = false;
- form.saveButton.visible = true;
- form.securityIDText.visible = false;
- form.securityIDHTML.visible = true;
- }
- else {
- error.message = "Insufficient rights to update data";
- throw error;
- }
- }
- }
- catch (Exception e) {
- form.errorHTML.text = "Error loading update form: " + e.message +
- " (" + e.code + ")"
- form.pageno = 2;
- }
- //
- // set the field events for the department field
- //
- // This allows the Select control to show values from the lookup table
- //
- this.employee1.rowset.fields["Department"].canChange =
- {| d |; var dept = this.parent.parent.parent.parent.department1 ;dept.rowset.applyLocate('Department = d') ;this.value = dept.rowset.fields["Department ID"].value; return false}
- this.employee1.rowset.fields["Department"].beforeGetValue =
- {; 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)};
- this.deptSelect.dataLink = this.employee1.rowset.fields["Department"];
- this.deptSelect.value = this.employee1.rowset.fields["Department"].value;
- }
-
- function Form_preRender(notForm, formRef)
- {
- var form = (notForm ? formRef : this);
- if (form.pageno == 1 && !form.rowset.endOfSet) {
- // determine if the update profile button should be enabled
- form.profileButton.visible = (form.security.getUserName() == form.rowset.fields["Security ID"].value);
- form.employeeIDHTML.text = form.employeeIDHTML.text;
- form.securityIDHTML.text = form.securityIDHTML.text;
- }
- }
-
- function navImage_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();
- // re-render the form
- this.form.Form_preRender(true, this.form);
- }
-
- function editImage_onImageServerClick(nLeft, nTop) {
- if (nLeft >= 26*0 && nLeft < 26*1)
- form.rowset.beginAppend();
- else if (nLeft >= 26*1 && nLeft < 26*2)
- form.rowset.delete();
- else if (nLeft >= 26*2 && nLeft < 26*3)
- form.rowset.save();
- else if (nLeft >= 26*3 && nLeft < 26*4)
- form.rowset.abandon();
- 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) {
- text="New Query";
- form.rowset.applyLocate();
- }
- else {
- text="Run Query";
- form.rowset.beginLocate();
- }
- }
- }
- else {
- with(this) {
- if (form.rowset.state==STATE_FILTER) {
- text="New Filter";
- form.rowset.applyFilter();
- }
- else {
- text="Run Filter";
- form.rowset.beginFilter();
- }
- }
- }
- // re-render the form
- this.form.Form_preRender(true, this.form);
- }
-
- function saveButton_onServerClick()
- {
- this.form.rowset.save();
- this.form.Form_preRender(true, this.form);
- }
-
- function profileButton_onServerClick()
- {
- _sys.scripts.load("empprof.jfm");
- var f = new empprofForm();
- f.security = this.form.security;
- f.callingForm = this.form;
- f.changeForm = "empchang.jfm";
- f.changeFormClass = "empchangForm";
- f.open();
- }
-
- function deptButton_onServerClick()
- {
- _sys.forms.run("departmt.jfm");
- }
-
- }
-