Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Library Project Phase 1
 
Library Project <ul><li>This Library project will use two class objects to </li></ul><ul><li>work with the menu form. The ...
 
Validation Class <ul><li>using System; </li></ul><ul><li>using System.Collections.Generic; </li></ul><ul><li>using System....
Validation Class <ul><li>public bool AllUpperCase(string inputChar) </li></ul><ul><li>{ </li></ul><ul><li>if (All_Caps_Reg...
Validation Class <ul><li>/// <summary> </li></ul><ul><li>/// verify that string of charaters following the capitalized  </...
Validation Class <ul><li>/// <summary> </li></ul><ul><li>/// verify the zip pattern is ##### or #####-#### </li></ul><ul><...
Validation Class <ul><li>/// <summary> </li></ul><ul><li>/// verify that the phone number is (###)###-#### </li></ul><ul><...
Validation Class <ul><li>/// <summary> </li></ul><ul><li>/// verify that the birthday is mm/dd/yyyy </li></ul><ul><li>/// ...
Validation Class <ul><li>/// <summary> </li></ul><ul><li>/// The confirmDate is check the juvenile's birthday to make sure...
Validation Class <ul><li>/// <summary> </li></ul><ul><li>/// The validateCheckout method will  </li></ul><ul><li>/// check...
Validation Class <ul><li>public StringBuilder ValidateCheckOut(Int32 bc) </li></ul><ul><li>{ </li></ul><ul><li>StringBuild...
Validation Class <ul><li>#region-EvaluateExpirationDate </li></ul><ul><li>//This is the method I should use to return </li...
Business Layer Class <ul><li>using System; </li></ul><ul><li>using System.Collections.Generic; </li></ul><ul><li>using Sys...
Business Layer Class <ul><li>/// <summary> </li></ul><ul><li>/// This method will retrive member Id. </li></ul><ul><li>///...
Business Layer Class <ul><li>/// <summary> </li></ul><ul><li>/// The Add New Member method is overloaded to take both adul...
Businss Layer Class <ul><li>/// <summary> </li></ul><ul><li>/// Get Member book Info will return a  </li></ul><ul><li>/// ...
Business Layer Class <ul><li>/// <summary> </li></ul><ul><li>/// Get Member book Info will return a  </li></ul><ul><li>///...
Business Layer Class <ul><li>/// <summary> </li></ul><ul><li>/// CheckIn method will check in books </li></ul><ul><li>/// ...
Business Layer Class <ul><li>/// <summary> </li></ul><ul><li>/// This will get the items in the Item class and return an o...
Business Layer Class <ul><li>/// </summary> </li></ul><ul><li>/// <param name=&quot;mem&quot;></param> </li></ul><ul><li>/...
Upcoming SlideShare
Loading in …5
×

Library Project Phase 1

1,128 views

Published on

Project written in C#

Published in: Education, Technology
  • Be the first to comment

Library Project Phase 1

  1. 1. Library Project Phase 1
  2. 3. Library Project <ul><li>This Library project will use two class objects to </li></ul><ul><li>work with the menu form. The first class object </li></ul><ul><li>is the businesslayer bl. This object will do </li></ul><ul><li>Library functions such as get MemberID, Check in </li></ul><ul><li>and out books. The second class object Validation </li></ul><ul><li>V will perform validation on the required </li></ul><ul><li>fields in the add new members menu. Each Method </li></ul><ul><li>and events will be decribed below. </li></ul><ul><li>T he following e xceptions will be handled </li></ul><ul><li>LibraryException, ArgumentNullException, </li></ul><ul><li>ArgumentOutOfRangeException,OverflowException </li></ul><ul><li>and FormatException. </li></ul>
  3. 5. Validation Class <ul><li>using System; </li></ul><ul><li>using System.Collections.Generic; </li></ul><ul><li>using System.Text; </li></ul><ul><li>using System.Text.RegularExpressions; </li></ul><ul><li>namespace JG.LibraryWinClient </li></ul><ul><li>{ </li></ul><ul><li>public class Validation </li></ul><ul><li>{ </li></ul><ul><li>enum Colors </li></ul><ul><li>{ </li></ul><ul><li>White, </li></ul><ul><li>Yellow, </li></ul><ul><li>Red </li></ul><ul><li>}; </li></ul><ul><li>/// <summary> </li></ul><ul><li>// method will check to see if the first charactor is upper class </li></ul><ul><li>/// </summary> </li></ul><ul><li>/// </li></ul><ul><li>#region- Upper check </li></ul><ul><li>const string ALL_CAPS_PATTERN = &quot;[a-z]&quot;; </li></ul><ul><li>static readonly Regex All_Caps_Regex = </li></ul><ul><li>new Regex(ALL_CAPS_PATTERN); </li></ul>
  4. 6. Validation Class <ul><li>public bool AllUpperCase(string inputChar) </li></ul><ul><li>{ </li></ul><ul><li>if (All_Caps_Regex.IsMatch(inputChar)) </li></ul><ul><li>{ </li></ul><ul><li>return false; </li></ul><ul><li>} </li></ul><ul><li>return true; </li></ul><ul><li>} </li></ul><ul><li>#endregion </li></ul><ul><li>/// <summary> </li></ul><ul><li>/// verify that a string is alphabits only </li></ul><ul><li>/// </summary> </li></ul><ul><li>/// <param name=&quot;strToCheck&quot;></param> </li></ul><ul><li>/// <returns></returns> </li></ul><ul><li>/// </li></ul><ul><li>#region-Alpha check for members </li></ul><ul><li>public bool IsAlpha(String strToCheck) </li></ul><ul><li>{ </li></ul><ul><li>Regex objAlphaPattern = new Regex(&quot;[^a-zA-Z]&quot;); </li></ul><ul><li>return !objAlphaPattern.IsMatch(strToCheck); </li></ul><ul><li>} </li></ul><ul><li>#endregion </li></ul>
  5. 7. Validation Class <ul><li>/// <summary> </li></ul><ul><li>/// verify that string of charaters following the capitalized </li></ul><ul><li>/// first letter are in lower case. </li></ul><ul><li>/// </summary> </li></ul><ul><li>#region-Firstletter upper rest lower </li></ul><ul><li>const string ALL_Lower_PATTERN = &quot;[A-Z]&quot;; </li></ul><ul><li>static readonly Regex All_LowCap_Regex = </li></ul><ul><li>new Regex(ALL_Lower_PATTERN); </li></ul><ul><li>public bool AllLowerCase(string inputstring) </li></ul><ul><li>{ </li></ul><ul><li>if (All_LowCap_Regex.IsMatch(inputstring)) </li></ul><ul><li>{ </li></ul><ul><li>return false; </li></ul><ul><li>} </li></ul><ul><li>return true; </li></ul><ul><li>} </li></ul><ul><li>#endregion </li></ul>
  6. 8. Validation Class <ul><li>/// <summary> </li></ul><ul><li>/// verify the zip pattern is ##### or #####-#### </li></ul><ul><li>/// </summary> </li></ul><ul><li>/// <param name=&quot;num&quot;></param> </li></ul><ul><li>/// <returns></returns> </li></ul><ul><li>#region-Zip pattern check </li></ul><ul><li>public bool ZipCheck(string num) </li></ul><ul><li>{ </li></ul><ul><li>string pattern = @&quot;^(d{5}-d{4}|d{5}|d{9})$&quot;; </li></ul><ul><li>Regex match = new Regex(pattern); </li></ul><ul><li>return match.IsMatch(num); </li></ul><ul><li>} </li></ul><ul><li>#endregion </li></ul>
  7. 9. Validation Class <ul><li>/// <summary> </li></ul><ul><li>/// verify that the phone number is (###)###-#### </li></ul><ul><li>/// </summary> </li></ul><ul><li>/// <param name=&quot;num&quot;></param> </li></ul><ul><li>/// <returns></returns> </li></ul><ul><li>#region-Phone validation </li></ul><ul><li>public bool Phone(string num) </li></ul><ul><li>{ </li></ul><ul><li>string pattern = &quot;&quot;; </li></ul><ul><li>Regex match = new Regex(pattern); </li></ul><ul><li>if (match.IsMatch(num)) </li></ul><ul><li>{ </li></ul><ul><li>return true; </li></ul><ul><li>} </li></ul><ul><li>return false; </li></ul><ul><li>} </li></ul><ul><li>#endregion </li></ul>
  8. 10. Validation Class <ul><li>/// <summary> </li></ul><ul><li>/// verify that the birthday is mm/dd/yyyy </li></ul><ul><li>/// </summary> </li></ul><ul><li>/// <param name=&quot;day&quot;></param> </li></ul><ul><li>/// <returns></returns> </li></ul><ul><li>#region-birthday validation </li></ul><ul><li>public bool Birthday(string day) </li></ul><ul><li>{ </li></ul><ul><li>string pattern = &quot;^([1-9]|0[1-9]|1[012])[ /.]([1-9]|0[1-9]|[12][0-9]|3[01])[ /.][0-9]{4}$&quot;; </li></ul><ul><li>Regex match = new Regex(pattern); </li></ul><ul><li>return match.IsMatch(day); </li></ul><ul><li>} </li></ul><ul><li>#endregion </li></ul>
  9. 11. Validation Class <ul><li>/// <summary> </li></ul><ul><li>/// The confirmDate is check the juvenile's birthday to make sure </li></ul><ul><li>/// it is within 18 years. </li></ul><ul><li>/// </summary> </li></ul><ul><li>/// <param name=&quot;d&quot;></param> </li></ul><ul><li>/// <returns></returns> </li></ul><ul><li>#region-check birthday for under 18 </li></ul><ul><li>public bool ConfirmDate(DateTime d) </li></ul><ul><li>{ </li></ul><ul><li>int yrs; </li></ul><ul><li>yrs = DateTime.Compare(DateTime.Now, d.AddYears(18)); </li></ul><ul><li>if (yrs >= 0) </li></ul><ul><li>{ return false; } </li></ul><ul><li>else </li></ul><ul><li>{ return true; } </li></ul><ul><li>} </li></ul>
  10. 12. Validation Class <ul><li>/// <summary> </li></ul><ul><li>/// The validateCheckout method will </li></ul><ul><li>/// check to see if a member is eligiable for </li></ul><ul><li>/// checking out books. </li></ul><ul><li>/// </summary> </li></ul><ul><li>/// <param name=&quot;D&quot;></param> </li></ul><ul><li>/// <param name=&quot;bc&quot;></param> </li></ul><ul><li>/// <returns></returns> </li></ul><ul><li>#region- ValidateCheckOut </li></ul><ul><li>public StringBuilder ValidateCheckOut(DateTime D, Int32 bc) </li></ul><ul><li>{ </li></ul><ul><li>StringBuilder Sb = new StringBuilder(); </li></ul><ul><li>int dc = DateTime.Compare(DateTime.Now, D); </li></ul><ul><li>if (dc >= 0) </li></ul><ul><li>{ </li></ul><ul><li>Sb.Append(&quot;Member membership has expired &quot;); </li></ul><ul><li>} </li></ul><ul><li>if (bc >= 4 && dc >= 0) </li></ul><ul><li>{ </li></ul><ul><li>Sb.Append(&quot; and member will exceed maximum allowed books for checkout&quot;); </li></ul><ul><li>} </li></ul><ul><li>else if (bc >= 4) </li></ul><ul><li>{ </li></ul><ul><li>Sb.Append(&quot;Member will exceed maximum allowed books for checkout&quot;); </li></ul><ul><li>} </li></ul><ul><li>return Sb; </li></ul><ul><li>} </li></ul>
  11. 13. Validation Class <ul><li>public StringBuilder ValidateCheckOut(Int32 bc) </li></ul><ul><li>{ </li></ul><ul><li>StringBuilder Sb = new StringBuilder(); </li></ul><ul><li>if (bc >= 4) </li></ul><ul><li>{ </li></ul><ul><li>Sb.Append(&quot;Member will exceed maximum allowed books for checkout&quot;); </li></ul><ul><li>} </li></ul><ul><li>return Sb; </li></ul><ul><li>} </li></ul><ul><li>#endregion </li></ul>
  12. 14. Validation Class <ul><li>#region-EvaluateExpirationDate </li></ul><ul><li>//This is the method I should use to return </li></ul><ul><li>//the color change for the expiration textbox </li></ul><ul><li>//in the Check out book tab. </li></ul><ul><li>public Enum ChangeColor(DateTime d) </li></ul><ul><li>{ </li></ul><ul><li>int expireDate; </li></ul><ul><li>Colors c = new Colors(); </li></ul><ul><li>c = Colors.White; </li></ul><ul><li>expireDate = DateTime.Compare(DateTime.Now.AddDays(7), d); </li></ul><ul><li>if (expireDate > 0) </li></ul><ul><li>{ </li></ul><ul><li>c = Colors.Yellow; </li></ul><ul><li>} </li></ul><ul><li>expireDate = DateTime.Compare(DateTime.Now, d); </li></ul><ul><li>if (expireDate >= 0) </li></ul><ul><li>{ </li></ul><ul><li>c = Colors.Red; </li></ul><ul><li>} </li></ul><ul><li>return c; </li></ul><ul><li>} </li></ul><ul><li>#endregion </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  13. 15. Business Layer Class <ul><li>using System; </li></ul><ul><li>using System.Collections.Generic; </li></ul><ul><li>using System.Text; </li></ul><ul><li>using SetFocus.Library.DataAccess; </li></ul><ul><li>using SetFocus.Library.Entities; </li></ul><ul><li>using System.Data; </li></ul><ul><li>namespace JG.LibraryBusiness </li></ul><ul><li>{ </li></ul><ul><li>public class BusinessLayer </li></ul><ul><li>{ </li></ul><ul><li>public BusinessLayer() </li></ul><ul><li>{ </li></ul><ul><li>} </li></ul>
  14. 16. Business Layer Class <ul><li>/// <summary> </li></ul><ul><li>/// This method will retrive member Id. </li></ul><ul><li>/// </summary> </li></ul><ul><li>/// <param name=&quot;memberId&quot;></param> </li></ul><ul><li>/// <returns></returns> </li></ul><ul><li>#region - Get Member ID </li></ul><ul><li>public Member GetInformation(short memberId) </li></ul><ul><li>{ </li></ul><ul><li>// Create a library data access object </li></ul><ul><li>LibraryDataAccess lda = new LibraryDataAccess(); </li></ul><ul><li>// Call the GetMember() method and pass in a member id </li></ul><ul><li>Member myMember = lda.GetMember(memberId); </li></ul><ul><li>// return the retrieved member </li></ul><ul><li>return myMember; </li></ul><ul><li>} </li></ul><ul><li>#endregion </li></ul>
  15. 17. Business Layer Class <ul><li>/// <summary> </li></ul><ul><li>/// The Add New Member method is overloaded to take both adult and juvenile members </li></ul><ul><li>/// </summary> </li></ul><ul><li>/// <param name=&quot;J&quot;></param> </li></ul><ul><li>#region- Add new members </li></ul><ul><li>public void AddNewMember(JuvenileMember J) </li></ul><ul><li>{ </li></ul><ul><li>LibraryDataAccess lda = new LibraryDataAccess(); </li></ul><ul><li>lda.AddMember(J); </li></ul><ul><li>} </li></ul><ul><li>public void AddNewMember(AdultMember A) </li></ul><ul><li>{ </li></ul><ul><li>LibraryDataAccess lda = new LibraryDataAccess(); </li></ul><ul><li>lda.AddMember(A); </li></ul><ul><li>} </li></ul><ul><li>#endregion </li></ul>
  16. 18. Businss Layer Class <ul><li>/// <summary> </li></ul><ul><li>/// Get Member book Info will return a </li></ul><ul><li>/// dataset of all the books that </li></ul><ul><li>/// are currently checked out by the member </li></ul><ul><li>/// </li></ul><ul><li>/// </summary> </li></ul><ul><li>/// <param name=&quot;num&quot;></param> </li></ul><ul><li>/// <returns>Dataset</returns> </li></ul><ul><li>#region -Get Member's book information </li></ul><ul><li>public DataSet GetCheckoutInfo(Int16 num) </li></ul><ul><li>{ </li></ul><ul><li>LibraryDataAccess lda = new LibraryDataAccess(); </li></ul><ul><li>DataSet Ds = lda.GetItems(num); </li></ul><ul><li>return Ds; </li></ul><ul><li>} </li></ul><ul><li>#endregion </li></ul>
  17. 19. Business Layer Class <ul><li>/// <summary> </li></ul><ul><li>/// Get Member book Info will return a </li></ul><ul><li>/// dataset of all the books that </li></ul><ul><li>/// are currently checked out by the member </li></ul><ul><li>/// </li></ul><ul><li>/// </summary> </li></ul><ul><li>/// <param name=&quot;num&quot;></param> </li></ul><ul><li>/// <returns>Dataset</returns> </li></ul><ul><li>#region -Get Member's book information </li></ul><ul><li>public DataSet GetCheckoutInfo(Int16 num) </li></ul><ul><li>{ </li></ul><ul><li>LibraryDataAccess lda = new LibraryDataAccess(); </li></ul><ul><li>DataSet Ds = lda.GetItems(num); </li></ul><ul><li>return Ds; </li></ul><ul><li>} </li></ul><ul><li>#endregion </li></ul>
  18. 20. Business Layer Class <ul><li>/// <summary> </li></ul><ul><li>/// CheckIn method will check in books </li></ul><ul><li>/// </summary> </li></ul><ul><li>/// <param name=&quot;isbn&quot;></param> </li></ul><ul><li>/// <param name=&quot;Cnum&quot;></param> </li></ul><ul><li>#region-CheckIn </li></ul><ul><li>public void CheckIn(Int32 isbn, Int16 Cnum) </li></ul><ul><li>{ </li></ul><ul><li>LibraryDataAccess lda = new LibraryDataAccess(); </li></ul><ul><li>lda.CheckInItem(isbn, Cnum); </li></ul><ul><li>} </li></ul><ul><li>#endregion </li></ul>
  19. 21. Business Layer Class <ul><li>/// <summary> </li></ul><ul><li>/// This will get the items in the Item class and return an object </li></ul><ul><li>/// </summary> </li></ul><ul><li>/// <param name=&quot;isbn&quot;></param> </li></ul><ul><li>/// <param name=&quot;Cnum&quot;></param> </li></ul><ul><li>/// <returns>Item Object</returns> </li></ul><ul><li>#region-GetItem </li></ul><ul><li>public object GetItem(Int32 isbn,Int16 Cnum) </li></ul><ul><li>{ </li></ul><ul><li>LibraryDataAccess ld = new LibraryDataAccess(); </li></ul><ul><li>Item It = ld.GetItem(isbn, Cnum); </li></ul><ul><li>return It; </li></ul><ul><li>} </li></ul><ul><li>#endregion </li></ul>
  20. 22. Business Layer Class <ul><li>/// </summary> </li></ul><ul><li>/// <param name=&quot;mem&quot;></param> </li></ul><ul><li>/// <param name=&quot;isdn&quot;></param> </li></ul><ul><li>/// <param name=&quot;copy&quot;></param> </li></ul><ul><li>#region-Check Out </li></ul><ul><li>public void CheckOut(Int16 mem, Int32 isdn, Int16 copy) </li></ul><ul><li>{ </li></ul><ul><li>try </li></ul><ul><li>{ </li></ul><ul><li>LibraryDataAccess lda = new LibraryDataAccess(); </li></ul><ul><li>lda.CheckOutItem(mem, isdn, copy); </li></ul><ul><li>} </li></ul><ul><li>catch (LibraryException) </li></ul><ul><li>{ } </li></ul><ul><li>} </li></ul><ul><li>#endregion </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>

×