SlideShare a Scribd company logo
1 of 18
.Net Portfolio
   Christopher Latham
 lathamcl@gmail.com
        (360)223-8745
Table of Contents
•   SetFocus Library System Overview
•   Windows Sample Forms and Code
•   Web Sample Forms and Code
•   Business Layer
•   Data Access Layer
SetFocus Library System
• Introduction:
   • This project is a simple library administration application.
• Audience:
   • The typical users would be librarians and library volunteers.
• Project Goals:
   • Both Windows and web based interfaces
   • Handle all common library functions (e.g. Check a book out, Add
     a new library member, etc.) with minimal required training.
   • Easily maintained code.
   • Appropriate error handling.
   • Validation for all entered fields.
Windows – Main Interface




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.
Windows – Add Members




           Form used to enter a new adult member. Fields are validated to ensure proper formatting.




Form used to add a new juvenile member. The Parent ID field is checked against the database to ensure that it is valid.
Windows – Check-In/Out




               Check in form used to process items that have been returned.




Check out form used to process items when a member wishes to take an item from the library
Windows – Validation
• Validation is performed at form level
   if (!IsValidName(firstNameTextBox.Text))
   {
         if (FirstName.Length == 0)
                  ValidatorErrorProvider.SetError(firstNameTextBox, "You must provide a valid first name");
         else
                  ValidatorErrorProvider.SetError(firstNameTextBox, "The first name must be capitalized and contain only letters");
         isValid = false;
      }
   else
           ValidatorErrorProvider.SetError(firstNameTextBox, string.Empty);

• Common validation is re-factored into separate methods
   private bool IsValidName(string name)
   {
            return Regex.IsMatch(name, @"^[A-Z][a-zA-Z]{0,14}$");
   }
   private bool IsValidPhone(string phone)
   {
             if(phone.Length > 0)
                   return Regex.IsMatch(phone, @"^([0-9]{3})[0-9]{3}-[0-9]{4}$");
             return true;
   }
Web – Main Interface




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.
Web – Get Member Info




Display of member information. Juvenile members also list the adult member ID and the member’s birth date.
Web – Add New Members
                   Add Adult




      Form used for entry of new adult members.

                 Add Juvenile




     Form used for entry of new juvenile members.
Web – Add Item




Form used for entering a new item into the system. Form has validation of the ISBN so to prevent duplicate items.
Web – Check In Item
            Check In Entry




                                                     Check In Confirmation




    Form for checking in an item upon return.

             Check In Error



                                                     Page to confirm check in of an item.




Page to notify user of possible error on check in.
Web – Check Out Item
            Check Out Entry



                                                             Check Out Confirmation




Form for checking out an item from the library system.
      Check In/Out Confirmation


                                                            Page to confirm check out of an item.




  Page to confirm a check in of an item before check out.
Web – Add New Item




Form used for entering a new item into the system. Form has validation of the ISBN so to prevent duplicate items
Web – Validation
• Validation is performed by the html code
  <asp:RequiredFieldValidator ID="firstNameReqValidator"
                                runat="server"
                                ControlToValidate="firstNameTextBox“
                                ErrorMessage="You must provide a first name“
                                ForeColor="White">
  </asp:RequiredFieldValidator>
   <asp:RegularExpressionValidator ID="firstNameRegExValidator“
                                    runat="server“
                                    ControlToValidate="firstNameTextBox"
                                    ErrorMessage="Firstname must be all lowercase except for the first letter“
                                    ForeColor="White“
                                    ValidationExpression="^[A-Z][a-zA-Z]{0,14}$">
   </asp:RegularExpressionValidator>
Business Layer
• Packages objects to pass to Data Access Layer
  public short AddAdultMember(string firstName, string middleInitial, string lastName, string street, string city, string state, string zipcode, string
  phone
  {
     AdultMember member = new AdultMember();
     member.FirstName = firstName;
     member.MiddleInitial = middleInitial;
     member.LastName = lastName;
     member.Street = street;
     member.City = city;
     member.State = state;
     member.ZipCode = zipcode;
     member.PhoneNumber = phone;

      try
      {
         lda.AddMember(member);
         return member.MemberID;
      }
      catch (LibraryException ex)
      {
          throw new LibraryException(ex.LibraryErrorCode, CreateErrorCodeString(ex.LibraryErrorCode));
       }
  }
Business Layer
• Converts Data Access errors to appropriate Business Errors
   private string CreateErrorCodeString(ErrorCode code)
   {
       string message;
       switch (code)
       {
             case ErrorCode.AddAdultFailed:
               message = "Failed to add new member";
               break;
             case ErrorCode.AddJuvenileFailed:
               message = "Failed to add new member.";
               break;
             case ErrorCode.ItemNotCreated:
               message = "Item not created.";
               break;
             default:
               message = "Unsupported ErrorCode.";
               break;
         }
         return message;
     }
Data Access Layer
• Database is accessed through Stored Procedures
   using (SqlConnection con = new SqlConnection(Properties.Settings.Default.LibraryConnectionString))
   {
           using (SqlCommand cmd = new SqlCommand("CheckIn", con))
           {
                 cmd.CommandType = System.Data.CommandType.StoredProcedure;
                 cmd.Parameters.AddWithValue("@isbn", isbn);
                 cmd.Parameters.AddWithValue("@copy_no", copyNumber);
                 con.Open();
                 cmd.ExecuteNonQuery();
             }
     }


• Database errors are caught and passed to the Business Layer
   catch (SqlException ex)
    {
          if (ex.Number == 50009 || ex.Number == 50010)
                throw new LibraryException(ErrorCode.CheckInFailed, "You must provide a isbn AND a copy number");
          if (ex.Number == 50011)
                throw new LibraryException(ErrorCode.ItemNotFound);
          if (ex.Number == 50014)
                throw new LibraryException(ErrorCode.ItemNotOnLoan);
          if (ex.Number == 50002)
                throw new LibraryException(ErrorCode.GenericException);
          throw;
      }

More Related Content

What's hot

WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISEWINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISEHitesh Mohapatra
 
Parsing in ios to create an app
Parsing in ios to create an appParsing in ios to create an app
Parsing in ios to create an appHeaderLabs .
 
Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4DEVCON
 
Hidden Docs in Angular
Hidden Docs in AngularHidden Docs in Angular
Hidden Docs in AngularYadong Xie
 
Python Code Camp for Professionals 2/4
Python Code Camp for Professionals 2/4Python Code Camp for Professionals 2/4
Python Code Camp for Professionals 2/4DEVCON
 
Typed? Dynamic? Both! Cross-platform DSLs in C#
Typed? Dynamic? Both! Cross-platform DSLs in C#Typed? Dynamic? Both! Cross-platform DSLs in C#
Typed? Dynamic? Both! Cross-platform DSLs in C#Vagif Abilov
 
Android ui layouts ,cntls,webservices examples codes
Android ui layouts ,cntls,webservices examples codesAndroid ui layouts ,cntls,webservices examples codes
Android ui layouts ,cntls,webservices examples codesAravindharamanan S
 
Dompletion: DOM-Aware JavaScript Code Completion
Dompletion: DOM-Aware JavaScript Code CompletionDompletion: DOM-Aware JavaScript Code Completion
Dompletion: DOM-Aware JavaScript Code CompletionSALT Lab @ UBC
 
Python Code Camp for Professionals 1/4
Python Code Camp for Professionals 1/4Python Code Camp for Professionals 1/4
Python Code Camp for Professionals 1/4DEVCON
 
ActiveRecord Query Interface (2), Season 2
ActiveRecord Query Interface (2), Season 2ActiveRecord Query Interface (2), Season 2
ActiveRecord Query Interface (2), Season 2RORLAB
 
Micro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicateMicro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicateKiev ALT.NET
 
16 interacting with user data contacts and appointments
16   interacting with user data contacts and appointments16   interacting with user data contacts and appointments
16 interacting with user data contacts and appointmentsWindowsPhoneRocks
 
Introduction to Active Record - Silicon Valley Ruby Conference 2007
Introduction to Active Record - Silicon Valley Ruby Conference 2007Introduction to Active Record - Silicon Valley Ruby Conference 2007
Introduction to Active Record - Silicon Valley Ruby Conference 2007Rabble .
 
Tutorial, Part 3: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 3: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...Tutorial, Part 3: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 3: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...SPTechCon
 
SPFx working with SharePoint data
SPFx working with SharePoint dataSPFx working with SharePoint data
SPFx working with SharePoint dataVladimir Medina
 
SPFx: Working with SharePoint Content
SPFx: Working with SharePoint ContentSPFx: Working with SharePoint Content
SPFx: Working with SharePoint ContentVladimir Medina
 
บทที่1
บทที่1บทที่1
บทที่1Palm Unnop
 

What's hot (18)

WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISEWINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
 
Parsing in ios to create an app
Parsing in ios to create an appParsing in ios to create an app
Parsing in ios to create an app
 
Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4
 
Hidden Docs in Angular
Hidden Docs in AngularHidden Docs in Angular
Hidden Docs in Angular
 
Python Code Camp for Professionals 2/4
Python Code Camp for Professionals 2/4Python Code Camp for Professionals 2/4
Python Code Camp for Professionals 2/4
 
Typed? Dynamic? Both! Cross-platform DSLs in C#
Typed? Dynamic? Both! Cross-platform DSLs in C#Typed? Dynamic? Both! Cross-platform DSLs in C#
Typed? Dynamic? Both! Cross-platform DSLs in C#
 
Android ui layouts ,cntls,webservices examples codes
Android ui layouts ,cntls,webservices examples codesAndroid ui layouts ,cntls,webservices examples codes
Android ui layouts ,cntls,webservices examples codes
 
Dompletion: DOM-Aware JavaScript Code Completion
Dompletion: DOM-Aware JavaScript Code CompletionDompletion: DOM-Aware JavaScript Code Completion
Dompletion: DOM-Aware JavaScript Code Completion
 
Python Code Camp for Professionals 1/4
Python Code Camp for Professionals 1/4Python Code Camp for Professionals 1/4
Python Code Camp for Professionals 1/4
 
ActiveRecord Query Interface (2), Season 2
ActiveRecord Query Interface (2), Season 2ActiveRecord Query Interface (2), Season 2
ActiveRecord Query Interface (2), Season 2
 
Micro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicateMicro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicate
 
ajax_pdf
ajax_pdfajax_pdf
ajax_pdf
 
16 interacting with user data contacts and appointments
16   interacting with user data contacts and appointments16   interacting with user data contacts and appointments
16 interacting with user data contacts and appointments
 
Introduction to Active Record - Silicon Valley Ruby Conference 2007
Introduction to Active Record - Silicon Valley Ruby Conference 2007Introduction to Active Record - Silicon Valley Ruby Conference 2007
Introduction to Active Record - Silicon Valley Ruby Conference 2007
 
Tutorial, Part 3: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 3: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...Tutorial, Part 3: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 3: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
 
SPFx working with SharePoint data
SPFx working with SharePoint dataSPFx working with SharePoint data
SPFx working with SharePoint data
 
SPFx: Working with SharePoint Content
SPFx: Working with SharePoint ContentSPFx: Working with SharePoint Content
SPFx: Working with SharePoint Content
 
บทที่1
บทที่1บทที่1
บทที่1
 

Similar to Christopher Latham Portfolio

My Portfolio
My PortfolioMy Portfolio
My Portfolioz02247
 
JavaScript - Chapter 14 - Form Handling
 JavaScript - Chapter 14 - Form Handling   JavaScript - Chapter 14 - Form Handling
JavaScript - Chapter 14 - Form Handling WebStackAcademy
 
Nj 09 T2 David Frischknecht
Nj 09 T2 David FrischknechtNj 09 T2 David Frischknecht
Nj 09 T2 David Frischknechtfishnet37222
 
My Portfolio
My PortfolioMy Portfolio
My Portfolioaemartin4
 
Apex Testing and Best Practices
Apex Testing and Best PracticesApex Testing and Best Practices
Apex Testing and Best PracticesJitendra Zaa
 
Introduction to apex code
Introduction to apex codeIntroduction to apex code
Introduction to apex codeEdwinOstos
 
Library Project
Library ProjectLibrary Project
Library ProjectMauro_Sist
 
Local data storage for mobile apps
Local data storage for mobile appsLocal data storage for mobile apps
Local data storage for mobile appsIvano Malavolta
 
Form demoinplaywithmysql
Form demoinplaywithmysqlForm demoinplaywithmysql
Form demoinplaywithmysqlKnoldus Inc.
 
Mark Jackson\'s Portfoilo
Mark Jackson\'s PortfoiloMark Jackson\'s Portfoilo
Mark Jackson\'s PortfoiloMark_Jackson
 
Local storage in Web apps
Local storage in Web appsLocal storage in Web apps
Local storage in Web appsIvano Malavolta
 
Web Technologies - forms and actions
Web Technologies -  forms and actionsWeb Technologies -  forms and actions
Web Technologies - forms and actionsAren Zomorodian
 
Secure Dot Net Programming
Secure Dot Net ProgrammingSecure Dot Net Programming
Secure Dot Net ProgrammingAdam Getchell
 
API first with Swagger and Scala by Slava Schmidt
API first with Swagger and Scala by  Slava SchmidtAPI first with Swagger and Scala by  Slava Schmidt
API first with Swagger and Scala by Slava SchmidtJavaDayUA
 

Similar to Christopher Latham Portfolio (20)

My Portfolio
My PortfolioMy Portfolio
My Portfolio
 
JavaScript - Chapter 14 - Form Handling
 JavaScript - Chapter 14 - Form Handling   JavaScript - Chapter 14 - Form Handling
JavaScript - Chapter 14 - Form Handling
 
Nj 09 T2 David Frischknecht
Nj 09 T2 David FrischknechtNj 09 T2 David Frischknecht
Nj 09 T2 David Frischknecht
 
Visual studio 2008 asp net
Visual studio 2008 asp netVisual studio 2008 asp net
Visual studio 2008 asp net
 
My Portfolio
My PortfolioMy Portfolio
My Portfolio
 
Wheels
WheelsWheels
Wheels
 
Apex Testing and Best Practices
Apex Testing and Best PracticesApex Testing and Best Practices
Apex Testing and Best Practices
 
Tutorial asp.net
Tutorial  asp.netTutorial  asp.net
Tutorial asp.net
 
Introduction to apex code
Introduction to apex codeIntroduction to apex code
Introduction to apex code
 
Lecture14
Lecture14Lecture14
Lecture14
 
Library Project
Library ProjectLibrary Project
Library Project
 
Local data storage for mobile apps
Local data storage for mobile appsLocal data storage for mobile apps
Local data storage for mobile apps
 
Form demoinplaywithmysql
Form demoinplaywithmysqlForm demoinplaywithmysql
Form demoinplaywithmysql
 
Mark Jackson\'s Portfoilo
Mark Jackson\'s PortfoiloMark Jackson\'s Portfoilo
Mark Jackson\'s Portfoilo
 
Local storage in Web apps
Local storage in Web appsLocal storage in Web apps
Local storage in Web apps
 
Leveraging Symfony2 Forms
Leveraging Symfony2 FormsLeveraging Symfony2 Forms
Leveraging Symfony2 Forms
 
Web Technologies - forms and actions
Web Technologies -  forms and actionsWeb Technologies -  forms and actions
Web Technologies - forms and actions
 
Secure Dot Net Programming
Secure Dot Net ProgrammingSecure Dot Net Programming
Secure Dot Net Programming
 
API first with Swagger and Scala by Slava Schmidt
API first with Swagger and Scala by  Slava SchmidtAPI first with Swagger and Scala by  Slava Schmidt
API first with Swagger and Scala by Slava Schmidt
 
JDBeyler
JDBeylerJDBeyler
JDBeyler
 

Christopher Latham Portfolio

  • 1. .Net Portfolio Christopher Latham lathamcl@gmail.com (360)223-8745
  • 2. Table of Contents • SetFocus Library System Overview • Windows Sample Forms and Code • Web Sample Forms and Code • Business Layer • Data Access Layer
  • 3. SetFocus Library System • Introduction: • This project is a simple library administration application. • Audience: • The typical users would be librarians and library volunteers. • Project Goals: • Both Windows and web based interfaces • Handle all common library functions (e.g. Check a book out, Add a new library member, etc.) with minimal required training. • Easily maintained code. • Appropriate error handling. • Validation for all entered fields.
  • 4. Windows – Main Interface 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.
  • 5. Windows – Add Members Form used to enter a new adult member. Fields are validated to ensure proper formatting. Form used to add a new juvenile member. The Parent ID field is checked against the database to ensure that it is valid.
  • 6. Windows – Check-In/Out Check in form used to process items that have been returned. Check out form used to process items when a member wishes to take an item from the library
  • 7. Windows – Validation • Validation is performed at form level if (!IsValidName(firstNameTextBox.Text)) { if (FirstName.Length == 0) ValidatorErrorProvider.SetError(firstNameTextBox, "You must provide a valid first name"); else ValidatorErrorProvider.SetError(firstNameTextBox, "The first name must be capitalized and contain only letters"); isValid = false; } else ValidatorErrorProvider.SetError(firstNameTextBox, string.Empty); • Common validation is re-factored into separate methods private bool IsValidName(string name) { return Regex.IsMatch(name, @"^[A-Z][a-zA-Z]{0,14}$"); } private bool IsValidPhone(string phone) { if(phone.Length > 0) return Regex.IsMatch(phone, @"^([0-9]{3})[0-9]{3}-[0-9]{4}$"); return true; }
  • 8. Web – Main Interface 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.
  • 9. Web – Get Member Info Display of member information. Juvenile members also list the adult member ID and the member’s birth date.
  • 10. Web – Add New Members Add Adult Form used for entry of new adult members. Add Juvenile Form used for entry of new juvenile members.
  • 11. Web – Add Item Form used for entering a new item into the system. Form has validation of the ISBN so to prevent duplicate items.
  • 12. Web – Check In Item Check In Entry Check In Confirmation Form for checking in an item upon return. Check In Error Page to confirm check in of an item. Page to notify user of possible error on check in.
  • 13. Web – Check Out Item Check Out Entry Check Out Confirmation Form for checking out an item from the library system. Check In/Out Confirmation Page to confirm check out of an item. Page to confirm a check in of an item before check out.
  • 14. Web – Add New Item Form used for entering a new item into the system. Form has validation of the ISBN so to prevent duplicate items
  • 15. Web – Validation • Validation is performed by the html code <asp:RequiredFieldValidator ID="firstNameReqValidator" runat="server" ControlToValidate="firstNameTextBox“ ErrorMessage="You must provide a first name“ ForeColor="White"> </asp:RequiredFieldValidator> <asp:RegularExpressionValidator ID="firstNameRegExValidator“ runat="server“ ControlToValidate="firstNameTextBox" ErrorMessage="Firstname must be all lowercase except for the first letter“ ForeColor="White“ ValidationExpression="^[A-Z][a-zA-Z]{0,14}$"> </asp:RegularExpressionValidator>
  • 16. Business Layer • Packages objects to pass to Data Access Layer public short AddAdultMember(string firstName, string middleInitial, string lastName, string street, string city, string state, string zipcode, string phone { AdultMember member = new AdultMember(); member.FirstName = firstName; member.MiddleInitial = middleInitial; member.LastName = lastName; member.Street = street; member.City = city; member.State = state; member.ZipCode = zipcode; member.PhoneNumber = phone; try { lda.AddMember(member); return member.MemberID; } catch (LibraryException ex) { throw new LibraryException(ex.LibraryErrorCode, CreateErrorCodeString(ex.LibraryErrorCode)); } }
  • 17. Business Layer • Converts Data Access errors to appropriate Business Errors private string CreateErrorCodeString(ErrorCode code) { string message; switch (code) { case ErrorCode.AddAdultFailed: message = "Failed to add new member"; break; case ErrorCode.AddJuvenileFailed: message = "Failed to add new member."; break; case ErrorCode.ItemNotCreated: message = "Item not created."; break; default: message = "Unsupported ErrorCode."; break; } return message; }
  • 18. Data Access Layer • Database is accessed through Stored Procedures using (SqlConnection con = new SqlConnection(Properties.Settings.Default.LibraryConnectionString)) { using (SqlCommand cmd = new SqlCommand("CheckIn", con)) { cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@isbn", isbn); cmd.Parameters.AddWithValue("@copy_no", copyNumber); con.Open(); cmd.ExecuteNonQuery(); } } • Database errors are caught and passed to the Business Layer catch (SqlException ex) { if (ex.Number == 50009 || ex.Number == 50010) throw new LibraryException(ErrorCode.CheckInFailed, "You must provide a isbn AND a copy number"); if (ex.Number == 50011) throw new LibraryException(ErrorCode.ItemNotFound); if (ex.Number == 50014) throw new LibraryException(ErrorCode.ItemNotOnLoan); if (ex.Number == 50002) throw new LibraryException(ErrorCode.GenericException); throw; }