Online Shopping Cart System (6 Copies)

download Online Shopping Cart System (6 Copies)

of 35

Transcript of Online Shopping Cart System (6 Copies)

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    1/35

    Introduction

    The project was all about developing a web application for maintaining online

    shopping. The web application should be accessed from anywhere in the world through

    Internet where visitors can create their account and become a customer. They can purchase

    goods available in the online store by paying through credit card. There is an administrator

    who monitors the website activity and adds, updates or removes product items as and when

    required.

    Problem Definition:

    These days the importance of online shopping has increased significantly. Spending

    hours for going to the shop and choosing the goods to buy is not always possible for

    everyone. Facing the crowd is also a tough job for especially the senior citizens. Often people

    do not get the world class goods in their locality. There are many more drawbacks of

    conventional shopping procedure.

    Proposed System:

    In order to overcome these drawbacks, online shopping is a very convenient

    alternative. We are designing a system that will facilitate the customers to review the

    products, conveniently choose the required one and purchase them. The customer can also

    add their needed items to their cart and buy those later on. An administrator will monitor the

    website activities and manage the product items. The administrator also has the privilege ofdeleting a particular customer and to manage the cart and the bank transactions database.

    Page | 1

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    2/35

    Requirements Analysis &Specifications

    Requirements Analysis

    Following is a list of functionalities of the system. The system must consist of two

    modules, Customer module or User module and an Administrator module.

    Customer Module:

    Visitors must create their account first to access the website contents.

    After registration a visitor becomes a customer. Each customer will have unique user id and a password with which they can log in.

    After log in the customer will be redirected to their own user-home page, where they

    can select their preferred product and add it to the cart.

    After adding to the cart, customers can also log out from the system and pay for those

    items later.

    The details specifications & price of each product must be provided at the website.

    The customers should be able to update or delete their account if they want to.

    Account must be prevented from unauthorized access.

    The payment method will be online payment through credit card.

    Administrator Module:

    An administrator can log in using his user id and password like any other users.

    After log in the administrator will be redirected to admin-home page.

    The administrator can add, update or remove products as and when required.

    The administrator can increase the number of stock of a product when required.

    The administrator can manage the user database.

    The administrator also has the privilege of managing the cart and the bank

    transactions database.

    Administrator can change the log in password if needed.

    Page | 2

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    3/35

    The administrator module must be prevented from unauthorized access. None other

    than the administrator can be able to access this module.

    Software & Hardware Specifications

    Softwares Used:

    o Operating System: Windows XP Professional SP3

    o Programming Language: C#

    o Development Kit: Microsoft Visual Studio 2008 Professional Edition

    o Web-Technology: ASP.NET

    o Front-End: HTML, CSSo Back-End: Microsoft SQL Server 2005 Express Edition

    o Web Server: Microsoft IIS Web Server 6.0

    o Diagram Drawing: SmartDraw VP, Microsoft Visio 2007

    o Documentation: Microsoft Word 2007

    Hardwares Used:

    o Processor: Intel Core2Duo 2.00GHz

    o RAM: 1GB/2GB DDR2 667MHz

    o HDD: 160GB 7200RPM

    Printer: HP Deskjet Ink Advantage K109a

    Page | 3

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    4/35

    Data Flow DiagramLevel 0: Context Level Diagram

    Level 1: Customer

    Page | 4

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    5/35

    Level 1: Administrator

    Page | 5

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    6/35

    Entity-Relationship Diagram

    Page | 6

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    7/35

    Table Schemas

    Page | 7

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    8/35

    Table 1: Usr

    Table 2: Record

    Table 3: Details

    Table 4: Stock

    Table 5: Cart

    Page | 8

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    9/35

    Table 6: Bank

    Table 7: Admin

    Project ScreenshotsCustomer Module:

    Page | 9

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    10/35

    User Login Page (default.aspx)

    New Registration Page (nwusr.aspx)

    Page | 10

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    11/35

    Products Home (products.aspx)

    Product Details (details.aspx)

    Page | 11

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    12/35

    User Account Details (account.aspx)

    Online Payment Page (payment.aspx)

    Page | 12

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    13/35

    Administrator Module:

    Administrator Login (eshoppe_admin32310.aspx)

    Manage Products (products_admin.aspx)

    Page | 13

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    14/35

    Manage Cart (cart_admin.aspx)

    Manage Bank (bank_admin.aspx)

    Manage Users (usr_admin.aspx)

    Page | 14

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    15/35

    Source CodeCustomer Module:

    User Functions Class (Class_usr.cs)

    using System;using System.Data;using System.Data.SqlClient;using System.Configuration;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 class Class_usr{

    SqlConnection con;

    SqlCommand com;SqlDataAdapter sda;string msg;public Class_usr()

    {con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|

    DataDirectory|\eshoppe_db.mdf;Integrated Security=True;User Instance=True");}

    public string Login(string email, string password){

    try{

    con.Open();com=new SqlCommand("select password from usr where email='" + email + "'", con);string pwd = com.ExecuteScalar().ToString();con.Close();if (pwd == password){

    msg = "DONE";return msg;

    }else{

    msg = "The username & password doesn't match!";return msg;

    }}catch (Exception ex){

    con.Close();msg = "Error in login, try again!";return msg;

    }}

    public string InsertUsr(string email, string name, string comp, string coun,string addr,stringtown,string pin,string phone,string job,string typecom,string password)

    {try{

    con.Open();com = new SqlCommand("insert into usr values('" + email + "','" + name + "','" + comp +

    "','" + coun + "','" + addr + "','" + town + "','" + pin + "','" + phone + "','" + job + "','" +typecom + "','" + password + "')", con);

    com.ExecuteNonQuery();con.Close();

    Page | 15

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    16/35

    msg = "DONE";return msg;

    }catch (Exception ex){

    con.Close();msg = "Error in registration (Maybe your username already in use), try again!";return msg;

    }}

    public DataSet FetchUsr(string email){

    sda = new SqlDataAdapter("select * from usr where email='" + email + "'", con);DataSet ds = new DataSet();sda.Fill(ds, "usr");return ds;

    }

    public string UpdateUsr(string email, string name, string comp, string coun, string addr, stringtown, string pin, string phone, string job, string typecom, string password)

    {try{

    con.Open();

    com = new SqlCommand("update usr set name='" + name + "',comp='" + comp + "',coun='" + coun+ "',addr='" + addr + "',town='" + town + "',pin='" + pin + "',phone='" + phone + "',job='" + job +"',typecom='" + typecom + "',password='" + password + "' where email='" + email + "'", con);

    com.ExecuteNonQuery();con.Close();msg = "DONE";return msg;

    }catch (Exception ex){

    con.Close();msg = "Error in updation, try again!";return msg;

    }}

    public void DeleteUsr(string email)

    {try{

    con.Open();com = new SqlCommand("delete from usr where email='" + email + "'", con);com.ExecuteNonQuery();con.Close();

    }catch (Exception ex){

    con.Close();}

    }

    public string InsertCart(string email,string pid,int qty){

    try

    {con.Open();com=new SqlCommand("select pprice from record where pid='" + pid + "'",con);int price=int.Parse(com.ExecuteScalar().ToString());com = new SqlCommand("select pmodel from details where pid='" + pid + "'", con);string model = com.ExecuteScalar().ToString();com=new SqlCommand("insert into cart values('" + email + "','" + pid +"','" + model + "',"

    + price +"," + qty + ")",con);com.ExecuteNonQuery();con.Close();msg="DONE";return msg;

    }catch(Exception ex)

    Page | 16

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    17/35

    {con.Close();msg = "NOT DONE";return msg;

    }}

    public void UpdateStock(string pid, int qty)

    { try{

    con.Open();com = new SqlCommand("select pqty from stock where pid='" + pid + "'", con);int quan = int.Parse(com.ExecuteScalar().ToString());quan = quan - qty;com = new SqlCommand("update stock set pqty=" + quan + " where pid='" + pid + "'", con);com.ExecuteNonQuery();con.Close();

    }catch (Exception ex){

    con.Close();}

    }

    public DataSet FetchCart(string email){SqlDataAdapter sda = new SqlDataAdapter("select price,qty from cart where email='" + email +

    "'", con);DataSet ds = new DataSet();ds.Clear();sda.Fill(ds, "cart");return ds;

    }

    public void DeleteCart(string email){

    try{

    con.Open();com = new SqlCommand("delete from cart where email='" + email + "'", con);com.ExecuteNonQuery();

    con.Close();}catch (Exception ex){

    con.Close();}

    }

    public string InsertBank(string email, string bname, string bbranch, string card, int amnt,DateTime datym)

    {string msg;try{

    con.Open();com = new SqlCommand("insert into bank values('" + email + "','" + bname + "','" + bbranch

    + "','" + card + "'," + amnt + ",'" + datym + "')", con);

    com.ExecuteNonQuery();con.Close();msg = "DONE";return msg;

    }catch (Exception ex){

    con.Close();msg = "NOT DONE";return msg;

    }}

    }

    Page | 17

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    18/35

    Login (Default.aspx.cs)

    using System;using System.Collections;using System.Configuration;using System.Data;using System.Data.SqlClient;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 _Default : System.Web.UI.Page{

    Class_usr cu = new Class_usr();protected void Page_Load(object sender, EventArgs e){}protected void LinkButton1_Click(object sender, EventArgs e){

    Response.Redirect("nwusr.aspx");

    }protected void ImageButton1_Click(object sender, ImageClickEventArgs e){

    this.Label1.Text = cu.Login(this.TextBox1.Text, this.TextBox2.Text); //To login in the account.if (this.Label1.Text == "DONE"){

    Session["email"] = this.TextBox1.Text;Response.Redirect("products.aspx");

    }}

    }

    New Registration (nwusr.aspx.cs)

    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 nwusr : System.Web.UI.Page{

    Class_usr cu=new Class_usr();protected void Page_Load(object sender, EventArgs e){

    }protected void LinkButton1_Click(object sender, EventArgs e)

    {Response.Redirect("privsypolicy.aspx");

    }protected void ImageButton1_Click(object sender, ImageClickEventArgs e){

    try{

    this.Label_error.Text = cu.InsertUsr(this.Text_email.Text, this.Text_name.Text,this.Text_com.Text, this.Drop_coun.SelectedItem.Text, this.Text_add.Text, this.Text_city.Text,this.Text_pc.Text, this.Text_pn.Text, this.Drop_job.SelectedItem.Text,this.Drop_type.SelectedItem.Text,this.Text_passwd.Text);

    Session["email"] = this.Text_email.Text;if (this.Label_error.Text == "DONE")

    Page | 18

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    19/35

    {Response.Redirect("account.aspx");

    }}catch (Exception ex){

    this.Label_error.Text = "Error in registration, please fill the registration formproperly!";

    }}protected void ImageButton2_Click(object sender, ImageClickEventArgs e){

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

    }

    Products Home (products.aspx.cs)

    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 items : System.Web.UI.Page{

    protected void Page_Load(object sender, EventArgs e){

    try{

    this.Label_wel.Text = Session["email"].ToString();}catch (Exception ex){

    //Response.Write("alert('Please Login to Enter!!')");Response.Redirect("Default.aspx");

    }}

    protected void GridView1_SelectedIndexChanged1(object sender, EventArgs e){

    Session["pidd"] = this.GridView1.SelectedRow.Cells[0].Text; //Stores the PID of the selectedproduct.

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

    }

    Product Details (details.aspx.cs)

    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 details : System.Web.UI.Page{

    Class_usr cu = new Class_usr();

    Page | 19

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    20/35

    protected void Page_Load(object sender, EventArgs e){

    try{

    string test = Session["email"].ToString(); //Checks the user is logged in or not.}catch (Exception ex){

    //Response.Write("alert('Please Login to Enter!!')");Response.Redirect("Default.aspx");}this.Label_pidd.Text = Session["pidd"].ToString();

    }protected void ImageButton1_Click(object sender, ImageClickEventArgs e){

    try{

    string rpl = cu.InsertCart(Session["email"].ToString(),Session["pidd"].ToString(),int.Parse(this.DropDownList1.SelectedItem.Text)); //Inserts the Qty. of theselected item into the CART.

    cu.UpdateStock(Session["pidd"].ToString(),int.Parse(this.DropDownList1.SelectedItem.Text)); //Reduces the STOCK of the selected item afterinserting into CART.

    if (rpl == "DONE"){

    Response.Write("alert('Added to Cart')");}else

    Response.Write("alert('Error!! Try Again..')");

    //Response.Redirect("products.aspx");}catch (Exception ex){

    Response.Write("alert('Error!! Try Again..')");}

    }protected void ImageButton3_Click(object sender, ImageClickEventArgs e){

    Response.Redirect("products.aspx");}protected void ImageButton2_Click(object sender, ImageClickEventArgs e)

    {Response.Redirect("payment.aspx");

    }}

    User Account Details (account.aspx.cs)

    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 account : System.Web.UI.Page{

    Class_usr cu = new Class_usr();protected void Page_Load(object sender, EventArgs e){

    try{

    string test = Session["email"].ToString();}catch (Exception ex){

    Page | 20

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    21/35

    //Response.Write("alert('Please Login to Enter!!')");Response.Redirect("Default.aspx"); //User is not logged in.

    }}protected void ImageButton3_Click(object sender, ImageClickEventArgs e){

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

    protected void ImageButton4_Click(object sender, ImageClickEventArgs e){Response.Redirect("products.aspx");

    }protected void ImageButton2_Click(object sender, ImageClickEventArgs e){

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

    }

    Online Payment (payment.aspx.cs)

    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 payment : System.Web.UI.Page{

    Class_usr cu = new Class_usr();DataSet ds;int total;protected void Page_Load(object sender, EventArgs e){

    try{

    if (IsPostBack == false){

    ds = cu.FetchCart(Session["email"].ToString()); //Used to feth the corresponding CARTvalues of the current user.

    int cnt = ds.Tables["cart"].Rows.Count; //How many produs have in the CART of thecurrent user?

    for (int i = 0; i < cnt; i++){

    total = total + int.Parse(ds.Tables["cart"].Rows[i][0].ToString()) *int.Parse(ds.Tables["cart"].Rows[i][1].ToString()); //Calculates the total amount.

    }this.Label_amnt.Text = total.ToString();

    }}catch (Exception ex){

    //Response.Write("alert('Please Login to Enter!!')");

    Response.Redirect("Default.aspx");}}protected void ImageButton1_Click(object sender, ImageClickEventArgs e){

    string rpl = cu.InsertBank(Session["email"].ToString(), this.TextBox_bname.Text,this.TextBox_branch.Text, this.TextBox_card.Text, int.Parse(this.Label_amnt.Text), DateTime.Now);//Inserts the payment details of the current user to the BANK.

    if (rpl == "DONE")Response.Write("alert('Thank You for your payment!')");

    elseResponse.Write("alert('Error!! Try Again..')");

    cu.DeleteCart(Session["email"].ToString()); //After the payment, clears the CART of the currentuser.

    Page | 21

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    22/35

    }protected void ImageButton2_Click(object sender, ImageClickEventArgs e){

    Session.Remove("email");Response.Write("var

    wnd=window.open('','newWin','height=1,width=1,left=900,top=700,status=no,toolbar=no,menubar=no,scrollbars=no,maximize=false,resizable=1')");

    Response.Write("wnd.close()");

    Response.Write("window.open('Default.aspx','_parent',replace=true)");}

    }

    Administrator Module:

    Administrator Functions Class (Class_admin.cs)

    using System;using System.Data;using System.Data.SqlClient;using System.Configuration;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 class Class_admin{

    SqlConnection con;SqlCommand com;SqlDataAdapter sda;string msg;

    public Class_admin(){con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|

    DataDirectory|\eshoppe_db.mdf;Integrated Security=True;User Instance=True");}

    public string Login(string unamead, string pwdad){

    try{

    con.Open();com = new SqlCommand("select pwdad from admin where unamead='" + unamead + "'", con);string pwd = com.ExecuteScalar().ToString();con.Close();if (pwd == pwdad){

    msg = "DONE";return msg;

    }else{

    msg = "The username & password doesn't match!";return msg;

    }}catch (Exception ex){

    con.Close();msg = "Error in login, try again!";return msg;

    }}

    public DataSet FetchPID()

    Page | 22

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    23/35

    {sda = new SqlDataAdapter("select pid from record", con);DataSet ds = new DataSet();sda.Fill(ds, "pid_record");return ds;

    }

    public DataSet FetchRecord(string pid)

    { sda = new SqlDataAdapter("select * from record where pid='" + pid + "'", con);DataSet ds = new DataSet();sda.Fill(ds, "record");return ds;

    }

    public DataSet FetchDetails(string pid){

    sda = new SqlDataAdapter("select pdurl,pmodel,pspec,mprice from details where pid='" + pid +"'", con);

    DataSet ds = new DataSet();sda.Fill(ds, "details");return ds;

    }

    public DataSet FetchStock(string pid)

    { sda = new SqlDataAdapter("select pqty from stock where pid='" + pid + "'", con);DataSet ds = new DataSet();sda.Fill(ds, "stock");return ds;

    }

    public string InsertRecord(string pid, string purl, string pname, int pprice){

    try{

    con.Open();com = new SqlCommand("insert into record values('" + pid + "','" + purl + "','" + pname +

    "'," + pprice + ")", con);com.ExecuteNonQuery();con.Close();

    msg = "Successfully Inserted into 'RECORD'";return msg;

    }catch (Exception ex){

    con.Close();msg = "Error insertion in 'RECORD'";return msg;

    }}

    public string InsertDetails(string pdurl, string pid, string pmodel, string pspec,int mprice,inteprice)

    {try{

    con.Open();

    com = new SqlCommand("insert into details values('" + pdurl + "','" + pid + "','" + pmodel+ "','" + pspec + "'," + mprice + "," + eprice + ")", con);

    com.ExecuteNonQuery();con.Close();msg = "Successfully Inserted into 'DETAILS'";return msg;

    }catch (Exception ex){

    con.Close();msg = "Error insertion in 'DETAILS'";return msg;

    }}

    Page | 23

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    24/35

    public string InsertStock(string pid, int pqty){

    try{

    con.Open();com = new SqlCommand("insert into stock values('" + pid + "'," + pqty + ")", con);com.ExecuteNonQuery();

    con.Close();msg = "Successfully Inserted into 'STOCK'";return msg;

    }catch (Exception ex){

    con.Close();msg = "Error insertion in 'STOCK'";return msg;

    }}

    public string UpdateRecord(string pid, string purl, string pname, int pprice){

    try{

    con.Open();

    com = new SqlCommand("update record set purl='" + purl + "',pname='" + pname + "',pprice="+ pprice + " where pid='" + pid + "'", con);com.ExecuteNonQuery();con.Close();msg = "'RECORD' Updated Successfully";return msg;

    }catch (Exception ex){

    con.Close();msg = "Error Updation in 'RECORD'";return msg;

    }}

    public string UpdateDetails(string pdurl, string pid, string pmodel,string pspec, int mprice,intpprice)

    {try{

    con.Open();com = new SqlCommand("update details set pdurl='" + pdurl + "',pmodel='" + pmodel +

    "',pspec='" + pspec + "',mprice='" + mprice + "',eprice='" + pprice + "' where pid='" + pid + "'",con);

    com.ExecuteNonQuery();con.Close();msg = "'DETAILS' Updated Successfully";return msg;

    }catch (Exception ex){

    con.Close();msg = "Error Updation in 'DETAILS'";return msg;

    }}

    public string UpdateStock(string pid,int pqty){

    try{

    con.Open();com = new SqlCommand("update stock set pqty=" + pqty + " where pid='" + pid + "'", con);com.ExecuteNonQuery();con.Close();msg = "'STOCK' Updated Successfully";return msg;

    }

    Page | 24

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    25/35

    catch (Exception ex){

    con.Close();msg = "Error Updation in 'STOCK'";return msg;

    }}

    public string DeleteRecord(string pid){try{

    con.Open();com = new SqlCommand("delete from record where pid='" + pid + "'", con);com.ExecuteNonQuery();con.Close();msg = "Entry Deleted Successfully";return msg;

    }catch (Exception ex){

    con.Close();msg = "Error in Deletion";return msg;

    }

    }public void DeleteUsr(string email){

    try{

    con.Open();com = new SqlCommand("delete from usr where email='" + email + "'", con);com.ExecuteNonQuery();con.Close();

    }catch (Exception ex){

    con.Close();}

    }

    public void DeleteCart(string email)

    {try{

    con.Open();com = new SqlCommand("delete from cart where email='" + email + "'", con);com.ExecuteNonQuery();con.Close();

    }catch (Exception ex){

    con.Close();}

    }

    public void DeleteBank_usr(string email){

    try

    {con.Open();com = new SqlCommand("delete from bank where email='" + email + "'", con);com.ExecuteNonQuery();con.Close();

    }catch (Exception ex){

    con.Close();}

    }

    public void DeleteBank_card(string card){

    Page | 25

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    26/35

    try{

    con.Open();com = new SqlCommand("delete from bank where card='" + card + "'", con);com.ExecuteNonQuery();con.Close();

    }catch (Exception ex)

    { con.Close();}

    }

    public string ChangeAdmin(string unamead, string pwdad){

    try{

    con.Open();com = new SqlCommand("update admin set pwdad='" + pwdad + "' where unamead='" + unamead +

    "'", con);com.ExecuteNonQuery();con.Close();msg = "Administrator Password Changed";return msg;

    }

    catch (Exception ex){con.Close();msg = "Error!! Try Again..";return msg;

    }}

    }

    Login (eshoppe_admin32310.aspx.cs)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 admin : System.Web.UI.Page{

    Class_admin ca=new Class_admin();protected void Page_Load(object sender, EventArgs e){

    }protected void Button1_Click(object sender, EventArgs e){

    this.Label1.Text = ca.Login(this.TextBox1.Text, this.TextBox2.Text); //Validate administrator.if (this.Label1.Text == "DONE"){

    Session["unamead"] = this.TextBox1.Text; //Will be used in the other administrator pages tocheck wheather the administrator is logged in or not.

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

    }}

    Manage Products (products_admin.aspx.cs)

    using System;using System.Collections;using System.Configuration;using System.Data;

    Page | 26

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    27/35

    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 products_admin : System.Web.UI.Page{

    DataSet TempDs; //User for fetching the values from 'RECORD','DETAILS' & 'STOCK' and showing themin the corresponding TextBoxes.

    Class_admin ca=new Class_admin();protected void Page_Load(object sender, EventArgs e){

    try{

    string test = Session["unamead"].ToString(); //Administrator is logged in or not?if (IsPostBack == false) //Will be TRUE only for the 1st PostBack, after that it will

    become FALSE.{

    TempDs = ca.FetchPID();int cnt = TempDs.Tables["pid_record"].Rows.Count; //Counts the no. of items in the

    'RECORD'.

    for (int i = 0; i < cnt; i++){this.DropDownList1.Items.Add(TempDs.Tables["pid_record"].Rows[i]

    [0].ToString()); //Loads the PID of the items in the 'DropDownList'}

    }}catch (Exception ex){

    //Response.Write("alert('Please Login to Enter!!')");Response.Redirect("eshoppe_admin32310.aspx"); //Administrator is not logged in.

    }

    }protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e){

    TempDs = ca.FetchRecord(this.DropDownList1.SelectedItem.Text);

    this.TextBox_pid.Text = TempDs.Tables["record"].Rows[0][0].ToString();this.TextBox_purl.Text = TempDs.Tables["record"].Rows[0][1].ToString();this.TextBox_pname.Text = TempDs.Tables["record"].Rows[0][2].ToString();this.TextBox_pprice.Text = TempDs.Tables["record"].Rows[0][3].ToString();TempDs = ca.FetchDetails(this.DropDownList1.SelectedItem.Text);this.TextBox_pdurl.Text = TempDs.Tables["details"].Rows[0][0].ToString();this.TextBox_pmodel.Text = TempDs.Tables["details"].Rows[0][1].ToString();this.TextBox_pspec.Text = TempDs.Tables["details"].Rows[0][2].ToString();this.TextBox_mprice.Text = TempDs.Tables["details"].Rows[0][3].ToString();TempDs = ca.FetchStock(this.DropDownList1.SelectedItem.Text);this.TextBox_qty.Text = TempDs.Tables["stock"].Rows[0][0].ToString();

    }protected void Button1_Click(object sender, EventArgs e) //Used to insert a new item & refresh the

    page.{

    try

    {this.Label1.Text = ca.InsertRecord(this.TextBox_pid.Text, this.TextBox_purl.Text,

    this.TextBox_pname.Text, int.Parse(this.TextBox_pprice.Text));this.Label2.Text = ca.InsertDetails(this.TextBox_pdurl.Text, this.TextBox_pid.Text,

    this.TextBox_pmodel.Text, this.TextBox_pspec.Text, int.Parse(this.TextBox_mprice.Text),int.Parse(this.TextBox_pprice.Text));

    this.Label3.Text = ca.InsertStock(this.TextBox_pid.Text, int.Parse(this.TextBox_qty.Text));//Response.Write("alert('Values Inserted Successfully!!')");Response.Redirect("products_admin.aspx");

    }catch (Exception ex){

    Response.Write("alert('Please Enter in Proper Formats!!')");}

    Page | 27

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    28/35

    }protected void Button3_Click(object sender, EventArgs e) //Used to delete an item from the

    RECORD(The item will automatically removed from DETAILS & STOCK because of the Foreign Key) & refreshthe page.

    {this.Label2.Text = ca.DeleteRecord(this.TextBox_pid.Text);Response.Redirect("products_admin.aspx");

    }

    protected void Button2_Click(object sender, EventArgs e) //Used to update an item & refresh thepage.{

    try{

    this.Label1.Text = ca.UpdateRecord(this.TextBox_pid.Text, this.TextBox_purl.Text,this.TextBox_pname.Text, int.Parse(this.TextBox_pprice.Text));

    this.Label2.Text = ca.UpdateDetails(this.TextBox_pdurl.Text, this.TextBox_pid.Text,this.TextBox_pmodel.Text, this.TextBox_pspec.Text, int.Parse(this.TextBox_mprice.Text),int.Parse(this.TextBox_pprice.Text));

    this.Label3.Text = ca.UpdateStock(this.TextBox_pid.Text, int.Parse(this.TextBox_qty.Text));//Response.Write("alert('Values Updated Successfully!!')");Response.Redirect("products_admin.aspx");

    }catch (Exception ex){

    Response.Write("alert('Please Enter in Proper Formats!!')");

    }}protected void Button4_Click(object sender, EventArgs e){

    Response.Redirect("usr_admin.aspx");}protected void Button5_Click(object sender, EventArgs e){

    Response.Redirect("cart_admin.aspx");}protected void Button6_Click(object sender, EventArgs e){

    Response.Redirect("bank_admin.aspx");}protected void Button7_Click(object sender, EventArgs e){

    Response.Redirect("esadmin_admin.aspx");

    }protected void Button8_Click(object sender, EventArgs e){

    Session.Remove("unamead");Response.Redirect("eshoppe_admin32310.aspx");

    }}

    Manage Cart (cart_admin.aspx.cs)

    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 cart_admin : System.Web.UI.Page{

    Class_admin ca = new Class_admin();protected void Page_Load(object sender, EventArgs e){

    try{

    string test = Session["unamead"].ToString();

    Page | 28

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    29/35

    }catch (Exception ex){

    //Response.Write("alert('Please Login to Enter!!')");Response.Redirect("eshoppe_admin32310.aspx");

    }}protected void Button4_Click(object sender, EventArgs e)

    { Response.Redirect("usr_admin.aspx");}protected void Button5_Click(object sender, EventArgs e){

    Response.Redirect("products_admin.aspx");}protected void Button6_Click(object sender, EventArgs e){

    Response.Redirect("bank_admin.aspx");}protected void Button7_Click(object sender, EventArgs e){

    Response.Redirect("esadmin_admin.aspx");}protected void Button8_Click(object sender, EventArgs e){

    Session.Remove("unamead");Response.Redirect("eshoppe_admin32310.aspx");}protected void Button10_Click(object sender, EventArgs e) //Some users are not paying & the CART is

    getting heavy? Delete items from CART.{

    ca.DeleteCart(this.TextBox1.Text);Response.Redirect("cart_admin.aspx");

    }}

    Manage Bank (bank_admin.aspx.cs)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 bank_admin : System.Web.UI.Page{

    Class_admin ca = new Class_admin();protected void Page_Load(object sender, EventArgs e){

    try{

    string test = Session["unamead"].ToString();}catch (Exception ex){

    //Response.Write("alert('Please Login to Enter!!')");Response.Redirect("eshoppe_admin32310.aspx");

    }}protected void Button4_Click(object sender, EventArgs e){

    Response.Redirect("usr_admin.aspx");}protected void Button5_Click(object sender, EventArgs e){

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

    Page | 29

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    30/35

    protected void Button6_Click(object sender, EventArgs e){

    Response.Redirect("products_admin.aspx");}protected void Button7_Click(object sender, EventArgs e){

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

    protected void Button8_Click(object sender, EventArgs e){Session.Remove("unamead");Response.Redirect("eshoppe_admin32310.aspx");

    }protected void Button10_Click(object sender, EventArgs e) //Delete the items from the BANK of this

    user.{

    ca.DeleteBank_usr(this.TextBox1.Text);Response.Redirect("bank_admin.aspx");

    }protected void Button11_Click(object sender, EventArgs e) //Delete the items from the BANK having

    the Credit Card No.___ .{

    ca.DeleteBank_card(this.TextBox2.Text);Response.Redirect("bank_admin.aspx");

    }

    }Manage Users (usr_admin.aspx.cs)

    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 user_admin : System.Web.UI.Page

    {Class_admin ca = new Class_admin();protected void Page_Load(object sender, EventArgs e){

    try{

    string test = Session["unamead"].ToString();}catch (Exception ex){

    //Response.Write("alert('Please Login to Enter!!')");Response.Redirect("eshoppe_admin32310.aspx");

    }

    }protected void Button4_Click(object sender, EventArgs e){

    Response.Redirect("products_admin.aspx");}protected void Button5_Click(object sender, EventArgs e){

    Response.Redirect("cart_admin.aspx");}protected void Button6_Click(object sender, EventArgs e){

    Response.Redirect("bank_admin.aspx");}protected void Button7_Click(object sender, EventArgs e){

    Response.Redirect("esadmin_admin.aspx");

    Page | 30

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    31/35

    }protected void Button8_Click(object sender, EventArgs e){

    Session.Remove("unamead");Response.Redirect("eshoppe_admin32310.aspx");

    }protected void Button10_Click(object sender, EventArgs e) //Deletes an user & refreshes the page.{

    ca.DeleteUsr(this.TextBox1.Text);Response.Redirect("usr_admin.aspx");}

    }

    Change Password (esadmin_admin.aspx.cs)

    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 esadmin_admin : System.Web.UI.Page{

    Class_admin ca = new Class_admin();protected void Page_Load(object sender, EventArgs e){

    try{

    string test = Session["unamead"].ToString();}catch (Exception ex){

    //Response.Write("alert('Please Login to Enter!!')");Response.Redirect("eshoppe_admin32310.aspx");

    }}

    protected void Button4_Click(object sender, EventArgs e){

    Response.Redirect("usr_admin.aspx");}protected void Button5_Click(object sender, EventArgs e){

    Response.Redirect("cart_admin.aspx");}protected void Button6_Click(object sender, EventArgs e){

    Response.Redirect("bank_admin.aspx");}protected void Button7_Click(object sender, EventArgs e){

    Response.Redirect("products_admin.aspx");}protected void Button8_Click(object sender, EventArgs e) //My administrator job is done, log me

    out.{

    Session.Remove("unamead");Response.Redirect("eshoppe_admin32310.aspx");

    }protected void Button1_Click(object sender, EventArgs e){

    this.Label1.Text = ca.ChangeAdmin(Session["unamead"].ToString(), this.TextBox2.Text); //Notfeeling secured? Change the administrator password.

    }}

    Page | 31

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    32/35

    TestingBlack-Box Testing:

    Page Input Expected Output Actual Output

    Page | 32

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    33/35

    User Login Page Correct username & password Redirect to Products Home Redirect to Products Home

    User Login Page Invalid Username Error: Error in login, try again! Error: Error in login, try again!

    User Login PageCorrect username & wrong

    password

    Error: The username &

    password doesn't match!

    Error: The username &

    password doesn't match!

    New Registration PagePassword less than 6 characters

    or greater than 10 charactersError: Within 6-10 characters Error: Within 6-10 characters

    New Registration PagePassword & Confirm password

    dont matchError: Passwords doesn't match Error: Passwords doesn't match

    New Registration Page Name field is blank Error: Can't leave blank Error: Can't leave blank

    New Registration Page Invalid E-Mail address Error: Enter a valid E-Mail Error: Enter a valid E-Mail

    New Registration Page Username already exist

    Error: Error in registration

    (Maybe your username already

    in use), try again!

    Error: Error in registration

    (Maybe your username already

    in use), try again!

    Confirm Password Page Wrong PasswordError Message: Wrong

    Password!

    Error Message: Wrong

    Password!

    Online Payment PageBank Name or Branch or Credit

    Card No. is blankError: Cant leave blank! Error: Cant leave blank!

    Administrator LoginCorrect username & wrong

    password

    Error: The username &

    password doesn't match!

    Error: The username &

    password doesn't match!

    Page | 33

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    34/35

    Conclusions

    We have tried our best to make this system bugs free as much as

    possible. We have designed it keeping in mind that our application looks like a

    real time application. It is designed in a very user friendly way. GUI is designed

    as simple as possible. System is made such a way that optimal execution timeis needed to perform an operation. Maximum level of security is implemented in

    the application. Moderating privilege is given to the administrator as much as

    possible.

    Use of Ajax components would make the application interactive and

    prevents annoying post backs. Its drag and drop feature would make it easy to

    use.

    Still there are certain limitations in our web application and we hope tosolve that as soon as possible.

    Page | 34

  • 8/7/2019 Online Shopping Cart System (6 Copies)

    35/35

    References

    Bibliography:

    1. Matthew MacDonald, Beginning ASP.NET 3.5 in C# 2008, Apress.

    2. George Shepherd, Microsoft ASP.NET 3.5 Step by Step, Microsoft Press.

    3. Dalton, Whitehead and Kogent, SQL Server 2005 (Black Book), Dreamtech Press.

    Webliography:

    1. http://www.roseindia.net/

    2. http://www.w3schools.com/

    3. http://www.tutorialspoint.com/

    4. http://www.stardeveloper.com/

    5. http://msdn.microsoft.com/en-us/library/ms123401.aspx