Library Application

Post on 25-Dec-2014

502 views 0 download

description

 

Transcript of Library Application

.NET PortfolioJason Reilly

jasonzreilly@gmail.com(863)202-5228

Library ApplicationGoal: Create an n-tier library

application for a librarian to use for day to day activities.

Specifications: users must have the ability to…Look up member info by their member

IDCheck in/out books to members (up to 4

books allowed out at a time)Add new adult and juvenile membersAdd new items to the database and new

copies to existing ISBNs.

Member Information

• Members are searched by their member numbers.

• All the member’s information is displayed and the user can choose to check in/out books directly to the user from here.

• Validation takes place on the member number, ISBN, and Copy# to ensure valid numbers are entered.

Extra FunctionalityAutomatically converts juveniles to adults on

lookup when they reach 18 and alerts the librarian that the conversion took place.

Items currently past due are highlighted in yellow when the member’s information is displayed.

Sample Code: Windows Layer/// <summary>/// constructor takes in an object of type AdultMember and fills/// the text boxes accordingly/// </summary>public MemberInfo(AdultMember myMember){ InitializeComponent(); this.myMember = myMember; this.txtMemberId.Tag = new PatternAndMessage(@"\d{1,5}$", "Please input a

proper numeric value up to 5 digits long"); txtMemberId.Text = myMember.MemberID.ToString(); SetInfoToForm(myMember);}

Add Adult/Juvenile• Each box in these

windows is validated to ensure data integrity and prevent crashes

• Once each box is validated correctly, the member will be added and the new member is opened automatically in a member information window to begin check in/out.

Sample Code: Data Access Layerpublic void AddMember(JR.LibDataEntities.AdultMember am){ using (SqlConnection con = new

SqlConnection(Properties.Settings.Default.LibraryConnectionString)) { SqlCommand cmd = con.CreateCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "usp_AddAdult"; cmd.Parameters.AddWithValue("@lastname", am.LastName); cmd.Parameters.AddWithValue("@firstname", am.FirstName); cmd.Parameters.AddWithValue("@middleinitial",

am.MiddleInitial); cmd.Parameters.AddWithValue("@street", am.Street); cmd.Parameters.AddWithValue("@city", am.City); cmd.Parameters.AddWithValue("@state", am.State); cmd.Parameters.AddWithValue("@zip", am.ZipCode); cmd.Parameters.AddWithValue("@phone_no",

am.PhoneNumber); SqlParameter prm = new SqlParameter("@member_no",

SqlDbType.SmallInt); prm.Direction = ParameterDirection.Output; cmd.Parameters.Add(prm);

try { con.Open(); cmd.ExecuteNonQuery(); am.MemberID =

(short)cmd.Parameters["@member_no"].Value; } catch (SqlException sqlEx) { throw new LibraryException(sqlEx.Message); } catch (Exception) { throw new LibraryException(LibErrorCode.AddAdultFailed); } }}

public void AddMember(JuvenileMember jm){ using (SqlConnection con = new SqlConnection(Properties.Settings.Default.LibraryConnectionString)) {

SqlCommand cmd = con.CreateCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "usp_AddJuvenile"; cmd.Parameters.AddWithValue("@lastname", jm.LastName); cmd.Parameters.AddWithValue("@firstname", jm.FirstName); cmd.Parameters.AddWithValue("@middleinitial", jm.MiddleInitial); cmd.Parameters.AddWithValue("@adult_member_no", jm.AdultMemberID); cmd.Parameters.AddWithValue("@birth_date", jm.BirthDate); SqlParameter prm = new SqlParameter("@member_no", SqlDbType.SmallInt); prm.Direction = ParameterDirection.Output; cmd.Parameters.Add(prm);

try { con.Open(); cmd.ExecuteNonQuery(); jm.MemberID = (short)cmd.Parameters["@member_no"].Value; } catch (SqlException sqlEx) { throw new LibraryException(sqlEx.Message); } catch (Exception) { throw new LibraryException(LibErrorCode.AddJuvenileFailed); } }}

Library Web SiteGoal: Create a web site version Library

Application created.Added Functionality:

Librarian functions must be limited to users under an administrator role.

Librarians must be able to add new items and item copies to the database.

Login

Only users under the admin role will be granted access to the Librarian Functions.

Member Services

• Members are searched by their member numbers.

• All the member’s information is displayed and the user can choose to check in/out books directly to the user from here.

• Validation takes place on the member number, ISBN, and Copy# to ensure valid numbers are entered.

• To check in a book, all the user has to do is select the book in the data grid view and click the check in button.

Add Members• Each box on this page is validated to ensure data integrity and prevent crashes

• Once each box is validated correctly, the member will be added and the new ID is supplied.

Add Item• When adding an item with an ISBN that does not exist, the user is given the option to create a new item with that ISBN.

• When adding an item to an existing ISBN, the user is given the option to create an additional copy to that ISBN.