SlideShare a Scribd company logo
1 of 8
[object Object],Adding Adult to the LibraryFrom the windows project (phase II), button click method: The user is enters the new adult member’s information and presses the button to accept the information to be added. The form will ask the user to confirm the addition and then call the business layer’s method to add the adult.// Add clided, validate then add memberprivate void btnAdd_Click(object sender, EventArgs e){  // validate all controls on the form (this is known as thorough validation)  if (!this.ValidateChildren(ValidationConstraints.Visible))  {    // keep the dialog open if controls do not validate    this.DialogResult = DialogResult.None;  }  else  {    string message = string.Format(
Add {0} {1} {2} as a member?
,    txtFirstName.Text, txtMI.Text, txtLastName.Text);    DialogResult myResult = MessageBox.Show(this, message, 
Add adult member
,         MessageBoxButtons.YesNo);    if (myResult == DialogResult.Yes)    {      // Everything has been validated      ErrorCode errCode;      BusinessLayer bl = new BusinessLayer();      AdultMember myMember = new AdultMember();      // Assign member information      myMember.FirstName = txtFirstName.Text;      myMember.MiddleInitial = txtMI.Text;      myMember.LastName = txtLastName.Text;      myMember.Street = txtStreet.Text;      myMember.City = txtCity.Text;      myMember.State = cboState.SelectedValue.ToString();      myMember.ZipCode = txtZipCode.Text;      myMember.PhoneNumber = txtPhone.Text;      // Add adult member      errCode = bl.AddNewMember(myMember);      if (errCode == ErrorCode.AddAdultFailed)      {        toolStripStatusLabel1.Text = 
Could not add this Adult record
;        return;      }      // Pass and create new Information form      frmMemberInfo myForm = new frmMemberInfo(myMember);      myForm.MdiParent = this.MdiParent;      myForm.Show();      this.Close();    }  }  else    toolStripStatusLabel1.Text = 
User canceled adding adult member
;  }} ADO.NET: Adding Juvenile to databaseAdd member method, overridden to handle either an Adult or Juvenile member. This code displays how I handled the addition of the juvenile member. The method is passed an object of type JuvenileMember./// ,[object Object],/// ,[object Object],JuvenileMemberpublic void AddMember(JuvenileMember aMember){  // Set-up the connection  using (SqlConnection cnn = new       SqlConnection(Properties.Settings.Default.LibraryConnection))  {    // Create the command    using (SqlCommand cmd = new SqlCommand(
dbo.AddJuvenile
, cnn))    {      try      {        // Assign the parameters        cmd.CommandType = CommandType.StoredProcedure;        cmd.Parameters.AddWithValue(
@FirstName
, aMember.FirstName);        cmd.Parameters.AddWithValue(
@MiddleInitial
, aMember.MiddleInitial);        cmd.Parameters.AddWithValue(
@LastName
, aMember.LastName);        cmd.Parameters.AddWithValue(
@Adult_Member_No
, aMember.AdultMemberID);        cmd.Parameters.AddWithValue(
@Birth_Date
, aMember.BirthDate);        cmd.Parameters.Add(
@MemberNo
, SqlDbType.SmallInt, 2).Direction             = ParameterDirection.Output;        cmd.Parameters.Add(
@Return
, SqlDbType.Int, 4).Direction             = ParameterDirection.ReturnValue;        // Open the connection        cnn.Open();        cmd.ExecuteNonQuery();        cnn.Close();        aMember.MemberID = Convert.ToInt16(cmd.Parameters[
@MemberNo
].Value);        aMember = (JuvenileMember)this.GetMember(aMember.MemberID);      }      // Catch any SQL Errors      catch (SqlException sqlex)      {        cnn.Close();        int sqlErr = Convert.ToInt32(cmd.Parameters[
@Return
].Value);        if (sqlex.Number == 50000)        {          switch (sqlex.State)          {            case 13:               // Invalid member number              throw new ArgumentOutOfRangeException(sqlex.Message);            case 10:              // Adult sponsor not found              throw new LibraryException(ErrorCode.MissingAdultMember);            case 11:              // Add Juvenile member failed              throw new LibraryException(ErrorCode.AddJuvenileFailed);            default:              throw new LibraryException(ErrorCode.GenericException, sqlex.Message, sqlex); ADO.NET: Adding Juvenile to databaseContinued          }        }        else        {          if (sqlex.Number == 8114) // ArgumentOutOfRange          {            throw new ArgumentOutOfRangeException(sqlex.Message);          }          else          {            throw new LibraryException(ErrorCode.GenericException, sqlex.Message, sqlex);          }        }      }      catch (Exception ex)      {        throw new LibraryException(ErrorCode.GenericException, ex.Message, ex);      }    }  }} Stored Procedure to Add Book (Phase III)The stored procedure checks if the ISBN is already in the database. If the ISBN exists then it will just add another copy to the Copy table. If the ISBN does not exist, then the title and author are added to the Title table first to get the Title_No and then the Title_No and ISBN are added to Item table. The last thing added is Copy_No to the Copy table.ALTER PROC [dbo].[AddBook]/************************************** *   Add Book to Library *   Add a new book if ISBN is not *     found. If found it adds a new *     copy number only *   Parameters: *    @ISBN - Number of item *    @Title - Title of item *    @Author - Author of item *   Return: *    @CopyNo - Copy number * *        Author: John Elmer *         Date: 06/26/2009 * *************************************/@ISBN int = 0,@Title varchar(63) = NULL,@Author varchar(31) = NULL,@CopyNo smallint OUTPUTASDECLARE @TitleNo int-- Check that ISBN is between 1 and 2,147,483,647IF @ISBN <= 0 OR @ISBN > 2147483647BEGINRAISERROR ('Invalid ISBN, must be between 1 and 2,147,483,647',14,13)RETURNEND-- Check if ISBN exists in ItemIF EXISTS (SELECT * FROM dbo.Item WHERE ISBN = @ISBN)BEGINBEGIN TRANDECLARE @TempCopyNo smallintSET @TempCopyNo = (SELECT MAX(Copy_No) FROMdbo.COPY WHERE ISBN = @ISBN) + 1SET @TitleNo = (SELECT I.Title_No FROM ITEM I WHEREI.ISBN = @ISBN)-- Add to Copy onlyINSERT dbo.CopyVALUES (@ISBN, @TempCopyNo, @TitleNo, 'N')IF @@ERROR <> 0BEGINROLLBACKRAISERROR ('Could not add Item', 14, 2)RETURN @@ERROREND Stored Procedure to Add Book (Phase III)ContinuedSET @CopyNo = @TempCopyNoCOMMIT TRANEND-- ISBN does not existELSEBEGINIF @Title IS NULL OR @Author IS NULLBEGINRAISERROR ('Title and Author must be provided',14,2)RETURNENDBEGIN TRAN-- Insert into Title first to get Title_noINSERT dbo.TitleVALUES (@Title, @Author, NULL)IF @@ERROR <> 0BEGINROLLBACKRAISERROR ('Could not add Item', 14, 2)RETURN @@ERRORENDSET @TitleNo = @@IDENTITY-- Add to ItemINSERT dbo.ItemVALUES (@ISBN, @TitleNo, NULL, NULL, 'Y')IF @@ERROR <> 0BEGINROLLBACKRAISERROR ('Could not add Item', 14, 2)RETURN @@ERROREND-- Add to CopyINSERT dbo.CopyVALUES (@ISBN, 1, @TitleNo, 'N')IF @@ERROR <> 0BEGINROLLBACKRAISERROR ('Could not add Item', 14, 2)RETURN @@ERRORENDSET @CopyNo = 1COMMIT TRANEND Member Information Screen (Windows) Member Information Screen (Web)
My Portfolio
My Portfolio
My Portfolio
My Portfolio
My Portfolio
My Portfolio
My Portfolio

More Related Content

Viewers also liked

Growing Through China: A Comprehensive Look at Market Opportunities
Growing Through China: A Comprehensive Look at Market Opportunities Growing Through China: A Comprehensive Look at Market Opportunities
Growing Through China: A Comprehensive Look at Market Opportunities Kegler Brown Hill + Ritter
 
Seniors u00 e9lu00e9ment_u00e9conomique_indispensable11-1
Seniors u00 e9lu00e9ment_u00e9conomique_indispensable11-1Seniors u00 e9lu00e9ment_u00e9conomique_indispensable11-1
Seniors u00 e9lu00e9ment_u00e9conomique_indispensable11-1André Thépin
 
Personnel Planning &amp; Recruiting
Personnel Planning &amp; RecruitingPersonnel Planning &amp; Recruiting
Personnel Planning &amp; Recruitingabir014
 
Bone Fractures
Bone FracturesBone Fractures
Bone Fracturesavlainich
 
Louisiana Technology Council Summer 2010
Louisiana Technology Council Summer 2010Louisiana Technology Council Summer 2010
Louisiana Technology Council Summer 2010JaclynSBR
 
BEACON 101: Sequencing tech
BEACON 101: Sequencing techBEACON 101: Sequencing tech
BEACON 101: Sequencing techc.titus.brown
 
Long term evaluation of IL programme paper
Long term evaluation of IL programme paperLong term evaluation of IL programme paper
Long term evaluation of IL programme paperTina Hohmann
 
La comunicazione-del-vino-ai-tempi-di-facebook
La comunicazione-del-vino-ai-tempi-di-facebookLa comunicazione-del-vino-ai-tempi-di-facebook
La comunicazione-del-vino-ai-tempi-di-facebookSlawka G. Scarso
 
Evaluaciones de jheickson noguera ingenieria economica
Evaluaciones de jheickson noguera   ingenieria economicaEvaluaciones de jheickson noguera   ingenieria economica
Evaluaciones de jheickson noguera ingenieria economicaLili Cardenas
 
Professional responsibility seminar in cleveland
Professional responsibility seminar in clevelandProfessional responsibility seminar in cleveland
Professional responsibility seminar in clevelandKegler Brown Hill + Ritter
 
Come misurare i risultati sui social media
Come misurare i risultati sui social mediaCome misurare i risultati sui social media
Come misurare i risultati sui social mediaLoris Castagnini
 
Advanced Site Recovery -- Technical Briefing
Advanced Site Recovery -- Technical BriefingAdvanced Site Recovery -- Technical Briefing
Advanced Site Recovery -- Technical BriefingJames Price
 
Real Kings Of Logistics
Real Kings Of LogisticsReal Kings Of Logistics
Real Kings Of Logisticsbamadogg
 
Printemps
PrintempsPrintemps
PrintempsJURY
 
3 Hr. Workbook - S1031 For Professionals
3 Hr.  Workbook - S1031 For Professionals3 Hr.  Workbook - S1031 For Professionals
3 Hr. Workbook - S1031 For ProfessionalsEdmund_Wheeler
 

Viewers also liked (20)

Growing Through China: A Comprehensive Look at Market Opportunities
Growing Through China: A Comprehensive Look at Market Opportunities Growing Through China: A Comprehensive Look at Market Opportunities
Growing Through China: A Comprehensive Look at Market Opportunities
 
MoMoTLV Israel March 2010 - Agenda
MoMoTLV Israel March 2010 - AgendaMoMoTLV Israel March 2010 - Agenda
MoMoTLV Israel March 2010 - Agenda
 
Seniors u00 e9lu00e9ment_u00e9conomique_indispensable11-1
Seniors u00 e9lu00e9ment_u00e9conomique_indispensable11-1Seniors u00 e9lu00e9ment_u00e9conomique_indispensable11-1
Seniors u00 e9lu00e9ment_u00e9conomique_indispensable11-1
 
Personnel Planning &amp; Recruiting
Personnel Planning &amp; RecruitingPersonnel Planning &amp; Recruiting
Personnel Planning &amp; Recruiting
 
Do You Know The 11g Plan?
Do You Know The 11g Plan?Do You Know The 11g Plan?
Do You Know The 11g Plan?
 
Bone Fractures
Bone FracturesBone Fractures
Bone Fractures
 
Louisiana Technology Council Summer 2010
Louisiana Technology Council Summer 2010Louisiana Technology Council Summer 2010
Louisiana Technology Council Summer 2010
 
BEACON 101: Sequencing tech
BEACON 101: Sequencing techBEACON 101: Sequencing tech
BEACON 101: Sequencing tech
 
Long term evaluation of IL programme paper
Long term evaluation of IL programme paperLong term evaluation of IL programme paper
Long term evaluation of IL programme paper
 
La comunicazione-del-vino-ai-tempi-di-facebook
La comunicazione-del-vino-ai-tempi-di-facebookLa comunicazione-del-vino-ai-tempi-di-facebook
La comunicazione-del-vino-ai-tempi-di-facebook
 
2014 naples
2014 naples2014 naples
2014 naples
 
2014 villefranche
2014 villefranche2014 villefranche
2014 villefranche
 
Evaluaciones de jheickson noguera ingenieria economica
Evaluaciones de jheickson noguera   ingenieria economicaEvaluaciones de jheickson noguera   ingenieria economica
Evaluaciones de jheickson noguera ingenieria economica
 
Professional responsibility seminar in cleveland
Professional responsibility seminar in clevelandProfessional responsibility seminar in cleveland
Professional responsibility seminar in cleveland
 
Come misurare i risultati sui social media
Come misurare i risultati sui social mediaCome misurare i risultati sui social media
Come misurare i risultati sui social media
 
2012 XLDB talk
2012 XLDB talk2012 XLDB talk
2012 XLDB talk
 
Advanced Site Recovery -- Technical Briefing
Advanced Site Recovery -- Technical BriefingAdvanced Site Recovery -- Technical Briefing
Advanced Site Recovery -- Technical Briefing
 
Real Kings Of Logistics
Real Kings Of LogisticsReal Kings Of Logistics
Real Kings Of Logistics
 
Printemps
PrintempsPrintemps
Printemps
 
3 Hr. Workbook - S1031 For Professionals
3 Hr.  Workbook - S1031 For Professionals3 Hr.  Workbook - S1031 For Professionals
3 Hr. Workbook - S1031 For Professionals
 

Similar to My Portfolio

Library Project
Library ProjectLibrary Project
Library ProjectMauro_Sist
 
Tony Vitabile .Net Portfolio
Tony Vitabile .Net PortfolioTony Vitabile .Net Portfolio
Tony Vitabile .Net Portfoliovitabile
 
My Portfolio
My PortfolioMy Portfolio
My Portfolioaemartin4
 
Cis407 a ilab 5 web application development devry university
Cis407 a ilab 5 web application development devry universityCis407 a ilab 5 web application development devry university
Cis407 a ilab 5 web application development devry universitylhkslkdh89009
 
Linked In Presentation
Linked In PresentationLinked In Presentation
Linked In Presentationapweir12
 
Lewis Chiu Portfolio
Lewis Chiu PortfolioLewis Chiu Portfolio
Lewis Chiu PortfolioLewisChiu
 
Mark Jackson\'s Portfoilo
Mark Jackson\'s PortfoiloMark Jackson\'s Portfoilo
Mark Jackson\'s PortfoiloMark_Jackson
 
Library Website
Library WebsiteLibrary Website
Library Websitegholtron
 
Christopher Latham Portfolio
Christopher Latham PortfolioChristopher Latham Portfolio
Christopher Latham Portfoliolathamcl
 
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
 
Il 09 T3 William Spreitzer
Il 09 T3 William SpreitzerIl 09 T3 William Spreitzer
Il 09 T3 William Spreitzerwspreitzer
 
SummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdf
SummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdfSummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdf
SummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdfARORACOCKERY2111
 
Library Management System - V1.0
Library Management System - V1.0Library Management System - V1.0
Library Management System - V1.0JamesMuturi
 
GWT Training - Session 3/3
GWT Training - Session 3/3GWT Training - Session 3/3
GWT Training - Session 3/3Faiz Bashir
 
.NET Code Examples
.NET Code Examples.NET Code Examples
.NET Code ExamplesGaryB47
 
Laravel 8 export data as excel file with example
Laravel 8 export data as excel file with exampleLaravel 8 export data as excel file with example
Laravel 8 export data as excel file with exampleKaty Slemon
 

Similar to My Portfolio (20)

Library Project
Library ProjectLibrary Project
Library Project
 
Tony Vitabile .Net Portfolio
Tony Vitabile .Net PortfolioTony Vitabile .Net Portfolio
Tony Vitabile .Net Portfolio
 
My Portfolio
My PortfolioMy Portfolio
My Portfolio
 
Library Project
Library ProjectLibrary Project
Library Project
 
Cis407 a ilab 5 web application development devry university
Cis407 a ilab 5 web application development devry universityCis407 a ilab 5 web application development devry university
Cis407 a ilab 5 web application development devry university
 
Linked In Presentation
Linked In PresentationLinked In Presentation
Linked In Presentation
 
C# labprograms
C# labprogramsC# labprograms
C# labprograms
 
Lewis Chiu Portfolio
Lewis Chiu PortfolioLewis Chiu Portfolio
Lewis Chiu Portfolio
 
Mark Jackson\'s Portfoilo
Mark Jackson\'s PortfoiloMark Jackson\'s Portfoilo
Mark Jackson\'s Portfoilo
 
Library Website
Library WebsiteLibrary Website
Library Website
 
Christopher Latham Portfolio
Christopher Latham PortfolioChristopher Latham Portfolio
Christopher Latham Portfolio
 
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
 
Using database in android
Using database in androidUsing database in android
Using database in android
 
Il 09 T3 William Spreitzer
Il 09 T3 William SpreitzerIl 09 T3 William Spreitzer
Il 09 T3 William Spreitzer
 
SummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdf
SummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdfSummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdf
SummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdf
 
SetFocus Portfolio
SetFocus PortfolioSetFocus Portfolio
SetFocus Portfolio
 
Library Management System - V1.0
Library Management System - V1.0Library Management System - V1.0
Library Management System - V1.0
 
GWT Training - Session 3/3
GWT Training - Session 3/3GWT Training - Session 3/3
GWT Training - Session 3/3
 
.NET Code Examples
.NET Code Examples.NET Code Examples
.NET Code Examples
 
Laravel 8 export data as excel file with example
Laravel 8 export data as excel file with exampleLaravel 8 export data as excel file with example
Laravel 8 export data as excel file with example
 

My Portfolio

  • 1.