示例#1
0
        protected void Button24_Click(object sender, EventArgs e)
        {
            masterRef.Service1Client r = new masterRef.Service1Client();
            r.clearcart();              // clearcart() function in the service is called

            string cart = r.getitems(); // Getting the list of items in the cart from the cart service

            if (cart.Equals("empty"))   // If the cart is empty
            {
                Label3.Text = "0";
                ListBox1.Items.Clear(); // Clear the contents of the cart listbox
            }

            else
            {
                ListBox1.Items.Clear();                                                 // Clear the listbox to update the cart
                string[] stringSeparators  = new string[] { "-----------1----------" }; // to split the cart into items
                string[] stringSeparators1 = new string[] { "\n" };

                string[] items = cart.Split(stringSeparators1, StringSplitOptions.RemoveEmptyEntries);


                // Current total value of cart is calculated here
                for (int i = 0; i < items.Length; i++)
                {
                    ListBox1.Items.Add(items[i]);
                }
                //Label3.Text = sum.ToString();           // total is displayed
            }
            Label22.Text = "0";
            //
        }
示例#2
0
        void remove(string hotel, string price)
        {
            masterRef.Service1Client r = new masterRef.Service1Client();
            bool deletion = r.deletefromcart(hotel); // Deteting the "Hotel-1" entry from the cart

            string cart = r.getitems();              // Getting the list of items in the cart from the cart service

            if (cart.Equals("empty"))                // If the cart is empty
            {
                Label22.Text = "0";
                ListBox1.Items.Clear(); // Clear the contents of the cart listbox
            }

            else
            {
                ListBox1.Items.Clear();                                                 // Clear the listbox to update the cart
                string[] stringSeparators  = new string[] { "-----------1----------" }; // to split the cart into items
                string[] stringSeparators1 = new string[] { "\n" };

                string[] items = cart.Split(stringSeparators1, StringSplitOptions.RemoveEmptyEntries);


                // Current total value of cart is calculated here
                for (int i = 0; i < items.Length; i++)
                {
                    ListBox1.Items.Add(items[i]);
                }
                //Label3.Text = sum.ToString();           // total is displayed
            }
            if ((Convert.ToInt32(Label22.Text) > 0) && deletion)
            {
                Label22.Text = (Convert.ToInt32(Label22.Text) - Convert.ToInt32(price)).ToString();
            }
        }
示例#3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpCookie myCookies = Request.Cookies["data"];

            Label1.Text = myCookies["username"];

            catalog.Visible    = (bool)Application["visibility_flag"];
            cart_block.Visible = (bool)Application["visibility_flag"];
            masterRef.Service1Client r = new masterRef.Service1Client();
            string cart = r.getitems(); // Getting the list of items in the cart from the cart service

            if (cart.Equals("empty"))   // If the cart is empty
            {
                Label22.Text = "0";
                ListBox1.Items.Clear(); // Clear the contents of the cart listbox
            }

            else
            {
                ListBox1.Items.Clear();                                                 // Clear the listbox to update the cart
                string[] stringSeparators  = new string[] { "-----------1----------" }; // to split the cart into items
                string[] stringSeparators1 = new string[] { "\n" };

                string[] items = cart.Split(stringSeparators1, StringSplitOptions.RemoveEmptyEntries);


                // Current total value of cart is calculated here
                for (int i = 0; i < items.Length; i++)
                {
                    ListBox1.Items.Add(items[i]);
                }
                //Label3.Text = sum.ToString();           // total is displayed
            }
        }
示例#4
0
        void add(string name, string price)
        {
            masterRef.Service1Client r = new masterRef.Service1Client();
            try
            {
                string result = r.addtocart(name, Convert.ToInt32(price));  // The arguments here can be dynamically generated in a real time application
            }
            catch (Exception ex) { Label22.Text = "in tryit" + ex.ToString(); }

            string cart = r.getitems(); // Getting the list of items in the cart from the cart service

            if (cart.Equals("empty"))   // If the cart is empty
            {
                Label22.Text = "0";
                ListBox1.Items.Clear(); // Clear the contents of the cart listbox
            }

            else
            {
                ListBox1.Items.Clear();                                                 // Clear the listbox to update the cart
                string[] stringSeparators  = new string[] { "-----------1----------" }; // to split the cart into items
                string[] stringSeparators1 = new string[] { "\n" };

                string[] items = cart.Split(stringSeparators1, StringSplitOptions.RemoveEmptyEntries);


                // Current total value of cart is calculated here
                for (int i = 0; i < items.Length; i++)
                {
                    ListBox1.Items.Add(items[i]);
                }
                //Label3.Text = sum.ToString();           // total is displayed
            }
            Label22.Text = (Convert.ToInt32(Label22.Text) + Convert.ToInt32(price)).ToString();
        }