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 New Item...
  15. In the Templates list, click Windows Form and set the name to Customers
  16. Click Add
  17. Drag the Customers node and drop it on the form
  18. 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
  19. Click OK
  20. Set DataGridView's Anchor property to Top, Bottom, Left, Right
  21. Under the DataGridView control, add a button and set its properties as follows:
    Text: Close
    (Name): btnClose
    Anchor: Bottom, Right
  22. Double-click the Close button and implement its even as follows:
    private void btnClose_Click(object sender, EventArgs e)
  23. Access the first form
  24. Add a button to it and set its properties as follows:
    Text: Customers
    (Name): btnCustomers
  25. Double-click the Customers button
  26. In the top section of the file, under the #pragma once line, type #include "Customers.h"
  27. Scroll to the bottom of the file and implement the even as follows:
    System::Void btnCustomers_Click(System::Object^  sender,
    				System::EventArgs^  e)
    	 Customers ^ frmCustomers = gcnew Customers;
  28. Execute the application to test it
  29. Display the Customers form
  30. Close the form(s)

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