1. Trang chủ
  2. » Khoa Học Tự Nhiên

Apress winform data entry and validation with c sharp an

947 121 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 947
Dung lượng 5,87 MB

Nội dung

Data Entry and Validation with C# and VB NET Windows Forms ISBN:1590591089 by Nick Symmonds Apress © 2003 (764 pages) This text demonstrates design patterns for everyday data entry programming tasks, showing the pitfalls of using some of the NET controls and how to program around them Table of Contents Data Entry and Validation with C# and VB NET Windows Forms Introduction Chapter 1 - The NET Data Entry Controls Chapter 2 - UI Design Considerations for Data Entry Chapter 3 - Data Presentation Screen Issues Chapter 4 - Keyboard- and Mouse-Based Data Entry Chapter 5 - The Object-Oriented GUI Chapter 6 - Advanced Data Entry Chapter 7 - Error Handling Advanced Validation and Custom Data Chapter 8 Validation Controls Chapter 9 - XML Data Entry and Validation Chapter 10 - Keeping Users Happy Chapter 11 - Pulling It All Together Application Blocks Index List of Figures List of Tables List of Listings List of Sidebars Back Cover The old hacker adage “Garbage in, garbage out” has never been so important as it is today With everincreasing amounts of information flowing into and out of modern applications, the task of an application developer to control and verify information is critically important to any software project For the first time, Data Entry and Validation with C# and VB NET Windows Forms brings together current knowledge on this subject in an understandable, easyto-read form Covering development and best practices for data entry and validation, including GDI+, custom controls, localization, accessibility, proper data validation techniques, and best practices with Visual Basic and C#, Data Entry and Validation with C# and VB NET Windows Forms is a book no modern programmer should be without About the Author Nick Symmonds works for the Security and Safety Solutions division of Ingersoll-Rand, developing and integrating security software He started out his professional life as an electronics technician While getting his bachelor's degree in electrical engineering from the University of Hartford, he started to gravitate toward programming Nick has spent quite a few years programming in assembly, C, C++, and Visual Basic Recently, he has latched onto NET like a lamprey and loves digging into the NET core Nick has written several articles on programming and has two books currently out: Internationalization and Localization Using Microsoft NET (Apress, 2002) and GDI+ Programming in C# and VB NET (Apress, 2002) Data Entry and Validation with C# and VB NET Windows Forms Nick Symmonds Apress™ Copyright © 2003 Nick Symmonds All rights reserved No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher (pbk): 1-59059-108-9 12345678910 Trademarked names may appear in this book Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark Technical Reviewer: Adriano Baglioni Editorial Board: Dan Appleman, Craig Berry, Gary Cornell, Tony Davis, Steven Rycroft, Julian Skinner, Martin Streicher, Jim Sumser, Karen Watterson, Gavin Wright, John Zukowski Assistant Publisher: Grace Wong Project Manager: Beth Christmas Copy Editor: Nicole LeClerc Production Manager: Kari Brooks Proofreader: Linda Siefert Compositor: Susan Glinert Stevens Indexer: Rebecca Plunkett Artist: April Milne Cover Designer: Kurt Krames Manufacturing Manager: Tom Debolski Distributed to the book trade in the United States by Springer-Verlag New York, Inc., 175 Fifth Avenue, New York, NY, 10010 and outside the United States by Springer-Verlag GmbH & Co KG, Tiergartenstr 17, 69112 Heidelberg, Germany In the United States: phone 1-800-SPRINGER, email orders@springerny.com, or visit http://www.springer-ny.com Outside the United States: fax +49 6221 345229, email orders@springer.de, or visit http://www.springer.de For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley, CA 94710 Phone 510-549-5930, fax 510-549-5939, email info@apress.com, or visit http://www.apress.com The information in this book is distributed on an "as is" basis, without warranty Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work The source code for this book is available to readers at http://www.apress.com in the Downloads section For Celeste You are the love of my life About the Author Nick Symmonds started out his professional life as an electronics technician While getting his bachelor's degree in electrical engineering from the University of Hartford, he started to gravitate toward programming Nick has spent quite a few years programming in assembly, C, C++, and VB Recently, he has latched onto NET like a lamprey and loves digging into the NET core Nick has written several articles on programming and has two books currently out: Internationalization and Localization Using Microsoft NET (Apress, 2002) and GDI+ Programming in C# and VB NET (Apress, 2002) He works for the Security and Safety Solutions division of Ingersoll-Rand, developing and integrating security software Nick lives with his family in the northwest hills of Connecticut and enjoys golfing, biking, and exploring the hills on his motorcycle About the Technical Reviewer Adriano Baglioni got his first taste of computers as a freshman in high school, using BASIC on a PDP-11/70 He pursued his interest in computers at Rensselaer Polytechnic Institute (RPI), where he graduated with a bachelor's degree in computer and systems engineering He followed that up with a master's degree in computer science, also from RPI He has worked in the computer industry for 20 years, programming mostly in C and C++ His experience runs the gamut from embedded programming on 8051s to scientific programming on mainframes He currently works at Veeder-Root Co., developing software for environmental monitoring equipment When it's time to take a break from the computer, Adriano enjoys hiking, biking, and camping with his wife, Carol Acknowledgments This is my third book for Apress Each time it becomes more enjoyable The level of professionalism within this company is unparalleled Thanks to Beth Christmas for keeping me on track as my project manager Nicole LeClerc did a wonderful job again as copy editor I can't believe how fast you do what you do Thanks to all those at Apress who helped and advised me on this book Special thanks go out to Adriano Baglioni Without his technical review comments, this book would not be nearly as good as it is It was a pleasure working with you again Introduction Anyone who has ever worked with a computer has had to enter data into it somehow Anyone who has done any Windows programming (or DOS programming, if you go back far enough) has had to write data entry screens What is data entry without some kind of validation? Then again, what is validation? Validation is the process of the receiving data (via the keyboard, the mouse, voice, serial connections, and so on) and making sure that the data meets the specifications you have laid out For instance, if you are looking for a number but receive a character, your validation code would ignore that character I wrote this book because it encompasses pretty much what most Windows programmers do on a day-to-day basis As programmers, we all work with data We collect it, massage it, store it, retrieve it, and present results back to the user As a matter of fact, data entry and validation are likely such constant themes throughout your programming day that I bet you don't even realize you're doing them When most new programmers think of data entry, they think "Booooring!" What often comes to mind are endless screens of text-based data entry fields for insurance companies Where is the fun in that? After all, there is no chance for any creativity and after a few weeks of this kind of work, life becomes dull It seems like assembly-line programming at its worst Data Entry Code Can Be Interesting Is data entry and validation really this simple and dull? I think not If it were, I would have changed professions long ago Data entry involves two aspects One is to collect data and the other is to make sure the data makes sense The fun part is how you go about programming it If you think that writing screen after screen of data entry fields is boring, how do you think end users feel using these screens? I would say they feel even more bored Your job as a programmer here is twofold First, you need to make the data entry screens not so boring to use, and second, you need to make the screens not so boring to program An additional task is to make the screens sensible The only thing worse to a user than an uninteresting program is a frustrating one How many times have you used a program and had to hunt down certain data fields in screens where they don't belong? You tend to wonder, what were they thinking?! Perhaps you have received some feedback like this about your own program Who Should Read This Book This book is for intermediate and well-seasoned programmers who are already writing in NET or want to change over to NET I assume a level of programming knowledge commensurate with a basic understanding of NET and a good understanding of programming in general Readers should know some object-oriented and general programming techniques such as the following: Function overloading Inheritance Class design and instantiation Use of threads and the advantages (and pitfalls) of threading Exception handling Readers should also be familiar with some of the NET-specific topics such as the following: Garbage collection JIT compiler Organization of the NET namespaces List of Listings Chapter 1: The NET Data Entry Controls Listing 1-1a: C# Code for the Terminal Setup Program Listing 1-1b: VB Code for the Terminal Setup Program Listing 1-2a: C# Code for the TextBox Setup Example Listing 1-2b: VB Code for the TextBox Setup Example Listing 1-3a: C# Code for the DataBound Project Listing 1-3b: VB Code for the DataBound Project Listing 1-4a: C# Code for the SelectText Program Listing 1-4b: VB Code for the SelectText Program Chapter 2: UI Design Considerations for Data Entry Listing 2-1a: C# Constructor Code for the PowerUser Main Form Listing 2-1b: VB Constructor Code for the PowerUser Main Form Listing 2-2a: C# Code for the Load Event Handler and Helper Function for the PowerUser Project Listing 2-2b: VB Code for the Load Event Handler and Helper Function for the PowerUser Project Listing 2-3a: C# Code for Event Delegates Listing 2-3b: VB Code for Event Delegates Listing 2-4a: C# Code for the EmpList Form Listing 2-4b: VB Code for the EmpList Form Listing 2-5a: C# Code for the Console Program Listing 2-5b: VB Code for the Console Program Chapter 3: Data Presentation Screen Issues Listing 3-1a: C# Code for Event Delegates Listing 3-1b: VB Code for Event Delegates Listing 3-2a: C# Code for the MDI Application Listing 3-2b: VB Code for the MDI Application Listing 3-3a: C# Code for the Resource Example Listing 3-3b: VB Code for the Resource Example Chapter 4: Keyboard- and Mouse-Based Data Entry Listing 4-1a: C# Code for the Complete Keys Example Listing 4-1b: VB Code for the Complete Keys Example Listing 4-2a: C# Code for Delegates Listing 4-2b: VB Code for Delegates Listing 4-3a: C# Code for the Rectangle Converter Class Listing 4-3b: VB Code for the Rectangle Converter Class Chapter 5: The Object-Oriented GUI Listing 5-1a: C# Code for the LvItems Class Listing 5-1b: VB Code for the LvItems Class Listing 5-2a: C# Code for the MovieList Class Listing 5-2b: VB Code for the MovieList Class Listing 5-3a: C# Constructor Initialization Code Listing 5-3b: VB Constructor Initialization Code Chapter 6: Advanced Data Entry Listing 6-1a: C# Code for the Form's Load Event Listing 6-1b: VB Code for the Form's Load Event Listing 6-2a: C# Code for the Towns Class Listing 6-2b: VB Code for the Towns Class Listing 6-3: C# Code for the MSComm Constructor and Delegate Chapter 7: Error Handling Listing 7-1: C# Code for the ErrDialog Example Listing 7-2a: C# Code for the EventLogger Class Listing 7-2b: VB Code for the EventLogger Class Listing 7-3a: C# Code for the Console Form Listing 7-3b: VB Code for the Console Form Chapter 8: Advanced Validation and Custom Data Validation Controls Listing 8-1a: C# Code for the Masked Edit Control Test Program Listing 8-1b: VB Code for the Masked Edit Control Test Program Listing 8-2a: C# Code for the Regx Class Listing 8-2b: VB Code for the Regx Class Chapter 9: XML Data Entry and Validation Listing 9-1a: C# Code for the Classify Static Class Listing 9-1b: VB Code for the Classify Static Class Listing 9-2a: C# Code for the Main Form Listing 9-2b: VB Code for the Main Form Chapter 10: Keeping Users Happy Listing 10-1: VB 6.0 Code for the Tree Tester Project Listing 10-2a: C# Code for the Inventory Class Listing 10-2b: VB Code for the Inventory Class Chapter 11: Pulling It All Together Example 11-1a: C# Code for the IHoleDetails Collection Classes Example 11-1b: VB Code for the IHoleDetails Collection Classes Listing 11-2a: C# Code for the Database Class Listing 11-2b: VB Code for the Database Class Listing 11-3a: C# Code for the Course Setup Tab and cmbHoles Click Event Listing 11-3b: VB Code for the Course Setup Tab and cmbHoles Click Event Listing 11-4a: C# Code for the Course Scores Tab Setup Listing 11-4b: VB Code for the Course Scores Tab Setup Listing 11-5a: C# Code for the HoleDetail Screen Listing 11-5b: VB Code for the HoleDetail Screen Listing 11-6a: C# Code for the Statistics Form Listing 11-6b: VB Code for the Statistics Form List of Sidebars Chapter 1: The NET Data Entry Controls The Base Control Chapter 5: The Object-Oriented GUI Overriding the ToString() Method ... for data entry and validation, including GDI+, custom controls, localization, accessibility, proper data validation techniques, and best practices with Visual Basic and C# , Data Entry and Validation with C# and VB NET Windows Forms is a book no modern... currently out: Internationalization and Localization Using Microsoft NET (Apress, 2002) and GDI+ Programming in C# and VB NET (Apress, 2002) Data Entry and Validation with C# and VB NET Windows Forms Nick Symmonds Apress Copyright © 2003 Nick Symmonds... of modern applications, the task of an application developer to control and verify information is critically important to any software project For the first time, Data Entry and Validation with C# and VB NET Windows Forms brings together current

Ngày đăng: 25/03/2019, 16:43

w