home *** CD-ROM | disk | FTP | other *** search
Wrap
/****************************************************************************\ * * * 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 * * apps\shared\string.js * * * * 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 11/12/96 by IntraBuilder Samples Group * * $Revision: 1.32 $ * * * * 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. _sys.scripts.load(_sys.env.home() + "APPS\\SHARED\\STRING.JS") 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 11/12/96 // var f = new updateForm(); f.open(); class updateForm extends Form { _sys.scripts.load(_sys.env.home() + "APPS\\SHARED\\CONTROLS.CC") with (this) { preRender = class::Form_preRender; onServerLoad = class::Form_onServerLoad; color = "cae4ff"; height = 14.6667; left = 0; top = 0; width = 76; title = "Update Employee"; } with (this.ibapps1 = new Database()){ left = 66; top = 5; databaseName = "IBAPPS"; active = true; } with (this.department1 = new Query()){ left = 66; top = 7; database = parent.ibapps1; sql = "select * from departmt"; active = true; with (rowset) { } } with (this.employee1 = new Query()){ left = 66; top = 6; database = parent.ibapps1; sql = "SELECT * FROM employee"; active = true; with (rowset) { } } with (this.rule1 = new Rule(this)){ top = 4; size = 2; right = 70; pageno = 0; } with (this.rule2 = new Rule(this)){ top = 22.5; size = 2; right = 70; pageno = 0; } with (this.PhoneBookLogo = new Image(this)){ height = 3.4167; width = 10.25; dataSource = "filename PHONBK31.GIF"; alignment = 4; pageno = 0; } with (this.HeadingHTML = new HTML(this)){ height = 2; left = 12; width = 58; color = "853a1a"; alignVertical = 1; text = "<H1>Update Employee Data</H1>"; pageno = 0; } with (this.navImage = new Image(this)){ onImageServerClick = class::navImage_onImageServerClick; visible = false; height = 0.9583; left = 12; top = 2; width = 13; dataSource = "filename EXPINAVH.GIF"; alignment = 4; } with (this.editImage = new Image(this)){ onImageServerClick = class::editImage_onImageServerClick; visible = false; height = 0.9583; left = 26; top = 2; width = 22.75; dataSource = "filename EXPIROWH.GIF"; alignment = 4; } with (this.profileButton = new Button(this)){ onServerClick = class::profileButton_onServerClick; visible = false; left = 50; top = 2; width = 18; text = "Security Profile"; } with (this.nameHTML = new HTML(this)){ height = 1; top = 5; width = 16; color = "black"; alignVertical = 1; text = "Full name"; } with (this.nameText = new Text(this)){ left = 16; top = 5; width = 28; dataLink = parent.employee1.rowset.fields["Full Name"]; } with (this.empidHTML = new HTML(this)){ height = 1; top = 6; width = 16; color = "black"; alignVertical = 1; text = "Employee Id"; } with (this.employeeIDHTML = new HTML(this)){ height = 1; left = 16; top = 6; width = 14; color = "black"; alignVertical = 1; text = {||this.parent.rowset.state==5 ? "(locating)" : this.parent.rowset.state==4 ? "(filtering)" : this.parent.rowset.state==3 ? "(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 = 30; top = 6; width = 14; color = "black"; alignVertical = 1; text = "Security id"; } with (this.securityIDText = new Text(this)){ left = 44; top = 6; width = 21; dataLink = parent.employee1.rowset.fields["Security ID"]; } with (this.securityIDHTML = new HTML(this)){ height = 1; left = 44; top = 6; width = 21; color = "black"; alignVertical = 1; text = {||this.parent.employee1.rowset.fields["Security ID"].value}; } with (this.deptHTML = new HTML(this)){ height = 1; top = 7.5; width = 16; color = "black"; alignVertical = 1; text = "Department"; } with (this.titleHTML = new HTML(this)){ height = 1; top = 8.5; width = 16; color = "black"; alignVertical = 1; text = "Title"; } with (this.titleText = new Text(this)){ left = 16; top = 8.5; width = 28; dataLink = parent.employee1.rowset.fields["Title"]; } with (this.phoneHTML = new HTML(this)){ height = 1; top = 10; width = 16; color = "black"; alignVertical = 1; text = "Phone"; } with (this.phoneText = new Text(this)){ left = 16; top = 10; width = 10; dataLink = parent.employee1.rowset.fields["Phone"]; } with (this.locationHTML = new HTML(this)){ height = 1; left = 30; top = 10; width = 10; color = "black"; alignVertical = 1; text = "Location"; } with (this.locationText = new Text(this)){ left = 40; top = 10; width = 9; dataLink = parent.employee1.rowset.fields["Location"]; } with (this.homepageHTML = new HTML(this)){ height = 1; top = 11; width = 16; color = "black"; alignVertical = 1; text = "Web address"; } with (this.homepageText = new Text(this)){ left = 16; top = 11; width = 42; dataLink = parent.employee1.rowset.fields["Homepage"]; } with (this.noteHTML = new HTML(this)){ height = 1; top = 12; width = 16; color = "black"; alignVertical = 1; text = "Phone note"; } with (this.noteText = new Text(this)){ left = 16; top = 12; width = 42; dataLink = parent.employee1.rowset.fields["Phone Note"]; } with (this.homeAddressHTML = new HTML(this)){ height = 1; top = 14; width = 16; color = "black"; alignVertical = 1; text = "Home address"; } with (this.addr1Text = new Text(this)){ left = 16; top = 14; width = 36; dataLink = parent.employee1.rowset.fields["Home Address1"]; } with (this.addr2Text = new Text(this)){ left = 16; top = 15; width = 36; dataLink = parent.employee1.rowset.fields["Home Address2"]; } with (this.cityText = new Text(this)){ left = 16; top = 16; width = 16; dataLink = parent.employee1.rowset.fields["Home City"]; } with (this.stateText = new Text(this)){ left = 36; top = 16; width = 4; dataLink = parent.employee1.rowset.fields["Home State"]; } with (this.zipText = new Text(this)){ left = 44; top = 16; width = 8; dataLink = parent.employee1.rowset.fields["Home Zip"]; } with (this.homePhoneHTML = new HTML(this)){ height = 1; top = 17; width = 16; color = "black"; alignVertical = 1; text = "Home phone"; } with (this.homePhoneText = new Text(this)){ left = 16; top = 17; width = 16; dataLink = parent.employee1.rowset.fields["Home Phone"]; } with (this.contactNameHTML = new HTML(this)){ height = 1; top = 18.5; width = 16; color = "black"; alignVertical = 1; text = "Contact name"; } with (this.contactText = new Text(this)){ left = 16; top = 18.5; width = 24; dataLink = parent.employee1.rowset.fields["Contact"]; } with (this.contactPhoneHTML = new HTML(this)){ height = 1; top = 19.5; width = 16; color = "black"; alignVertical = 1; text = "Contact phone"; } with (this.contactPhoneText = new Text(this)){ left = 16; top = 19.5; width = 16; dataLink = parent.employee1.rowset.fields["Contact Phone"]; } with (this.saveButton = new Button(this)){ onServerClick = class::saveButton_onServerClick; visible = false; left = 12; top = 2; width = 12; text = "Save Updates"; } 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 = 16; top = 7.5; width = 28; options = "array {'departmt','department'}"; } with (this.deptButton = new Button(this)){ onServerClick = class::deptButton_onServerClick; left = 48; top = 7.5; width = 10.125; text = "Update..."; } with (this.LinksHTML = new HTML(this)){ height = 1; top = 21.375; width = 70; color = "black"; text = {||'<A HREF="/ibapps/index.htm">[Home]</A> <A HREF="/svr/intrasrv.isv?apps/phone/phoneemp.jrp">[List by Employee]</A> <A HREF="/svr/intrasrv.isv?apps/phone/phonedep.jrp">[List by Department]</A>'}; pageno = 0; } with (this.GeneratedHTML1 = new GeneratedHTML(this)){ height = 1; top = 23; width = 70; pageno = 0; } this.rowset = this.employee1.rowset; function Form_onServerLoad() { var form = this; form.updateDeptList = false; // 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"=' + "'" + escapeChar(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.rowset.first(); 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 = '" + escapeChar(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; } if (form.updateDeptList) { form.deptSelect.fillOptions(); form.updateDeptList = false; } } 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) { if (!form.rowset.endOfSet) 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() { this.form.updateDeptList = true; _sys.forms.run("departmt.jfm"); } }