SlideShare ist ein Scribd-Unternehmen logo
1 von 13
shangbaby@gmail.com
                   818-235-9779
http://www.shangbaby.net/joomlajoy
•MSSQL  SERVER user stored procedure
•SSRS – Customer Transaction Summary
•HTML Form – The HTML behind it!
•PHP Form Validation – The PHP behind it!
   This particular piece of code creates a stored procedure. Upon
    execution it initially validates that the customer is linked to
    the account.

   There are two other validations that has to do with entry of
    negative numbers in the “TransactionAmount” field and
    adding an overdraft service charge when there isn‟t any funds
    to cover the transaction.
Microsoft SQL
   USE [PiggyBank]
   GO
   /****** Object: StoredProcedure [dbo].[WithdrawalODFees] Script Date: 02/24/2011 13:23:09 ******/
   SET ANSI_NULLS ON
   GO
   SET QUOTED_IDENTIFIER ON
   GO
   ---- =============================================
   ---- Author: Shangz Brown
   ---- Create date: 02/22/2011
   ---- Description Withdrawal with overdraft fee generation
   ---- =============================================
   CREATE PROCEDURE [dbo].[WithdrawalODFees]
   --Input and output parameters to create account
           @CustomerID               int      = null,
           @AccountID                int      = null,
           @TransactionAmount        money = null,
           @TransactionTypeID         int     = null,
           @NewBalance               money      OUTPUT
   AS
   SET XACT_ABORT ON
   --Validate that @AccountID belongs to the same customer (linked in customer Accounts table)
                   IF (SELECT CustomerAccountID
                       FROM CustomerAccount
                       WHERE AccountID = @AccountID
                      and CustomerID = @CustomerID) is null
                  BEGIN
                  raiserror('Account must be linked to the CustomerID entered', 11, 1)
                  RETURN
                  END
This part of the T-SQL stored procedure code blocks
activity on closed accounts that may be entered by users
   --Block Transactions on inactive accounts.
             IF (Select A.AccountID
                 FROM Account AS A
                 JOIN CustomerAccount AS CA
                 ON A.AccountID=CA.AccountID
                 WHERE AccountStatusID=2
                 AND CA.CustomerID=@CustomerID
                 AND A.AccountID =@AccountID) =@AccountID
             BEGIN
                      raiserror('Transactions are not allowed on inactive accounts', 11, 1)
           RETURN
             END
   --D/E CHECK: Prevent negative money amounts to be entered in the Transaction Amount parameter.
   --Logic: You can not make a deposit via the withdraw proc.
         IF @TransactionAmount <=0
             BEGIN
                     raiserror('Transaction Amount can not be a negative number.', 11, 1)
            RETURN
            END
   BEGIN
   -- SET NOCOUNT ON added to prevent extra result sets from
   -- interfering with SELECT statements.
   SET NOCOUNT ON;
   -- Encapsulate procedure in a try catch block
         BEGIN TRY
         BEGIN TRAN
   --make insert conditional
   -- If TA >CB, AND test if EXIST [OD] is true, if TRUE proceed.
          IF @TransactionAmount >
               (SELECT CurrentBalance
                 FROM Account
                 WHERE AccountID =@AccountID)
                 AND exists (SELECT AccountID
                FROM Account
                 WHERE OverDraftAccountID is not null)
           SET @NewBalance =
              (SELECT CurrentBalance
               FROM Account
               WHERE AccountID = @AccountID) - (@TransactionAmount+10)
          -- record transaction.
   INSERT INTO [PiggyBank].[dbo].[Transactions]
            ([AccountID]
            ,[TransactionTypeID]
            ,[CustomerID]
            ,[TransactionDate]
            ,[TransactionAmount]
            ,[NewBalance])

   VALUES
          (@AccountID
          ,@TransactionTypeID
          ,@CustomerID
          ,GETDATE()
          ,@TransactionAmount
          ,@NewBalance)
                   UPDATE dbo.Account
                   SET CurrentBalance =@NewBalance
                   WHERE AccountID = @AccountID
           Print 'Not enough funds in main account to cover transaction.
           Transaction amount + $10 service fee HAS BEEN debited from this account'
         COMMIT TRAN
         END TRY
   --Catch errors
      BEGIN CATCH
   --Rollback transaction
           IF @@trancount > 0
           ROLLBACK TRAN
           DECLARE       @ErrorMessage      NVARCHAR(4000),
                         @ErrorState        INT
           SELECT        @ErrorMessage = ERROR_MESSAGE(),
                         @ErrorState      = ERROR_STATE()
           RAISERROR ( @ErrorMessage, 11, @ErrorState)
           RETURN
      END CATCH
   END
   GO
SSRS – SQL Server Reporting Services – This is a report I created using Visual Studio
2008. The source was a stored procedure in my PiggyBank project. I wanted to create a
statement listing the transactions along with customer name and address. The result
follows on the next slide.
   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
     <metahttp-equiv="content-type" content="text/html; charset=iso-8859-1" />
     <title>Simple HTML Form</title>
    </head>
    <body>

    <form action="handle_form.php" method="post">

     <fieldset><legend>Enter your information in the form below:</legend>

     <p> <b>Name:</b>
         <input type="text" name="name" size="20” maxlength="40" />
    </p>
     <p> <b> Email Address: </b>
        <input type="text" name="email" size="40“ maxlength="60" />
    </p>
     <p> <b>Gender:</b>
        <input type="radio" name="gender" value="M" />Male
        <input type="radio" name="gender" value="F" /> Female
    </p>
     <p> <b>Age:</b>
         <select name="age">
         <option value="0-29"> Under 30            </option>
         <option value="30-60"> Between 30 and 60 </option>
         <option value="60+"> Over 60             </option>
         </select>
    </p>
     <p> <b>Comments:</b>
        <textarea name="comments" rows="3" cols="40"></textarea>
    </p>
     </fieldset>
     <div align="center"><input type="submit" name="submit" value="Submit My Information" />
     </div>
    </form>
    </body>
   <html>
   <head>
    <title>PHP Test</title>
   </head>
   <body>
   <?php # handle_form.php
   // Create a shorthand for the form data.
   $name                   = $_REQUEST['name'];
   $email                  = $_REQUEST['email'];
   $comments               = $_REQUEST['comments'];
   $age                    = $_REQUEST['age'];
   $gender                 = $_REQUEST['gender'];
   //Validate the name and combat Magic Quotes, if necessary.
   if (!empty($_REQUEST['name']))
   { $name = stripslashes($_REQUEST['name']);
   } else {$name = NULL; echo „ <p><font color ="red">You forgot to enter your
    name!</font></p>';
   }
   //Validate the email address.
   if (!empty($_REQUEST['email'])) {
         $email = $_REQUEST['email'];
   } else {
         $email = NULL;
   echo '<p><font color="red"> You forgot to enter your email address! </font></p>';
   }
   //*Validate the comments and combat Magic Quotes, if necessary*//
   if ( !empty($_REQUEST['comments‟])) {
   $comments = stripslashes($_REQUEST['comments„]);
   } else { $comments = NULL;
   echo '<p><font color ="red">What? Nothing to say! You forgot to leave some comments! <font/>
           </p> ';
   }
   if (isset($_REQUEST['gender„])) {
      $gender = $_REQUEST['gender'];
   if ($gender == 'M') {
         $message = '<p><b>Good day, Sir!</b></p>';
      } elseif ($'gender == 'F‟) {
         $message = '<p><b>Good day, Madam!</b> </p>';
      } else {        // Unacceptable value.
         $message=NULL;
         echo '<p><font color="red">Gender should be either male or female!</font></p>';
      }
   } else {           //gender is not set.
      $gender = NULL;
      echo „ <p><font color="red">You forgot to select your gender! </font></p>';
   }
   // If everything is okay, print the message.
   if ($name && $email && $gender && $comments) {
   echo '<p>Thank you <b>$name</b> for the following comments: <br/>
        <tt>$comments</tt> </p>';
        echo '<p> We will reply to you at <i>$email</i></p> n';
        echo $message; // From the $gender conditional.
   } else {              // One form element was not filled out properly.
        echo „<p><font color="red">Please go back and fill out the form again.</font></p>';
   }
   ?>
   </body>
   </html>

Weitere ähnliche Inhalte

Was ist angesagt?

Taming forms with React
Taming forms with ReactTaming forms with React
Taming forms with ReactGreeceJS
 
Candies for everybody - Meet Magento Italia 2015
Candies for everybody - Meet Magento Italia 2015Candies for everybody - Meet Magento Italia 2015
Candies for everybody - Meet Magento Italia 2015Alberto López Martín
 
Alberto López: Candies for everybody: hacking from 9 a.m. to 6 p.m.
Alberto López: Candies for everybody: hacking from 9 a.m. to 6 p.m.Alberto López: Candies for everybody: hacking from 9 a.m. to 6 p.m.
Alberto López: Candies for everybody: hacking from 9 a.m. to 6 p.m.Meet Magento Italy
 
Rapid Prototyping with PEAR
Rapid Prototyping with PEARRapid Prototyping with PEAR
Rapid Prototyping with PEARMarkus Wolff
 
Who Needs Ruby When You've Got CodeIgniter
Who Needs Ruby When You've Got CodeIgniterWho Needs Ruby When You've Got CodeIgniter
Who Needs Ruby When You've Got CodeIgniterciconf
 
Frank Rodenbaugh Portfolio
Frank Rodenbaugh PortfolioFrank Rodenbaugh Portfolio
Frank Rodenbaugh PortfolioFrankRodenbaugh
 
Dig Deeper into WordPress - WD Meetup Cairo
Dig Deeper into WordPress - WD Meetup CairoDig Deeper into WordPress - WD Meetup Cairo
Dig Deeper into WordPress - WD Meetup CairoMohamed Mosaad
 
Tony Vitabile .Net Portfolio
Tony Vitabile .Net PortfolioTony Vitabile .Net Portfolio
Tony Vitabile .Net Portfoliovitabile
 
Library Website
Library WebsiteLibrary Website
Library Websitegholtron
 
Refactoring using Codeception
Refactoring using CodeceptionRefactoring using Codeception
Refactoring using CodeceptionJeroen van Dijk
 
TYCS Visual Basic Practicals
TYCS Visual Basic PracticalsTYCS Visual Basic Practicals
TYCS Visual Basic Practicalsyogita kachve
 
Zend_Form to the Rescue - A Brief Introduction to Zend_Form
Zend_Form to the Rescue - A Brief Introduction to Zend_FormZend_Form to the Rescue - A Brief Introduction to Zend_Form
Zend_Form to the Rescue - A Brief Introduction to Zend_FormJeremy Kendall
 
Form validation server side
Form validation server side Form validation server side
Form validation server side Mudasir Syed
 

Was ist angesagt? (20)

Web 6 | JavaScript DOM
Web 6 | JavaScript DOMWeb 6 | JavaScript DOM
Web 6 | JavaScript DOM
 
Taming forms with React
Taming forms with ReactTaming forms with React
Taming forms with React
 
Candies for everybody - Meet Magento Italia 2015
Candies for everybody - Meet Magento Italia 2015Candies for everybody - Meet Magento Italia 2015
Candies for everybody - Meet Magento Italia 2015
 
Alberto López: Candies for everybody: hacking from 9 a.m. to 6 p.m.
Alberto López: Candies for everybody: hacking from 9 a.m. to 6 p.m.Alberto López: Candies for everybody: hacking from 9 a.m. to 6 p.m.
Alberto López: Candies for everybody: hacking from 9 a.m. to 6 p.m.
 
Rapid Prototyping with PEAR
Rapid Prototyping with PEARRapid Prototyping with PEAR
Rapid Prototyping with PEAR
 
Who Needs Ruby When You've Got CodeIgniter
Who Needs Ruby When You've Got CodeIgniterWho Needs Ruby When You've Got CodeIgniter
Who Needs Ruby When You've Got CodeIgniter
 
Frank Rodenbaugh Portfolio
Frank Rodenbaugh PortfolioFrank Rodenbaugh Portfolio
Frank Rodenbaugh Portfolio
 
Dig Deeper into WordPress - WD Meetup Cairo
Dig Deeper into WordPress - WD Meetup CairoDig Deeper into WordPress - WD Meetup Cairo
Dig Deeper into WordPress - WD Meetup Cairo
 
Tony Vitabile .Net Portfolio
Tony Vitabile .Net PortfolioTony Vitabile .Net Portfolio
Tony Vitabile .Net Portfolio
 
Library Website
Library WebsiteLibrary Website
Library Website
 
Refactoring using Codeception
Refactoring using CodeceptionRefactoring using Codeception
Refactoring using Codeception
 
Os Nixon
Os NixonOs Nixon
Os Nixon
 
Web 5 | JavaScript Events
Web 5 | JavaScript EventsWeb 5 | JavaScript Events
Web 5 | JavaScript Events
 
Framework
FrameworkFramework
Framework
 
Order to cash cycle
Order to cash cycleOrder to cash cycle
Order to cash cycle
 
Javascript
JavascriptJavascript
Javascript
 
Ruby - Design patterns tdc2011
Ruby - Design patterns tdc2011Ruby - Design patterns tdc2011
Ruby - Design patterns tdc2011
 
TYCS Visual Basic Practicals
TYCS Visual Basic PracticalsTYCS Visual Basic Practicals
TYCS Visual Basic Practicals
 
Zend_Form to the Rescue - A Brief Introduction to Zend_Form
Zend_Form to the Rescue - A Brief Introduction to Zend_FormZend_Form to the Rescue - A Brief Introduction to Zend_Form
Zend_Form to the Rescue - A Brief Introduction to Zend_Form
 
Form validation server side
Form validation server side Form validation server side
Form validation server side
 

Andere mochten auch

Andere mochten auch (7)

A software factory in a box
A software factory in a boxA software factory in a box
A software factory in a box
 
Stored Procedure
Stored ProcedureStored Procedure
Stored Procedure
 
Advance Sql Server Store procedure Presentation
Advance Sql Server Store procedure PresentationAdvance Sql Server Store procedure Presentation
Advance Sql Server Store procedure Presentation
 
Stored procedures with cursor
Stored procedures with cursorStored procedures with cursor
Stored procedures with cursor
 
PHP and database functionality
PHP and database functionalityPHP and database functionality
PHP and database functionality
 
Pert 3. stored_procedure
Pert 3. stored_procedurePert 3. stored_procedure
Pert 3. stored_procedure
 
Stored procedure tunning
Stored procedure tunningStored procedure tunning
Stored procedure tunning
 

Ähnlich wie Shangz R Brown Presentation

Dependency injection - the right way
Dependency injection - the right wayDependency injection - the right way
Dependency injection - the right wayThibaud Desodt
 
Practical PHP by example Jan Leth-Kjaer
Practical PHP by example   Jan Leth-KjaerPractical PHP by example   Jan Leth-Kjaer
Practical PHP by example Jan Leth-KjaerCOMMON Europe
 
Serverless Functions and Vue.js
Serverless Functions and Vue.jsServerless Functions and Vue.js
Serverless Functions and Vue.jsSarah Drasner
 
WEB DESIGN PRACTICLE bca
WEB DESIGN PRACTICLE bcaWEB DESIGN PRACTICLE bca
WEB DESIGN PRACTICLE bcaYashKoli22
 
YASH HTML CODES
YASH HTML CODESYASH HTML CODES
YASH HTML CODESYashKoli22
 
YASH HTML CODE
YASH HTML CODE YASH HTML CODE
YASH HTML CODE YashKoli22
 
Kyoto sfdg meetup3_samplecode__forsharing
Kyoto sfdg meetup3_samplecode__forsharingKyoto sfdg meetup3_samplecode__forsharing
Kyoto sfdg meetup3_samplecode__forsharing友嗣 小野
 
Rajeev oops 2nd march
Rajeev oops 2nd marchRajeev oops 2nd march
Rajeev oops 2nd marchRajeev Sharan
 
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdf
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdfC++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdf
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdfJUSTSTYLISH3B2MOHALI
 
This what Im suppose to do and this is what I have so far.In thi.pdf
This what Im suppose to do and this is what I have so far.In thi.pdfThis what Im suppose to do and this is what I have so far.In thi.pdf
This what Im suppose to do and this is what I have so far.In thi.pdfkavithaarp
 
#include iostream #include BankAccountClass.cpp #include .pdf
#include iostream #include BankAccountClass.cpp #include .pdf#include iostream #include BankAccountClass.cpp #include .pdf
#include iostream #include BankAccountClass.cpp #include .pdfANJANEYAINTERIOURGAL
 
main.cpp #include iostream #include iomanip #include fs.pdf
main.cpp #include iostream #include iomanip #include fs.pdfmain.cpp #include iostream #include iomanip #include fs.pdf
main.cpp #include iostream #include iomanip #include fs.pdfarwholesalelors
 
Ruby on Rails For Java Programmers
Ruby on Rails For Java ProgrammersRuby on Rails For Java Programmers
Ruby on Rails For Java Programmerselliando dias
 

Ähnlich wie Shangz R Brown Presentation (20)

Presentation Paul
Presentation PaulPresentation Paul
Presentation Paul
 
Marcus Portfolio
Marcus  PortfolioMarcus  Portfolio
Marcus Portfolio
 
Banking Database
Banking DatabaseBanking Database
Banking Database
 
My Portfolio
My PortfolioMy Portfolio
My Portfolio
 
My Portfolio
My PortfolioMy Portfolio
My Portfolio
 
Marcus Matthews
Marcus MatthewsMarcus Matthews
Marcus Matthews
 
Dependency injection - the right way
Dependency injection - the right wayDependency injection - the right way
Dependency injection - the right way
 
Payments On Rails
Payments On RailsPayments On Rails
Payments On Rails
 
Practical PHP by example Jan Leth-Kjaer
Practical PHP by example   Jan Leth-KjaerPractical PHP by example   Jan Leth-Kjaer
Practical PHP by example Jan Leth-Kjaer
 
Serverless Functions and Vue.js
Serverless Functions and Vue.jsServerless Functions and Vue.js
Serverless Functions and Vue.js
 
WEB DESIGN PRACTICLE bca
WEB DESIGN PRACTICLE bcaWEB DESIGN PRACTICLE bca
WEB DESIGN PRACTICLE bca
 
YASH HTML CODES
YASH HTML CODESYASH HTML CODES
YASH HTML CODES
 
YASH HTML CODE
YASH HTML CODE YASH HTML CODE
YASH HTML CODE
 
Kyoto sfdg meetup3_samplecode__forsharing
Kyoto sfdg meetup3_samplecode__forsharingKyoto sfdg meetup3_samplecode__forsharing
Kyoto sfdg meetup3_samplecode__forsharing
 
Rajeev oops 2nd march
Rajeev oops 2nd marchRajeev oops 2nd march
Rajeev oops 2nd march
 
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdf
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdfC++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdf
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdf
 
This what Im suppose to do and this is what I have so far.In thi.pdf
This what Im suppose to do and this is what I have so far.In thi.pdfThis what Im suppose to do and this is what I have so far.In thi.pdf
This what Im suppose to do and this is what I have so far.In thi.pdf
 
#include iostream #include BankAccountClass.cpp #include .pdf
#include iostream #include BankAccountClass.cpp #include .pdf#include iostream #include BankAccountClass.cpp #include .pdf
#include iostream #include BankAccountClass.cpp #include .pdf
 
main.cpp #include iostream #include iomanip #include fs.pdf
main.cpp #include iostream #include iomanip #include fs.pdfmain.cpp #include iostream #include iomanip #include fs.pdf
main.cpp #include iostream #include iomanip #include fs.pdf
 
Ruby on Rails For Java Programmers
Ruby on Rails For Java ProgrammersRuby on Rails For Java Programmers
Ruby on Rails For Java Programmers
 

Mehr von shangbaby

Shangz Brown Excel Sample
Shangz Brown Excel SampleShangz Brown Excel Sample
Shangz Brown Excel Sampleshangbaby
 
Northwind Sales Contest Analysis
Northwind Sales Contest AnalysisNorthwind Sales Contest Analysis
Northwind Sales Contest Analysisshangbaby
 
Loan Interest Calculation
Loan Interest CalculationLoan Interest Calculation
Loan Interest Calculationshangbaby
 
Decision Analysis
Decision AnalysisDecision Analysis
Decision Analysisshangbaby
 
Brown Expository Essay
Brown Expository EssayBrown Expository Essay
Brown Expository Essayshangbaby
 
Cover Letter Only040511
Cover Letter Only040511Cover Letter Only040511
Cover Letter Only040511shangbaby
 

Mehr von shangbaby (6)

Shangz Brown Excel Sample
Shangz Brown Excel SampleShangz Brown Excel Sample
Shangz Brown Excel Sample
 
Northwind Sales Contest Analysis
Northwind Sales Contest AnalysisNorthwind Sales Contest Analysis
Northwind Sales Contest Analysis
 
Loan Interest Calculation
Loan Interest CalculationLoan Interest Calculation
Loan Interest Calculation
 
Decision Analysis
Decision AnalysisDecision Analysis
Decision Analysis
 
Brown Expository Essay
Brown Expository EssayBrown Expository Essay
Brown Expository Essay
 
Cover Letter Only040511
Cover Letter Only040511Cover Letter Only040511
Cover Letter Only040511
 

Shangz R Brown Presentation

  • 1. shangbaby@gmail.com 818-235-9779 http://www.shangbaby.net/joomlajoy
  • 2. •MSSQL SERVER user stored procedure •SSRS – Customer Transaction Summary •HTML Form – The HTML behind it! •PHP Form Validation – The PHP behind it!
  • 3. This particular piece of code creates a stored procedure. Upon execution it initially validates that the customer is linked to the account.  There are two other validations that has to do with entry of negative numbers in the “TransactionAmount” field and adding an overdraft service charge when there isn‟t any funds to cover the transaction.
  • 4. Microsoft SQL  USE [PiggyBank]  GO  /****** Object: StoredProcedure [dbo].[WithdrawalODFees] Script Date: 02/24/2011 13:23:09 ******/  SET ANSI_NULLS ON  GO  SET QUOTED_IDENTIFIER ON  GO  ---- =============================================  ---- Author: Shangz Brown  ---- Create date: 02/22/2011  ---- Description Withdrawal with overdraft fee generation  ---- =============================================  CREATE PROCEDURE [dbo].[WithdrawalODFees]  --Input and output parameters to create account  @CustomerID int = null,  @AccountID int = null,  @TransactionAmount money = null,  @TransactionTypeID int = null,  @NewBalance money OUTPUT  AS  SET XACT_ABORT ON  --Validate that @AccountID belongs to the same customer (linked in customer Accounts table)  IF (SELECT CustomerAccountID  FROM CustomerAccount  WHERE AccountID = @AccountID and CustomerID = @CustomerID) is null  BEGIN  raiserror('Account must be linked to the CustomerID entered', 11, 1)  RETURN  END
  • 5. This part of the T-SQL stored procedure code blocks activity on closed accounts that may be entered by users  --Block Transactions on inactive accounts.  IF (Select A.AccountID  FROM Account AS A  JOIN CustomerAccount AS CA  ON A.AccountID=CA.AccountID  WHERE AccountStatusID=2  AND CA.CustomerID=@CustomerID  AND A.AccountID =@AccountID) =@AccountID  BEGIN  raiserror('Transactions are not allowed on inactive accounts', 11, 1)  RETURN  END  --D/E CHECK: Prevent negative money amounts to be entered in the Transaction Amount parameter.  --Logic: You can not make a deposit via the withdraw proc.  IF @TransactionAmount <=0  BEGIN  raiserror('Transaction Amount can not be a negative number.', 11, 1)  RETURN  END  BEGIN  -- SET NOCOUNT ON added to prevent extra result sets from  -- interfering with SELECT statements.  SET NOCOUNT ON;
  • 6. -- Encapsulate procedure in a try catch block  BEGIN TRY  BEGIN TRAN  --make insert conditional  -- If TA >CB, AND test if EXIST [OD] is true, if TRUE proceed.  IF @TransactionAmount >  (SELECT CurrentBalance  FROM Account  WHERE AccountID =@AccountID)  AND exists (SELECT AccountID  FROM Account  WHERE OverDraftAccountID is not null)  SET @NewBalance =  (SELECT CurrentBalance  FROM Account  WHERE AccountID = @AccountID) - (@TransactionAmount+10)  -- record transaction.  INSERT INTO [PiggyBank].[dbo].[Transactions]  ([AccountID]  ,[TransactionTypeID]  ,[CustomerID]  ,[TransactionDate]  ,[TransactionAmount]  ,[NewBalance]) 
  • 7. VALUES  (@AccountID  ,@TransactionTypeID  ,@CustomerID  ,GETDATE()  ,@TransactionAmount  ,@NewBalance)  UPDATE dbo.Account  SET CurrentBalance =@NewBalance  WHERE AccountID = @AccountID  Print 'Not enough funds in main account to cover transaction.  Transaction amount + $10 service fee HAS BEEN debited from this account'  COMMIT TRAN  END TRY  --Catch errors  BEGIN CATCH  --Rollback transaction  IF @@trancount > 0  ROLLBACK TRAN  DECLARE @ErrorMessage NVARCHAR(4000),  @ErrorState INT  SELECT @ErrorMessage = ERROR_MESSAGE(),  @ErrorState = ERROR_STATE()  RAISERROR ( @ErrorMessage, 11, @ErrorState)  RETURN  END CATCH  END  GO
  • 8. SSRS – SQL Server Reporting Services – This is a report I created using Visual Studio 2008. The source was a stored procedure in my PiggyBank project. I wanted to create a statement listing the transactions along with customer name and address. The result follows on the next slide.
  • 9.
  • 10. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <metahttp-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>Simple HTML Form</title> </head> <body> <form action="handle_form.php" method="post"> <fieldset><legend>Enter your information in the form below:</legend> <p> <b>Name:</b>  <input type="text" name="name" size="20” maxlength="40" />  </p> <p> <b> Email Address: </b>  <input type="text" name="email" size="40“ maxlength="60" />  </p> <p> <b>Gender:</b>  <input type="radio" name="gender" value="M" />Male  <input type="radio" name="gender" value="F" /> Female  </p> <p> <b>Age:</b> <select name="age"> <option value="0-29"> Under 30 </option> <option value="30-60"> Between 30 and 60 </option> <option value="60+"> Over 60 </option> </select>  </p> <p> <b>Comments:</b>  <textarea name="comments" rows="3" cols="40"></textarea>  </p> </fieldset> <div align="center"><input type="submit" name="submit" value="Submit My Information" /> </div> </form> </body>
  • 11. <html>  <head>  <title>PHP Test</title>  </head>  <body>  <?php # handle_form.php  // Create a shorthand for the form data.  $name = $_REQUEST['name'];  $email = $_REQUEST['email'];  $comments = $_REQUEST['comments'];  $age = $_REQUEST['age'];  $gender = $_REQUEST['gender'];  //Validate the name and combat Magic Quotes, if necessary.  if (!empty($_REQUEST['name']))  { $name = stripslashes($_REQUEST['name']);  } else {$name = NULL; echo „ <p><font color ="red">You forgot to enter your name!</font></p>';  }  //Validate the email address.  if (!empty($_REQUEST['email'])) {  $email = $_REQUEST['email'];  } else {  $email = NULL;  echo '<p><font color="red"> You forgot to enter your email address! </font></p>';  }
  • 12. //*Validate the comments and combat Magic Quotes, if necessary*//  if ( !empty($_REQUEST['comments‟])) {  $comments = stripslashes($_REQUEST['comments„]);  } else { $comments = NULL;  echo '<p><font color ="red">What? Nothing to say! You forgot to leave some comments! <font/>  </p> ';  }  if (isset($_REQUEST['gender„])) {  $gender = $_REQUEST['gender'];  if ($gender == 'M') {  $message = '<p><b>Good day, Sir!</b></p>';  } elseif ($'gender == 'F‟) {  $message = '<p><b>Good day, Madam!</b> </p>';  } else { // Unacceptable value.  $message=NULL;  echo '<p><font color="red">Gender should be either male or female!</font></p>';  }  } else { //gender is not set.  $gender = NULL;  echo „ <p><font color="red">You forgot to select your gender! </font></p>';  }
  • 13. // If everything is okay, print the message.  if ($name && $email && $gender && $comments) {  echo '<p>Thank you <b>$name</b> for the following comments: <br/>  <tt>$comments</tt> </p>';  echo '<p> We will reply to you at <i>$email</i></p> n';  echo $message; // From the $gender conditional.  } else { // One form element was not filled out properly.  echo „<p><font color="red">Please go back and fill out the form again.</font></p>';  }  ?>  </body>  </html>