Christopher Latham Portfolio


Published on

Christopher Latham\'s Portfolio

Published in: Education, Technology
  • 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. SetFocus Library System<br />Introduction: <br /><ul><li>This project is a simple library administration application.</li></ul>Audience: <br /><ul><li>The typical users would be librarians and library volunteers.</li></ul>Project Goals:<br /><ul><li>Both Windows and web based interfaces
  2. 2. Handle all common library functions (e.g. Check a book out, Add a new library member, etc.) with minimal required training.
  3. 3. Easily maintained code.
  4. 4. Appropriate error handling.
  5. 5. Validation for all entered fields.</li></ul>Code Samples<br />Windows Validation<br /> private bool IsValidMember()<br /> {<br /> bool isValid = true;<br /> if (!IsValidName(firstNameTextBox.Text))<br /> {<br /> if (FirstName.Length == 0)<br /> ValidatorErrorProvider.SetError(firstNameTextBox, " You must provide a valid first name" );<br /> else<br /> ValidatorErrorProvider.SetError(firstNameTextBox, " The first name must be capitalized and contain only letters" );<br /> isValid = false;<br /> }<br /> else<br /> ValidatorErrorProvider.SetError(firstNameTextBox, string.Empty);<br /> if (!IsValidName(lastNameTextBox.Text))<br /> {<br /> if (LastName.Length == 0)<br /> ValidatorErrorProvider.SetError(lastNameTextBox, " You must provide a valid last name" );<br /> else<br /> ValidatorErrorProvider.SetError(lastNameTextBox, " The last name must be capitalized and contain only letters" );<br /> isValid = false;<br /> }<br /> else<br /> ValidatorErrorProvider.SetError(lastNameTextBox, string.Empty);<br /> if (!IsValidMiddleInitial(MiddleInitial))<br /> {<br /> ValidatorErrorProvider.SetError(middleInitialTextBox, " The middle initial must be one capital letter or left blank" );<br /> isValid = false;<br /> }<br /> else<br /> ValidatorErrorProvider.SetError(middleInitialTextBox, string.Empty);<br /> if (!IsValidStreet(Street))<br /> {<br /> ValidatorErrorProvider.SetError(streetTextBox, " You must provide a valid street address" );<br /> isValid = false;<br /> }<br /> else<br /> ValidatorErrorProvider.SetError(streetTextBox, string.Empty);<br /> if (!IsValidCity(City))<br /> {<br /> <br /> ValidatorErrorProvider.SetError(cityTextBox, " You must provide a valid city name" );<br /> isValid = false;<br /> }<br /> else<br /> ValidatorErrorProvider.SetError(cityTextBox, string.Empty);<br /> if (!IsValidZipcode(Zipcode))<br /> {<br /> if (Zipcode.Length == 0)<br /> ValidatorErrorProvider.SetError(zipTextBox, " You must provide a valid zipcode" );<br /> else<br /> ValidatorErrorProvider.SetError(zipTextBox, " The zipcode must be of the format ##### or #####-####" );<br /> isValid = false;<br /> }<br /> else<br /> ValidatorErrorProvider.SetError(zipTextBox, string.Empty);<br /> if (!IsValidPhone(Phone))<br /> {<br /> ValidatorErrorProvider.SetError(phoneTextBox, " You must provide a valid phone number in the form (###)###-### or leave it blank" );<br /> isValid = false;<br /> }<br /> else<br /> ValidatorErrorProvider.SetError(phoneTextBox, string.Empty);<br /> addMemberButton.Enabled = isValid;<br /> return isValid;<br /> } <br />This section of code is in the AddNewAdultMember form and is used to validate all the data entered into the form. I chose to place it all in one method so that in order for the Add Member button to be accessible all required fields had valid information.<br />MemberInfo web page<br /> if (lbl.IsJuvenile(memberNumber))<br /> {<br /> TimeSpan adultAge = new TimeSpan(365 * 18, 0, 0, 0);<br /> if ((DateTime.Today - lbl.GetJuvenileMemberBirthdate(memberNumber)) > adultAge)<br /> {<br /> try<br /> {<br /> lbl.PromoteJuvenile(memberNumber);<br /> messageLabel.Text += lbl.GetMemberFirstName(memberNumber) + " " + lbl.GetMemberLastName(memberNumber) + " converted to an adult./n" ;<br /> }<br /> catch (LibraryException ex)<br /> {<br /> if (ex.LibraryErrorCode == ErrorCode.JuvenileNotOldEnough)<br /> messageLabel.Text += " Juvenile conversion failed, juvenile not old enough." ;<br /> else<br /> throw;<br /> }<br /> }<br /> birthdateLabelLabel.Visible = true;<br /> birthdateLabelLabel.Text = " Birthdate: " ;<br /> birthdateLabel.Text = lbl.GetJuvenileMemberBirthdate(memberNumber).ToLongDateString();<br /> adultMemberLabelLabel.Visible = true;<br /> adultMemberLabelLabel.Text = " Adult Member No: " ;<br /> adultMemberNumLabel.Text = lbl.GetJuvenileMemberAdultMemberID(memberNumber).ToString();<br /> }<br /> else<br /> {<br /> birthdateLabelLabel.Visible = false;<br /> birthdateLabel.Visible = false;<br /> adultMemberLabelLabel.Visible = false;<br /> adultMemberNumLabel.Visible = false; <br /> }<br />This section of code determines if a member is either an adult or juvenile. If a juvenile member is eligible to be promoted to an adult the conversion is done and a message is added to the page. If a member is an adult the birthdate and adultMemberNumber labels are made invisible. This reduces the number of pages that would need to be maintained if I had coded individual adult and juvenile pages.<br />Data Access Layer error handling<br />catch (SqlException ex)<br /> {<br /> if (ex.Number == 50009 || ex.Number == 50010)<br /> throw new LibraryException(ErrorCode.CheckOutFailed, " You must provide a isbn AND a copy number" );<br /> if (ex.Number == 50011)<br /> throw new LibraryException(ErrorCode.ItemNotFound);<br /> if (ex.Number == 50012)<br /> throw new LibraryException(ErrorCode.ItemNotLoanable," Item is not loanable" );<br /> if (ex.Number == 50002)<br /> throw new LibraryException(ErrorCode.GenericException);<br /> if (ex.Number == 50004)<br /> throw new LibraryException(ErrorCode.CheckOutFailed," You must provide a member_no" );<br /> if (ex.Number == 50005)<br /> throw new LibraryException(ErrorCode.NoSuchMember);<br /> if (ex.Number == 50013)<br /> throw new LibraryException(ErrorCode.ItemAlreadyOnLoan);<br /> if (ex.Number == 50016)<br /> throw new LibraryException(ErrorCode.MembershipExpired);<br /> throw;<br /> }<br />Errors that occur in the database are returned as just a number. This code converts the database error number s to a LibraryException, which is a custom exception written for this application.<br />SetFocus Library System<br />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.<br />Windows Check In<br />Check in form used to process items that have been returned.<br />Windows Check Out<br />Check out form used to process items when a member wishes to take an item from the library<br />Windows Add Adult<br />Form used to enter a new adult member. Fields are validated to ensure proper formatting.<br />Windows Add Juvenile<br />Form used to add a new juvenile member. The Parent ID field is checked against the database to ensure that it is valid.<br />Web Get Member Information<br />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.<br />Web Member Information<br />Display of member information. Juvenile members also list the adult member ID and the member’s birth date.<br />Web Add Adult Member<br />Form used for entry of new adult members.<br />Web Add Juvenile Member<br />Form used for entry of new juvenile members.<br />Web Add New Item<br />Form used for entering a new item into the system. Form has validation of the ISBN so to prevent duplicate items.<br />Web Check In<br />Form for checking in an item upon return.<br />Web Check Out<br />Form for checking on a item from the library system.<br />