Delete companies: Delete Record Wizard

The last page in the company folder will allow you to delete companies from the database. To implement the actual delete operation, the Delete Record Transaction  will be used. It is similar to the Insert/Update wizards and it also uses the user interface persistence to fill in its fields. At the same time, it is different from the Insert and Update wizards as it does not add any HTML elements into the page.

To create the company delete page, follow the next steps:

Create the page design

Unlike for the other pages, the delete page's design section will help you set up a safety net for the delete operation. More exactly, you will create a page section which will display details of the company to delete, and ask for confirmation. This way, you will not be able to delete a record accidentally, simply by clicking on the delete link in the main page.

To create the page design, follow the next steps:

  1. First off, add a table to the page. Set it to have 4 rows and 2 columns. Make its width 500 px and set the border, cell spacing and cell padding to 0.
  2. Merge the first row's cells. Type the delete question in the new cell: "Are you sure you want to delete this company?" (without the quotes).
  3. On the second and third row you will display the company details: its name and address. But in order to retrieve these details, you must first create a filtered recordset . This recordset will use the company_com table, filtered after the id_com URL parameter. The recordset creation dialog box should look like the following:


                  
  4. Now type in the first cell of the second row "Company name:"; drag and drop the field name_com from the Bindings tab into the second cell of the second row.
  5. In the third row's first cell type "Company address:", and then drag and drop the field address_com from the Bindings tab into the row's second cell.
  6. At this point, you are displaying all company details in the delete page. The last action concerning the delete page design is to add the buttons that will continue or stop the delete transaction. To add them, follow the instructions given below.
  7. Merge the cells on the last row. Also add a form submit button. When adding the button from the Forms tab of the Insert panel, a form will be added as well. If a message requesting confirmation to add the form tag appears, click Yes.
  8. As this will be the confirmation button, you have to change its Name to KT_Submit and the Label to Yes. Note down the exact name you've given the button as it will be needed as the starting condition for the delete transaction.
  9. Add another button at the right. Change its display value to No. Leave the button name to its default state, as you will apply a simple Dreamweaver behavior, which opens another URL on click. This change will be done later in the tutorial.

  10. Select the form around the buttons, and using the Property inspector make sure that the text box corresponding to its Action is blank.
 

Now, the page design should display the company details and the Yes/No buttons:

 

Let's first make the No button redirect the page to the main index page. Select the No button.

For Dreamweaver MX 2004 users - open the Tag Inspector Panel, the Behaviors tab, and select Go To URL.

 

For Dreamweaver MX 6.1 users - open the Design panel, the Behaviors tab, and select Go To URL.

 

Select the index page.

Next, you'll have to apply the Delete Record Wizard. You can find its button on the MX Kollection tab of the Insert panel (in the upper left side of the Dreamweaver window, below the menu). After the dialog box opens, you'll notice that most of the fields are already correctly completed: Connection, Delete from table, Primary key column and Primary key equals. If left like this, the delete operation would occur immediately when the page loads, making our safety net completely useless. There is however one dialog box option that lets you define a start condition: the First check variable field.

To start the delete action only after pressing the Yes button, select in the First check variable drop-down menu the Form Variable option. Type in the corresponding text field the exact name of the Yes button, as defined earlier (at step 8 of this section of the tutorial) - KT_Submit.

 

Since all other fields are already set up, click the OK button to add the server behavior to the page. If you simply preview the page in the browser, you will only see the empty placeholders for the dynamic data. This happens because the page is expecting a value for the id_com URL parameter. Please click the Delete link from the index page.

This is the last page to be created in the company folder. Through the existing pages, all needed operations on companies are covered: adding, editing and deleting are all implemented. It is time to move on to the second section of the site: the contacts.