You are on page 1of 63

SS TECH BOOK STORE

Introduction: SS TECH BOOK STORE

Background

SS Tech Book Store is an online shopping application that


allows the Web users to purchase books online.

Existing System

SS Tech Book Store maintains different files for storing the


information related to the customer details, book details,
transaction details, and payment details. Whenever, a user
asks for a book a sales person searches for the books that,
sometimes may take more time. Whenever a customer buys
a book, he is issued a bill. Whenever a customer purchases
books from their store and the store does not have the
customer details in the register, then a new entry is done.
The exact number of the books available is also not known
all the time and the bookstore people need to recount the
books available. The format of the bill is:

Department of Computer Science and Engineering, KITE-SOM

1
SS TECH BOOK STORE

SYSTEM SUMMARY

System Summary: SS Tech Book Store is an online shopping

module that facilitates users to purchase books online. The

application stores the details of the books selected by the user in

a shopping cart.The company has a bookstore in Orlando, Atlanta.

The company has now decided to expand its operations and plans

to develop an online Web application to spread its operations

worldwide.

Department of Computer Science and Engineering, KITE-SOM

2
SS TECH BOOK STORE

CONFIGURATION

Hardware: PC compatible with a Intel Pentium-IV


processor,1GB
RAM, and 20GB of Hard disk

Operating system: Windows Server 2003

Software: Microsoft Visual Studio .NET Enterprise 2008


Microsoft .NET Framework 3.5

Department of Computer Science and Engineering, KITE-SOM

3
SS TECH BOOK STORE

Online Automated System Requirement

As according to the existing system, the SS Tech Book Store


maintains files to store information. A lot of time is wasted
in manually maintaining these files. The senior management
in SS Tech Book Store has decided to expand its operations
to increase the customer base. With the increase in sales,
manual maintenance of files will be too difficult. Therefore,
the management is planning to develop an automated
system that will ease the book-shopping procedure and
ensure easy maintenance of information.

The management of SS Tech Book has decided to develop


a SS Tech Book Online Shopping (SSTBOS) application,
which will change the entire book shopping process to an
automated Web-based system. Using SSTBOS, customers
will be able to shop for books online, without visiting any
physical location of SS Tech Book Store.

SSTBOS will enable online book shoppers to search for


books available in the SS Tech Book Store. Online shoppers
will also be able to store their selected books in a shopping
cart and pay for books online using credit cards. SSTBOS
will maintain records of all the sales transactions to help in
creating reports for Management Information System (MIS).
To provide all the envisioned functionalities, SSTBOS should
have following features:

1. The system should have a mechanism to search the


books available in the SS Tech Book Store. Searches for
books should be made category-wise, such as computer
books, medical books and engineering books. The search
mechanism will display the list of the books in a selected

Department of Computer Science and Engineering, KITE-SOM

4
SS TECH BOOK STORE

category. Online users will be able to check book details


such as book name, book price, author name, publisher
name and ISBN number from the search result list.

2. The system should have a mechanism to register new


users. To buy books online, an online user will need to
register himself with SS Tech Book Store. A unique user
name will be assigned after successful registration. Using
the user name, a registered user will be able to shop for
books online.

3. The system should have a login mechanism to


authenticate credentials of registered users. Every registered
user will have to login before searching or buying books.

4. The system should maintain the details of book


information, registered users information, bill information
and payment information in a centralized database named
SS TechBookStore. The details of book information to be
stored include book id, category name, book title, author,
publisher, ISBN, book price and book description. The details
of registered user’s information to be stored include user
name, password, first name, last name, address, city, state,
pin code, email and phone. The details of bill information to
be stored
Include bill number, book id and book purchase date. The
details of payment information to be stored include bill
number, total bill amount, user name, credit card number
and credit card type.

5. The system should have a mechanism to maintain unique


sessions for authorized users. The system should keep track
of user sessions as the user browses through the Web site of
SSTBOS. Once the user logs out from the site, the user
session will get invalidated.

Department of Computer Science and Engineering, KITE-SOM

5
SS TECH BOOK STORE

6. The system should have a mechanism in which an online


user can add the selected books in a shopping cart. A user
should also be able to remove books stored in the shopping
cart.

7. The system should have a mechanism in which an online


user can view the total price of all the books stored in a
shopping cart in different currencies. The system will use a
Web service to display price information in different
currencies as per the prevailing exchange rate.

8. The system should have a mechanism to make online


payments using credit cards. Credit card numbers will be
verified before confirming online book purchase.

Department of Computer Science and Engineering, KITE-SOM

6
SS TECH BOOK STORE

To implement all the features, the SSTBOS system needs to

have the following modules:

 Login module to check the credentials of registered

users.
 Registration module to register a new user.
 Core module 1 to implement the search functionality to

search books category wise.


 Core module 2 to implement session management and

to implement SSTBOS system application functionality

such as adding books in a shopping cart and removing

books from the shopping cart.


 Web service module to create a Web service to display

total book price in different currencies.


 Payment module to manage the online book purchase

USE CASE DIAGRAM

Department of Computer Science and Engineering, KITE-SOM

7
SS TECH BOOK STORE

Use case Diagram representing the functional


relationship among various actors in the system.

Department of Computer Science and Engineering, KITE-SOM

8
SS TECH BOOK STORE

E-R DIAGRAM

Database Name: SSTechBookStore


E-R Diagram representing the relationship among
various entities of the database.

Department of Computer Science and Engineering, KITE-SOM

9
SS TECH BOOK STORE

SCHEMATIC DIAGRAM OF DATABASE

Database Name: SSTechBookStore


Schematic diagram of the database depicting the primary
and foreign key relationships.

Department of Computer Science and Engineering, KITE-SOM

10
SS TECH BOOK STORE

LOGICAL FLOW DIAGRAM

Logical Flow Diagram representing the control flow the


application.

Search.aspx.cs ShoppingCart.aspx
Search.aspx

ShoppingCart.aspx.cs
Login.aspx Login.aspx.cs

Registration.aspx CreditCard.aspx Currency Converter


Web Service

CreditCard.aspx.cs
Registration.aspx.cs

CheckOut.aspx

CheckOut.aspx.cs

Department of Computer Science and Engineering, KITE-SOM

11
SS TECH BOOK STORE

PROJECT FILE DETAILS


Sr.No. File Name Remarks
1 Login.aspx Contains the User
Interface
(UI) to for welcome
page
incorporated with login
page
for online shopping
application.
It displays three
hyperlinks,
Search Books,
Registration,
Member Login and
Logout.
2 Login.aspx.cs Contains the code to
accept
the user information
sent from
the login page and
validates
the user. On successful
user
authentication, a
session for
the user is created. It
contains
the code to accept user
information and verify
it with
the user information
stored in
the database.

Department of Computer Science and Engineering, KITE-SOM

12
SS TECH BOOK STORE

3 Registration.aspx Contains the UI that


displays a
user registration form
to
register a new Web
site user.
The user after filling
the form
clicks the Submit
button to
transfer the user
information
to the
Registration.aspx.cs.
4 Registration.aspx.cs Contains the code to
accept
the user information
submitted
by a new user. After
accepting
the user information
the aspx
page stores the user
information in the
UserProfile
table of the
NewTechBookStore
database.
5 Search.aspx Contains the UI to
display the
user interface to select
the
category of books that
the
user wants to search.
6 Search.aspx.cs Contains the code to

Department of Computer Science and Engineering, KITE-SOM

13
SS TECH BOOK STORE

display
the books of a selected
category in data grid
and store
the books selected by
the user
in the shopping cart.
7 ShoppingCart.aspx Contains User
Interface that
displays the final list of
all the
selected books in the
shopping
cart with an option to
remove
any of the selected
books from
the cart. It also has a
link to
the Credit Card details
page
for the payment.
8 ShoppingCart.aspx.cs Contains the code to
accept
the details of the books
purchased by the user
and
calculates the total bill
that the
user needs to pay.
9 CardDetails.aspx Contains the UI that
displays
the form to accept the
credit
card details to make
the

Department of Computer Science and Engineering, KITE-SOM

14
SS TECH BOOK STORE

payment. The user


after filling
the form clicks the
Submit
button to transfer the
card
details to the
CardDetails.aspx.cs.
10 CardDetails.aspx.cs Contains the code that
validates the card
number,
card type and expiry
date of
the card provided by
the user
for payment.
11 CheckOut.aspx Contains the UI to
display a
customer bill layout
that wraps
the bill number, bill
date,
books title and price
for each
book purchased. It also
displays the currency
equivalent in Euro,
Ruble, Yen
and Pound
corresponding to
Indian National Rupee.
12 ChekOut.aspx.cs Contains the code that
collects
the data from multiple
tables
in database for the

Department of Computer Science and Engineering, KITE-SOM

15
SS TECH BOOK STORE

creation of
bill.
13 CurrencyConverter.asmx This is a Web service,
which
converts total book
price
amount in different
world
currencies.
14 CurrencyConverter.asmx.cs Contains the code to
declare
the Web service
method
converting book price
in
different world
currencies.
15 Header.ascx Contains the web
control for
header layout common
to
every page.

Department of Computer Science and Engineering, KITE-SOM

16
SS TECH BOOK STORE

Language Used: c#(ASP.Net )

Introduction: Microsoft Visual Studio.Net (ASP.NET) is Microsoft’s solution


to creating dynamic web pages. An ASP.Net file can contain text, HTML tags
and scripts. Scripts in an asp file are executed on the server.

What is ASP.Net?

ASP.Net is a program that runs at server. With Windows 2000/XP


IIS plays the role of server. IIS comes as a free component with Windows
2000/XP.

The detailed discussion about IIS has been given as separate topic.

An ASP.Net file is just the same as an HTML file; it can contain


text, HTML, XML, and scripts. Scripts in an ASP.Net file are executed on the
server and it has an extension .aspx.

In ASP.Net Client-Server Model is implemented. A client computer


requests some needed information from Server computer. The Server
returns this information and the client acts on it. The client is a web
browser on the internet. With the internet the server is a particular web
server. A web server is a computer that contains all the web pages for a

Department of Computer Science and Engineering, KITE-SOM

17
SS TECH BOOK STORE

particular web site and has special software installed to send these web
pages to web browsers that request them.

ABOUT HTML:

Hypertext Markup Language (HTML) is a language for describing


how pages of text, graphics, and other information are organized. Hypertext
means text stored in electronic form with cross-reference links between
pages.

HTML pages are standard interface to the Internet. A web browser


just retrieves a file and put it on the screen. It actually assembles the
component parts of a page and arranges those parts according to
commands hidden in the text by the author of the file. Those commands
are written in the HTML. The most popular HTML compatible browsers are
Internet Explorer and Netscape Navigator.

Department of Computer Science and Engineering, KITE-SOM

18
SS TECH BOOK STORE

C# (pronounced "see sharp") is a multi-paradigm programming language


encompassing imperative, functional, generic, object-oriented (class-
based), and component-oriented programming disciplines. It was developed
by Microsoft within the .NET initiative and later approved as a standard by
Ecma (ECMA-334) and ISO (ISO/IEC 23270). C# is one of the programming
languages designed for the Common Language Infrastructure.

C# is intended to be a simple, modern, general-purpose, object-oriented


programming language. Its development team is led by Anders Hejlsberg,
the designer of Borland's Turbo Pascal, who has said that its object-oriented
syntax is based on 22C++ and other languages.The most recent version is
3030C# 3.0, which was released in conjunction with the .NET Framework
3.5 in 2007. The next proposed version, 40.4.0, is in development.

Design goals

The Ecma standard lists these design goals for C#:

 C# language is intended to be a simple, modern, general-purpose,


object-oriented programming language.
 The language, and implementations thereof, should provide support
for software engineering principles such as strong type checking,
array bounds checking, detection of attempts to use uninitialized
variables, and automatic garbage collection. Software robustness,
durability, and programmer productivity are important.

Department of Computer Science and Engineering, KITE-SOM

19
SS TECH BOOK STORE

 The language is intended for use in developing software components


suitable for deployment in distributed environments.

 Source code portability is very important, as is programmer


portability, especially for those programmers already familiar with C
and C++.

 Support for internationalization is very important.

 C# is intended to be suitable for writing applications for both hosted


and embedded systems, ranging from the very large that use
sophisticated operating systems, down to the very small having
dedicated functions.

 Although C# applications are intended to be economical with regard


to memory and processing power requirements, the language was
not intended to compete directly on performance and size with C or
assembly language.

Language name

The name "C sharp" was inspired from musical notation where a sharp
indicates that the written note should be made a half-step higher in

Department of Computer Science and Engineering, KITE-SOM

20
SS TECH BOOK STORE

pitch.This is similar to the language name of 22C++, where "++" indicates


that a variable should be incremented by 1.

Due to technical limitations of display (standard fonts, browsers, etc.) and


the fact that the sharp symbol (♯, U+266F, MUSIC SHARP SIGN) is not
present on the standard keyboard, the number sign (#, U+0023, NUMBER
SIGN) was chosen to represent the sharp symbol in the written name of the
programming language.This convention is reflected in the ECMA-334 C#
Language Specification. However, when it is practical to do so (for example,
in advertising or in box art), Microsoft uses the intended musical symbol.

The "sharp" suffix has been used by a number of other .NET languages that
are variants of existing languages, including J# (a .NET language also
designed by Microsoft which is derived from Java 1.1), A# (from Ada), and
the functional F#.The original implementation of Eiffel for .NET was called
Eiffel#, a name since retired since the full Eiffel language is now supported.
The suffix has also been used for libraries, such as Gtk# (a .NET wrapper for
2GTK+ and other GNOME libraries), Cocoa# (a wrapper for Cocoa) and 1Qt#
(a .NET language binding for the Qt toolkit).

History

During the development of the .NET Framework, the class libraries were
originally written using a managed code compiler system called Simple
Managed C (SMC).In January 1999, Anders Hejlsberg formed a team to
build a new language at the time called Cool, which stood for "C-like Object

Department of Computer Science and Engineering, KITE-SOM

21
SS TECH BOOK STORE

Oriented Language". Microsoft had considered keeping the name "Cool" as


the final name of the language, but chose not to do so for trademark
reasons. By the time the .NET project was publicly announced at the July
2000 Professional Developers Conference, the language had been renamed
C#, and the class libraries and ASP.NET runtime had been ported to C#.

C#'s principal designer and lead architect at Microsoft is Anders Hejlsberg,


who was previously involved with the design of Turbo Pascal, Embarcadero
Delphi (formerly CodeGear Delphi and Borland Delphi), and 22Visual J++. In
interviews and technical papers he has stated that flaws in most major
programming languages (e.g. 22C++, Java, Delphi, and Smalltalk) drove the
fundamentals of the Common Language Runtime (CLR), which, in turn,
drove the design of the C# programming language itself.

James Gosling, who created the Java programming language in 1994, and
Billy Joy, a co-founder of Sun Microsystems, the proprietor of Java, called C#
an "imitation" of Java; Gosling further claimed that "[C# is] sort of Java with
reliability, productivity and security deleted."Klaus Kreft and Angelika
Langer (authors of a C++ streams book) stated in a blog post that "Java and
C# are almost identical programming languages. Boring repetition that lacks
innovation," "Hardly anybody will claim that Java or C# are revolutionary
programming languages that changed the way we write programs," and "C#
borrowed a lot from Java - and vice versa. Now that C# supports boxing and
unboxing, we'll have a very similar feature in Java."

Department of Computer Science and Engineering, KITE-SOM

22
SS TECH BOOK STORE

Versions
In the course of its development, the C# language has gone through several versions:

Versio Language
Microsoft Compiler
n Specification

C# 1.0 December 2001 January 2002

C# 2.0 December 2002 November 2005

C# 3.0 June 2005 November 2006

Intended release March 2010 [17] (Expected


C# 4.0 June 2006
delayed)

Features

By design, C# is the programming language that most directly reflects the


underlying Common Language Infrastructure (CLI). Most of its intrinsic
types correspond to value-types implemented by the CLI framework.
However, the language specification does not state the code generation
requirements of the compiler: that is, it does not state that a C# compiler
must target a Common Language Runtime, or generate Common
Intermediate Language (CIL), or generate any other specific format.

Department of Computer Science and Engineering, KITE-SOM

23
SS TECH BOOK STORE

Theoretically, a C# compiler could generate machine code like traditional


compilers of C++ or FORTRAN.

Some notable distinguishing features of C# are:

 There are no global variables or functions. All methods and members


must be declared within classes. Static members of public classes can
substitute for global variables and functions.
 Local variables cannot shadow variables of the enclosing block, unlike
C and C++. Variable shadowing is often considered confusing by C++
texts.

 C# supports a strict Boolean datatype, bool. Statements that take


conditions, such as while and if, require an expression of a type that
implements the true operator, such as the boolean type. While C++
also has a boolean type, it can be freely converted to and from
integers, and expressions such as if(a) require only that a is
convertible to bool, allowing a to be an int, or a pointer. C# disallows
this "integer meaning true or false" approach on the grounds that
forcing programmers to use expressions that return exactly bool can
prevent certain types of programming mistakes such as if (a = b) (use
of = instead of ==).

 In C#, memory address pointers can only be used within blocks


specifically marked as unsafe, and programs with unsafe code need
appropriate permissions to run. Most object access is done through

Department of Computer Science and Engineering, KITE-SOM

24
SS TECH BOOK STORE

safe object references, which always either point to a "live" object or


have the well-defined null value; it is impossible to obtain a reference
to a "dead" object (one which has been garbage collected), or to a
random block of memory. An unsafe pointer can point to an instance
of a value-type, array, string, or a block of memory allocated on a
stack. Code that is not marked as unsafe can still store and
manipulate pointers through the System.IntPtr type, but it cannot
dereference them.

 Managed memory cannot be explicitly freed; instead, it is


automatically garbage collected. Garbage collection addresses the
problem of memory leaks by freeing the programmer of
responsibility for releasing memory which is no longer needed.

 In addition to the try...catch construct to handle exceptions, C# has a


try...finally construct to guarantee execution of the code in the finally
block.

 Multiple inheritance is not supported, although a class can


implement any number of interfaces. This was a design decision by
the language's lead architect to avoid complication and simplify
architectural requirements throughout CLI.

 C# is more typesafe than C++. The only implicit conversions by default


are those which are considered safe, such as widening of integers.
This is enforced at compile-time, during JIT, and, in some cases, at

Department of Computer Science and Engineering, KITE-SOM

25
SS TECH BOOK STORE

runtime. There are no implicit conversions between booleans and


integers, nor between enumeration members and integers (except
for literal 0, which can be implicitly converted to any enumerated
type). Any user-defined conversion must be explicitly marked as
explicit or implicit, unlike C++ copy constructors and conversion
operators, which are both implicit by default.

 Enumeration members are placed in their own scope.

 C# provides properties as syntactic sugar for a common pattern in


which a pair of methods, accessor (getter) and mutator (setter)
encapsulate operations on a single attribute of a class.

DATABASE SYSTEM USED: SQL Server 2005

WHY SQL Server 2005?

SQL Server is one of the most popular RDBMS of today. Its Popularity is
owned to a number of factors like its ability to support dozens to thousands
of simultaneous users, its ability to handle high transaction rates and its
ability to access databases that ranges in size from several hundred
megabytes to many gigabytes.

Department of Computer Science and Engineering, KITE-SOM

26
SS TECH BOOK STORE

SQL Server 2005 is based on new architecture; know as NCA (Network


Computing Architecture). NCA is a three-tried architecture as opposed to
client/server architecture that is two tired.

There are many features of SQL Server

Security Management: SQL Server provides a controlled access to data to


users by providing a combination of privileges.

Backup and Recovery: SQL Server provided sophisticated security backup


and recovery routines.

Department of Computer Science and Engineering, KITE-SOM

27
SS TECH BOOK STORE

Department of Computer Science and Engineering, KITE-SOM

28
SS TECH BOOK STORE

---------------------------------------------------------------------------------------------------------------------------------
---------------
CardDetails.aspx.CS
---------------------------------------------------------------------------------------------------------------------------------
---------------

using Microsoft.VisualBasic;
using System.Data;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System;
using System.Collections;
using System.Web;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Drawing;
using System.Data.SqlClient;
using System.Text.RegularExpressions;

namespace SSTBS
{
/// <summary>
/// Summary description for CardDetails.
/// </summary>
public partial class CardDetails :
System.Web.UI.Page
{

private static Regex _isNumber = new


Regex(@"^\d+$");

public static bool IsNumeric(string


theValue)
{
Match m = _isNumber.Match(theValue);
return m.Success;
}

private Collection myCollection;

Department of Computer Science and Engineering, KITE-SOM

29
SS TECH BOOK STORE

protected void Page_Load(object sender,


System.EventArgs e)
{
// Put user code to initialize the
page here
myCollection =
(Collection)Session["BookIds"];
}

#region Web Form Designer generated code


override protected void OnInit(EventArgs
e)
{
//
// CODEGEN: This call is required by
the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support -
do not modify
/// the contents of this method with the
code editor.
/// </summary>
private void InitializeComponent()
{

}
#endregion

private void InsertPayment ()


{

try

Department of Computer Science and Engineering, KITE-SOM

30
SS TECH BOOK STORE

{
SqlConnection Con = new
SqlConnection("Integrated Security=True;Initial
Catalog=SSTBS; Data Source=CLIENTBASE01");
int RetVal;

Con.Open();
Session["netAmount"] =
CalculateAmount();
SqlCommand cmd = new
SqlCommand("INSERT INTO
Payment(TotalAmount,UserName,CreditCardNum,CreditCa
rdType) Values(" + Session["netAmount"] + ",'" +
Session["UserName"] + "','" + txtCardNo.Text +
"','" + ddlCardType.SelectedItem.Text + "')", Con);
RetVal = cmd.ExecuteNonQuery();

if (RetVal > 0)
{
int i;
object BillNo = GetBillNo();
for (i = 1; i <=
myCollection.Count; i++)
{
SqlCommand cmd1 = new
SqlCommand("Insert into Bill(BillNo,BookID) values
(" + BillNo + "," + myCollection[i] + ")", Con);
RetVal =
cmd1.ExecuteNonQuery();
if (RetVal == 0)
{
lblError.Text =
"Error occured while updating transactions..Please
contact system administrator";
break;
}
}
}

Department of Computer Science and Engineering, KITE-SOM

31
SS TECH BOOK STORE

else
{
lblError.Text = "Error occured
while updating transactions..Please contact system
administrator";
}
Con.Close();
Con.Dispose();

}
catch (Exception)
{
lblError.Text = "Error occurred
while card validation. Please contact system
administrator.";
}
}

private double CalculateAmount()


{
double NetAmount;
try
{
SqlConnection Con = new
SqlConnection("Integrated Security=True;Initial
Catalog=SSTBS; Data Source=CLIENTBASE01");

SqlCommand Cmd = new SqlCommand();


string SqlString = "Select
Sum(Price) as sum from BookDetails Where BookId IN
(";
int i;
for (i = 1; i <=
myCollection.Count - 1; i++)
{
SqlString = SqlString +
myCollection[i] + ", ";
}

Department of Computer Science and Engineering, KITE-SOM

32
SS TECH BOOK STORE

SqlString = SqlString +
myCollection[i] + ")";
SqlDataAdapter da = new
SqlDataAdapter(SqlString, Con);
Con.Open();
DataSet ds = new DataSet();
da.Fill(ds);
NetAmount =
System.Convert.ToDouble(ds.Tables[0].Rows[0]
["sum"]);
Con.Close();
Con.Dispose();
return NetAmount;
}
catch (Exception)
{
lblError.Text = "Error occurred.
Please contact system administrator.";
return 0;
}
}

private int GetBillNo()


{
SqlDataReader dr;
int billNo;
SqlConnection cn = new
SqlConnection("Integrated Security=True;Initial
Catalog=SSTBS; Data Source=CLIENTBASE01");
try
{
cn.Open();
SqlCommand cmd2 = new
SqlCommand("Select Max(BillNo) from Payment", cn);
dr = cmd2.ExecuteReader();
if (dr.HasRows)
{
dr.Read();

Department of Computer Science and Engineering, KITE-SOM

33
SS TECH BOOK STORE

billNo = (int)dr[0];
}
else
{
billNo = 0;
}
Session["BillNo"] = billNo;
dr.Close();
return billNo;
}
catch (Exception)
{
lblError.Text = "Error occurred.
Contact system admnistrator";
return 0;
}

protected void lnkProceed_Click(object


sender, System.EventArgs e)
{
lblError.Text = "";
try
{
if ((txtCardNo.Text.Length < 16) &&
(IsNumeric(txtCardNo.Text)))
{
lblError.Text = "Card No is Not
Valid.";
}
else
{
if (ddlCardType.SelectedValue
== "0")
{
lblError.Text =
lblError.Text + " Please select card type.";

Department of Computer Science and Engineering, KITE-SOM

34
SS TECH BOOK STORE

}
else if
((ddlMonth.SelectedValue.Trim().ToString() == "0")
|| (ddlYear.SelectedValue.Trim().ToString() ==
"0"))
{
lblError.Text =
lblError.Text + " Please select valid date.";
}
else
{
InsertPayment();

Response.Redirect("CheckOut.aspx");
}
}

}
catch (Exception)
{
lblError.Text = "Error occurred
while submission. Please contact system
administrator.";
}

}
}
---------------------------------------------------------------------------------------------------------------------------------
---------------

CheckOut.aspx.cs
---------------------------------------------------------------------------------------------------------------------------------
---------------
using Microsoft.VisualBasic;
using System.Data;
using System.Web.UI;
using System.Web.UI.HtmlControls;

Department of Computer Science and Engineering, KITE-SOM

35
SS TECH BOOK STORE

using System;
using System.Collections;
using System.Web;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Drawing;
using System.Data.SqlClient;
using SSTBS;

namespace SSTBS
{
/// <summary>
/// Summary description for CheckOut.
/// </summary>
public partial class CheckOut :
System.Web.UI.Page
{

private int BillNo;


private DateTime BillDate;
private Collection myCollection;

protected void Page_Load(object sender,


System.EventArgs e)
{
// Put user code to initialize the
page here
myCollection =
(Collection)Session["BookIds"];
if (! IsPostBack)
{
GetBillInfo();
FillGrid();
BillReport();
}
}

Department of Computer Science and Engineering, KITE-SOM

36
SS TECH BOOK STORE

#region Web Form Designer generated code


override protected void OnInit(EventArgs
e)
{
//
// CODEGEN: This call is required by
the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support -
do not modify
/// the contents of this method with the
code editor.
/// </summary>
private void InitializeComponent()
{

}
#endregion

private void FillGrid ()


{
DataSet ds = new DataSet();
string SqlString;
SqlString = "Select title, price from
BookDetails Where BookId In (";
int i;
for (i = 1; i <= myCollection.Count -
1; i++)
{
SqlString = SqlString +
myCollection[i] + ", ";
}
SqlString = SqlString +

Department of Computer Science and Engineering, KITE-SOM

37
SS TECH BOOK STORE

myCollection[i] + ")";
try
{
SqlConnection con = new
SqlConnection("Integrated Security=True;Initial
Catalog=SSTBS; Data Source=CLIENTBASE01");
SqlDataAdapter da = new
SqlDataAdapter(SqlString,con);
da.Fill(ds);
dgCheckOut.DataSource = ds;
dgCheckOut.DataBind();
}
catch (Exception)
{
lblError.Text = "Error
occurred...";
}
}
private void GetBillInfo ()
{
SqlConnection cn = new
SqlConnection("Integrated Security=True;Initial
Catalog=SSTBS; Data Source=CLIENTBASE01");
SqlDataAdapter da = new
SqlDataAdapter("Select max(BillNo) as
billno,max(Currentdate) as date from Payment where
UserName='" + Session["Username"] + "'", cn);
DataSet ds = new DataSet();
try
{
cn.Open();
da.Fill(ds);
BillNo =
System.Convert.ToInt32(ds.Tables[0].Rows[0][0]);
BillDate =
System.Convert.ToDateTime(ds.Tables[0].Rows[0][1]);
}
catch (Exception ex)

Department of Computer Science and Engineering, KITE-SOM

38
SS TECH BOOK STORE

{
lblError.Text = ex.Message;
//lblError.Text = "Error occurred
while creating bill. Contact system admnistrator"
}

}
private void BillReport ()
{
try
{
localhost.CurrencyConverter cc =
new localhost.CurrencyConverter();
double[] ArrCurrency =
cc.GetCurrencyInfo(System.Convert.ToDouble(Session[
"netAmount"]));
lblBillNo.Text =
BillNo.ToString();
lblBillDate.Text =
BillDate.ToString();
lblINR.Text =
string.Format("{0:C}", Session["netAmount"]);
lblEuro.Text =
ArrCurrency[0].ToString();
lblRuble.Text =
ArrCurrency[1].ToString();
lblYen.Text =
ArrCurrency[2].ToString();
lblPound.Text =
ArrCurrency[3].ToString();
}
catch (Exception)
{
lblError.Text = lblError.Text +
"Error occurred while creating Bill.";
}

Department of Computer Science and Engineering, KITE-SOM

39
SS TECH BOOK STORE

}
}

---------------------------------------------------------------------------------------------------------------------------------
---------------

Login.aspx.cs
---------------------------------------------------------------------------------------------------------------------------------
---------------
using System.Data;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System;
using System.Collections;
using System.Web;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Drawing;
using System.Data.SqlClient;
using System.Web.Security;

namespace SSTBS
{
/// <summary>
/// Summary description for Login.
/// </summary>
public partial class Login : System.Web.UI.Page
{

protected void Page_Load(object sender,


System.EventArgs e)
{
// Put user code to initialize the
page here
}

#region Web Form Designer generated code


override protected void OnInit(EventArgs

Department of Computer Science and Engineering, KITE-SOM

40
SS TECH BOOK STORE

e)
{
//
// CODEGEN: This call is required by
the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support -
do not modify
/// the contents of this method with the
code editor.
/// </summary>
private void InitializeComponent()
{

}
#endregion

private bool ValidateUser(string uid,


string passwd)
{
SqlDataReader dr;
try
{
SqlConnection cn = new
SqlConnection("Integrated Security=True;Initial
Catalog=SSTBS; Data Source=CLIENTBASE01");
SqlCommand cmd = new
SqlCommand("Select * From UserProfile Where
UserName='" + uid + "'",cn);
cn.Open();
dr = cmd.ExecuteReader();
while (dr.Read())
{

Department of Computer Science and Engineering, KITE-SOM

41
SS TECH BOOK STORE

if
(string.Compare(dr["Password"].ToString(), passwd,
false) == 0)
{
dr.Close();
Session["Username"] =
uid;
return true;
}
}
dr.Close();
return false;
}
catch (Exception)
{
lblError.Text = "Error occured
while validating user. Please contact system
administrator.";
return false;
}
}

protected void lnkLogin_Click(object


sender, System.EventArgs e)
{
if (!
ValidateUser(txtUserName.Value.ToString(),
txtPassword.Value.ToString()))
{
lblError.Text = "Login
failed..Invalid username/password. Register to
proceed";
}
else
{

FormsAuthentication.SetAuthCookie(txtUserName.Value
.Trim(), false);

Department of Computer Science and Engineering, KITE-SOM

42
SS TECH BOOK STORE

Response.Redirect("Search.aspx");
}
}
}
}
---------------------------------------------------------------------------------------------------------------------------------
---------------

Registration.aspx.cs
---------------------------------------------------------------------------------------------------------------------------------
---------------
using Microsoft.VisualBasic;
using System.Data;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System;
using System.Collections;
using System.Web;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Drawing;
using System.Data.SqlClient;
using System.Web.Security;

namespace SSTBS
{
/// <summary>
/// Summary description for Registration.
/// </summary>
public partial class Registration :
System.Web.UI.Page
{

protected void Page_Load(object sender,


System.EventArgs e)
{
// Put user code to initialize the
page here
}

Department of Computer Science and Engineering, KITE-SOM

43
SS TECH BOOK STORE

#region Web Form Designer generated code


override protected void OnInit(EventArgs
e)
{
//
// CODEGEN: This call is required by
the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support -
do not modify
/// the contents of this method with the
code editor.
/// </summary>
private void InitializeComponent()
{

}
#endregion

private bool CheckUserName(string


UserName)
{
SqlDataReader dr;
SqlConnection con = new
SqlConnection("Integrated Security=True;Initial
Catalog=SSTBS; Data Source=CLIENTBASE01");
SqlCommand cmd = new SqlCommand("Select
* from UserProfile where UserName='" + UserName +
"'");
con.Open();
dr = cmd.ExecuteReader();
while (dr.Read())
{

Department of Computer Science and Engineering, KITE-SOM

44
SS TECH BOOK STORE

if
(string.Compare(dr["UserName"].ToString(),
UserName, false) == 0)
{
dr.Close();
return true;
}
}
dr.Close();
return false;
}

private int InsertRecord(string UserName,


string Password, string FirstName, string
MiddleName, string LastName, string Address1,
string Address2, string City, string State, string
PinCode, string Email, string Phone)
{
int rowsAffected = 0;
try
{
SqlConnection con = new
SqlConnection("Integrated Security=True;Initial
Catalog=SSTBS; Data Source=CLIENTBASE01");
SqlCommand cmd = new
SqlCommand("INSERT INTO UserProfile(UserName,
Password, FirstName, MiddleName, LastName,
Address1, Address2, City, State, PinCode, Email,
Phone) VALUES ('" + UserName + "', '" + Password +
"', '" + FirstName + "', '" + MiddleName + "', '" +
LastName + "', '" + Address1 + "', '" + Address2 +
"', '" + City + "', '" + State + "', '" + PinCode +
"', '" + Email + "', '" + Phone + "')",con);
con.Open();
rowsAffected =
cmd.ExecuteNonQuery();

Department of Computer Science and Engineering, KITE-SOM

45
SS TECH BOOK STORE

}
catch (Exception ex)
{
lblErr.Text = ex.Message + " :
Please contact your administrator";
}
return rowsAffected;
}

private void ResetControls ()


{
txtAddress1.Value = "";
txtAddress2.Value = "";
txtCity.Value = "";
txtEmail.Value = "";
txtFirstName.Value = "";
txtLastName.Value = "";
txtMiddleName.Value = "";
txtPassword.Value = "";
txtREPassword.Value = "";
txtState.Value = "";
txtTelephone.Value = "";
txtUserName.Value = "";
txtZip.Value = "";
}

protected void btnSubmit_Click(object


sender, System.EventArgs e)
{
if (IsValid)
{

if
(CheckUserName(txtUserName.Value))
{
UsrLabel.Font.Bold = true;
UsrLabel.Text = "Username
exists..Please choose another Username";

Department of Computer Science and Engineering, KITE-SOM

46
SS TECH BOOK STORE

UsrLabel.Visible = true;
}
else
{
if
(InsertRecord(txtUserName.Value, txtPassword.Value,
txtFirstName.Value, txtMiddleName.Value,
txtLastName.Value, txtAddress1.Value,
txtAddress2.Value, txtCity.Value, txtState.Value,
txtZip.Value, txtEmail.Value, txtTelephone.Value)
== 0)
{
lblErr.Font.Bold = true;
lblErr.Text = "Error
occurred while creating your account..Plz contact
the system administrator";
lblErr.Visible = true;
}
else
{

Response.Redirect("login.aspx");
Response.Write("You Have
Been Registered. Log On To Proceed");
}
}
}
}

protected void btnReset_Click(object


sender, System.EventArgs e)
{
ResetControls();
}
}
}

---------------------------------------------------------------------------------------------------------------------------------
---------------

Department of Computer Science and Engineering, KITE-SOM

47
SS TECH BOOK STORE

Search.aspx.cs
---------------------------------------------------------------------------------------------------------------------------------
---------------
using Microsoft.VisualBasic;
using System.Data;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System;
using System.Collections;
using System.Web;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Drawing;
using System.Data.SqlClient;

namespace SSTBS
{
/// <summary>
/// Summary description for Search.
/// </summary>
public partial class Search :
System.Web.UI.Page
{

private Collection myCollection = new


Collection();

protected void Page_Load(object sender,


System.EventArgs e)
{
// Put user code to initialize the
page here
if (Session["BookIds"] == null)
{
Session["BookIds"] = myCollection;
}
else
{

Department of Computer Science and Engineering, KITE-SOM

48
SS TECH BOOK STORE

myCollection =
(Collection)Session["BookIds"];
}
lblError.Text = "";
if (! IsPostBack)
{
pnlBookList.Visible = false;
pnlCombo.Visible = true;
ddlSelectCategory.Items.Add(new
ListItem("Select A Category"));
FillDDL();
// CreateTable()
}
}

#region Web Form Designer generated code


override protected void OnInit(EventArgs
e)
{
//
// CODEGEN: This call is required by
the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support -
do not modify
/// the contents of this method with the
code editor.
/// </summary>
private void InitializeComponent()
{
this.dgBooklist.ItemCommand += new
System.Web.UI.WebControls.DataGridCommandEventHandl
er(this.dgBooklist_ItemCommand);

Department of Computer Science and Engineering, KITE-SOM

49
SS TECH BOOK STORE

}
#endregion

private void FillDDL()


{
SqlDataReader dr;
try
{
SqlConnection con = new
SqlConnection("Integrated Security=True;Initial
Catalog=SSTBS; Data Source=CLIENTBASE01");
SqlCommand cmd = new
SqlCommand("Select DISTINCT(CategoryName) from
BookDetails ORDER BY CategoryName",con);
con.Open();
dr = cmd.ExecuteReader();
while (dr.Read())
{

ddlSelectCategory.Items.Add(new
ListItem(dr[0].ToString()));
}
dr.Close();
}
catch (Exception ex)
{
lblError.Text = ex.Message;
}
}

private void dgBooklist_ItemCommand(object


source,
System.Web.UI.WebControls.DataGridCommandEventArgs
e)
{
if (e.CommandName == "ADD")
{

Department of Computer Science and Engineering, KITE-SOM

50
SS TECH BOOK STORE

int i;
for (i = 1; i <=
myCollection.Count; i++)
{
if (myCollection[i].ToString()
==
dgBooklist.Items[e.Item.ItemIndex].Cells[0].Text.To
String())
{
lblError.Text = "Book
already in the shopping cart";
return;
}
}

myCollection.Add(dgBooklist.Items[e.Item.ItemIndex]
.Cells[0].Text.ToString(),
dgBooklist.Items[e.Item.ItemIndex].Cells[0].Text.To
String(), null, null);
//Session("myCart") = myCollection
}

protected void
ddlSelectCategory_SelectedIndexChanged(object
sender, System.EventArgs e)
{
DataSet ds = new DataSet();
string SqlString;
pnlBookList.Visible = true;
SqlString = "Select * from BookDetails
Where CategoryName ='" +
ddlSelectCategory.SelectedItem.Text + "'";
try
{
SqlConnection cn = new
SqlConnection("Integrated Security=True;Initial

Department of Computer Science and Engineering, KITE-SOM

51
SS TECH BOOK STORE

Catalog=SSTBS; Data Source=CLIENTBASE01");


SqlDataAdapter da = new
SqlDataAdapter(SqlString,cn);

da.Fill(ds);
dgBooklist.DataSource = ds;
dgBooklist.DataBind();
}
catch (Exception ex)
{
lblError.Text = ex.Message;
}

protected void lnkShowMyCart_Click(object


sender, System.EventArgs e)
{

Response.Redirect("ShoppingCart.aspx");
}

}
}

---------------------------------------------------------------------------------------------------------------------------------
---------------
ShoppingCart.aspx.cs

---------------------------------------------------------------------------------------------------------------------------------
---------------
using Microsoft.VisualBasic;
using System.Data;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System;
using System.Collections;
using System.Web;
using System.Web.UI.WebControls;
using System.Configuration;

Department of Computer Science and Engineering, KITE-SOM

52
SS TECH BOOK STORE

using System.Drawing;
using System.Data.SqlClient;

namespace SSTBS
{
/// <summary>
/// Summary description for ShoppingCart.
/// </summary>
public partial class ShoppingCart :
System.Web.UI.Page
{

private Collection myCollection;

protected void Page_Load(object sender,


System.EventArgs e)
{
// Put user code to initialize the
page here
myCollection =
(Collection)Session["BookIds"];
if (! IsPostBack)
{
FillCartGrid();
}
}

private void FillCartGrid ()


{
DataSet ds = new DataSet();
string SqlString;
int i;

SqlString = "Select * from BookDetails


Where BookId In (";
for (i = 1; i <= myCollection.Count -
1; i++)
{

Department of Computer Science and Engineering, KITE-SOM

53
SS TECH BOOK STORE

SqlString = SqlString +
myCollection[i].ToString() + ", ";
}
SqlString = SqlString +
myCollection[myCollection.Count].ToString() + ")";
try
{
SqlConnection con = new
SqlConnection("Integrated Security=True;Initial
Catalog=SSTBS; Data Source=CLIENTBASE01");
SqlDataAdapter da = new
SqlDataAdapter(SqlString, con);
da.Fill(ds);
dgShoppingCart.DataSource = ds;
dgShoppingCart.DataBind();

}
catch (Exception ex)
{
lblError.Text = ex.Message;
}
}

#region Web Form Designer generated code


override protected void OnInit(EventArgs
e)
{
//
// CODEGEN: This call is required by
the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support -
do not modify

Department of Computer Science and Engineering, KITE-SOM

54
SS TECH BOOK STORE

/// the contents of this method with the


code editor.
/// </summary>
private void InitializeComponent()
{
this.dgShoppingCart.ItemCommand += new
System.Web.UI.WebControls.DataGridCommandEventHandl
er(this.dgShoppingCart_ItemCommand);

}
#endregion

protected void lnkPayment_Click(object


sender, System.EventArgs e)
{
Response.Redirect("CardDetails.aspx");
}

private void
dgShoppingCart_ItemCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs
e)
{
if (e.CommandName == "REMOVE")
{

myCollection.Remove(dgShoppingCart.Items[e.Item.Ite
mIndex].Cells[0].Text);
FillCartGrid();
}
}
}
}
---------------------------------------------------------------------------------------------------------------------------------
---------------
CurrencyConverter.asmx.cs
---------------------------------------------------------------------------------------------------------------------------------
---------------
using System;

Department of Computer Science and Engineering, KITE-SOM

55
SS TECH BOOK STORE

using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;

namespace SSTBS
{
/// <summary>
/// Summary description for CurrencyConverter.
/// </summary>
public class CurrencyConverter :
System.Web.Services.WebService
{
public CurrencyConverter()
{
//CODEGEN: This call is required by
the ASP.NET Web Services Designer
InitializeComponent();
}

#region Component Designer generated code

//Required by the Web Services Designer


private IContainer components = null;

/// <summary>
/// Required method for Designer support -
do not modify
/// the contents of this method with the
code editor.
/// </summary>
private void InitializeComponent()
{
}

/// <summary>

Department of Computer Science and Engineering, KITE-SOM

56
SS TECH BOOK STORE

/// Clean up any resources being used.


/// </summary>
protected override void Dispose( bool
disposing )
{
if(disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}

#endregion

[WebMethod()]
public double[] GetCurrencyInfo(double
Currency)
{
double[] currencyInfo = new double[4];
//European Union Euro equivalent of
dollar
currencyInfo[0] = 0.88 * Currency;
//Japanese Yen equivalent of dollar
currencyInfo[1] = 113.98 * Currency;
//Russian Ruble equivalent of dollar
currencyInfo[2] = 30.53 * Currency;
//United Kingdom Pound equivalent of
dollar
currencyInfo[3] = 0.61 * Currency;

//Returns the equivalent curencies


return currencyInfo;
}
}
}

Department of Computer Science and Engineering, KITE-SOM

57
SS TECH BOOK STORE

Snapshots

1. On the login page user have to enter the User Name and Password for shopping, if it is
not created than click on Registration link for registration with SSTBS online shopping.

Department of Computer Science and Engineering, KITE-SOM

58
SS TECH BOOK STORE

2. For searching the books user has to select the category and then category of the books
will be displayed and user can add the books to his cart by clicking on the Add To Cart
Link. Then user can see his cart by clicking on the Show My Cart Link.

Department of Computer Science and Engineering, KITE-SOM

59
SS TECH BOOK STORE

REGISTRATION

CHECK OUT

Department of Computer Science and Engineering, KITE-SOM

60
SS TECH BOOK STORE

CARD DETAILS

Department of Computer Science and Engineering, KITE-SOM

61
SS TECH BOOK STORE

Department of Computer Science and Engineering, KITE-SOM

62
SS TECH BOOK STORE

SEARCH

Department of Computer Science and Engineering, KITE-SOM

63

You might also like