18
.Net Portfolio Christopher Latham [email protected] (360)223-8745

Christopher Latham Portfolio

Embed Size (px)

DESCRIPTION

Christopher Latham\'s Portfolio

Citation preview

Page 1: Christopher Latham Portfolio

.Net Portfolio

Christopher [email protected]

(360)223-8745

Page 2: Christopher Latham Portfolio

Table of Contents

• SetFocus Library System Overview• Windows Sample Forms and Code• Web Sample Forms and Code• Business Layer• Data Access Layer

Page 3: Christopher Latham Portfolio

SetFocus Library System• Introduction:

• This project is a simple library administration application.• Audience:

• The typical users would be librarians and library volunteers.• Project Goals:

• Both Windows and web based interfaces• Handle all common library functions (e.g. Check a book out, Add

a new library member, etc.) with minimal required training.• Easily maintained code.• Appropriate error handling.• Validation for all entered fields.

Page 4: Christopher Latham Portfolio

Windows – Main Interface

The main interface window provides access to all the main functions via the menu bar or tool strip. The grid view also provides a context menu for item related tasks.

Page 5: Christopher Latham Portfolio

Windows – Add Members

Form used to enter a new adult member. Fields are validated to ensure proper formatting.

Form used to add a new juvenile member. The Parent ID field is checked against the database to ensure that it is valid.

Page 6: Christopher Latham Portfolio

Windows – Check-In/Out

Check in form used to process items that have been returned.

Check out form used to process items when a member wishes to take an item from the library

Page 7: Christopher Latham Portfolio

Windows – Validation

• Validation is performed at form levelif (!IsValidName(firstNameTextBox.Text)){ if (FirstName.Length == 0) ValidatorErrorProvider.SetError(firstNameTextBox, "You must provide a valid first name"); else ValidatorErrorProvider.SetError(firstNameTextBox, "The first name must be capitalized and contain only letters"); isValid = false; }else

ValidatorErrorProvider.SetError(firstNameTextBox, string.Empty);

• Common validation is re-factored into separate methods private bool IsValidName(string name)

{ return Regex.IsMatch(name, @"^[A-Z][a-zA-Z]{0,14}$"); }

private bool IsValidPhone(string phone) { if(phone.Length > 0) return Regex.IsMatch(phone, @"^\([0-9]{3}\)[0-9]{3}-[0-9]{4}$"); return true; }

Page 8: Christopher Latham Portfolio

Web – Main Interface

Main interface of the web application. Navigation is done view the links along the left side. The system has a security feature that only allows registered librarians and volunteers access the interface.

Page 9: Christopher Latham Portfolio

Web – Get Member Info

Display of member information. Juvenile members also list the adult member ID and the member’s birth date.

Page 10: Christopher Latham Portfolio

Web – Add New MembersAdd Adult

Add Juvenile

Form used for entry of new adult members.

Form used for entry of new juvenile members.

Page 11: Christopher Latham Portfolio

Web – Add Item

Form used for entering a new item into the system. Form has validation of the ISBN so to prevent duplicate items.

Page 12: Christopher Latham Portfolio

Web – Check In Item Check In Entry

Check In Confirmation

Check In ErrorForm for checking in an item upon return.

Page to confirm check in of an item.

Page to notify user of possible error on check in.

Page 13: Christopher Latham Portfolio

Web – Check Out Item Check Out Entry

Check Out Confirmation

Check In/Out Confirmation

Page to confirm a check in of an item before check out.

Form for checking out an item from the library system.

Page to confirm check out of an item.

Page 14: Christopher Latham Portfolio

Web – Add New Item

Form used for entering a new item into the system. Form has validation of the ISBN so to prevent duplicate items

Page 15: Christopher Latham Portfolio

Web – Validation

• Validation is performed by the html code<asp:RequiredFieldValidator ID="firstNameReqValidator"

runat="server" ControlToValidate="firstNameTextBox“

ErrorMessage="You must provide a first name“ ForeColor="White">

</asp:RequiredFieldValidator> <asp:RegularExpressionValidator ID="firstNameRegExValidator“ runat="server“ ControlToValidate="firstNameTextBox" ErrorMessage="Firstname must be all lowercase except for the first letter“ ForeColor="White“ ValidationExpression="^[A-Z][a-zA-Z]{0,14}$"> </asp:RegularExpressionValidator>

Page 16: Christopher Latham Portfolio

Business Layer

• Packages objects to pass to Data Access Layer public short AddAdultMember(string firstName, string middleInitial, string lastName, string street, string city, string state, string zipcode, string

phone { AdultMember member = new AdultMember(); member.FirstName = firstName; member.MiddleInitial = middleInitial; member.LastName = lastName; member.Street = street; member.City = city; member.State = state; member.ZipCode = zipcode; member.PhoneNumber = phone;

try { lda.AddMember(member); return member.MemberID; } catch (LibraryException ex) { throw new LibraryException(ex.LibraryErrorCode, CreateErrorCodeString(ex.LibraryErrorCode)); } }

Page 17: Christopher Latham Portfolio

Business Layer

• Converts Data Access errors to appropriate Business Errorsprivate string CreateErrorCodeString(ErrorCode code){ string message; switch (code) { case ErrorCode.AddAdultFailed: message = "Failed to add new member"; break; case ErrorCode.AddJuvenileFailed: message = "Failed to add new member."; break; case ErrorCode.ItemNotCreated: message = "Item not created."; break; default: message = "Unsupported ErrorCode."; break; } return message; }

Page 18: Christopher Latham Portfolio

Data Access Layer• Database is accessed through Stored Procedures

using (SqlConnection con = new SqlConnection(Properties.Settings.Default.LibraryConnectionString)) { using (SqlCommand cmd = new SqlCommand("CheckIn", con)) { cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@isbn", isbn); cmd.Parameters.AddWithValue("@copy_no", copyNumber); con.Open(); cmd.ExecuteNonQuery(); } }

• Database errors are caught and passed to the Business Layercatch (SqlException ex) { if (ex.Number == 50009 || ex.Number == 50010) throw new LibraryException(ErrorCode.CheckInFailed, "You must provide a isbn AND a copy number"); if (ex.Number == 50011) throw new LibraryException(ErrorCode.ItemNotFound); if (ex.Number == 50014) throw new LibraryException(ErrorCode.ItemNotOnLoan); if (ex.Number == 50002) throw new LibraryException(ErrorCode.GenericException); throw; }