Library Application

12
.NET Portfolio Jason Reilly [email protected] (863)202-5228

description

 

Transcript of Library Application

Page 1: Library Application

.NET PortfolioJason Reilly

[email protected](863)202-5228

Page 2: Library Application

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.

Page 3: Library Application

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.

Page 4: Library Application

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.

Page 5: Library Application

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);}

Page 6: Library Application

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.

Page 7: Library Application

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); } }}

Page 8: Library Application

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.

Page 9: Library Application

Login

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

Page 10: Library Application

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.

Page 11: Library Application

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.

Page 12: Library Application

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.