System Administration

Add/Modify Interest Group

/*====================================================================== The get_db_intgrp_rec function retrieves a single interest group from the database. This is a method of the interest group object. Once the interest group object has been created and an initial value for interestgroupid place in it, this method is called to complete the population of the objects attribute values. ======================================================================= */ function get_db_intgrp_rec() { intgrp_info = database.cursor('SELECT interestgroupid, interestgroup, description FROM interestgroup WHERE interestgroupid = '+this.interestgroupid); if(intgrp_info.next()) {this.interestgroupid = intgrp_info.interestgroupid; this.interestgroup = ""+intgrp_info.interestgroup+""; this.description = ""+intgrp_info.description+""; intgrp_info.close(); result = true; } else {write('

Record Not Found!

Another administrator has deleted this record!'); result = false; } return result; } /*====================================================================== The get_db_intgrp_rec2 function retrieves a single interest group from the database. This is a method of the interest group object. If a new interest group record is created by the user, the application has no way of getting the interestgroup id generated by the database. This method attempts to retrieve the record, (including the interest group id) from the database by matching other criteria that it has about the record. ====================================================================== */ function get_db_intgrp_rec2() { intgrp_info = database.cursor('SELECT interestgroupid, interestgroup, description FROM interestgroup WHERE interestgroup = "'+this.interestgroup+'"'); if(intgrp_info.next()) {this.interestgroupid = intgrp_info.interestgroupid; this.interestgroup = ""+intgrp_info.interestgroup+""; this.description = ""+intgrp_info.description+""; intgrp_info.close(); result = true; } else {write('

Record Not Found!

Another administrator has deleted this record!'); result = false; } return result; } /*====================================================================== The ins_db_intgrp_rec function inserts a single interest group into the database. This is a method of the interest group object. ====================================================================== */ function ins_db_intgrp_rec() //Inserts an interest group into the database { this.description = check_size(this.description, 255); this.interestgroup = check_text_entry(this.interestgroup); this.description = check_text_entry(this.description); result = database.execute('INSERT INTO interestgroup (interestgroupid, interestgroup, description ) VALUES ('+this.interestgroupid+',"' + this.interestgroup +'","'+this.description +'")' ); if (result != 0) {write('
A Database error has occurred ' + result + '
'); write('
' + database.majorErrorCode() + '
'); write('
' + database.majorErrorMessage() + '
'); request.mode="add"}; else {write('

The following Interest Group has been added.

');} } /*====================================================================== The del_db_intgrp_rec function deletes a single interest group from the database. This is a method of the interest group object. ====================================================================== */ function del_db_intgrp_rec() //Deletes an interest group from a database { get_count = database.cursor('SELECT * FROM user WHERE interestgroupid='+this.interestgroupid); if (!get_count.next()) { get_count.close(); result = database.execute('DELETE FROM interestgroup WHERE interestgroupid='+this.interestgroupid); if (result != 0) {write('
A Database error has occurred ' + result + '
'); write('
' + database.majorErrorCode() + '
'); write('
' + database.majorErrorMessage() + '
'); request.mode="D"}; else {write('Interest Group: '+this.interestgroup+' deleted.'); } } else {get_count.close(); write('

Unable to D Interest Group: '+this.interestgroup+'

'); write('There are user accounts still linked to this interest group!'); } } /*====================================================================== The upd_db_intgrp_rec function updates a single interest group in the database. This is a method of the interest group object. ====================================================================== */ function upd_db_intgrp_rec() //Updates an interest group in the database { this.description = check_size(this.description, 255); this.interestgroup = check_text_entry(this.interestgroup); this.description = check_text_entry(this.description); result = database.execute('UPDATE interestgroup SET interestgroup="'+ this.interestgroup +'", description="'+ this.description +'" WHERE interestgroupid='+this.interestgroupid); if (result != 0) {write('
A Database error has occurred ' + result + '
'); write('
' + database.majorErrorCode() + '
'); write('
' + database.majorErrorMessage() + '
'); request.mode="add"}; else {write('

The following Interest Group has been updated.

');} } //Interest Group Object function intgrp_rec(interestgroupid, interestgroup, description) { this.interestgroupid = interestgroupid; this.interestgroup = interestgroup; this.description = description; this.ins_db_intgrp_rec = ins_db_intgrp_rec; this.upd_db_intgrp_rec = upd_db_intgrp_rec; this.get_db_intgrp_rec = get_db_intgrp_rec; this.get_db_intgrp_rec2 = get_db_intgrp_rec2; this.del_db_intgrp_rec = del_db_intgrp_rec; } /*====================================================================== The load_Int_Grp_Tbl function creates the interest group object and loads it with initial values. The appropriate method is then executed against the current object based on the mode the form is in. The form basically has two main categories of modes: user and database. User modes are add, D (delete), M (modify). Database modes are insert, dump, and update. Once the initial method has been called on the object, the specifics of the page formatting are determined based on field, user access, and mode. ====================================================================== */ function load_Int_Grp_Tbl() { if (request.mode == "insert") { temp_intgrp = new intgrp_rec(request.interestgroupid, request.interestgroup, request.description); temp_intgrp.ins_db_intgrp_rec(); result = temp_intgrp.get_db_intgrp_rec2(); } if (request.mode == "add") { temp_intgrp = new intgrp_rec(0,"",""); result = true; } if (request.mode == "dump") { temp_intgrp = new intgrp_rec(request.interestgroupid, request.interestgroup,""); temp_intgrp.del_db_intgrp_rec(); } if ((request.mode == "M") || (request.mode == "D")) { temp_intgrp = new intgrp_rec(request.interestgroupid,"",""); result = temp_intgrp.get_db_intgrp_rec(); } if (request.mode == "update") { temp_intgrp = new intgrp_rec(request.interestgroupid, request.interestgroup, request.description); temp_intgrp.upd_db_intgrp_rec(); result = temp_intgrp.get_db_intgrp_rec(); } if ((request.mode != "dump") && (result)) { write(''); write(''); displayRow("Interest Group","RIGHT","TEXT","interestgroup",temp_intgrp.interestgroup, client.accesslevel, 40, 30, "A"); write(''); write(''); write(''); write('
Description'); if ((request.mode == "add") || (request.mode == "M")) { write(''); } else {write(''); write(temp_intgrp.description); } write('
'); result = true; } else { result = false; } return result; } write('
'); result = load_Int_Grp_Tbl(); if (result) { write('

'); if (request.mode == "add") { } if (request.mode == "M") { } if (request.mode == "D") { write(''); } if ((request.mode == "dump") || (request.mode == "insert") || (request.mode == "update")) { write(''); } write('

'); write('
'); } else {write('');}