Professional Documents
Culture Documents
Online Book Shopping
Online Book Shopping
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.
CONFIGURATION
Hardware: PC compatible with a Intel Pentium-IV processor,1GB RAM, and 20GB of Hard disk
Software: Microsoft Visual Studio .NET Enterprise 2008 Microsoft .NET Framework 3.5
mechanism will display the list of the books in a selected 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 users 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. 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.
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 representing the functional relationship among various actors in the system.
E-R DIAGRAM
Database Name: SSTechBookStore E-R Diagram representing the relationship among various entities of the database.
Database Name: SSTechBookStore Schematic diagram of the database depicting the primary and foreign key relationships.
LOGICAL FLOW DIAGRAM Logical Flow Diagram representing the control flow the application.
Search.aspx
Search.aspx.cs
ShoppingCart.aspx
Registration.aspx
CreditCard.aspx
Registration.aspx.cs
CreditCard.aspx.cs
CheckOut.aspx
CheckOut.aspx.cs
Sr.No. 1 Login.aspx
PROJECT FILE DETAILS File Name Remarks 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. 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.
Login.aspx.cs
Registration.aspx
Registration.aspx.cs
Search.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. 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. Contains the UI to display the user interface to select the category of books that the user wants to search.
Search.aspx.cs
ShoppingCart.aspx
ShoppingCart.aspx.cs
CardDetails.aspx
Contains the code to display the books of a selected category in data grid and store the books selected by the user in the shopping cart. 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. 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. Contains the UI that displays the form to accept the credit
10
CardDetails.aspx.cs
11
CheckOut.aspx
12
ChekOut.aspx.cs
card details to make the payment. The user after filling the form clicks the Submit button to transfer the card details to the 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. 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. Contains the code that collects
13
14
15
the data from multiple tables in database for the creation of bill. CurrencyConverter.asmx This is a Web service, which converts total book price amount in different world currencies. CurrencyConverter.asmx.cs Contains the code to declare the Web service method converting book price in different world currencies. Header.ascx Contains the web control for header layout common to every page.
Introduction:
Microsoft
Visual
Studio.Net
(ASP.NET)
is
Microsofts 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
Department of Computer Science and Engineering, KITE-SOM 17
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 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.
C#
(pronounced
"see
sharp")
is
programming functional,
language
encompassing
generic,
object-oriented programming
(class-based), disciplines.
component-oriented
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#:
object-oriented
programming
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.
The language is intended for use in developing software components suitable for deployment in distributed environments.
Source
code
portability portability,
is
very
important, for
as
is
programmer
especially
those
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
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 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 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."
Versions In the course of its development, the C# language has gone through several versions: Vers ion C# 1.0 C# 2.0 C# 3.0 C# 4.0 Language Specification Microsoft Compiler
June 2005
June 2006
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. 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
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
In C#, memory address pointers can only be used within blocks specifically with unsafe marked as code need unsafe, and programs appropriate
permissions to run. Most object access is done through 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 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.
C# provides properties as syntactic sugar for a common pattern in which a pair of methods, accessor
Department of Computer Science and Engineering, KITE-SOM 27
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. 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.
CardDetails.aspx.CS
-----------------------------------------------------------------------------------------------------------------------------------------------
using using using using using using using using using using using using
Microsoft.VisualBasic; System.Data; System.Web.UI; System.Web.UI.HtmlControls; System; System.Collections; System.Web; System.Web.UI.WebControls; System.Configuration; System.Drawing; System.Data.SqlClient; 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 31
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 32
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 33
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 34
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 35
} else {
billNo = (int)dr[0];
} 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 36
billNo = 0;
} 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 -----------------------------------------------------------------------------------------------------------------------------------------------
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 38
e)
#region Web Form Designer generated code override protected void OnInit(EventArgs {
// // 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] + ", "; }
Department of Computer Science and Engineering, KITE-SOM 39
SqlString = SqlString + 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]); }
Department of Computer Science and Engineering, KITE-SOM 40
catch (Exception ex) { 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."; }
} } }
----------------------------------------------------------------------------------------------------------------------------------------------Login.aspx.cs -----------------------------------------------------------------------------------------------------------------------------------------------
using using using using using using using using using using using
System.Data; System.Web.UI; System.Web.UI.HtmlControls; System; System.Collections; System.Web; System.Web.UI.WebControls; System.Configuration; System.Drawing; System.Data.SqlClient; 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
Department of Computer Science and Engineering, KITE-SOM 42
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 43
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 {
using using using using using using using using using using using using
Microsoft.VisualBasic; System.Data; System.Web.UI; System.Web.UI.HtmlControls; System; System.Collections; System.Web; System.Web.UI.WebControls; System.Configuration; System.Drawing; System.Data.SqlClient; 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) {
page here }
#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 + "'");
Department of Computer Science and Engineering, KITE-SOM 46
con.Open(); dr = cmd.ExecuteReader(); while (dr.Read()) { 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);
Department of Computer Science and Engineering, KITE-SOM 47
con.Open(); rowsAffected = cmd.ExecuteNonQuery(); } 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))
Department of Computer Science and Engineering, KITE-SOM 48
UsrLabel.Font.Bold = true; UsrLabel.Text = "Username exists..Please choose another Username"; 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 49
----------------------------------------------------------------------------------------------------------------------------------------------Search.aspx.cs -----------------------------------------------------------------------------------------------------------------------------------------------
using using using using using using using using using using using
Microsoft.VisualBasic; System.Data; System.Web.UI; System.Web.UI.HtmlControls; System; System.Collections; System.Web; System.Web.UI.WebControls; System.Configuration; System.Drawing; 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)
Department of Computer Science and Engineering, KITE-SOM 50
{ } else {
Session["BookIds"] = myCollection;
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>
Department of Computer Science and Engineering, KITE-SOM 51
private void InitializeComponent() { this.dgBooklist.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandl er(this.dgBooklist_ItemCommand); } #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; } } source, private void dgBooklist_ItemCommand(object
System.Web.UI.WebControls.DataGridCommandEventArgs e) { if (e.CommandName == "ADD") { 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
Department of Computer Science and Engineering, KITE-SOM 53
Where CategoryName ='" + ddlSelectCategory.SelectedItem.Text + "'"; try { SqlConnection cn = new SqlConnection("Integrated Security=True;Initial 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 -----------------------------------------------------------------------------------------------------------------------------------------------
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;
Department of Computer Science and Engineering, KITE-SOM 55
int i; SqlString = "Select * from BookDetails Where BookId In ("; for (i = 1; i <= myCollection.Count 1; i++) { 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. //
Department of Computer Science and Engineering, KITE-SOM 56
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.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(); }
Department of Computer Science and Engineering, KITE-SOM 57
} }
----------------------------------------------------------------------------------------------------------------------------------------------CurrencyConverter.asmx.cs -----------------------------------------------------------------------------------------------------------------------------------------------
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
Department of Computer Science and Engineering, KITE-SOM 58
/// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { } /// <summary> /// 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;
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.
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.
REGISTRATION
CHECK OUT
CARD DETAILS