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:
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 Operating system: Windows Server 2003 Software: Microsoft Visual Studio .NET Enterprise 2008 Microsoft .NET Framework 3.5
|
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 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.
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:
USE CASE DIAGRAM
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. |
SCHEMATIC DIAGRAM OF 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 Login.aspx Login.aspx.cs ShoppingCart.aspx.cs Registration.aspx CreditCard.aspx Registration.aspx.cs CreditCard.aspx.cs CheckOut.aspx CheckOut.aspx.cs Currency Converter Web Service
|
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. |
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 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 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 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. |
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 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 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# HYPERLINK "%22C# HYPERLINK"3HYPERLINK "%22C# HYPERLINK".HYPERLINK "%22C# HYPERLINK"0, which was released in conjunction with the .NET Framework 3.5 in 2007. The next proposed version, 40.4HYPERLINK "0%224HYPERLINK%20%22%224.0%22.HYPERLINK%20%22%224.0%220".HYPERLINK "0%224HYPERLINK%20%22%224.0%22.HYPERLINK%20%22%224.0%220"0, is in development.
Design goals
The Ecma standard lists these design goals for C#:
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:
Version | Language Specification | Microsoft Compiler |
January 2002 | ||
November 2005 | ||
November 2006 | ||
June HYPERLINK "http://www.ecma-international.org/publications/standards/Ecma-334.htm"2006 | Intended release March 2010 [HYPERLINK "http://en.wikipedia.org/wiki/C_Sharp_(programming_language)"17HYPERLINK "http://en.wikipedia.org/wiki/C_Sharp_(programming_language)"] (Expected 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. Theoretically, a C# compiler could generate machine code like traditional compilers of C++ or FORTRAN.
Some notable distinguishing features of C# are:
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.
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 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;
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
{
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,CreditCardType) 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;
}
}
}
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] + ", ";
}
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();
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.";
}
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;
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();
}
}
#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 + 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)
{
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 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 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())
{
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);
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
}
#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())
{
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();
}
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";
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();
}
}
}
------------------------------------------------------------------------------------------------------------------------------------------------
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
{
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.DataGridCommandEventHandler(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;
}
}
private void dgBooklist_ItemCommand(object source, 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.ToString())
{
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.ToString(), 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 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;
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++)
{
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
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dgShoppingCart.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(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.ItemIndex].Cells[0].Text);
FillCartGrid();
}
}
}
}
------------------------------------------------------------------------------------------------------------------------------------------------
CurrencyConverter.asmx.cs
------------------------------------------------------------------------------------------------------------------------------------------------
using System;
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>
/// 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;
}
}
}
Snapshots
REGISTRATION
CHECK OUT
CARD DETAILS
SEARCH
Department of Computer Science and Engineering, KITE-SOM
- 66 -