SetFocus Portfolio
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
439
On Slideshare
433
From Embeds
6
Number of Embeds
1

Actions

Shares
Downloads
8
Comments
0
Likes
0

Embeds 6

http://www.linkedin.com 6

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. SetFocus Portfolio<br />Frank Stepanski<br />215-820-2353<br />fsjay@hotmail.com<br />http://www.linkedin.com/in/fstepanskipanet<br />SetFocus Project #1 - .Net Framework<br />Objective Build a C# language only business- tier framework, consisting of two assemblies; Foundation and AppTypes.<br />SummaryThis project demonstrates fundamental .NET skills and interaction between a n-tiered application.<br />A list of C#/.NET sills used in project:<br />
    • Delegates, events
    • 2. Abstract classes
    • 3. Enumerations
    • 4. Generic Collections
    • 5. Methods and properties
    • 6. Custom exception/attribute classes
    • 7. Collection classes
    • 8. Custom Enumerators Implementation of ISerializable, IComparer, IComparable, & IList<T> interfaces
    Foundation AssemblyThis assembly contains the foundation interfaces and base classes used throughout the project.<br />SetFocus Project #1 - .Net Framework<br />AppTypes Assembly<br />This assembly contains various entity, collections, and exception classes used by the library.<br />SetFocus Project #2 – Windows Forms Application<br />Objective<br />Create a Windows Forms-based front-end application that will provide a user with a visual interface through which various functions are performed. Required functionality included adding new member (adult and juvenile) and checking books in and out.<br />Summary<br />This project demonstrates the use of .NET Windows Form development techniques. Some of the techniques used include:<br />
    • User input validation and feedback using error providers
    • 9. Data binding to a grid view control
    • 10. Incorporates n-tier architecture for scalability
    • 11. Create error and exception handling
    • 12. Use of regular expressions for input validation
    424815082550Description<br />The code behind the user interface (FS.LibraryPhase1) handled all validations, screen changes and logic to perform each operation.<br />The Business layer (FS.LibraryBusiness) provided the connection between the UI and the data access functions. In this project, all data (book, member, loan, etc.) was stored in a SQL Server 2008 database.<br />The UI does not reference the data access layer, and uses only methods provided by the business layer classes provided true scalability for future modifications or updates.<br />The UI frontend contains an instance and a reference to the Business layer.<br />using System;<br />using System.Collections.Generic;<br />using System.ComponentModel;<br />using System.Data;<br />using System.Drawing;<br />using System.Linq;<br />using System.Text;<br />using System.Windows.Forms;<br />using FS.LibraryBusiness;<br /> private BusinessLogic businessLogic = new BusinessLogic();<br />SetFocus Project #2 – Windows Forms Application<br />Functionality Overview<br />Add Adult – Adds row to database with fields of Name, Address, City, State, City, Zip, and Phone.<br />Add Juvenile – Adds row to database with fields ( First, Last Name, and Birthdate).<br />Search Member – Returns all member data (name, address, books on loan, etc) from member id search.<br />Checkout - Loans a book for a member by first checking availability and then adding to loaned book queue.<br />Checkin – Returns book from member and removing loaned status from book.<br />Business Rules:<br />
    • First and Last Name must only be 15 characters long and start with a capital letter.
    • 13. Street and City must only be 15 characters long.
    • 14. State is selected from a drop down populated by an XML file.
    • 15. Zip must be in format of either ##### or #####-####.
    • 16. Phone must be in the format of (###) ###- ####.
    • 17. Birthdate must be in the range of 18 years or younger (from today’s date).
    • 18. Juvenile must have a sponsoring adult member before adding to database.
    • 19. Each member can only checkout 4 books at a time.
    • 20. If book to be checked out is already on loan, must be checked in first.
    • 21. Functions for checkin and checkout must be confirmed first by user (Confirm or Cancel).
    SetFocus Project #2 – Windows Forms Application<br />Screenshots:<br />SetFocus Project #3 – Data Access Layer (Class library)<br />Objective<br />This project created the Data Access layer and SQL Server Stored Procedures for the library application to replace the pre-built DLLs that were supplied in the previous project. Additional exception, entity and error code classes were also created as part of this project.<br />Summary<br />This project demonstrates the use of ADO.NET and Transact-SQL to access a SQL Server 2008 database. Some of the techniques used include:<br />
    • Data validation in SQL
    • 22. Stored procedures in Transact-SQL (T-SQL) on SQL Server 2008
    • 23. Implementing error handing in SQL
    • 24. Accessing stored procedures through System.Data.SqlClient
    • 25. Retrieve and process result sets returned from stored procedures
    • 26. Process errors raised by T-SQL in ADO.NET using error numbers and states
    4133850151130Description<br />LibraryEntities contained the various classes and enumerations referenced by the entire project. It contains the AdultMember, JuvenileMember, Member, Item and LibraryException classes as well as the ErrorCode enumeration.<br />The LibraryDataAccess project provides the layer between the Business Layer and the database. The UI (user interface) layer makes requests to the LibraryBusiness layer, which in turn makes requests of the Data Access layer.<br />The Data Access layer executes the appropriate SQL Server database stored procedures via ADO.NET. <br />The Business layer contains an instance and has a reference to the Data Access layer:<br />using System;<br />using System.Collections.Generic;<br />using System.Linq;<br />using System.Text;<br />using System.Data;<br />using FS.LibraryDataAccess;<br />private DataAccess DataAccess = new DataAccess();<br />SetFocus Project #3 – Data Access Layer (Class library)<br />Database diagram of tables and relationships<br />Data Access method to connect to database:<br />private SqlConnection GetConnection()<br />{<br /> return new SqlConnection(Properties.Settings.Default.LibraryConnection);<br />}<br /><connectionStrings><br /> <add name=" FS.LibraryDataAccess.Properties.Settings.LibraryConnection" <br /> connectionString=" Data Source=.;Initial Catalog=library;Integrated <br /> Security=True" <br /> providerName=" System.Data.SqlClient" /><br /></connectionStrings><br />SetFocus Project #3 – Data Access Layer (Class library)<br />523875093345Stored Procedures<br />Several stored procedures were created to interact with the various related tables in the database. Each stored procedure contains input and output parameters as well as error handing and transactions for any data updates (INSERT, UPDATE or DELETE).<br />FS_AddultMember – Inserts row into the dbo.member and dbo.adult tables<br />CREATE PROCEDURE [dbo].[FS_AddAdultMember]<br />-- parameters <br /> @firstname VARCHAR(15), @middleinitial CHAR(1) = null,<br /> @lastname VARCHAR(15), @street VARCHAR(15),<br /> @city VARCHAR(15), @state CHAR(2),<br /> @zip CHAR(10), @phone CHAR(13) = null,<br /> @memberID smallint OUTPUT<br />AS<br />BEGIN<br />SET NOCOUNT ON;<br /> <br />BEGIN TRY<br />BEGIN TRAN<br /> IF @firstname IS NULL OR @lastname IS NULL OR @street IS NULL OR<br /> @city IS NULL OR @state IS NULL OR @zip IS NULL<br /> <br />BEGIN<br />RAISERROR('Library: Missing inputs are required',11,1)<br />RETURN<br />END<br />-- temporary variable<br />DECLARE @expirationDate datetime<br />-- set expiration (1 year from today)<br />SET @expirationDate = DATEADD(year,1,getdate())<br /> <br />-- insert into member table to generate memberid<br />INSERT INTO dbo.member(firstname,middleinitial,lastname)<br />VALUES(@firstname,@middleinitial,@lastname)<br /> <br />-- Get the new ProductID<br />SET @memberID=SCOPE_IDENTITY()<br /> <br />-- insert into adult table for member contact info<br />INSERT INTO dbo.adult(member_no,street,city,state,zip,phone_no,expr_date)<br /> VALUES(@MemberID,@street,@city,@state,@zip,@phone,@expirationDate)<br />COMMIT TRAN<br />END TRY<br />SetFocus Project #3 – Data Access Layer (Class library)<br />FS_AddItem - Inserts row into dbo.copy table or dbo.title and dbo.item table if item exists or not.<br />BEGIN TRY <br />BEGIN TRAN<br />-- Check to see if item exists first<br />-- If it does, just add new copy number (1+highest)<br />IF EXISTS (SELECT isbn FROM dbo.item WHERE isbn = @isbn)<br />BEGIN <br />-- Grab highest copy_no<br />DECLARE @highest_copy_no int, @new_copy_no int<br />SELECT TOP 1 @highest_copy_no = copy_no FROM dbo.copy <br /> WHERE isbn = @isbn ORDER BY copy_no DESC<br />SET @new_copy_no = @highest_copy_no + 1<br />-- Grab title_no<br />DECLARE @title_no int<br />SELECT @title_no = title_no FROM dbo.copy WHERE isbn = @isbn<br />INSERT INTO dbo.copy(isbn,copy_no,title_no, on_loan)<br /> VALUES (@isbn, @new_copy_no, @title_no, @loanable)<br />SET @copy_no_output = @new_copy_no<br />END<br />ELSE<br />BEGIN <br />-- ADD NEW ITEM<br />-- step 1: add to title (title_no is identity spec)<br />DECLARE @new_title_no int<br />INSERT INTO dbo.title (title,author,synopsis)<br /> VALUES (@title, @author, @synopsis)<br /> <br />--Get the new title no<br />SET @new_title_no=SCOPE_IDENTITY()<br /> <br />-- step 2: add to item<br /> <br />INSERT INTO dbo.item (isbn,title_no,cover,loanable)<br /> VALUES (@isbn, @new_title_no, @cover, @loanable)<br />-- step 3: add to copy (not on loan by deafult)<br />INSERT INTO dbo.copy (isbn,copy_no,title_no,on_loan)<br /> VALUES (@isbn, @new_title_no, @cover, 'N')<br />SetFocus Project #3 – Data Access Layer (Class library)<br />FS_Checkin - Updates record from dbo.copy table and inserts row into dbo.loan and dbo.loanhist table<br />BEGIN TRY<br />BEGIN TRAN<br />-- temporary variables<br />DECLARE @out_date datetime, @title_no int, @member_no smallint, @on_loan CHAR(1)<br />-- Make sure item is first in database<br />IF NOT EXISTS (SELECT isbn, copy_no FROM dbo.copy WHERE isbn = @isbn)<br />BEGIN<br />RAISERROR('Library: Item not found in Database',11,2)<br />RETURN<br />END<br />-- Make sure item is on loan so it can be checked in<br />SELECT @on_loan = on_loan FROM dbo.copy WHERE isbn = @isbn AND copy_no = @copy_no<br />IF (@on_loan = 'N')<br />BEGIN <br /> RAISERROR('Library: Item not on loan',11,3)<br /> RETURN<br />END<br />BEGIN<br />-- Grab title_no<br />SELECT @title_no = title_no FROM dbo.copy WHERE isbn = @isbn <br /> AND copy_no = @copy_no<br />--Grab member_no, out_date<br />SELECT @member_no = member_no, @out_date = out_date<br />FROM dbo.loan <br />WHERE isbn = @isbn AND copy_no = @copy_no AND @title_no = title_no<br />--Update copy <br />UPDATE dbo.copy SET on_loan = 'N' WHERE isbn = @isbn AND copy_no = @copy_no <br /> --Remove record from loan<br /> DELETE dbo.loan WHERE isbn = @isbn AND copy_no = @copy_no<br /> <br />--Insert into loanhist<br />INSERT INTO dbo.loanhist<br />(isbn, copy_no, out_date, title_no, member_no, due_date, in_date)<br />VALUES<br />(@isbn, @copy_no, @out_date, @title_no, @member_no, <br /> DATEADD(day,14,@out_date), GETDATE()) <br />END<br />COMMIT TRAN<br />END TRY<br />SetFocus Project #3 – Data Access Layer (Class library)<br />Data Access layer methods:<br />Methods created in the Data Access layer interact with the SQL Server 2008 database and execute and return values from Stored Procedures.<br />Sample Code:<br />public void AddMember(AdultMember adult)<br />{<br />try<br />{<br /> using (SqlConnection cn = GetConnection())<br /> using (SqlCommand cmd = new SqlCommand(" FS_AddAdultMember" , cn))<br /> {<br /> cmd.CommandType = CommandType.StoredProcedure;<br /> cmd.Parameters.Add(" @firstName" , SqlDbType.VarChar, 15).Value = adult.fName;<br /> cmd.Parameters.Add(" @middleInitial" , SqlDbType.Char, 1).Value = adult.mInitial;<br />cmd.Parameters.Add(" @lastName" , SqlDbType.VarChar, 15).Value = adult.LastName;<br />cmd.Parameters.Add(" @street" , SqlDbType.VarChar, 15).Value = adult.Street; <br />cmd.Parameters.Add(" @city" , SqlDbType.VarChar, 15).Value = adult.City;<br /> cmd.Parameters.Add(" @state" , SqlDbType.Char, 2).Value = adult.State;<br /> cmd.Parameters.Add(" @zip" , SqlDbType.Char, 10).Value = adult.ZipCode;<br /> cmd.Parameters.Add(" @phone" , SqlDbType.Char, 13).Value = adult.PhoneNumber;<br />cmd.Parameters.Add(" @memberID" , SqlDbType.SmallInt).Direction =<br /> ParameterDirection.Output;<br /> cn.Open();<br /> cmd.ExecuteNonQuery();<br /> adult.MemberID = (short)cmd.Parameters[" @memberID" ].Value;<br /> }<br />}<br />catch (SqlException ex)<br />{<br />switch (ex.State)<br /> {<br /> case 1:<br /> <br /> throw new LibraryException(ErrorCode.MissingRequiredItems, ex.Message, ex);<br /> default:<br /> <br /> throw new LibraryException(ErrorCode.AddAdultFailed, ex.Message, ex);<br /> }<br />}<br />}<br />SetFocus Project #3 – Data Access Layer (Class library)<br />Sample Code:<br />public short AddItem(int isbn, string title, string author, string cover)<br />{<br />try<br />{<br />using (SqlConnection cn = GetConnection())<br /> using (SqlCommand cmd = new SqlCommand(" FS_AddItem" , cn))<br /> {<br /> cmd.CommandType = CommandType.StoredProcedure;<br /> cmd.Parameters.Add(" @isbn" , SqlDbType.VarChar, 15).Value = isbn;<br /> cmd.Parameters.Add(" @title" , SqlDbType.VarChar, 15).Value = title;<br /> cmd.Parameters.Add(" @author" , SqlDbType.VarChar, 15).Value = author;<br /> cmd.Parameters.Add(" @cover" , SqlDbType.Char, 8).Value = cover;<br /> <br />cmd.Parameters.Add(" @copy_no_output" , SqlDbType.SmallInt).Direction =<br /> ParameterDirection.Output;<br /> <br /> cn.Open();<br /> cmd.ExecuteNonQuery();<br /> short newCopyNumber = (short)cmd.Parameters[" @copy_no_output" ].Value;<br /> return newCopyNumber;<br /> }<br />}<br />catch (SqlException ex)<br />{<br />switch (ex.State)<br /> {<br /> case 1:<br /> throw new LibraryException(ErrorCode.MissingRequiredItems, ex.Message, ex);<br /> <br /> default:<br /> throw new LibraryException(ErrorCode.GetItemFailed, ex.Message, ex);<br /> }<br />}<br /> <br />}<br />SetFocus Project #3 – Data Access Layer (Class library)<br />Sample Code:<br />public void CheckInItem(int isbn, short copyNum)<br />{<br />try<br />{<br />using (SqlConnection cn = GetConnection())<br /> using (SqlCommand cmd = new SqlCommand(" FS_CheckIn" , cn))<br /> {<br /> cmd.CommandType = CommandType.StoredProcedure;<br /> cmd.Parameters.Add(" @isbn" , SqlDbType.Int).Value = isbn;<br /> cmd.Parameters.Add(" @copy_no" , SqlDbType.SmallInt).Value = copyNum;<br /> cn.Open();<br /> cmd.ExecuteNonQuery();<br /> }<br /> }<br /> <br />catch (SqlException ex)<br />{<br />switch (ex.State)<br />{<br /> case 1:<br /> <br /> throw new LibraryException(ErrorCode.MissingRequiredItems, ex.Message, ex);<br /> <br /> case 2:<br /> <br /> throw new LibraryException(ErrorCode.ItemNotFound, ex.Message, ex);<br /> <br /> case 3:<br /> <br /> throw new LibraryException(ErrorCode.ItemNotOnLoan, ex.Message, ex);<br /> default:<br /> <br /> throw new LibraryException(ErrorCode.CheckInFailed, ex.Message, ex);<br /> }<br />}<br />}<br />SetFocus Project #4 – ASP.NET Web Application<br />Summary<br />This project demonstrates the use of ASP.NET 3.5. in creating a web application. Some of the techniques used include:<br />
    • Use of Membership Roles to restrict access to pages.
    • 27. Created MasterPage to provide consistent look and feel for website.
    • 28. Conversion of a HTML/CSS layout implemented with a MasterPage and content pages.
    • 29. Use of Skins and CSS to modify design layout characteristics.
    • 30. Utilizing ViewState objects to save data between postbacks.
    • 31. Use of validation controls (required, range and expression) to validate input before postback.
    • 32. Use of various AJAX controls such as UpdatePanel, UpdateProgress as well as Ajax Toolkit controls to provide partial updates and improved user interactions.
    • 33. Navigation was accomplished via a sitemap and menu control.
    • 34. Additional 3rd party controls were used for additional functionality such as GoogleMaps.
    • 35. Use of JavaScript library jQuery was implemented for effects and animations.
    4010025174625Description<br />The visual interface was created by converting a HTML/CSS layout into a MasterPage and each corresponding content page used various ASP.NET web controls.<br />Each web page had their own validation controls and used an instance of the Business Layer class to initiate methods that executed from the Data Access layer. <br />Communication of the resulting data from the Data Access layer was accomplished by either using ObjectDataSource controls or ADO.NET objects such as Connection, Command, and DataSet.<br />The UI frontend has an instance and reference to the Business layer class: <br />using System;<br />using System.Collections.Generic;<br />using System.Linq;<br />using System.Web;<br />using System.Web.UI;<br />using System.Web.UI.WebControls;<br />using FS.LibraryBusiness;<br />private BusinessLogic businessLogic = new BusinessLogic();<br />SetFocus Project #4 – ASP.NET Web Application<br />Sample Code:<br />protected void btnAddAdult_Click(object sender, EventArgs e)<br />{<br /> try<br /> {<br />AdultMember adultMember = new AdultMember();<br /> Member member = new Member();<br /> adultMember.FirstName = txtFirstName.Text.Trim();<br /> adultMember.MiddleInitial = txtMiddleName.Text.Trim();<br /> adultMember.LastName = txtLastName.Text.Trim();<br /> adultMember.Street = txtAddress.Text.Trim();<br /> adultMember.City = txtCity.Text.Trim();<br /> adultMember.State = ddlState.SelectedValue.ToString();<br /> adultMember.ZipCode = txtZip.Text.Trim();<br /> adultMember.PhoneNumber = txtPhone.Text.Trim();<br /> businessLogic.AddMember(adultMember);<br /> member = businessLogic.GetMember(adultMember.MemberID);<br /> lblStatus.Text = newMember.MemberID.ToString() + " was added" ;<br />}<br />catch (LibraryException lex){<br />switch (lex.LibraryErrorCode){<br />      case ErrorCode.GenericException:<br />            lblStatus.Text = " Error: Database Error please contact IT" ;            break;<br />            case ErrorCode.AddAdultFailed:<br />      lblStatus.Text = " Error: Adding Adult Member failed" ;                  break;<br />            default:<br />lblStatus.Text = " Error: " + lex.Message;break;<br />}}<br />catch (Exception ex){ lblStatus.Text = " Error: " + ex.Message;}<br />SetFocus Project #4 – ASP.NET Web Application<br />Sample Code:<br />protected void btnAddItem_Click(object sender, EventArgs e){<br />try<br /> {<br /> Item item = new Item();<br /> item.ISBN = int.Parse(txtISBN.Text);<br /> item.Author = txtAuthor.Text;<br /> item.Title = txtTitle.Text;<br /> item.Cover = radioListCover.SelectedItem.Value;<br /> <br /> short copy_no = businessLogic.AddItem(item.ISBN, item.Title, item.Author);<br /> if (copy_no != 0)<br /> {<br /> lblStatus.Text = " Item added with Copy Number of " + copy_no;<br /> }<br /> resetControls();<br /> }<br /> <br /> catch (LibraryException lex)<br /> {<br /> switch (lex.LibraryErrorCode)<br /> {<br /> case ErrorCode.GenericException:<br /> <br />lblStatus.Text = " Error: Database Error please contact IT" ;<br /> break;<br /> <br />case ErrorCode.MissingRequiredItems:<br /> <br />lblStatus.Text = " Error: Missing Required Items" ;<br /> break;<br /> <br />default:<br /> lblStatus.Text = " Error: " + lex.Message;<br /> break;<br /> }<br /> }<br /> catch (Exception ex)<br /> {<br /> lblStatus.Text = " Error: " + ex.Message;<br /> }<br /> }<br />}<br />SetFocus Project #4 – ASP.NET Web Application<br />Sample Code:<br />protected void btnCheckinConfirm_Click(object sender, EventArgs e){try{<br />short isbn = short.Parse(GridView1.SelectedRow.Cells[1].Text);short copyNumber = short.Parse(GridView1.SelectedRow.Cells[2].Text);<br /> businessLogic.CheckInItem(isbn, copyNumber);<br />GridView1.DataBind();setStatus(" ISBN: " + isbn + " CopyNumber: " + copyNumber + " has been checked in" );<br />}<br /> catch (LibraryException lex)<br /> { switch (lex.LibraryErrorCode)<br />{ case ErrorCode.GenericException:<br />setStatus(" Error: Database Error please contact IT" );break;<br />            case ErrorCode.CheckInFailed:<br />setStatus(" Error: Checkin Failed" );break;<br />            default:<br />setStatus(" Error:  " + lex.Message);break;<br />     }<br />}<br />catch (Exception ex){<br />setStatus(" Error: " + ex.Message);<br />}<br />SetFocus Project #4 – ASP.NET Web Application<br />MasterPage:<br /><%@ Master Language=" C#" CodeFile=" Site.master.cs" Inherits=" Site" %><br /><!DOCTYPE html PUBLIC " -//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" ><br /><head id=" Head1" runat=" server" ><br /> <br /> <link href=" master.css" rel=" stylesheet" type=" text/css" /> <br /> <link href=" page.css" rel=" stylesheet" type=" text/css" /> <br /> <br /> <script src=" ../scripts/jquery-1.4.2.min.js" type=" text/javascript" ></script><br /> <br /></head><br /><body><br /> <form id=" form1" runat=" server" ><br /> <br /> <asp:SiteMapDataSource ID=" SiteMapDataSource1" runat=" server" /> <br /> <br /> <div id=" wrap" ><br /> <br /> <div id=" header" ><br /> <h1><asp:Label ID=" lblSiteHeading" runat=" server" ></asp:Label></h1><br /> </div><br /> <br /> <div id=" nav" ><br /> <asp:Menu ID=" Menu1" Width=" 300px" runat=" server" Orientation=" Horizontal" <br /> StaticEnableDefaultPopOutImage=" False" DataSourceID=" SiteMapDataSource1" <br /> CssClass=" menu" ><br /> </asp:Menu><br /> <br /> <asp:LoginStatus ID=" LoginStatus1" runat=" server" CssClass=" login_status" <br /> LogoutPageUrl=" ~/Login.aspx" LogoutAction=" Redirect" /><br /> <br /> </div><br /> <br /> <div id=" main" ><br /> <asp:ContentPlaceHolder ID=" ContentPlaceHolderMain" runat=" server" ><br /> </asp:ContentPlaceHolder><br /> <br /> </div><br /> <br /> <div id=" sidebar" > <br /> <asp:ContentPlaceHolder ID=" ContentPlaceHolderSidebar" runat=" server" ><br /> </asp:ContentPlaceHolder><br /> </div><br /><div id=" footer" >Copyright © 2010 LibraryCheckout.com</div><br /></div><br />SetFocus Project #4 – ASP.NET Web Application<br />Screenshots:<br />