Thư viện tri thức trực tuyến
Kho tài liệu với 50,000+ tài liệu học thuật
© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Tài liệu An Example—Customer Maintenance pptx
Nội dung xem thử
Mô tả chi tiết
An Example—Customer Maintenance
As an example, consider a simple scenario. You have been asked to build a Customer
Maintenance application. Part of the application needs to record the essential details of a
customer, including title, name, and gender. You decide to create a form like the one
shown in the following graphic.
You need to ensure that the user's input is consistent; the title (Mr, Mrs, Miss, or Ms)
must match the selected gender (Male or Female), and vice versa.
A First Attempt at Performing Validation
In the following exercises, you will examine the Customer Maintenance application and
run it to see how easily you can get validation wrong.
Examine the program
1. Open the CustomerDetails project, located in the \Microsoft Press\Visual CSharp
Step By Step\ Chapter 22\CustomerDetails folder in your My Documents folder.
2. In the Solution Explorer, double-click CustomerForm.cs to display the Customer
Details form in Design View.
3. Click the Title combo box on the form, and then click the Items property in the
Properties window. It should appear as (Collection). Click the Ellipses button to
display the strings in the collection.
You can see from this collection that the list box contains four titles: Mr, Mrs,
Miss, and Ms. Click Cancel to close the String Collection Editor window.
4. Examine the Gender group box and radio buttons. The group box contains two
radio buttons called Male and Female.
The application enforces the business rule that the gender and the title must match.
If the title is Mr, the gender must be male, and if the title is Mrs, Miss, or Ms, the
gender must be female.