The GiftCertificate Data Access Class

The GiftCertificate class serves two main purposes. First, it encapsulates the query necessary to retrieve a gift certificate's value. Second, it houses the query needed to redeem a gift certificate.

The gift certificate value retrieval functionality is implemented in the GetGiftCertificate Value method, which is shown in Listing 11.1.

Listing 11.1. The GetGiftCertificateValue Method
public decimal GetGiftCertificateValue( int GCID )
{
    decimal retval = 0;

    SqlConnection conn = new SqlConnection(ConnectionString);
    SqlCommand myCommand = new SqlCommand("Select * from GiftCertificates where GCID=" +
 GCID.ToString(), ...

Get Building e-Commerce Sites with the .NET Framework now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.