Date post: | 14-Jun-2015 |
Category: |
Technology |
Upload: | jeffhuber |
View: | 503 times |
Download: | 0 times |
Jeff Huber [email protected] Page 1 of 20
SetFocus Project #1 - .NET Framework
Objective Build parts of the business tier for a retail company, consisting of two assemblies; Foundation
and AppTypes.
Requirements • Delegates, events
• Custom exception/attribute classes
• Custom EventArgs classes
• Event logger and collection classes
• Generic Collections
• Custom Serializations
• Binary & SOAP Formatters
• Abstract classes & interfaces
• Enumerations
• Properties
• Custom Enumerators Implementation
of ISerializable, IComparer,
IComparable, & IList<T> interfaces
Foundation Assembly This assembly contains the foundation interfaces and base classes used throughout the project.
Jeff Huber [email protected] Page 2 of 20
SetFocus Project #1 - .NET Framework
AppTypes Assembly This assembly contains various entity, collection, and exception classes used by the business.
Jeff Huber [email protected] Page 3 of 20
SetFocus Project #2 - Library Phase 1(Windows Front End Application)
Objective Create 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.
Requirements • Design and develop a front end application that satisfies four basic functionalities: Add
Adult, Add Juvenile, Check In a book, Check Out a book.
• Develop code that is easily maintainable using n-tier architecture.
• Provide validation for all required fields using regular expressions where needed.
• Provide adequate error handling and exception handling that also incorporates custom
exceptions.
• Produce a user interface that is intuitive, requiring minimal training for users.
Description Making the document intuitive I created a Multi Document
Interface that upon opening loads the Member Information
form which is the main child form in the program. The
parent forms menu strip has all items needed to perform the
functions required for the user to perform their tasks. Each
option opens up into its own child form within the parent.
The code behind the user interface (JH.LibraryWinClient)
handled all the validations, form loading, and contained the
logic for each operation.
The Business Layer (JH.LibraryBusiness) is the connection
between the User Interface and the Data Access Layer. In
this project the Data Access Layer was given to us as a
compiled DLL file. This file provided the connection to the
Library database holding all the information and records
needed on SQL Server 2005.
Using the n-tiered architecture allows for the ability of the way data is accessed or retrieved to
be changed if needed without the need to make changes to the User Interface.
Jeff Huber [email protected] Page 4 of 20
SetFocus Project #2 - Library Phase 1(Windows Front End Application)
Functionality Details
Add Adult – First and Last name, Street, City, State, and Zip code are required. Middle Initial and phone number are optional. Add Juvenile – First and Last name, Birth date, and Sponsoring Adult Member ID are required. Middle Initial is an optional field. Rules implemented while adding and displaying a member: • The first and last name fields must be non-empty and could only contain 15 alphabetic
characters. The first letter was required to be uppercase and the remaining characters must be
lowercase.
• The middle initial is optional, but if entered it must be one uppercase character.
• The Street and City fields must be non-empty and could be no more than 15 characters.
• The State field had to be two uppercase letters. The dropdown was populated from a XML file.
• The Zip code field must be a non-empty and had to be a ##### or #####-#### where # is a
number (0-9).
• The phone number had to be in the (###)###-#### format when supplied.
• For a juvenile member, birth date must be a valid date (MM/DD/YYYY format), and the birth
date must fall within the 18 year period ending on the current date.
• Sponsoring Adult Member ID had to reference a valid adult member already in the database
and not have an expired membership.
• Each member could only have 4 books checked out at a time. Checking out a book also
required that the member’s expiration date current.
• If a book was to be checked out, but the database indicated that it was already on loan, the
librarian was prompted if they wanted to check the book in first.
• All functions like check in book, check out book, and canceling the addition of a new member
provided a method for the librarian to cancel the operation.
Jeff Huber [email protected] Page 5 of 20
SetFocus Project #2 - Library Phase 1(Windows Front End Application)
Screenshots
Member Information: Member information is shown displayed inside the parent form. An adult member is shown
loaded into the form.
Member Information: Member information is shown displayed inside the parent form. A juvenile member is shown
loaded into the form.
Jeff Huber [email protected] Page 6 of 20
SetFocus Project #2 - Library Phase 1(Windows Front End Application)
Add Member: Add Member form has tabs to allow for a dual purpose of adding either Adult Member or a
Juvenile Member depending on which tab is selected. The Juvenile member form uses a
DateTime Picker that displays from the dropdown box to allow the user to type in birth date or
select from a calendar.
Check In Book: The Check In Book displays a form to enter information about the book. After information is
entered and the OK button is clicked user is asked to confirm the check in of the book and also
gives the user the option to back out of the operation.
Jeff Huber [email protected] Page 7 of 20
SetFocus Project #2 - Library Phase 1(Windows Front End Application)
Check Out Book: The Check Out Book displays a form to enter information about the book. After information is
entered and the OK button is clicked user is asked to confirm the check out of the book and also
gives the user the option to back out of the operation. Check out book only becomes in scope
when a valid, current member is entered in the Member Information page.
About Tab: The about the author tab was put in as a way of showing my graphic design ability. All items in
the graphic were created by me using Adobe Photoshop.
Jeff Huber [email protected] Page 8 of 20
SetFocus Project #3 - Library Phase 2(Data Access/SQL Stored Procedures)
Objective Create a Data Access layer and SQL Server Stored Procedures to replace the ones provided in
the Library application Phase 1. In Phase 2 of the project additional functionality of the UI was
to have an overdue book to be highlighted in the Data Table on the member information form.
Requirements • Create and implement the Entities classes used in the library project • Data validation in SQL • Stored procedures in Transact‐SQL (T‐SQL) on SQL Server 2005 • Implementing error handling in SQL • Accessing stored procedures through System.Data.SqlClient • Retrieve and process result sets returned from stored procedures • Process errors raised by T‐SQL in ADO.NET using error numbers and states • Write a T‐SQL script to test Stored Procedures for functionality • Create and utilize strongly typed datasets based on stored procedures.
Description The objective of this project was to recreate the Data
Access layer using ADO.NET, Library Entities, and using
Transact-SQL Stored Procedures needed to access SQL
Server 2005 database to get the Library application
running as it was in the Phase 1 project.
The Library Entities contains the AdultMember,
JuvenileMember, Member, Item, LibaryException classes
as well as an, ErrorCode enumeration and an ItemDataSet
that are referenced by the entire project.
The JH.DataAccess provided the layer between the
database and the Business layer. The DataAccess layer
calls the appropriate SQL Server stored procedures
through ADO.NET code.
As long as the DataAccess layer returns the expected
objects, the Business and UI layers do NOT need
modifying. These layers were only modified was to add
functionality and change from the SetFocus provided
DLLs from phase 1. This provides for scalability and
flexibility on the database server.
Jeff Huber [email protected] Page 9 of 20
SetFocus Project #3 - Library Phase 2(Data Access/SQL Stored Procedures)
Stored Procedures All stored procedures created in this project were to duplicate the results for the Library Phase 1
project.
Each stored procedure contained validation to ensure all
data going into the database followed the same
requirements as required at the user interface.
The AddAdult, and AddJuvenile stored procedures
called the GetMember_With_Member_No procedure to
return the member records to the Data Access layer. The
CheckOutItem stored procedure called the
GetMember_With_Member_No procedure to retrieve
the member information and check if the membership is
expired. This procedure also calls the
GetItem_W_ISBN_Copy to retrieve information on the
book to see if it is loanable.This simplifies code
modification by requiring change to a single stored
procedure and a single Data Access method to change
the data.
The SqlExceptions that were caught in the DataAccess layer were caught using a switch
statement of the State property in the SQL error checking to ensure that appropriate message
would be displayed in the user interface to help the user fix the appropriate problem that had
occurred.
#region Check In Item Exceptions
catch (SqlException se)
{
switch (se.State)
{
case 1:
throw new ArgumentOutOfRangeException(se.Message, se);
case 2:
throw new ArgumentOutOfRangeException(se.Message, se);
case 3:
throw new ArgumentOutOfRangeException(se.Message, se);
case 4:
throw new ArgumentOutOfRangeException(se.Message, se);
case 5:
throw new LibraryException(ErrorCode.ItemNotFound, se.Message, se);
case 6:
throw new LibraryException(ErrorCode.ItemNotOnLoan, se.Message, se);
case 7:
throw new LibraryException(ErrorCode.ItemNotFound, se.Message, se);
default:
throw new LibraryException(ErrorCode.GenericException, se.Message, se);
}
Jeff Huber [email protected] Page 10 of 20
SetFocus Project #3 - Library Phase 2(Data Access/SQL Stored Procedures)
The CheckInItem stored procedure shows multiple error checking as well as multiple
modifications to multiple tables in the database.
--***********************************************************
--******** THIS IS THE CHECK IN ITEM ********
--******** STORED PROCEDURE CREATED BY JEFF HUBER ********
--******** LIBRARY PHASE 2 JANUARY 2009 ********
--***********************************************************
IF (@isbn IS NULL)
BEGIN
RAISERROR (14043, --SQL NULL error code
16, --Severity
1, --State
'isbn', --Parameter
'csp_JH_CheckInItem')
RETURN
END
IF ((@isbn <= 0) OR (LEN(@isbn)=0))
BEGIN
RAISERROR (21119, --SQL negative value error code
16, --Severity
3, --State
'isbn', --Parameter
'csp_JH_CheckInItem')
RETURN
END
IF (@copyNumber IS NULL)
BEGIN
RAISERROR (14043, --SQL NULL error code
16, --Severity
2, --State
'copy_no', --Parameter
'csp_JH_CheckInItem')
RETURN
END
IF ((@copyNumber <= 0) OR (LEN(@copyNumber)=0))
BEGIN
RAISERROR (21119, --SQL negative value error code
16, --Severity
4, --State
'copy_no', --Parameter
'csp_JH_CheckInItem')
RETURN
END
-- check to make sure that isbn and copy number are a valid numbers
DECLARE @temp2 smallint
SELECT @temp2 = COUNT(*)
FROM copy
WHERE (isbn = @isbn) AND (copy_no = @copyNumber)
IF (@temp2 = 0)
BEGIN
RAISERROR (14262, --SQL NULL error code
16, --Severity
5, --State
'isbn or copy_no', --Parameter
'csp_JH_CheckInItem') --Procedure
RETURN
END
--Check to see if item is on loan and throw appropriate error
DECLARE @temp char(1)
SET @temp = (SELECT on_loan
FROM copy
WHERE (isbn = @isbn) AND (copy_no = @copyNumber))
IF (@temp = 'N')
BEGIN
RAISERROR ('Item is not on loan.', --Custom error message
11, --Severity
6, --State
'on_loan', --Parameter
'csp_JH_CheckInItem') --Procedure
RETURN
END
Jeff Huber [email protected] Page 11 of 20
SetFocus Project #3 - Library Phase 2(Data Access/SQL Stored Procedures)
IF (@temp IS NULL)
BEGIN
RAISERROR ('Item does not exist in database.', --Custom error message
11, --Severity
7, --State
'on_loan', --Parameter
'csp_JH_CheckInItem') --Procedure
RETURN
END
BEGIN TRANSACTION
BEGIN TRY
--Update copy table to change on_loan column to 'N' - "NO"
UPDATE copy
SET on_loan = 'N'
WHERE (isbn = @isbn) AND (copy_no = @copyNumber)
--Insert items from loan table to loanhist table
INSERT loanhist
SELECT isbn, copy_no, out_date, title_no, member_no
,due_date, GETDATE(), NULL, NULL, NULL, NULL
FROM loan
WHERE (isbn = @isbn) AND (copy_no = @copyNumber)
--DELETE items from loan table where (isbn = @isbn) and (copy_no = @copyNumber)
DELETE loan
WHERE (isbn = @isbn) AND (copy_no = @copyNumber)
END TRY
--If SQL error exist
BEGIN CATCH
DECLARE @error int
SET @error = @@error
IF @@error <> 0
BEGIN
RAISERROR(@error,16,8)
ROLLBACK TRANSACTION
RETURN
END
END CATCH
COMMIT TRANSACTION
Jeff Huber [email protected] Page 12 of 20
SetFocus Project #3 - Library Phase 2(Data Access/SQL Stored Procedures)
This diagram shows the tables and their relationships in the Library database used in this project.
Jeff Huber [email protected] Page 13 of 20
SetFocus Project #4 - Library Phase 3(Web Application)
Objective Create a web based application of the Library management system utilizing ASP.NET.
Additional functionality needed consists of the ability to renew an adult’s membership, check if
juvenile is 18 years old and convert to an adult member, add new books to the system, highlight
overdue book(s), and implement authentication and authorization to restrict access to the system.
Requirements • Create and use ASP.NET master pages to provide a consistent look across the website.
• Use of Membership Roles to restrict access to pages.
• Utilizing ViewState and SessionState objects to save data between postbacks.
• Databinding through the ObjectDataSource control.
• Create a web interface that is intuitive and requires minimal training.
• Use various validation controls to validate input before postback.
Description To make the interface visually pleasing, yet functional, the
background images represent items a library would
normally use.
Each control had appropriate error validation controls
attached such that validation would occur through
JavaScript on the client.
The code behind files for each page contained the same
validations and provided the appropriate feedback in case
JavaScript was disabled.
The user interface used the same business layer
(JH.LibraryBusiness) as the previous phases of the project
with additional functionality added to complete the new
requirements.
The additional functionality of adding a book, updating a
juvenile member to an adult member, and renewing an
adult’s membership required the addition of several
Business Layer, Data Access Layer, and Stored
Procedures.
Jeff Huber [email protected] Page 14 of 20
SetFocus Project #4 - Library Phase 3(Web Application)
Screenshots
Login: The Login screen is used to allow only Librarian members access to the Library website.
Home page: After the Librarian logs into the website they are directed to a main home page that has a
description of the Library and/or any new information that may need to be given to them.
Jeff Huber [email protected] Page 15 of 20
SetFocus Project #4 - Library Phase 3(Web Application)
Display Expired Adult Member: If a membership is expired the expiration date will be displayed in red and a status label will
display asking if the Librarian wants to update the expired member’s membership.
Display Adult Member: Screen showing adult member information.
Jeff Huber [email protected] Page 16 of 20
SetFocus Project #4 - Library Phase 3(Web Application)
Display Juvenile Member: Screen showing juvenile member information. Juvenile member information adds the birthdate
and the sponsoring adult member’s member ID.
Check Out Book: Since you cannot check out a book without a member to check the book out I have incorporated
the check in book method directly in with the member information page. Just enter the ISBN
and Copy Number and a status label displays the information about the book and whether this is
the book needing to be checked out to the member.
Jeff Huber [email protected] Page 17 of 20
SetFocus Project #4 - Library Phase 3(Web Application)
Check In Book: The Check In Book displays a form to enter information about the book. After information is
entered and the OK button is clicked user is asked to confirm the check in of the book and also
gives the user the option to back out of the operation.
Add Book: This project had a requirement for the Librarian to have the ability to add a new book. This
picture shows the first step in adding a new book by determining whether the book is a
completely new book to the library or a new copy of an existing book already in the library.
Jeff Huber [email protected] Page 18 of 20
SetFocus Project #4 - Library Phase 3(Web Application)
Add Book: After entering the ISBN number of the book and you clicking the button. If the book already
exists in the database the screen display all the information about the book and ask the Librarian
if they would like to add the book to the library.
Add Book: If the book does not exist in the library the screen will display textboxes for the Librarian to
enter information about new book to be entered in the library.
Jeff Huber [email protected] Page 19 of 20
SetFocus Project #4 - Library Phase 3(Web Application)
Add Book: Once the Librarian enters information about the new book they will click the Add Book button
to enter the new book into the database.
Add Book: After clicking the button the librarian will be displayed information about what they just enter
and asked to confirm the addition of the new book.
Jeff Huber [email protected] Page 20 of 20
SetFocus Project #5 - Library Phase 5(Web Services)
Objective As the potential to acquire libraries and creating partnerships with other libraries was increasing,
there was a need to take the library system to the next level. To do this the need of Web
Services must be implemented. The Web Service will access the Business Layer of the system.
Due to the possibility of utilizing the service with partner libraries, security must be employed.
Requirements • Customization of XML attributes
• Employment of WSE 3.0 security setting • Usage of Certificates for Security, Signing, and Encryption • True N‐Tier structures • Creation and interpretation of custom SoapException objects • Dynamic creation of XML for inclusion in SoapExceptions
Requirements The goal of this phase of development was to separate the UI from the business and data layers. Certain business layer methods were overloaded. I reworked these for the web service since web services do not support overloaded methods. Certain properties of the Juvenile Member and Adult Member classes could not serialize due to the properties’ implementation techniques. Additional web methods and classes were developed to allow for the interoperability of these properties. The Add Member methods of the business layer simply modified the parameters passed in. Since web services are inherently one‐way, these were rewritten so the appropriate data was passed back to the UI layer. Another obstacle is that web services only throw SoapExceptions. I developed a method of encoding the type of error received from the business layer and encoding all appropriate information into a custom SoapException. This required dynamically creating an XML document and attaching it to the SoapException.