void Button_Click(object sender, EventArgs e)
        {
            try
            {
                int    id;
                string s;
                Button b = (Button)sender;
                s  = b.ID;
                id = int.Parse(s[6].ToString());
                string name   = "Package" + (id + 1).ToString();
                string prodid = city + (id + 1).ToString();

                if (Session[prodid] == null)
                {
                    string[] delim = result[id].Split(';');
                    double   price = Convert.ToDouble(delim[0]) * Convert.ToDouble(delim[4]);

                    orderItem order = new orderItem(name, prodid, price);
                    Session[prodid] = order;
                    // orderItem order1 = (orderItem)Session[prodid];
                    // updated = order1._Name;
                    viewcart1.updatecart(name, prodid, price);
                }
                else
                {
                    Label2.Text = "Sorry you cannot add the same package again!";
                }
            }
            catch (Exception ex)
            {
                Label2.Text = "Error! " + ex.ToString();
            }
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpCookie myCookies = Request.Cookies["details"];

            if (myCookies == null)
            {
                Response.Redirect("http://webstrar13.fulton.asu.edu/page0/Home.aspx");
            }
            else
            {
                Label1.Text = "Hello, " + myCookies["username"];
                city        = Request.QueryString["city"];
                int    i     = 1;
                int    count = 0;
                string carid = city + "car";
                totalprice = 0;

                if (Session.Count != 0)
                {
                    while (i <= 10 && count <= Session.Count)
                    {
                        if (Session[city + i.ToString()] != null)
                        {
                            order = (orderItem)Session[city + i.ToString()];
                            string result = "<b>Product ID : </b>" + order._ProductId + "<br>" +
                                            "<b> Product Name: </b>" + order._Name + "<br>" +
                                            "<b> Product Price: </b>" + order._Price.ToString();

                            TableRow trow = new TableRow();
                            trow.BorderStyle = BorderStyle.Solid;
                            Table1.Rows.Add(trow);

                            TableCell tcell1 = new TableCell();
                            tcell1.BorderStyle = BorderStyle.Solid;
                            tcell1.Text        = result;
                            trow.Cells.Add(tcell1);

                            Button b = new Button();
                            b.Text   = "Delete from Cart";
                            b.ID     = "Button" + (i - 1).ToString();
                            b.Click += new EventHandler(Button_Click);
                            TableCell tcell2 = new TableCell();
                            tcell2.BorderStyle = BorderStyle.Solid;
                            tcell2.Controls.Add(b);
                            tcell2.HorizontalAlign = HorizontalAlign.Center;
                            tcell2.VerticalAlign   = VerticalAlign.Middle;
                            trow.Cells.Add(tcell2);

                            count++;
                            totalprice = totalprice + order._Price;
                        }
                        i++;
                    }

                    i = 1;

                    while (i <= 10 && count <= Session.Count)
                    {
                        if (Session[carid + i.ToString()] != null)
                        {
                            order = (orderItem)Session[carid + i.ToString()];
                            string result = "<b>Product ID : </b>" + order._ProductId + "<br>" +
                                            "<b> Product Name: </b>" + order._Name + "<br>" +
                                            "<b> Product Price: </b>" + order._Price.ToString();

                            TableRow trow = new TableRow();
                            trow.BorderStyle = BorderStyle.Solid;
                            Table1.Rows.Add(trow);

                            TableCell tcell1 = new TableCell();
                            tcell1.BorderStyle = BorderStyle.Solid;
                            tcell1.Text        = result;
                            trow.Cells.Add(tcell1);

                            Button b = new Button();
                            b.Text   = "Delete from Cart";
                            b.ID     = "CarButton" + (i - 1).ToString();
                            b.Click += new EventHandler(Button_Click);
                            TableCell tcell2 = new TableCell();
                            tcell2.BorderStyle = BorderStyle.Solid;
                            tcell2.Controls.Add(b);
                            tcell2.HorizontalAlign = HorizontalAlign.Center;
                            tcell2.VerticalAlign   = VerticalAlign.Middle;
                            trow.Cells.Add(tcell2);

                            count++;
                            totalprice = totalprice + order._Price;
                        }
                        i++;
                    }

                    TableRow trow1 = new TableRow();
                    trow1.BorderStyle = BorderStyle.Solid;
                    Table1.Rows.Add(trow1);

                    TableCell tcell11 = new TableCell();
                    tcell11.BorderStyle     = BorderStyle.Solid;
                    tcell11.Text            = "<b>Total Price </b>";
                    tcell11.HorizontalAlign = HorizontalAlign.Center;
                    trow1.Cells.Add(tcell11);

                    TableCell tcell21 = new TableCell();
                    tcell21.BorderStyle     = BorderStyle.Solid;
                    tcell21.Text            = totalprice.ToString();
                    tcell21.HorizontalAlign = HorizontalAlign.Center;
                    trow1.Cells.Add(tcell21);
                }

                if (Session.Count == 0 || totalprice == 0)
                {
                    Label2.Text      = "Your shopping cart is empty!";
                    Button11.Enabled = false;
                }
                else
                {
                    Label2.Text      = "";
                    Button11.Enabled = true;
                }
            }
        }
        //string updated = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpCookie myCookies = Request.Cookies["details"];

            if (myCookies == null)
            {
                Response.Redirect("http://webstrar13.fulton.asu.edu/page0/Home.aspx");
            }
            else
            {
                Label1.Text = "Hello, " + myCookies["username"];
                ServiceReference1.CatalogService1Client client = new ServiceReference1.CatalogService1Client();
                city  = Request.QueryString["city"];
                carid = city + "car";

                result = client.GetHotelDeals(city);

                for (int i = 0; i < result.Count(); i++)
                {
                    string[] delim = result[i].Split(';');
                    string   res   = "<b> Package " + (i + 1).ToString() + "</b> <br> <br>" + "<b> Night Duration: </b>" + delim[0] + "<br>" +
                                     "<b> Start Date: </b>" + delim[1] + "<br>" +
                                     "<b> End Date: </b>" + delim[2] + "<br>" +
                                     "<b> Description: </b>" + delim[3] + "<br>" +
                                     "<b> Price per night: </b>" + delim[4] + "<br>" +
                                     "<b> City: </b>" + delim[5];

                    TableRow trow = new TableRow();
                    trow.BorderStyle = BorderStyle.Solid;
                    Table1.Rows.Add(trow);

                    TableCell tcell1 = new TableCell();
                    tcell1.BorderStyle = BorderStyle.Solid;
                    tcell1.Text        = res;
                    trow.Cells.Add(tcell1);

                    Button b = new Button();
                    b.Text   = "Add To Cart";
                    b.ID     = "Button" + i.ToString();
                    b.Click += new EventHandler(Button_Click);
                    TableCell tcell2 = new TableCell();
                    tcell2.BorderStyle = BorderStyle.Solid;
                    tcell2.Controls.Add(b);
                    tcell2.HorizontalAlign = HorizontalAlign.Center;
                    tcell2.VerticalAlign   = VerticalAlign.Middle;
                    trow.Cells.Add(tcell2);
                }

                int j     = 1;
                int count = 0;
                if (Session.Count != 0)
                {
                    while (j <= 10 && count <= Session.Count)
                    {
                        if (Session[city + j.ToString()] != null)
                        {
                            order = (orderItem)Session[city + j.ToString()];
                            viewcart1.updatecart(order._Name, order._ProductId, order._Price);
                            count++;
                        }
                        j++;
                    }

                    j = 1;

                    while (j <= 10 && count <= Session.Count)
                    {
                        if (Session[carid + j.ToString()] != null)
                        {
                            order = (orderItem)Session[carid + j.ToString()];
                            viewcart1.updatecart(order._Name, order._ProductId, order._Price);
                            count++;
                        }
                        j++;
                    }
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpCookie myCookies = Request.Cookies["details"];

            if (myCookies == null)
            {
                Response.Redirect("http://webstrar13.fulton.asu.edu/page0/Home.aspx");
            }
            else
            {
                Label1.Text = "Hello, " + myCookies["username"];
                city        = Request.QueryString["city"];
                carid       = city + "car";
                String start = Request.QueryString["start"];
                String end   = Request.QueryString["end"];
                String pick  = Request.QueryString["pick"];
                String drop  = Request.QueryString["drop"];

                ServiceReference1.CatalogService1Client client = new ServiceReference1.CatalogService1Client();

                result = client.GetCarDeals(city, start, end, pick, drop);

                for (int i = 0; (i < 11) || (i < result.Count()); i++)
                {
                    string[] delim = result[i].Split(';');
                    string   res   = "<b> Deal " + (i + 1).ToString() + "</b> <br> <br>" + "<b> Car Type Code: </b>" + delim[0] + "<br>" +
                                     "<b> Daily Rate: </b>" + delim[1] + "<br>" +
                                     "<b> Pick Up Code: </b>" + delim[2] + "<br>" +
                                     "<b> Rental Days: </b>" + delim[3] + "<br>" +
                                     "<b> Sub Total: </b>" + delim[5] + "<br>" +
                                     "<b> Taxes and Fares: </b>" + delim[6] + "<br>" +
                                     "<b> Total Price: </b>" + delim[7];

                    TableRow trow = new TableRow();
                    trow.BorderStyle = BorderStyle.Solid;
                    Table1.Rows.Add(trow);

                    TableCell tcell1 = new TableCell();
                    tcell1.BorderStyle = BorderStyle.Solid;
                    tcell1.Text        = res;
                    trow.Cells.Add(tcell1);

                    Button b = new Button();
                    b.Text   = "Add To Cart";
                    b.ID     = "But" + i.ToString();
                    b.Click += new EventHandler(Button_Click);
                    TableCell tcell2 = new TableCell();
                    tcell2.BorderStyle = BorderStyle.Solid;
                    tcell2.Controls.Add(b);
                    tcell2.HorizontalAlign = HorizontalAlign.Center;
                    tcell2.VerticalAlign   = VerticalAlign.Middle;
                    trow.Cells.Add(tcell2);
                }

                int j     = 1;
                int count = 0;
                if (Session.Count != 0)
                {
                    while (j <= 10 && count <= Session.Count)
                    {
                        if (Session[city + j.ToString()] != null)
                        {
                            order = (orderItem)Session[city + j.ToString()];
                            viewcart1.updatecart(order._Name, order._ProductId, order._Price);
                            count++;
                        }
                        j++;
                    }

                    j = 1;

                    while (j <= 10 && count <= Session.Count)
                    {
                        if (Session[carid + j.ToString()] != null)
                        {
                            order = (orderItem)Session[carid + j.ToString()];
                            viewcart1.updatecart(order._Name, order._ProductId, order._Price);
                            count++;
                        }
                        j++;
                    }
                }
            }
        }