An Example—Customer Maintenance

An-Khách hàng bảo trì Ví dụ Ví dụ, hãy xem xét một kịch bản đơn giản. Bạn đã được yêu cầu để xây dựng một ứng dụng bảo trì khách hàng. Một phần của ứng dụng cần để ghi lại các chi tiết cần thiết của một khách hàng, bao gồm tiêu đề, tên, và giới tính. | 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 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. 5. On the View menu click Code to switch to the Code And Text Editor window displaying . Look at the checkTitleAndGender method situated immediately below the CustomerForm constructor 6. Cross check the gender and the title to make sure they correspond 7. private bool checkTitleAndGender 8. 9. if Mr 10. 11. Check that gender is Male 12. if 13. 14. .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
17    94    2    07-06-2024
13    287    1    07-06-2024
21    73    3    07-06-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.