2. Table of Content Introduction / Summary 3 Projects: Project 1 FrameWork Business Project 5 FrameWork Code Snippets 6,7 Phase 2 Library Project 10 Windows Front End Validation 11 - 15 Phase 3 Library Project 16 Create DataAccess Tiers Phase 4 Library Project 28 Integrate into a Web Project Phase 5 Library Project 44 Integrate into a Web Service
3. .NET Projects Overviewpage 2 Summary Project 1 .NET Framework Foundation Build parts of the business tier for a retail company, consisting of two assemblies; Foundation and AppTypes. The Foundation class library contains various interfaces and base classes. The AppTypes class library contains various entity, collection, and exception classes used by the various business processes. Project 2 Library Phase 1 Given an ADO.NET data access library to a SQL database that contains Library books, adult and juvenile members, develop an intuitive Windows Forms user interface that requires minimal training. Development of business tier software that isolates the ADO.NET code from the user interface is also required to add members, check books in and out of the database. Additional requirements include validation of all input parameters including regular expression validators, exception handling minimizing resource utilization. Project 3 Library Phase 2 Using the UI developed in Library Phase 1 project, the requirement here is to convert the ADO.NET data access tier to use LinqToSQL to develop object models and abstract away data provider code and modify the business tier software as required to interface with this new data access tier. Develop code that is easily maintainable and provides adequate error handling.
4. .NET Projects Overviewcont. .NET Framework Projects Overview Project 4 Library Phase 3 Convert the user interface of the Library Phase 2 project to a Web application preserving all of the Windows Forms functionality. Specific requirements include the use of AJAX controls for book check in and implementing a secure login for the librarian to access to the library functions using forms based authorization and authentication. Additional functionality includes the ability to add books or another copy of an existing book to the database, automatically convert juvenile members to adult members when they turn 18, and allow the option to renew a membership that has expired. Project 5 Library Phase 4 Allow Interoperability of the Library project with other systems by implementing Windows Communication Foundation (WCF) Web Services called from the web based user interface that provides a secure communication mechanism to the library business layer. Authorization and authentication of the transport channel shall be provided using ASP.NET membership and role permissions. Project 6 Test Management Application
5. FrameWork ProjectProject 1 The FrameWork project features parts of the business tier for a retail company, consisting of two assemblies; Foundation and AppTypes. The Foundation class library contains various interfaces and base classes. The AppTypes class library contains various entity, collection, and exception classes used by the various business processes.
7. Partial FrameWork Code SnippetsDefine the Supplier classApplication Type /// <summary> / Supplier Class [DeveloperInfoAttribute( "JerielMikell", "Programmer", "11072009")] [CustomDescriptionAttribute("Supplier Class")] [Serializable] public sealed class Supplier : Contact { //Fields /// <summary> /// HomePage /// </summary> public string _homePage; /// <summary> /// SupplierType type /// /// </summary> public SupplierTypes _type; //Properties /// <summary> /// public property HomePage /// </summary> public string HomePage { get { return _homePage; } set { if (value.Length < 5 || value.Length > 50) throw new InvalidOperationException("HomePage must be between 5 and 50 characters" + _homePage); else _homePage = value; }
8. Supplier Typecont. /// <summary> /// Supplier Types can not be null /automatic property for Type /// </summary> public SupplierTypes Type { get { return _type; } set { if (_type == 0) throw new InvalidOperationException(_type +"Supplier Type must not be Empty" ); else _type = value; } } /// <summary> /// defalultconstuctor /// </summary> public Supplier() { } //overload constructor
11. Library Project Phase 2 LWindows Front-End Application Requirements Design and develop a front end application that satisfies the four basic functionalities: Add Adult, Add Juvenile, Check In a book, Check Out a book. Develop code that is easily maintainable. Provide validation for all required fields (see details below). Provide adequate error handling. Produce a user interface that is intuitive, requiring minimal training for users while minimizing resource utilization. Provisions Database scripts are provided in order to create the Library database (see APPENDIX A). An interface that specifies the methods supported by the Data Access tier used for all database access and a class that implements the interface are provided. Classes that represent various “business entities” (e.g., an AdultMember class) are also provided. Detailed information appears in Appendix B. A reference implementation that illustrates one possible solution for this project is provided. The reference implementation is not intended as a model to be emulated in your solution; rather, it serves only to illustrate how you might implement your solution, rather than how you must implement your solution. If you wish to use the reference implementation as a basis for how your implementation will appear and function, you are free to do so, but you are not obligated to replicate the appearance of the reference implementation. A database has been created to support the principal functions of a lending library’s day-to-day operations: adding new members (adult and juvenile) and checking books in and out. An assembly has been created that contains classes and interfaces that provide access to the database for these functions. What is needed is a Windows Forms-based front-end application that will provide a librarian with a visual interface through which he or she may perform the desired functions
13. Front end validation If a value is entered into the middle initial field, that field must be validated to ensure that the value entered is a single alphabetic character. If a value is entered into the phone number field, that field must be validated to ensure that the value conforms to the format (XXX)XXX-XXXX, where X is a digit from 0 through 9. Note there is no space after the right parenthesis; the field in the database for the phone number is thirteen characters long, so including a space at this point would cause the phone number to be truncated. The adult member ID field must be validated to ensure that it contains only a numeric value in the range 1 through 32767 inclusive. The birthday field must be validated to ensure that it contains a value in the format MM/DD/YYYY and that the value parses to a date that is no more than eighteen years prior to the current date. When a member ID is entered to perform a member lookup, that field must be validated according to the same rule specified for the adult member ID field above. For the ISBN and copy number fields used in the check-in and check-out operations, these fields must be validated to ensure that only numeric values are entered. For the copy number field, the value must be in the range 1 through 32767 inclusive. Suggested Project Techniques : Use menus instead of buttons to free screen space, when appropriate. Use combo boxes (drop-down lists) and list boxes instead of free-form textboxes for data entry whenever possible. Avoid overuse of message boxes and other modal communications to the user. Use other display techniques such as a status bar or a label. Use standard naming conventions to provide code readability. Make use of collections to produce concise code. While calls into the data access class’s methods by the presentation tier (i.e., by the code in your Form’s event handlers) are permitted, you might want to consider creating a middle tier for mediating between your presentation tier and the data access tier. Using a middle tier can simplify the code in your presentation tier considerably.
14. Validation cont. Enrolling Members To become a library member, an individual must provide his or her mailing address and, optionally, his or her phone number. A librarian then issues the individual a numbered, machine-readable card. This card is good for one year from the date of issue. Juveniles are considered to be individuals under the age of eighteen. A juvenile can be a member of the library, but must have an adult member sign for them when they join. The juvenile’s address and phone number information is that of the sponsoring adult member, and the juvenile’s card is valid only until the sponsoring adult member's card expires. The only information that the library keeps on a juvenile member is his or her name, sponsoring adult member card number, and his or her date of birth. Checking Out Books Books are checked out for 14 days. Members are allowed to have at most four books checked out at a time. Members bring books to the front desk after they locate the ones that they want to check out. A librarian then enters the card number from the member's card. A screen displays information about the member's account, such as name, address, phone number, and the card's expiration date. Ideally, cards that have expired will be highlighted. The screen also displays information about a member's outstanding loans, including title, checkout date, and due date. If a member's account is in order (i.e., the card is not expired and fewer than four books are on loan to the member currently), a librarian checks out the books. Librarians check out books by entering the ISBN and copy number of the item, both of which appear in a label on the book’s spine. The ISBN, copy number, title, and author information then appear on the computer screen so that the librarian may verify that the database entry corresponds to the item being checked out. The librarian then can elect to check the book out or to cancel the check-out operation. Occasionally, books are accidentally re-shelved before librarians check them in. If a librarian tries to check out a book that the database lists as already checked out, the librarian should be alerted and be given the opportunity to check the book in before proceeding with the check-out operation. Checking In Books When a book is returned to the library, a librarian checks it in by entering the ISBN and copy number that appears on the book’s spine. The ISBN, copy number, title, and author information then appear on the computer screen, as well as the card number and name of the member to whom the book is checked out, and the book's due date. The librarian can then elect to check the book in or to cancel the check-in operation.
15. Validation cont. Data Validation To enroll an adult member, the required fields are: First name Last name Street City State Zipcode Middle initial and phone number are optional fields. To enroll a juvenile member, the required fields are: First name Last name Adult member ID Birthday Middle initial is an optional field. First name and last name fields must be validated to ensure that the values contained in these fields are alphabetic only and that the first character of each of these fields is uppercase. The Zipcode field must be validated to ensure that only a five-digit (XXXXX) or a nine-digit (XXXXX-XXXX) value is entered.
16. Validationcont. Value entered is a single alphabetic character. If a value is entered into the phone number field, that field must be validated to ensure that the value conforms to the format (XXX)XXX-XXXX, where X is a digit from 0 through 9. Note there is no space after the right parenthesis; the field in the database for the phone number is thirteen characters long, so including a space at this point would cause the phone number to be truncated. The adult member ID field must be validated to ensure that it contains only a numeric value in the range 1 through 32767 inclusive. The birthday field must be validated to ensure that it contains a value in the format MM/DD/YYYY and that the value parses to a date that is no more than eighteen years prior to the current date. When a member ID is entered to perform a member lookup, that field must be validated according to the same rule specified for the adult member ID field above.
17. Validation cont. For the ISBN and copy number fields used in the check-in and check-out operations, these fields must be validated to ensure that only numeric values are entered. For the copy number field, the value must be in the range 1 through 32767 inclusive. Suggested Project Techniques : Use menus instead of buttons to free screen space, when appropriate. Use combo boxes (drop-down lists) and list boxes instead of free-form textboxes for data entry whenever possible. Avoid overuse of message boxes and other modal communications to the user. Use other display techniques such as a status bar or a label. Use standard naming conventions to provide code readability. Make use of collections to produce concise code. While calls into the data access class’s methods by the presentation tier (i.e., by the code in your Form’s event handlers) are permitted, you might want to consider creating a middle tier for mediating between your presentation tier and the data access tier. Using a middle tier can simplify the code in your presentation tier considerably.
18. Library Project Phase3 Project Phase 3 consist of building the DataAccess and Business Tiers. Preserving the use of the Stored Procedures, validation and ease of access among other features created in the previous project, like members card has expired.
19. Add Adult stored procedure /* Methods that can be used in the try catch blocks Function Description ERROR_NUMBER() Returns the number of the error ERROR_SEVERITY() Returns the severity ERROR_STATE() Returns the error state number ERROR_PROCEDURE() Returns the name of the stored procedure or trigger where the error occurred ERROR_LINE() Returns the line number inside the routine that caused the error ERROR_MESSAGE() Returns the complete text of the error message. The text includes the values supplied for any substitutable parameters, such as lengths, object names, or times */ USE library GO /*Drop the Procedure before creating it if it exists.*/ IF OBJECT_ID ('usp_AddAdultMember') IS NOT NULL DROP PROCEDURE usp_AddAdultMember; GO /*Create the Procedure*/ CREATE PROCEDURE usp_AddAdultMember @nlastnamevarchar(15),@nfirstnamevarchar(15),@nmiddleinitial char(1), @nstreetvarchar(15),@ncityvarchar(15),@nstate char(2), @nzip char(10),@nphoneno char(13), @nexpirationDateDateTime, @adultmemberidsmallint OUTPUT AS BEGIN BEGIN TRY --IF EXISTS SELECT (@noutput_Adultmemberid ) --IF EXISTS (SELECT * FROM member WHERE member_no = @adultmemberid) -- RETURN -1
20. Add Adult stored procedure cont /*Validation Testing*/ /*Test each field for null or out of Range values*/ IF (@nfirstname IS NULL) RETURN -1; IF (@nlastname IS NULL) RETURN -1; IF (@nstreet IS NULL) RETURN -1; /*Validation Testing*/ /*Test each field for null vaues */ IF (@ncity IS NULL) RETURN -2; /*Validation Testing*/ /*Test each field for null values*/ IF (@nstate IS NULL) RETURN -3; /*Validation Testing*/ /*Test each field for null vaues*/ IF (@nzip IS NULL) RETURN -4; /*Validation Testing*/ /*Test each field for null or out of Range values*/ IF (@nexpirationDate IS NULL) RETURN -5
21. Add Adult stored procedurecont. --Need to insert values into the Member table as well as the Adult table --memeberno in the member table is IDentity column BEGIN TRANSACTION INSERT INTO member(lastname,firstname,middleinitial) VALUES (@nlastname,@nfirstname,@nmiddleinitial); IF (@@ERROR <> 0) BEGIN ROLLBACK RETURN -10; END Set @adultmemberid = scope_identity(); INSERT INTO adult(member_no,street,city,[state],zip,phone_no,expr_date) VALUES (@adultmemberid,@nstreet,@ncity,@nstate,@nzip,@nphoneno,@nexpirationDate) IF (@@ERROR <> 0) BEGIN ROLLBACK ; RETURN -11; END COMMIT TRANSACTION; RETURN @adultmemberid; END TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK DECLARE @ErrMsgnvarchar(4000), @ErrSeverityint SELECT @ErrMsg = ERROR_MESSAGE(), @ErrSeverity = ERROR_SEVERITY() RAISERROR(@ErrMsg, @ErrSeverity, 1) END CATCH; END GO --END TRANSACTION --END TRAN AddAdultMemberTrans --
31. Summary The Web Application utilizes Http binding and MasterPage and ContentPages as the structure for the application. The Interface has changed but preserves the functionality as the previous projects. The application uses custom user controls hyperlinks to navigate to each page, continues to provide validation and error handling. The project also features AJAX processing. Extra processing was added in the web application to automatically update a juvenile who's eighteenth birthday has just past or is current and that the member is still active or the members card has not expired. Also extra processing has been added to highlight overdue books. Books that have exceeded the return date. Other features included; Security for Librarians and authorized users of the system, search feature to find members by member number.
47. Project Phase 5WCFWeb Service WCF web service project uses the same Web application Windows Client interface and processing as project 4 , but adds attributes for the web service contracts and data contract objects and methods in the DataAccess Layer of the project. Uses fault exception and LibraryExceptions. The service was first hosted in a console application and later migrated to a windows application to be hosted in Internet Information Services(IIS).