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

More Related Content

PPT
Library Website
PPTX
Sql Objects And PL/SQL
PDF
Packages - PL/SQL
PDF
Dynamic websites lec3
PDF
Library Proposal
PPT
Library
DOC
Digital Library Project Proposal
DOCX
Tony Vitabile .Net Portfolio
Library Website
Sql Objects And PL/SQL
Packages - PL/SQL
Dynamic websites lec3
Library Proposal
Library
Digital Library Project Proposal
Tony Vitabile .Net Portfolio

Similar to Library Project Phase 1 (20)

DOC
Library Project
PPTX
Final Project Presentation
DOCX
Harmik Uchian Portfolio
PPTX
Il 09 T3 William Spreitzer
DOC
SetFocus Portfolio
PPT
.NET Code Examples
DOC
Library Project Marcelo Salvador
DOC
Email Program By Marcelo
PPTX
C#Portfolio
DOC
Martin Roy Portfolio
DOC
Email Program By Marcelo
DOC
Email Program By Marcelo
PPT
Nj 09 T2 David Frischknecht
PPTX
Back-2-Basics: .NET Coding Standards For The Real World (2011)
DOCX
SetFocus Portfolio
DOCX
Portfolio Martin Roy
DOCX
Portfolio Martin Roy
DOC
Library Project
PDF
Library Windows Project
DOC
Code Samples &amp; Screenshots
Library Project
Final Project Presentation
Harmik Uchian Portfolio
Il 09 T3 William Spreitzer
SetFocus Portfolio
.NET Code Examples
Library Project Marcelo Salvador
Email Program By Marcelo
C#Portfolio
Martin Roy Portfolio
Email Program By Marcelo
Email Program By Marcelo
Nj 09 T2 David Frischknecht
Back-2-Basics: .NET Coding Standards For The Real World (2011)
SetFocus Portfolio
Portfolio Martin Roy
Portfolio Martin Roy
Library Project
Library Windows Project
Code Samples &amp; Screenshots
Ad

Recently uploaded (20)

PPTX
Institutional Correction lecture only . . .
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
Pharma ospi slides which help in ospi learning
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Insiders guide to clinical Medicine.pdf
PPTX
Cell Structure & Organelles in detailed.
PPTX
Cell Types and Its function , kingdom of life
PDF
Sports Quiz easy sports quiz sports quiz
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Institutional Correction lecture only . . .
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Microbial disease of the cardiovascular and lymphatic systems
Pharma ospi slides which help in ospi learning
VCE English Exam - Section C Student Revision Booklet
O5-L3 Freight Transport Ops (International) V1.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
O7-L3 Supply Chain Operations - ICLT Program
Insiders guide to clinical Medicine.pdf
Cell Structure & Organelles in detailed.
Cell Types and Its function , kingdom of life
Sports Quiz easy sports quiz sports quiz
PPH.pptx obstetrics and gynecology in nursing
TR - Agricultural Crops Production NC III.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Renaissance Architecture: A Journey from Faith to Humanism
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Ad

Library Project Phase 1

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