Customer Update - democupd.bbx
This program is launched from the Customer Maintenance form. It reads the CGI input stream for form values and adds or updates the customer record accordingly.
|
For a new customer entry, the CGI value "cust_id" contains blanks, and the program jumps to the new customer entry label. An existing customer, selected from the customer list, will have a hidden value on the form that contains the ID, and the current record is read into CUST$.
|
On an existing record, the contents of the form are updated into the contents of the CUST$ record using the utfrmin.wbb program. The record is then updated, and the program continues.
Concurrency issues are not addressed in the sample programs because the task that loaded the maintenance form cannot retain a lock on the record. There are several methods for managing records that cannot be locked during maintenance. One method is to store a CRC value as a hidden field on the form, calculated from the record used to generate the form. When the current record is loaded in the update program, the CRC values can be compared to determine if a change was made to the record after the form was displayed, and appropriate action can be taken.
|
When the customer is updated or added, a message is stored in MSG$, indicating success. The customer entry program is run, which builds a new form for the customer, showing their changes, and also displays the MSG$ value so the user can see that the last update was successful.
|
When the CGI value "cust_id" does not contain a valid customer number, a new customer is added. The CUST$ data template is filled in from the form CGI data by calling utfrmin.wbb. The customer ID is generated by adding 1 to the last key in the file and formatting a new 5-digit key. Once successful, the program continues.
|
Although a normal exit from this program runs utcent.bbx, the error routine may need to exit this way.
|