ADO.NET Application: Bethesda Car Rental



For a car rental company, the customers are the people or entities who rent cars. In a small application, you can enter the customer's when processing a rental order. A better way is to create a list of customers so that a repeating customer would have his or her records already in the database.

Practical Learning Practical Learning: Introducing the Application

  1. In the Microsoft SQL Server Management Studio, if necessary, expand the Databases, the bcr, and the Tables node.
    To create a new table, right the Tables node under bcr and click New Table...
  2. Set the first column name to CustomerID
  3. Set its Data Type to int
  4. In the lower section, expand Identity Specification and set the (Is Identify) field to Yes
  5. Right-click CustomerID and click Set Primary Key
  6. Complete the table with the following columns
    Column Name Data Type Allow Nulls
    CustomerID int  
    DrvLicNbr varchar(50) Uncheck
    FullName varchar(50) Uncheck
    Address varchar(50)  
    City varchar(50)  
    State varchar(50)  
    ZIPCode varchar(20)  
    Country varchar(50)  
  7. Save the table as Customers and close it
  8. In the Object Explorer, right-click dbo.Customers and click Open Table
  9. Create a few records
  10. In Microsoft Visual Studio, if necessary, open the bcr1 application created in the previous section
  11. In the Data Source window, right-click dsBCR and click Configure DataSet With Wizard...
  12. Expand the Tables node and click the check box of Customers
  13. Click Finish
  14. To create a new form, on the main menu, click Project -> Add Windows Form...
  15. Set the name to Customers and click Add
  16. Drag the Customers node and drop it on the form
  17. While the DataGridView control is still selected on the form, in the Properties window, click the ellipsis of the Columns field and make the following changes:
    Selected Columns HeaderText Width
    CustomerID Customer ID 75
    DrvLicNbr Drv. Lic. #  
    FullName Full Name  
    Address   130
    City   80
    State   50
    ZIPCode ZIP Code 50
    Country   50
  18. Click OK
  19. Set DataGridView's Anchor property to Top, Bottom, Left, Right
  20. Under the DataGridView control, add a button and set its properties as follows:
    Text: Close
    (Name): btnClose
    Anchor: Bottom, Right
  21. Double-click the Close button and implement its even as follows:
    System::Void btnClose_Click(System::Object^  sender,
    			    System::EventArgs^  e)
  22. Access the Central form
  23. Add a button to it and set its properties as follows:
    Text: Customers
    (Name): btnCustomers
  24. Double-click the Customers button
  25. Implement the even as follows:
    private void btnCustomers_Click(object sender, EventArgs e)
        Customers frmCustomers = new Customers();
  26. Execute the application to test it
  27. Display the Customers form
  28. Close the form(s)

Previous Copyright © 2006-2008, FunctionX, Inc. Next