Top Banner
57

online shopping cart : Documentation

Apr 21, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: online shopping cart : Documentation
Page 2: online shopping cart : Documentation

ONLINE SHOPPING CART

Project Prepared By From College

Bikramjit Banerjee Camellia school of engineering & technology

Somrita Mitra Camellia school of engineering & technology

Sudipta Kundu Camellia school of engineering & technology

Subhajit Biswas Camellia school of engineering & technology

Pratik Chakraborty Camellia school of engineering & technology

Subhankar Bhattacharjee Camellia school of engineering & technology

2 | P a g e

Page 3: online shopping cart : Documentation

Acknowledgement

Any attempt at any level cannot be satisfactorily completed without the support and guidance of learned people. I would like to express my immense

gratitude to Mr. Arindam Biswas for his constant support and motivation that that has encouraged us to come up with this Project on “ONLINE SHOPPING CART”.

I am also thankful to all other members who have contributed their ideas in this project.

3 | P a g e

Page 4: online shopping cart : Documentation

Certification

Here by this to certify that Subhankar Bhattacharjee of CAMELLIA SCHOOL OF ENGINEERING & TECHNOLOGY,KAJIPARA, BARASAT,KOLKATA has done the project on ONLINE SHOPPING CART in .NET after being trained by HCL WEBEL IT ACADEMY under the supervision of MR. ARINDAM BISWAS.

Verified by:

___________________ ___________________________ (Subhankar Bhattacharjee) (MR. ARINDAM BISWAS)

---------------------------- (Official Seal)

4 | P a g e

Page 5: online shopping cart : Documentation

INTRODUCTION

Going online shopping is a process by which consumers go to internet in order to buy products. An online shop, e-shop, internet shop, web shop evokes the physical analogy of buying products or services at a shopping mall. When an Online shopper has an initial good experience with a certain website, sixty percent of the time they will return to that website to buy more. Books are one of the things bought most online. Cosmetics, nutrition products, and groceries are increasingly being purchased online.

In our project, mainly stress has been put to keep the online customers as much satisfied as possible. There are two modules in the system, one for the Administrator and another for the Customers. The interfaces, for both the entities have been kept too simple to understand. Administrators have the privileges regarding Adding a product, updating the product details or removing a product. On the other hand, Customers can Buy a product, or Edit their account details.

As far as Security is considered, Customers cannot enter into the Administrator’s area, or Administrators cannot enter into a Customer’s account. Also, only registered customers are allowed to do the shopping, so that no anonymous product order is generated. In case, a user gives a fraud Credit Card No. or CRN No. , then, in that case, they won’t be able to do the shopping, because, after 3 chances, the customer gets automatically logged out. If a user does not have an account, then they are allowed to create a new account. No, shopping can be done without doing the payments….

5 | P a g e

Page 6: online shopping cart : Documentation

Hardware And Software Requirements

The System is compatible to run on any kind of hardware, regarding chipsets, motherboard, etc. As far as software requirement is considered, the system requires Windows 98 / 2000 / XP / Vista. Also the system requires a minimum of .NET Framework 2.0 installed on the computer. The system also requires a Web-Browser, because the system is made to run online.

Once the above requirements are confirmed, then the system can run fluently on the computer.

Database Design

The System consists of a single Database named as Shopping_cart

There are four tables under the Shopping_cart:

Product ID , Name, Category, Product_type, Price, Stock, Description

Customer Uname, Cname, Address, Email, Phno

User Uname ,Password , Type

AccountInvoiceno , Product_id , Uname , Transeation_date , Name_of_item ,Total_price , Discount

6 | P a g e

Page 7: online shopping cart : Documentation

Product table:

product_id varchar(5) Not null

product_name varchar(30)

category varchar(30)

product_type varchar(30)

price float

stock int

description varchar(50)

customer table:

uname varchar(20) Not null

cname varchar(30)

address varchar(60)

email varchar(50)

phno varchar(50)

[User] table:

uname varchar(20) Not null

password varchar(12)

type varchar(50)

Accounts table:

invoice_no varchar(50)

product_id varchar(50)

uname varchar(50)

date_of_transaction varchar(50)

price float

no_of_items int

total_price float

discount int

id int Not null

7 | P a g e

Page 8: online shopping cart : Documentation

User Interface Design

The system consists of two modules :

ADMINISTRATOR

It consists of a webform AddProduct, where a new product can added, updated, or deleted.

CUSTOMER

It consists of webforms NewAcc_Form, EditAccount, Authentication, Catalog, ProductReceipt.

NewAcc_Form

It is used to allow new customers to make a new account, by giving their personal as well as their account details.

EditAccount

It is used to allow a registered customer to edit their account details, regarding their passwords, credit card details, etc.

Authentication

It is used to authenticate the credit card details before conforming any kind of shopping.

Catalog

It is used to allow the registered customers to select the items to be shopped for, from the list of the products available in the web store, by adding the selected products to their basket. The customers can also see the subtotals along with the grand total.

ProductReceiptIt is used to get the final receipt of the items for which the shopping has been done.

8 | P a g e

Page 9: online shopping cart : Documentation

9 | P a g e

Page 10: online shopping cart : Documentation

CONTROL FLOW OF ADMINISTRATOR

.

10 | P a g e

Page 11: online shopping cart : Documentation

CONTROL FLOW OF CUSTOMER

11 | P a g e

Page 12: online shopping cart : Documentation

Screenshots :

Home page:

Add to bucket after selecting the product:

12 | P a g e

Page 13: online shopping cart : Documentation

If there is not a single product in bucket:

Coustomer login page:

13 | P a g e

Page 14: online shopping cart : Documentation

For new member create a new account:

Proceed to checkout:

14 | P a g e

Page 15: online shopping cart : Documentation

Payment details:

Delivery report:

15 | P a g e

Page 16: online shopping cart : Documentation

Administrator login page:

Welcome administrator:

16 | P a g e

Page 17: online shopping cart : Documentation

Update stock by administator :

Update product details by administrator:

17 | P a g e

Page 18: online shopping cart : Documentation

Update product price by administrator:

Add new product by administrator:

18 | P a g e

Page 19: online shopping cart : Documentation

Delete product by administrator:

Contact us page:

19 | P a g e

Page 20: online shopping cart : Documentation

Home page:

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page{ SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;AttachDbFilename=C:\\Program Files (x86)\\Microsoft SQL Server\\MSSQL.1\\MSSQL\\Data\\shopping_cart.mdf;Integrated Security=True"); protected void Page_Load(object sender, EventArgs e) {

if (Session["logged"] != null) { LinkButton1.Text= Session["logged"].ToString(); LinkButton2.Text = "Log Out"; } if (!IsPostBack) { SqlCommand cmd1 = new SqlCommand("SELECT DISTINCT CATEGORY FROM PRODUCT", con); SqlDataReader dr; con.Open(); dr = cmd1.ExecuteReader(); DropDownList1.Items.Add("~~Select~~"); while (dr.Read()) { DropDownList1.Items.Add(dr.GetValue(0).ToString()); } con.Close(); } } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { SqlCommand cmd2 = new SqlCommand("SELECT DISTINCT PRODUCT_TYPE FROM PRODUCT WHERE CATEGORY=@C", con); cmd2.Parameters.Add("@C", SqlDbType.VarChar); cmd2.Parameters["@C"].Value = DropDownList1.SelectedItem.ToString(); SqlDataReader dr; con.Open(); dr = cmd2.ExecuteReader(); DropDownList2.Items.Clear(); DropDownList2.Items.Add("~~Select~~"); while (dr.Read()) { DropDownList2.Items.Add(dr.GetValue(0).ToString()); } con.Close(); } protected void Button1_Click(object sender, EventArgs e) { if (DropDownList1.Text != "" && DropDownList2.Text != "") { Session["cat"] = DropDownList1.SelectedItem.ToString(); Session["ptype"] = DropDownList2.SelectedItem.ToString(); Response.Redirect("product_select.aspx"); } } protected void LinkButton3_Click(object sender, EventArgs e) { Response.Redirect("new_acc.aspx"); } protected void LinkButton2_Click(object sender, EventArgs e) {

20 | P a g e

Page 21: online shopping cart : Documentation

if (LinkButton2.Text == "Log In") { Session["cat"] = "~~Select~~"; Session["ptype"] = "~~Select~~"; Session["guest"] = "Guest"; Response.Redirect("login.aspx"); } else { Session["logged"] = null; Response.Redirect("home.aspx"); } } protected void LinkButton4_Click(object sender, EventArgs e) { Response.Redirect("home.aspx"); } protected void LinkButton5_Click(object sender, EventArgs e) { Session["cat"] = DropDownList1.SelectedItem.ToString(); Session["ptype"] = "~~Select~~"; Response.Redirect("my_account.aspx"); } protected void LinkButton6_Click(object sender, EventArgs e) { Response.Redirect("Contact_us.aspx"); } protected void LinkButton7_Click(object sender, EventArgs e) { Response.Redirect("Contact_us.aspx"); } protected void LinkButton1_Click(object sender, EventArgs e) { Response.Redirect("my_account.aspx"); }}

Product select:

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class select_products : System.Web.UI.Page{ SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;AttachDbFilename=C:\\Program Files\\Microsoft SQL Server\\MSSQL.1\\MSSQL\\Data\\shopping_cart.mdf;Integrated Security=True"); DataTable dt = new DataTable(); protected void Page_Load(object sender, EventArgs e) { if (Session["logged"] != null) { Label4.Text = Session["logged"].ToString(); LinkButton6.Text = "Log Out"; } if (!IsPostBack) { Label6.Text = ""; SqlCommand cmd1 = new SqlCommand("SELECT DISTINCT CATEGORY FROM PRODUCT", con); SqlDataReader dr; con.Open(); dr = cmd1.ExecuteReader(); DropDownList1.Items.Clear(); DropDownList1.Items.Add("~~Select~~"); while (dr.Read())

21 | P a g e

Page 22: online shopping cart : Documentation

{ DropDownList1.Items.Add(dr.GetValue(0).ToString()); } con.Close(); DropDownList1.Text = Session["cat"].ToString(); SqlCommand cmd2 = new SqlCommand("SELECT DISTINCT PRODUCT_TYPE FROM PRODUCT WHERE CATEGORY=@C", con); cmd2.Parameters.Add("@C", SqlDbType.VarChar); cmd2.Parameters["@C"].Value = DropDownList1.SelectedItem.ToString(); con.Open(); dr = cmd2.ExecuteReader(); DropDownList2.Items.Clear(); DropDownList2.Items.Add("~~Select~~"); while (dr.Read()) { DropDownList2.Items.Add(dr.GetValue(0).ToString()); } con.Close(); DropDownList2.Text = Session["ptype"].ToString();

// grid view display

SqlCommand cmd3 = new SqlCommand("SELECT PRODUCT_ID,PRODUCT_NAME,DESCRIPTION,STOCK,PRICE FROM PRODUCT WHERE CATEGORY=@C AND PRODUCT_TYPE=@P", con); cmd3.Parameters.Add("@C", SqlDbType.VarChar); cmd3.Parameters["@C"].Value = Session["cat"].ToString(); cmd3.Parameters.Add("@P", SqlDbType.VarChar); cmd3.Parameters["@P"].Value = Session["ptype"].ToString(); con.Open(); dr = cmd3.ExecuteReader(); DataTable dt1 = new DataTable(); dt1.Load(dr); GridView1.DataSource = dt1; GridView1.DataBind(); con.Close(); DataTable dt=new DataTable(); dt.Columns.Add(new DataColumn("product_id")); dt.Columns.Add(new DataColumn("product_name")); dt.Columns.Add(new DataColumn("description")); dt.Columns.Add(new DataColumn("price")); dt.Columns.Add(new DataColumn("quantity")); Session["b"]=dt; } } protected void LinkButton5_Click(object sender, EventArgs e) { Response.Redirect("my_account.aspx"); } protected void LinkButton6_Click(object sender, EventArgs e) { if (LinkButton6.Text == "Log Out") { Session["logged"] = null; Label1.Text = "Guest"; LinkButton6.Text = "Log In"; Response.Redirect("home.aspx"); } else { LinkButton6.Text = "Log Out"; Response.Redirect("login.aspx"); } } protected void Button1_Click(object sender, EventArgs e) { SqlCommand cmd3 = new SqlCommand("SELECT PRODUCT_ID,PRODUCT_NAME,DESCRIPTION,STOCK,PRICE FROM PRODUCT WHERE CATEGORY=@C AND PRODUCT_TYPE=@P", con); cmd3.Parameters.Add("@C", SqlDbType.VarChar); cmd3.Parameters["@C"].Value = DropDownList1.SelectedItem.ToString(); cmd3.Parameters.Add("@P", SqlDbType.VarChar); cmd3.Parameters["@P"].Value = DropDownList2.SelectedItem.ToString(); SqlDataReader dr; con.Open(); dr = cmd3.ExecuteReader(); DataTable dt = new DataTable();

22 | P a g e

Page 23: online shopping cart : Documentation

dt.Load(dr); GridView1.DataSource = dt; GridView1.DataBind(); Session["cat"] = DropDownList1.SelectedItem.ToString(); Session["ptype"] = DropDownList2.SelectedItem.ToString(); con.Close(); } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { SqlCommand cmd2 = new SqlCommand("SELECT DISTINCT PRODUCT_TYPE FROM PRODUCT WHERE CATEGORY=@C", con); cmd2.Parameters.Add("@C", SqlDbType.VarChar); cmd2.Parameters["@C"].Value = DropDownList1.SelectedItem.ToString(); SqlDataReader dr; con.Open(); dr = cmd2.ExecuteReader(); DropDownList2.Items.Clear(); DropDownList2.Items.Add("~~Select~~"); while (dr.Read()) { DropDownList2.Items.Add(dr.GetValue(0).ToString()); } con.Close(); } protected void LinkButton1_Click(object sender, EventArgs e) { Response.Redirect("Home.aspx"); } protected void LinkButton2_Click(object sender, EventArgs e) { Response.Redirect("my_account.aspx"); } protected void Button2_Click(object sender, EventArgs e) { DataTable dt=(DataTable )Session["b"]; for (int i = 0; i < GridView1.Rows.Count; i++) { Label l, l1, l2, l3,l4; CheckBox c; GridViewRow r = GridView1.Rows[i]; c = (CheckBox)r.FindControl("CheckBox1"); if (c.Checked == true) { DataRow dr = dt.NewRow(); l = (Label)r.FindControl("Label1"); l1 = (Label)r.FindControl("Label2"); l2 = (Label)r.FindControl("Label3"); l3 = (Label)r.FindControl("Label5"); l4 = (Label)r.FindControl("Label4"); TextBox t = (TextBox)r.FindControl("TextBox6"); if (int.Parse(t.Text) <= int.Parse(l4.Text)) { Label6.Text = ""; dr[0] = l.Text; dr[1] = l1.Text; dr[2] = l2.Text; dr[3] = l3.Text; dr[4] = t.Text; dt.Rows.Add(dr); } else { Label6.Text = "Quantity is more than Stock Available"; return; } } } GridView2.DataSource = dt; GridView2.DataBind(); float tot = 0; DataTable dt5 = ((DataTable)Session["b"]); GridView2.DataSource = dt5; GridView2.DataBind(); for (int i = 0; i < GridView2.Rows.Count; i++) { Label l1, l2, l3;

23 | P a g e

Page 24: online shopping cart : Documentation

GridViewRow r = GridView2.Rows[i]; l1 = (Label)r.FindControl("Label5"); l2 = (Label)r.FindControl("Label1"); l3 = (Label)r.FindControl("Label6"); float uprc = float.Parse(l1.Text); float qty = float.Parse(l2.Text); l3.Text = (qty * uprc).ToString(); tot = tot + float.Parse(l3.Text); TextBox7.Text = tot.ToString(); }

} protected void LinkButton3_Click(object sender, EventArgs e) { Response.Redirect("Contact_us.aspx"); } protected void LinkButton4_Click(object sender, EventArgs e) { Response.Redirect("Contact_us.aspx"); } private void setdata() { GridView2.EditIndex = -1; } protected void GridView2_RowCancelingEdit1(object sender, GridViewCancelEditEventArgs e) { setdata(); dt = ((DataTable)Session["dt"]); GridView2.DataSource = dt; GridView2.DataBind(); } protected void GridView2_RowDeleting1(object sender, GridViewDeleteEventArgs e) { int index = e.RowIndex; DataTable dt = (DataTable)Session["b"]; dt.Rows[index].Delete(); setdata(); GridView2.DataSource = dt; GridView2.DataBind(); } protected void GridView2_RowEditing1(object sender, GridViewEditEventArgs e) { GridView2.EditIndex = e.NewEditIndex; dt = ((DataTable)Session["b"]); GridView2.DataSource = dt; GridView2.DataBind(); } protected void GridView2_RowUpdating(object sender, GridViewUpdateEventArgs e) { int index = e.RowIndex; DataTable dt = (DataTable)Session["b"]; GridViewRow r = GridView2.Rows[index]; TextBox t; t = (TextBox)r.FindControl("TextBox1"); dt.Rows[index][4] = t.Text; Session["b"] = dt; setdata(); GridView2.DataSource = dt; GridView2.DataBind(); } protected void Button3_Click(object sender, EventArgs e) { if (Session["logged"] == null) { Response.Redirect("login.aspx"); } else { Response.Redirect("user_details_confirm.aspx"); } } protected void GridView2_SelectedIndexChanged(object sender, EventArgs e) {

24 | P a g e

Page 25: online shopping cart : Documentation

} protected void CheckBox1_CheckedChanged(object sender, EventArgs e) { for (int i = 0; i < GridView1.Rows.Count; i++) { CheckBox ch; GridViewRow r = GridView1.Rows[i]; ch = (CheckBox)r.FindControl("CheckBox1"); if (ch.Checked == true) { TextBox t; t = (TextBox)r.FindControl("TextBox6"); t.Visible = true; } else { TextBox t; t = (TextBox)r.FindControl("TextBox6"); t.Visible = false; } } }}

Login page:

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class Default4 : System.Web.UI.Page{ SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;AttachDbFilename=C:\\Program Files (x86)\\Microsoft SQL Server\\MSSQL.1\\MSSQL\\Data\\shopping_cart.mdf;Integrated Security=True"); SqlDataAdapter da; DataSet ds; DataTable dt; protected void Page_Load(object sender, EventArgs e) { if (Session["guest"] != null) { LinkButton4.Text = Session["guest"].ToString(); } } protected void LinkButton2_Click(object sender, EventArgs e) { Response.Redirect("new_acc.aspx"); } protected void Button1_Click(object sender, EventArgs e) { da = new SqlDataAdapter("SELECT UNAME,PASSWORD,TYPE FROM [USER]", con); ds = new DataSet(); da.Fill(ds, "user1"); dt = ds.Tables[0]; bool flag = false; for (int i = 0; i < dt.Rows.Count; i++) { if (TextBox1.Text == dt.Rows[i][0].ToString() && TextBox2.Text == dt.Rows[i][1].ToString()) { flag = true; if (dt.Rows[i][2].ToString().Equals("Administrator") == true) { Session["admin"] = TextBox1.Text; Response.Redirect("admin.aspx");

25 | P a g e

Page 26: online shopping cart : Documentation

break; } else if (dt.Rows[i][2].ToString().Equals("General") == true) { Session["logged"] = TextBox1.Text; Response.Redirect("my_account.aspx"); break; } } } if (flag == false) { Label7.Visible = true; TextBox1.Text = ""; TextBox2.Text = ""; TextBox1.Focus(); Label7.Text = "Username or Password is incorrect"; } }

protected void LinkButton4_Click(object sender, EventArgs e) { Response.Redirect("my_account.aspx"); } protected void LinkButton3_Click(object sender, EventArgs e) { Response.Redirect("Contact_us.aspx"); }}

Create new account:

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class Default5 : System.Web.UI.Page{ SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;AttachDbFilename=C:\\Program Files (x86)\\Microsoft SQL Server\\MSSQL.1\\MSSQL\\Data\\shopping_cart.mdf;Integrated Security=True"); public static int a = 0000; protected void Page_Load(object sender, EventArgs e) { TextBox1.Focus(); Label18.Text=""; } protected void Button2_Click(object sender, EventArgs e) { TextBox1.Text = ""; TextBox2.Text = ""; TextBox3.Text = ""; TextBox4.Text = ""; TextBox5.Text = ""; TextBox6.Text = ""; TextBox7.Text = ""; } protected void TextBox1_PreRender(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { string s = TextBox1.Text; bool flag = false;

26 | P a g e

Page 27: online shopping cart : Documentation

SqlCommand cmd3 = new SqlCommand("SELECT UNAME FROM [USER]", con); SqlDataReader dr; con.Open(); dr = cmd3.ExecuteReader(); Label19.Text=""; while (dr.Read()) { if (dr.GetValue(0).ToString() == s) { flag = true; break; } } con.Close(); if (flag == true) { Label19.Text = "Username already Present"; TextBox1.Focus(); } else { SqlCommand cmd1 = new SqlCommand("INSERT INTO CUSTOMER(UNAME,CNAME,ADDRESS,EMAIL,PHNO) VALUES(@U,@C,@A,@E,@P)", con); SqlCommand cmd2 = new SqlCommand("INSERT INTO [USER](UNAME,PASSWORD,TYPE) VALUES(@UN,@PASS,@T)", con); cmd1.Parameters.Add("@U", SqlDbType.VarChar); cmd1.Parameters.Add("@C", SqlDbType.VarChar); cmd1.Parameters.Add("@A", SqlDbType.VarChar); cmd1.Parameters.Add("@E", SqlDbType.VarChar); cmd1.Parameters.Add("@P", SqlDbType.VarChar); cmd1.Parameters["@U"].Value = TextBox1.Text; cmd1.Parameters["@C"].Value = TextBox4.Text; cmd1.Parameters["@A"].Value = TextBox5.Text; cmd1.Parameters["@E"].Value = TextBox6.Text; cmd1.Parameters["@P"].Value = TextBox7.Text; cmd2.Parameters.Add("@UN", SqlDbType.VarChar); cmd2.Parameters.Add("@PASS", SqlDbType.VarChar); cmd2.Parameters.Add("@T", SqlDbType.VarChar); cmd2.Parameters["@UN"].Value = TextBox1.Text; cmd2.Parameters["@PASS"].Value = TextBox2.Text; cmd2.Parameters["@T"].Value = TextBox8.Text; string s1 = TextBox6.Text; bool flag1 = false; Label20.Text = ""; for (int i = 0; i < s1.Length; i++) { if (s1[i] == '@') { flag1 = true; break; } } if(flag1==false) { Label20.Text = "Incorrect Email ID"; } if (TextBox1.Text != "" && TextBox2.Text != "" && TextBox4.Text != "" && TextBox5.Text != "" && flag1==true && TextBox7.Text.Length >= 10) { con.Open(); int x = cmd1.ExecuteNonQuery(); int y = cmd2.ExecuteNonQuery(); Label18.Text = "account Successfully Created"; } con.Close(); } } protected void LinkButton1_Click(object sender, EventArgs e) { Response.Redirect("login.aspx"); } protected void TextBox1_TextChanged(object sender, EventArgs e) { } protected void LinkButton2_Click(object sender, EventArgs e)

27 | P a g e

Page 28: online shopping cart : Documentation

{ Response.Redirect("home.aspx"); }}

Conform login:using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class Default6 : System.Web.UI.Page{ SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;AttachDbFilename=C:\\Program Files (x86)\\Microsoft SQL Server\\MSSQL.1\\MSSQL\\Data\\shopping_cart.mdf;Integrated Security=True"); protected void Page_Load(object sender, EventArgs e) { if (Session["logged"] != null) { Label1.Text = Session["logged"].ToString(); LinkButton1.Text = "Log Out"; } if (!IsPostBack) { getdata(); }

} protected void Button2_Click(object sender, EventArgs e) { TextBox1.Enabled = true; TextBox2.Enabled = true; TextBox3.Enabled = true; TextBox4.Enabled = true; } protected void Button1_Click(object sender, EventArgs e) { SqlDataAdapter da=new SqlDataAdapter("SELECT UNAME,CNAME,ADDRESS,EMAIL,PHNO FROM CUSTOMER",con); DataSet ds=new DataSet(); da.Fill(ds, "cust"); DataTable dt = ds.Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { if (Session["logged"].ToString() == dt.Rows[i][0].ToString()) { dt.Rows[i][1] = TextBox1.Text; dt.Rows[i][2] = TextBox2.Text; dt.Rows[i][3] = TextBox4.Text; dt.Rows[i][4] = TextBox3.Text; break; } } SqlCommandBuilder scb = new SqlCommandBuilder(da); da.Update(ds.Tables[0]); Response.Redirect("credit_pay.aspx");

} protected void LinkButton1_Click(object sender, EventArgs e) { if (LinkButton1.Text == "Log Out") { Session["logged"] = null; LinkButton1.Text = "Log In"; Label1.Text = "Guest"; Response.Redirect("home.aspx"); }

28 | P a g e

Page 29: online shopping cart : Documentation

} private void getdata() { SqlCommand cmd1 = new SqlCommand("SELECT CNAME,ADDRESS,PHNO,EMAIL FROM CUSTOMER WHERE UNAME=@UN", con); cmd1.Parameters.Add("@UN", SqlDbType.VarChar); cmd1.Parameters["@UN"].Value = Session["logged"].ToString(); SqlDataReader dr; TextBox1.Text = ""; TextBox2.Text = ""; TextBox3.Text = ""; TextBox4.Text = ""; con.Open(); dr = cmd1.ExecuteReader(); while (dr.Read()) { TextBox1.Text = dr.GetValue(0).ToString(); TextBox2.Text = dr.GetValue(1).ToString(); TextBox3.Text = dr.GetValue(2).ToString(); TextBox4.Text = dr.GetValue(3).ToString(); } con.Close(); }}

Credit pay:

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class Default7 : System.Web.UI.Page{ SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;AttachDbFilename=C:\\Program Files (x86)\\Microsoft SQL Server\\MSSQL.1\\MSSQL\\Data\\shopping_cart.mdf;Integrated Security=True"); protected void Page_Load(object sender, EventArgs e) { if (Session["Logged"] != null) { LinkButton1.Text = Session["logged"].ToString(); LinkButton2.Text = "Log Out"; TextBox3.Text = Session["total"].ToString(); } } protected void Button1_Click(object sender, EventArgs e) { SqlDataAdapter da = new SqlDataAdapter("SELECT PRODUCT_ID,STOCK FROM PRODUCT", con); DataSet ds = new DataSet(); da.Fill(ds, "prod"); DataTable dt = ((DataTable)Session["b"]); DataTable dt1 = ds.Tables["prod"]; for (int i = 0; i < dt.Rows.Count; i++) { for (int j = 0; j < dt1.Rows.Count; j++) { if (dt1.Rows[j][0].ToString() == dt.Rows[i][0].ToString()) { dt1.Rows[j][1] = int.Parse(dt1.Rows[j][1].ToString()) - int.Parse(dt.Rows[i][4].ToString()); } } } SqlCommandBuilder scb = new SqlCommandBuilder(da); da.Update(dt1); Response.Redirect("delivery.aspx");

29 | P a g e

Page 30: online shopping cart : Documentation

} protected void LinkButton1_Click(object sender, EventArgs e) { Response.Redirect("my_account.aspx"); } protected void LinkButton2_Click(object sender, EventArgs e) { if (LinkButton2.Text == "Log Out") { LinkButton2.Text = "Log In"; Session["Logged"] = null; Response.Redirect("Home.aspx"); } }}

Shopping details:

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class my_account : System.Web.UI.Page{ SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;AttachDbFilename=C:\\Program Files (x86)\\Microsoft SQL Server\\MSSQL.1\\MSSQL\\Data\\shopping_cart.mdf;Integrated Security=True"); protected void Page_Load(object sender, EventArgs e) { setfalse(); if (Session["logged"] != null) { LinkButton4.Text = Session["logged"].ToString(); LinkButton1.Text = "Log Out"; Label11.Text = Session["logged"].ToString(); } else { Label11.Text = "Guest"; LinkButton3.Enabled = false; } if (!IsPostBack) { float tot = 0; DataTable dt = ((DataTable)Session["b"]); GridView1.DataSource = dt; GridView1.DataBind(); for (int i = 0; i < GridView1.Rows.Count; i++) { Label l1, l2,l3; GridViewRow r = GridView1.Rows[i]; l1 = (Label)r.FindControl("Label4"); l2 = (Label)r.FindControl("Label5"); l3 = (Label)r.FindControl("Label6"); float uprc = float.Parse(l1.Text); float qty = float.Parse(l2.Text); l3.Text = (qty * uprc).ToString(); tot=tot+float.Parse(l3.Text); TextBox3.Text = tot.ToString(); } Session["total"] = tot.ToString(); } } protected void LinkButton1_Click(object sender, EventArgs e)

30 | P a g e

Page 31: online shopping cart : Documentation

{ if (LinkButton1.Text == "Log Out") { Session["logged"] = null; Response.Redirect("home.aspx"); } else { Response.Redirect("login.aspx"); } } protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e) { } private void setdata() { GridView1.EditIndex = -1; } protected void GridView2_SelectedIndexChanged(object sender, EventArgs e) {

} protected void Button3_Click(object sender, EventArgs e) { gettotal(); } protected void Button2_Click(object sender, EventArgs e) { SqlDataAdapter da = new SqlDataAdapter("SELECT ID,INVOICE_NO,PRODUCT_ID,UNAME,DATE_OF_TRANSACTION,PRICE,NO_OF_ITEMS,TOTAL_PRICE FROM ACCOUNTS",con); DataTable dt = ((DataTable)Session["b"]); DataSet ds = new DataSet(); da.Fill(ds, "acc"); DataTable dt1 = ds.Tables[0]; int temp = 0; int ivno =(1+ getinvoiceno()); if (Session["logged"] != null) { for (int i = 0; i < dt.Rows.Count; i++) { temp = temp + 1; DataRow dr = dt1.NewRow(); dr[0] = (temp + getid()).ToString(); dr[1] = "ivc" + (ivno.ToString()); dr[2] = dt.Rows[i][0].ToString(); dr[3] = Session["logged"].ToString(); dr[4] = "9-07-2011"; dr[5] = dt.Rows[i][3].ToString(); dr[6] = dt.Rows[i][4].ToString(); dr[7] = (float.Parse(dt.Rows[i][3].ToString()) * (float.Parse(dt.Rows[i][4].ToString()))); dt1.Rows.Add(dr); } SqlCommandBuilder scb = new SqlCommandBuilder(da); da.Update(ds.Tables[0]); Response.Redirect("user_details_confirm.aspx"); } else { Response.Redirect("login.aspx"); } } protected void LinkButton3_Click(object sender, EventArgs e) { settrue(); } protected void Button4_Click(object sender, EventArgs e) { SqlDataAdapter da = new SqlDataAdapter("SELECT UNAME,PASSWORD FROM [USER]", con); DataSet ds = new DataSet(); da.Fill(ds, "usr1"); DataTable dt = ds.Tables[0]; bool flag = false; for (int i = 0; i < dt.Rows.Count; i++) {

31 | P a g e

Page 32: online shopping cart : Documentation

if (Session["logged"].ToString() == dt.Rows[i][0].ToString()) { if (TextBox6.Text == TextBox7.Text) { dt.Rows[i][1] = TextBox6.Text; setlinktrue(); break; } else { flag = true; } } } SqlCommandBuilder scb = new SqlCommandBuilder(da); da.Update(ds.Tables[0]); if (flag == true) { Label16.Text = "Password mismatched"; }

} private void setfalse() { Button4.Visible = false; Label16.Visible = false; Label14.Visible = false; Label15.Visible = false; TextBox6.Visible = false; TextBox7.Visible = false; } private void settrue() { Button4.Visible = true; Label14.Visible = true; Label15.Visible = true; TextBox6.Visible = true; TextBox7.Visible = true; Label16.Visible = true; setlinkfalse(); } private void setlinkfalse() { LinkButton3.Visible = false; } private void setlinktrue() { LinkButton3.Visible = true; } private void gettotal() { float tot=0; for (int i = 0; i < GridView1.Rows.Count; i++) { Label l; GridViewRow r = GridView1.Rows[i]; l = (Label)r.FindControl("Label3"); tot = tot + float.Parse(l.Text); } TextBox3.Text = tot.ToString(); } protected void LinkButton4_Click(object sender, EventArgs e) { Session["b"] = null; Response.Redirect("my_account.aspx"); } protected void LinkButton5_Click(object sender, EventArgs e) { Response.Redirect("home.aspx"); } private int getid() { SqlCommand cmd1 = new SqlCommand("SELECT ID FROM ACCOUNTS", con); SqlDataReader dr; con.Open(); dr = cmd1.ExecuteReader();

32 | P a g e

Page 33: online shopping cart : Documentation

int id = 0; while (dr.Read()) { id = id + 1; } con.Close(); id = id + 1; return (id); } private int getinvoiceno() { SqlCommand cmd1 = new SqlCommand("SELECT DISTINCT INVOICE_NO FROM ACCOUNTS", con); SqlDataReader dr; con.Open(); dr = cmd1.ExecuteReader(); int ivn = 0; while (dr.Read()) { ivn = ivn + 1; } con.Close(); ivn = ivn + 1; return (ivn); }}

Delivery details:

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;

public partial class delivery : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { if (Session["logged"] != null) { Label1.Text = Session["logged"].ToString(); } } protected void LinkButton1_Click(object sender, EventArgs e) { Session.Clear(); Response.Redirect("home.aspx"); }}

Administrator page:

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;

public partial class Default8 : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) {

33 | P a g e

Page 34: online shopping cart : Documentation

if (!IsPostBack) { if (Session["admin"] != null) { LinkButton6.Text = Session["admin"].ToString(); LinkButton5.Text = "Log Out"; } } } protected void LinkButton2_Click(object sender, EventArgs e) { Response.Redirect("update_price.aspx"); } protected void LinkButton5_Click(object sender, EventArgs e) { if (LinkButton5.Text == "Log Out") { Session["admin"] = null; Response.Redirect("home.aspx"); } else { Response.Redirect("login.aspx"); } } protected void LinkButton4_Click(object sender, EventArgs e) { Response.Redirect("product_update.aspx"); } protected void LinkButton1_Click(object sender, EventArgs e) { Response.Redirect("add_new_product.aspx"); } protected void LinkButton3_Click(object sender, EventArgs e) { Response.Redirect("update_stock.aspx"); } protected void LinkButton6_Click(object sender, EventArgs e) { Response.Redirect("admin.aspx"); } protected void LinkButton7_Click(object sender, EventArgs e) { Response.Redirect("delete_product.aspx"); }}

Product add page:

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class add_new_product : System.Web.UI.Page{ SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;AttachDbFilename=C:\\Program Files (x86)\\Microsoft SQL Server\\MSSQL.1\\MSSQL\\Data\\shopping_cart.mdf;Integrated Security=True"); private int a = 0; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SqlCommand cmd1 = new SqlCommand("SELECT DISTINCT CATEGORY FROM PRODUCT", con); SqlDataReader dr; con.Open();

34 | P a g e

Page 35: online shopping cart : Documentation

dr = cmd1.ExecuteReader(); DropDownList1.Items.Clear(); DropDownList1.Items.Add("~~Select~~"); while (dr.Read()) { DropDownList1.Items.Add(dr.GetValue(0).ToString()); } con.Close(); } a = 0; if (Session["admin"] != null) { LinkButton2.Text = Session["admin"].ToString(); LinkButton1.Text = "Log Out"; } } protected void Button1_Click(object sender, EventArgs e) { SqlDataAdapter da = new SqlDataAdapter("SELECT PRODUCT_ID,PRODUCT_NAME,CATEGORY,PRODUCT_TYPE,PRICE,STOCK,DESCRIPTION FROM PRODUCT", con); DataSet ds = new DataSet(); da.Fill(ds, "prod1"); DataTable dt = ds.Tables[0]; DataRow dr = dt.NewRow(); getpid(); dr[0] = ("P" + a); dr[1] = TextBox1.Text; dr[2] = TextBox2.Text; dr[3] = TextBox3.Text; dr[4] = TextBox4.Text; dr[5] = TextBox5.Text; dr[6] = TextBox6.Text; dt.Rows.Add(dr); SqlCommandBuilder scb = new SqlCommandBuilder(da); da.Update(dt); Label10.Text ="One New Product Inserted."; } private void getpid() { SqlCommand cmd1=new SqlCommand("SELECT PRODUCT_ID FROM PRODUCT", con); SqlDataReader dr; con.Open(); dr = cmd1.ExecuteReader(); while (dr.Read()) { a=a+1; } a=a+1; con.Close(); } protected void Button2_Click(object sender, EventArgs e) { TextBox1.Text = ""; TextBox2.Text = ""; TextBox3.Text = ""; TextBox4.Text = ""; TextBox5.Text = ""; TextBox6.Text = ""; } protected void LinkButton2_Click(object sender, EventArgs e) { Response.Redirect("admin.aspx"); } protected void LinkButton1_Click(object sender, EventArgs e) { if (LinkButton1.Text == "Log Out") { Session["admin"] = null; Response.Redirect("home.aspx"); } else { Response.Redirect("login.aspx"); } } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) {

35 | P a g e

Page 36: online shopping cart : Documentation

TextBox2.Text=DropDownList1.SelectedItem.ToString(); SqlCommand cmd2 = new SqlCommand("SELECT DISTINCT PRODUCT_TYPE FROM PRODUCT WHERE CATEGORY=@C", con); cmd2.Parameters.Add("@C", SqlDbType.VarChar); cmd2.Parameters["@C"].Value = DropDownList1.SelectedItem.ToString(); SqlDataReader dr; con.Open(); dr = cmd2.ExecuteReader(); DropDownList2.Items.Clear(); DropDownList2.Items.Add("~~Select~~"); while (dr.Read()) { DropDownList2.Items.Add(dr.GetValue(0).ToString()); } con.Close(); } protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e) { TextBox3.Text = DropDownList2.SelectedItem.ToString(); }}

Price update page:

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class Default3 : System.Web.UI.Page{ SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;AttachDbFilename=C:\\Program Files (x86)\\Microsoft SQL Server\\MSSQL.1\\MSSQL\\Data\\shopping_cart.mdf;Integrated Security=True"); protected void Page_Load(object sender, EventArgs e) { if (Session["admin"] != null) { LinkButton1.Text = Session["admin"].ToString(); LinkButton2.Text = "Log Out"; } if (!IsPostBack) { SqlCommand cmd1 = new SqlCommand("SELECT DISTINCT CATEGORY FROM PRODUCT", con); SqlDataReader dr; con.Open(); dr = cmd1.ExecuteReader(); DropDownList1.Items.Clear(); DropDownList1.Items.Add("~~Select~~"); while (dr.Read()) { DropDownList1.Items.Add(dr.GetValue(0).ToString()); } con.Close(); }

} protected void LinkButton1_Click(object sender, EventArgs e) { Response.Redirect("admin.aspx"); } protected void LinkButton2_Click(object sender, EventArgs e) { if (LinkButton2.Text == "Log Out") { Session["admin"] = null; Response.Redirect("Home.aspx");

36 | P a g e

Page 37: online shopping cart : Documentation

} } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { SqlCommand cmd2 = new SqlCommand("SELECT DISTINCT PRODUCT_TYPE FROM PRODUCT WHERE CATEGORY=@C", con); cmd2.Parameters.Add("@C", SqlDbType.VarChar); cmd2.Parameters["@C"].Value = DropDownList1.SelectedItem.ToString(); SqlDataReader dr; con.Open(); dr = cmd2.ExecuteReader(); DropDownList2.Items.Clear(); DropDownList2.Items.Add("~~Select~~"); while (dr.Read()) { DropDownList2.Items.Add(dr.GetValue(0).ToString()); } con.Close(); } private void loaddata() { SqlCommand cmd3 = new SqlCommand("SELECT PRODUCT_ID,PRODUCT_NAME,PRICE FROM PRODUCT WHERE CATEGORY=@C AND PRODUCT_TYPE=@P", con); cmd3.Parameters.Add("@C", SqlDbType.VarChar); cmd3.Parameters["@C"].Value = DropDownList1.SelectedItem.ToString(); cmd3.Parameters.Add("@P", SqlDbType.VarChar); cmd3.Parameters["@P"].Value = DropDownList2.SelectedItem.ToString(); SqlDataReader dr; con.Open(); dr = cmd3.ExecuteReader(); DataTable dt = new DataTable(); dt.Load(dr); GridView1.DataSource = dt; GridView1.DataBind(); con.Close(); } private void setdata() { GridView1.EditIndex = -1; } protected void Button1_Click(object sender, EventArgs e) { loaddata(); } protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) { GridView1.EditIndex = e.NewEditIndex; loaddata(); } protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e) { setdata(); loaddata(); } protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { int index = e.RowIndex; GridViewRow r = GridView1.Rows[index]; TextBox t1; Label l; l = (Label)(r.FindControl("Label1")); t1 = (TextBox)(r.FindControl("TextBox3")); SqlCommand cmd1 = new SqlCommand("UPDATE PRODUCT SET price=@P WHERE PRODUCT_ID=@C", con); cmd1.Parameters.Add("@P", SqlDbType.Float); cmd1.Parameters.Add("@C", SqlDbType.VarChar); cmd1.Parameters["@P"].Value =float.Parse(t1.Text); cmd1.Parameters["@C"].Value = l.Text; con.Open(); int x = cmd1.ExecuteNonQuery(); con.Close(); setdata(); loaddata(); }}

37 | P a g e

Page 38: online shopping cart : Documentation

Stock update page:

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class update_stock : System.Web.UI.Page{ SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;AttachDbFilename=C:\\Program Files (x86)\\Microsoft SQL Server\\MSSQL.1\\MSSQL\\Data\\shopping_cart.mdf;Integrated Security=True"); protected void Page_Load(object sender, EventArgs e) { if (Session["admin"] != null) { LinkButton1.Text = Session["admin"].ToString(); LinkButton2.Text = "Log Out"; } if (!IsPostBack) { SqlCommand cmd1 = new SqlCommand("SELECT DISTINCT CATEGORY FROM PRODUCT", con); SqlDataReader dr; con.Open(); dr = cmd1.ExecuteReader(); DropDownList1.Items.Clear(); DropDownList1.Items.Add("~~Select~~"); while (dr.Read()) { DropDownList1.Items.Add(dr.GetValue(0).ToString()); } con.Close(); } } protected void LinkButton1_Click(object sender, EventArgs e) { Response.Redirect("admin.aspx"); } protected void LinkButton2_Click(object sender, EventArgs e) { if (LinkButton2.Text == "Log Out") { Session["admin"] = null; Response.Redirect("Home.aspx"); } } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { SqlCommand cmd2 = new SqlCommand("SELECT DISTINCT PRODUCT_TYPE FROM PRODUCT WHERE CATEGORY=@C", con); cmd2.Parameters.Add("@C", SqlDbType.VarChar); cmd2.Parameters["@C"].Value = DropDownList1.SelectedItem.ToString(); SqlDataReader dr; con.Open(); dr = cmd2.ExecuteReader(); DropDownList2.Items.Clear(); DropDownList2.Items.Add("~~Select~~"); while (dr.Read()) { DropDownList2.Items.Add(dr.GetValue(0).ToString()); } con.Close(); } private void loaddata() {

38 | P a g e

Page 39: online shopping cart : Documentation

SqlCommand cmd3 = new SqlCommand("SELECT PRODUCT_ID,PRODUCT_NAME,STOCK FROM PRODUCT WHERE CATEGORY=@C AND PRODUCT_TYPE=@P", con); cmd3.Parameters.Add("@C", SqlDbType.VarChar); cmd3.Parameters["@C"].Value = DropDownList1.SelectedItem.ToString(); cmd3.Parameters.Add("@P", SqlDbType.VarChar); cmd3.Parameters["@P"].Value = DropDownList2.SelectedItem.ToString(); SqlDataReader dr; con.Open(); dr = cmd3.ExecuteReader(); DataTable dt = new DataTable(); dt.Load(dr); GridView1.DataSource = dt; GridView1.DataBind(); con.Close(); } private void setdata() { GridView1.EditIndex = -1; } protected void Button1_Click(object sender, EventArgs e) { loaddata(); } protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e) { setdata(); loaddata(); } protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) { GridView1.EditIndex = e.NewEditIndex; loaddata(); } protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { int index = e.RowIndex; GridViewRow r = GridView1.Rows[index]; TextBox t1; Label l; l = (Label)(r.FindControl("Label1")); t1 = (TextBox)(r.FindControl("TextBox3")); SqlCommand cmd1 = new SqlCommand("UPDATE PRODUCT SET STOCK=@S WHERE PRODUCT_ID=@C", con); cmd1.Parameters.Add("@S", SqlDbType.Int); cmd1.Parameters.Add("@C", SqlDbType.VarChar); cmd1.Parameters["@S"].Value = t1.Text; cmd1.Parameters["@C"].Value = l.Text; con.Open(); int x = cmd1.ExecuteNonQuery(); con.Close(); setdata(); loaddata(); }}

Details update page:

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class Default9 : System.Web.UI.Page{ SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;AttachDbFilename=C:\\Program Files (x86)\\Microsoft SQL Server\\MSSQL.1\\MSSQL\\Data\\shopping_cart.mdf;Integrated Security=True");

39 | P a g e

Page 40: online shopping cart : Documentation

protected void Page_Load(object sender, EventArgs e) { if (Session["admin"] != null) { LinkButton1.Text = Session["admin"].ToString(); LinkButton2.Text = "Log Out"; } if (!IsPostBack) { SqlCommand cmd1 = new SqlCommand("SELECT DISTINCT CATEGORY FROM PRODUCT", con); SqlDataReader dr; con.Open(); dr = cmd1.ExecuteReader(); DropDownList1.Items.Clear(); DropDownList1.Items.Add("~~Select~~"); while (dr.Read()) { DropDownList1.Items.Add(dr.GetValue(0).ToString()); } con.Close(); } } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) {

} protected void LinkButton1_Click(object sender, EventArgs e) { Response.Redirect("admin.aspx"); } protected void LinkButton2_Click(object sender, EventArgs e) { if (LinkButton2.Text == "Log Out") { Session["admin"] = null; Response.Redirect("Home.aspx"); } } protected void DropDownList1_SelectedIndexChanged1(object sender, EventArgs e) { SqlCommand cmd2 = new SqlCommand("SELECT DISTINCT PRODUCT_TYPE FROM PRODUCT WHERE CATEGORY=@C", con); cmd2.Parameters.Add("@C", SqlDbType.VarChar); cmd2.Parameters["@C"].Value = DropDownList1.SelectedItem.ToString(); SqlDataReader dr; con.Open(); dr = cmd2.ExecuteReader(); DropDownList2.Items.Clear(); DropDownList2.Items.Add("~~Select~~"); while (dr.Read()) { DropDownList2.Items.Add(dr.GetValue(0).ToString()); } con.Close(); } protected void Button1_Click(object sender, EventArgs e) { loaddata(); } protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) { GridView1.EditIndex = e.NewEditIndex; loaddata(); } protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { int index = e.RowIndex; GridViewRow r = GridView1.Rows[index]; TextBox t1, t2; Label l; l = (Label)(r.FindControl("Label1")); t1 = (TextBox)(r.FindControl("TextBox2")); t2 = (TextBox)(r.FindControl("TextBox3")); SqlCommand cmd1 = new SqlCommand("UPDATE PRODUCT SET PRODUCT_NAME=@P,DESCRIPTION=@D WHERE PRODUCT_ID=@C", con); cmd1.Parameters.Add("@P", SqlDbType.VarChar); cmd1.Parameters.Add("@D", SqlDbType.VarChar);

40 | P a g e

Page 41: online shopping cart : Documentation

cmd1.Parameters.Add("@C", SqlDbType.VarChar); cmd1.Parameters["@P"].Value = t1.Text; cmd1.Parameters["@D"].Value = t2.Text; cmd1.Parameters["@C"].Value = l.Text; con.Open(); int x = cmd1.ExecuteNonQuery(); con.Close(); setdata(); loaddata(); } protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e) { setdata(); loaddata(); } private void loaddata() { SqlCommand cmd3 = new SqlCommand("SELECT PRODUCT_ID,PRODUCT_NAME,DESCRIPTION FROM PRODUCT WHERE CATEGORY=@C AND PRODUCT_TYPE=@P", con); cmd3.Parameters.Add("@C", SqlDbType.VarChar); cmd3.Parameters["@C"].Value = DropDownList1.SelectedItem.ToString(); cmd3.Parameters.Add("@P", SqlDbType.VarChar); cmd3.Parameters["@P"].Value = DropDownList2.SelectedItem.ToString(); SqlDataReader dr; con.Open(); dr = cmd3.ExecuteReader(); DataTable dt = new DataTable(); dt.Load(dr); GridView1.DataSource = dt; GridView1.DataBind(); con.Close(); } private void setdata() { GridView1.EditIndex = -1; }}

Delete product page:

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class delete_product : System.Web.UI.Page{ SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;AttachDbFilename=C:\\Program Files (x86)\\Microsoft SQL Server\\MSSQL.1\\MSSQL\\Data\\shopping_cart.mdf;Integrated Security=True"); protected void Page_Load(object sender, EventArgs e) { if (Session["admin"] != null) { LinkButton1.Text = Session["admin"].ToString(); LinkButton2.Text = "Log Out"; } if (!IsPostBack) { SqlCommand cmd1 = new SqlCommand("SELECT DISTINCT CATEGORY FROM PRODUCT", con); SqlDataReader dr; con.Open(); dr = cmd1.ExecuteReader(); DropDownList1.Items.Clear(); DropDownList1.Items.Add("~~Select~~"); while (dr.Read()) {

41 | P a g e

Page 42: online shopping cart : Documentation

DropDownList1.Items.Add(dr.GetValue(0).ToString()); } con.Close(); } } protected void Button1_Click(object sender, EventArgs e) { loaddata(); } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { SqlCommand cmd2 = new SqlCommand("SELECT DISTINCT PRODUCT_TYPE FROM PRODUCT WHERE CATEGORY=@C", con); cmd2.Parameters.Add("@C", SqlDbType.VarChar); cmd2.Parameters["@C"].Value = DropDownList1.SelectedItem.ToString(); SqlDataReader dr; con.Open(); dr = cmd2.ExecuteReader(); DropDownList2.Items.Clear(); DropDownList2.Items.Add("~~Select~~"); while (dr.Read()) { DropDownList2.Items.Add(dr.GetValue(0).ToString()); } con.Close(); } private void loaddata() { SqlCommand cmd3 = new SqlCommand("SELECT PRODUCT_ID,PRODUCT_NAME,DESCRIPTION,PRICE FROM PRODUCT WHERE CATEGORY=@C AND PRODUCT_TYPE=@P", con); cmd3.Parameters.Add("@C", SqlDbType.VarChar); cmd3.Parameters["@C"].Value = DropDownList1.SelectedItem.ToString(); cmd3.Parameters.Add("@P", SqlDbType.VarChar); cmd3.Parameters["@P"].Value = DropDownList2.SelectedItem.ToString(); SqlDataReader dr; con.Open(); dr = cmd3.ExecuteReader(); DataTable dt = new DataTable(); dt.Load(dr); GridView1.DataSource = dt; GridView1.DataBind(); con.Close(); } private void setdata() { GridView1.EditIndex = -1; } protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { SqlCommand cmd1 = new SqlCommand("DELETE FROM PRODUCT WHERE PRODUCT_ID=@PR", con); cmd1.Parameters.Add("@PR", SqlDbType.VarChar); int index = e.RowIndex; GridViewRow r = GridView1.Rows[index]; Label l; l = (Label)r.FindControl("Label1"); cmd1.Parameters["@PR"].Value = l.Text; con.Open(); int x = cmd1.ExecuteNonQuery(); Label5.Text = x + " Record Deleted From Database"; con.Close(); loaddata(); setdata();

} protected void LinkButton2_Click(object sender, EventArgs e) { if (LinkButton2.Text == "Log Out") { Session["admin"] = null; Response.Redirect("Home.aspx"); } } protected void LinkButton1_Click(object sender, EventArgs e) { Response.Redirect("admin.aspx"); }}

42 | P a g e

Page 43: online shopping cart : Documentation

Application Architecture

The system has a 3-tier architecture, which are User Interface Layer (UIL) , Business Logic Layer (BLL) and Database Application Layer (DAL).

User Interface Layer consists of only the Webforms.

Business Logic Layer consists of two classes; Customer, and Product.

Customer consists of following methods :

logup ( ) :

It takes the new customer’s details as input & passes those details to the DAL.

Login( ):

It checks the registered user’s username against the corresponding password and allows only authenticated users to proceed for shopping.

checkcreditcard( ) :

It checks the credit card details of the corresponding logged on customer against his credit card details. The customer can proceed for shopping, only when the authentication has been done.

Updateprofile ( ):

It updates the personal account details of the logged on customer by bringing changes to account made by the customer.

Product consists of following methods :

getdataProduct( ) :

It fetches the details of the Product from DAL and then passes it on to the User Interface.

AddProduct( ) :

It passes the details of the new product to be added in the database of the Products to the DAL.

43 | P a g e

Page 44: online shopping cart : Documentation

Data Access Layer consists of following methods :

getpassword( ) :

It returns the username and password of the requested user to BLL.

addproduct( ) :

It adds the details of the new Product to the product database.

getCrnno( ) :

It retrieves the credit card no. and CRN no. of a particular customer from the customer database and returns it to the BLL.

addCustomer( ) :

It adds the details of the new customer to the customer database.

getdataproduct( ) :

It returns the details of the required product to the BLL.

getdataCustomer( ) :

It retrieves the details of customers in the customer database.

updateProfile ( ) :

It edits the account details of the required customer.

Coding of Business Logic Layer (BLL ) :

The BLL have two classes:

Product Customer

44 | P a g e

Page 45: online shopping cart : Documentation

Future Enhancements The system is compatible of many enhancements which could have been

done but could not be completed due to some unavoidable reasons. Some of the facilities which could have been introduced are as follows.

There can be many administrators for the present Webstore, though it has been designed to work for only one administrator.

As a measure of security to the credit card details, a firewall could be designed which could prevent those details from leaking outside and falling into unsafe hands.

Before making a new account, the account details given by the customer must be confirmed online by the banks under which the customer bears an account.

Any registered customer won’t be able to buy any products if he provides the wrong account details more than 3 times.

Administrator can see the total shopping done by all the customers for a given particular date.

VALIDATION Every table has a primary key, so no chance of duplicate value. There is some restriction for every transaction action, so if some action or transaction violates that restriction it cannot be successful. People can get their required data about the products very easily and very fast.

45 | P a g e