Christopher Latham Portfolio


Published on

Christopher Latham\'s Portfolio

  • Be the first to comment

  • Be the first to like this

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Christopher Latham Portfolio

  1. 1. .Net Portfolio Christopher Latham (360)223-8745
  2. 2. Table of Contents • SetFocus Library System Overview • Windows Sample Forms and Code • Web Sample Forms and Code • Business Layer • Data Access Layer
  3. 3. 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.
  4. 4. 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.
  5. 5. 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.
  6. 6. 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
  7. 7. Windows – Validation • Validation is performed at form level if (!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; }
  8. 8. 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.
  9. 9. Web – Get Member Info Display of member information. Juvenile members also list the adult member ID and the member’s birth date.
  10. 10. Web – Add New Members Add Adult Form used for entry of new adult members. Add Juvenile Form used for entry of new juvenile members.
  11. 11. Web – Add Item Form used for entering a new item into the system. Form has validation of the ISBN so to prevent duplicate items.
  12. 12. Web – Check In Item Check In Entry Check In Confirmation Form for checking in an item upon return. Check In Error Page to confirm check in of an item. Page to notify user of possible error on check in.
  13. 13. Web – Check Out Item Check Out Entry Check Out Confirmation Form for checking out an item from the library system. Check In/Out Confirmation Page to confirm check out of an item. Page to confirm a check in of an item before check out.
  14. 14. 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
  15. 15. 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>
  16. 16. 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)); } }
  17. 17. Business Layer • Converts Data Access errors to appropriate Business Errors private 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; }
  18. 18. 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 Layer catch (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; }
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.