A dictionay-based is a type of list where each item is represented by a key.
This application explores the characteristics of a dictionary-based list. It
is fictitious company that rents cars to customers.

Practical
Learning: Starting the Application

Start Microsoft Visual Studio

Create a new Windows Application named BethesdaCarRental1

To add a new form to the project, in the Solution Explorer,
right-click BethesdaCarRental1 -> Add -> Windows Form...

Set the Name to RentalRates and press Enter

Add a ListView to the form and create its Columns as follows:

(Name)

Text

TextAlign

Width

colCategory

Category

90

colDaily

Daily

Right

colWeekly

Weekly

Right

colMonthly

Monthly

Right

colWeekend

Weekend

Right

Create its Items as follows:

ListViewItem

SubItems

SubItems

SubItems

SubItems

Text

Text

Text

Text

Economy

35.95

32.75

28.95

24.95

Compact

39.95

35.75

32.95

28.95

Standard

45.95

39.75

35.95

32.95

Full Size

49.95

42.75

38.95

35.95

Mini Van

55.95

50.75

45.95

42.95

SUV

55.95

50.75

45.95

42.95

Truck

42.75

38.75

35.95

32.95

Van

69.95

62.75

55.95

52.95

Complete the design of the form as follows:

To add a new form to the application, in the Solution Explorer,
right-click BethesdaCarRental1 -> Add -> Windows Form...

Set the Name to Employees and click Add

From the Toolbox, add a ListView to the form

While the new list view is still selected, in the Properties window,
click the ellipsis button of the Columns field and create the columns as
follows:

To add a new class to the project, in the Class View, right-click
BethesdaCarRental -> Add -> Class...

Set the Class Name to RentalOrder and press Enter

Access the RentalOrder.cs file and change it as follows:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BethesdaCarRental1
{
[Serializable]
public class RentalOrder
{
public string EmployeeNumber;
// The following flag will allow us to update/know whether
// * The car is currently being used by the customer.
// That is, if the car has been picked up by the customer
// * The customer has brought the car back
public string OrderStatus;
// Because every car has a tag number
// and that tag number will not change
// during the lifetime of a car (while the car remains with our
// car rental company, we will
// use only the tag number here.
// The other pieces of information will
// be retrieved from the list of cars
public string CarTagNumber;
// We will identify the customer by the number
// and the name on his or her driver's license
public string CustomerDrvLicNbr;
public string CustomerName;
// Although he or she may keep the same driver's
// license number for a lifetime, a customer who
// rents cars at different times with this company
// over months or years may have different addresses.
// Therefore, although we will primarily retrieve the
// customer's address from the list of customers,
// we will give the clerk the ability to change this
// information on a rental order. This means that the
// same customer could have different information on
// different rental orders.
// For this reason, each rental order will its own set
// of these pieces of information
public string CustomerAddress;
public string CustomerCity;
public string CustomerState;
public string CustomerZIPCode;
public string CarCondition;
public string TankLevel;
// This information will be entered when the car is being rented
public int MileageStart;
// This information will be entered when the car is brought back
public int MileageEnd;
// This information will be entered when the car is being rented
public DateTime DateStart;
// This information will be entered when the car is brought back
public DateTime DateEnd;
public int Days;
// This information will be entered when the car is being rented
public double RateApplied;
// This calculation should occur when the car is brought back
public double SubTotal;
public double TaxRate;
public double TaxAmount;
public double OrderTotal;
public RentalOrder()
{
}
}
}

To add a new form to the project, in the Solution Explorer,
right-click BethesdaCarRenat1 -> Add -> Windows Form...

Return to the Order Processing form and double-click the End Date
control

Implement its Click event as follows:

// This event approximately evaluates the number of days as a
// difference between the end date and the starting date
private void dtpEndDate_ValueChanged(object sender, EventArgs e)
{
int days;
DateTime dteStart = this.dtpStartDate.Value;
DateTime dteEnd = this.dtpEndDate.Value;
// Let's calculate the difference in days
TimeSpan tme = dteEnd - dteStart;
days = tme.Days;
// If the customer returns the car the same day,
// we consider that the car was rented for 1 day
if (days == 0)
days = 1;
txtDays.Text = days.ToString();
// At any case, we will let the clerk specify the actual number of days
}

Return to the Order Processing form and double-click the Rental
Rates button