Пример #1
0
        protected void btn_UpdateOrder_Click(object sender, EventArgs e)
        {
            //Makes sure that not both values are selected
            if (CheckBoxList_Update.Items[0].Selected && CheckBoxList_Update.Items[1].Selected)
            {
                lbl_CheckStatus.Text    = "Du kan bara ange ett alternativ";
                lbl_CheckStatus.Visible = true;
            }
            else
            {
                I_EshopserviceClient client = new I_EshopserviceClient();
                string username             = Request.QueryString["user"];
                string orderdate            = Request.QueryString["orderdate"];

                //Just to be extra sure that right values are being inserted
                if (CheckBoxList_Update.Items[0].Selected)
                {
                    client.UpdateOrder(username, orderdate, true);
                    System.Diagnostics.Debug.WriteLine("Order flyttad till levererade");
                }
                else if (CheckBoxList_Update.Items[1].Selected)
                {
                    client.UpdateOrder(username, orderdate, false);
                    System.Diagnostics.Debug.WriteLine("Order flyttad till ej levererade");
                }

                Response.Redirect("~/Account/Admin/MadeOrders.aspx");
            }
        }
Пример #2
0
        private void LoadOrders()
        {
            I_EshopserviceClient client = new I_EshopserviceClient();

            unDeliveredOrders = client.GetOrders(WebProfile.Current.UserName, false);
            DeliveredOrders   = client.GetOrders(WebProfile.Current.UserName, true);
        }
Пример #3
0
        private void MakeSearch()
        {
            I_EshopserviceClient client = new I_EshopserviceClient();

            try
            {
                ResultTable = client.GetProductsBySearch(_QueryString);

                Repeater_SearchResult.DataSource = ResultTable;
                Repeater_SearchResult.DataBind();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Unable to send Querystring: " + _QueryString + "\nMessage: " + ex.Message);
            }

            int resultnr = 1;

            foreach (RepeaterItem item in Repeater_SearchResult.Items)
            {
                Label lbl_resultnr = (Label)item.FindControl("lbl_ResultNumber");
                lbl_resultnr.Text = "Nr: " + resultnr;

                resultnr++; //+1 foreach item
            }
        }
Пример #4
0
        protected void btn_MakeDeal_Click(object sender, EventArgs e)
        {
            //Make the deal
            string username   = WebProfile.Current.UserName;
            string firstname  = WebProfile.Current.FirstName;
            string lastname   = WebProfile.Current.LastName;
            string city       = WebProfile.Current.City;
            string address    = WebProfile.Current.Address;
            int    zipcode    = Convert.ToInt32(WebProfile.Current.ZipCode);
            int    totalprice = Convert.ToInt32(WebProfile.Current.Cart.TotalPrice);

            I_EshopserviceClient client    = new I_EshopserviceClient();
            ShoppingCart         OrderCart = new ShoppingCart();

            cart = WebProfile.Current.Cart; //Must be used for sending shoppingcart through

            OrderCart = OrderCart.CopyFrom(cart);
            System.Diagnostics.Debug.WriteLine("OrderCart: " + OrderCart.Items.Count + "varor");

            try
            {
                client.InsertNewOrder(username, firstname, lastname, city, address, zipcode, OrderCart);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Something went wrong with inserting order: \n" + ex.Message);
            }

            WebProfile.Current.Cart.DeleteAllItems();
            Response.Redirect("~/Sites/StatusForm.aspx?statusid=madedeal");
        }
Пример #5
0
        /// <summary>
        /// Loads all products that matches the current node
        /// </summary>
        /// <param name="current">Tell webbservice which products to get</param>
        /// <param name="parent">Ignore this, no longer used</param>
        private void LoadData(string current, string parent)
        {
            //Shows all products for admins
            bool isAdmin = false;

            if (User.IsInRole("admin"))
            {
                isAdmin = true;
            }

            I_EshopserviceClient client = new I_EshopserviceClient();
            DataTable            table  = new DataTable();

            try
            {
                table = client.GetProductsByTags(current, parent, isAdmin);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Error message: " + ex.Message);
            }

            Repeater1.DataSource = table;
            Repeater1.DataBind();
        }
Пример #6
0
        /// <summary>
        /// Loads all products to be shown
        /// </summary>
        private void LoadData()
        {
            //Shows all products for admins
            bool isAdmin = false;

            if (User.IsInRole("admin"))
            {
                isAdmin = true;
            }

            I_EshopserviceClient client = new I_EshopserviceClient();
            DataTable            table  = new DataTable();

            try
            {
                //lbl_webbService.Text += client.Test();    //Makes sure that the service actually works
                table = client.GetAllProducts(isAdmin).Copy();
                //table = client.GetProductsFromDataSet().Copy();   //Should be used later
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Errormessage: " + ex.Message);
            }
            Repeater1.DataSource = table;
            Repeater1.DataBind();

            //lbl_querystring.Text = table.Rows[0]["PTitle"].ToString();
        }
Пример #7
0
        private void LoadValues(string PTitle)
        {
            client = new I_EshopserviceClient();    //Just to make sure that a new request is made each time
            DataTable table = new DataTable();

            try
            {
                table = client.GetProduct(PTitle).Copy();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Something went wrong when getting product: " + ex.Message);
            }

            if (table.Rows.Count != 0)  //Last check, to make sure that the table contains values
            {
                txtbox_quantity.Visible          = true;
                lbl_productnrlabel.Visible       = true;
                lbl_productpricelabel.Visible    = true;
                lbl_productquantitylabel.Visible = true;

                //If everything went fine, just load values into website elements
                lbl_ProductNr.Text    = table.Rows[0]["PId"].ToString();
                lbl_ProductTitle.Text = table.Rows[0]["PTitle"].ToString();
                img_Product.ImageUrl  = table.Rows[0]["PImgurl"].ToString();
                //img_Product.ImageUrl = "~/imgs/products/no_image.jpg";
                img_Product.DescriptionUrl = "En bild på " + table.Rows[0]["PTitle"].ToString();

                double price = Convert.ToDouble(table.Rows[0]["PPrice"].ToString());
                lbl_ProductPrice.Text = price.ToString();

                _Quantity = Convert.ToInt32(table.Rows[0]["PInStock"]);
                lbl_ProductInStock.Text = "" + _Quantity;
                lbl_ProductInfo.Text    = table.Rows[0]["PInfo"].ToString();

                //Makes it impossible for users add to cart if quantity is 0
                if (_Quantity == 0)
                {
                    btn_addToCart.Enabled = false;
                }
                else
                {
                    btn_addToCart.Enabled = true;
                }
            }
            else
            {
                btn_addToCart.Visible            = false; //Hides button for add to cart
                lbl_ProductTitle.Text            = "Produkten finns inte!";
                lbl_ProductInfo.Text             = "Kontrollera sökvägen igen, eller kontakta supporten för hjälp";
                txtbox_quantity.Visible          = false;
                lbl_productnrlabel.Visible       = false;
                lbl_productpricelabel.Visible    = false;
                lbl_productquantitylabel.Visible = false;
            }
            //lbl_ProductTitle.Text = "Nu fungerar det inte" + "<br />Värdet: " + PTitle;    //used with errorhunting
        }
Пример #8
0
        private void LoadValues()
        {
            I_EshopserviceClient client = new I_EshopserviceClient();
            DataTable            table  = new DataTable();

            table = client.GetAllProductsOutOfStock();

            Repeater_OutOfStock.DataSource = table;
            Repeater_OutOfStock.DataBind();
        }
Пример #9
0
        private void LoadOrderDetails()
        {
            Orderid   = Convert.ToInt32(Request.QueryString["orderid"]);
            OrderDate = Request.QueryString["orderdate"];

            I_EshopserviceClient client = new I_EshopserviceClient();

            OrderTable = client.GetOrderDetails(Orderid, OrderDate);

            Repeater_OrderDetails.DataSource = OrderTable;
            Repeater_OrderDetails.DataBind();
        }
Пример #10
0
        private void InsertProduct(string Title, string Info, int Quantity, string Tags, string ImgUrl, double Price)
        {
            I_EshopserviceClient client = new I_EshopserviceClient();

            try
            {
                client.InsertProduct(Title, Info, Quantity, Tags, ImgUrl, Price);
            }
            catch
            {
                System.Diagnostics.Debug.WriteLine("Couldn't send insertvalues");
            }
        }
Пример #11
0
        private void LoadUnDeliveredOrders()
        {
            I_EshopserviceClient client = new I_EshopserviceClient();

            UnDeliveredOrders = new DataTable();
            UnDeliveredOrders = client.AdminGetOrders(false);
            //DeliveredOrders = client.AdminGetOrders(true);

            Repeater_unDelivered.DataSource = UnDeliveredOrders;
            Repeater_unDelivered.DataBind();

            //Repeater_Delivered.DataSource = DeliveredOrders;
            //Repeater_Delivered.DataBind();
        }
Пример #12
0
        private void LoadDeliveredOrdersByDate()
        {
            string startdate = Calendar_Startdate.SelectedDate.ToString();
            string enddate   = Calendar_Enddate.SelectedDate.ToString();

            System.Diagnostics.Debug.WriteLine("Startdate: " + startdate + " Enddate: " + enddate);

            I_EshopserviceClient client = new I_EshopserviceClient();

            DeliveredOrders = new DataTable();
            DeliveredOrders = client.AdminGetOrdersByDate(true, startdate, enddate);

            Repeater_Delivered.DataSource = DeliveredOrders;
            Repeater_Delivered.DataBind();
        }
Пример #13
0
        protected void btn_UpdateQuantity_Click(object sender, EventArgs e)
        {
            if (User.IsInRole("admin"))
            {
                int    quantity     = Convert.ToInt32(txtbox_quantity.Text);
                int    oldquantity  = Convert.ToInt32(lbl_ProductInStock.Text);
                string productTitle = lbl_ProductTitle.Text;

                //For debugging
                //System.Diagnostics.Debug.WriteLine("In stock: " + oldquantity);

                I_EshopserviceClient client = new I_EshopserviceClient();
                client.UpdateQuantity(productTitle, quantity, oldquantity);

                Response.Redirect(Request.RawUrl);  //reloads the page
            }
        }
Пример #14
0
        protected void btn_UpdateProducts_Click(object sender, EventArgs e)
        {
            I_EshopserviceClient client = new I_EshopserviceClient();

            foreach (RepeaterItem item in Repeater_OutOfStock.Items)
            {
                TextBox QuantityBox = new TextBox();
                QuantityBox = (TextBox)item.FindControl("txtBox_Quantity");
                int quantity = Convert.ToInt32(QuantityBox.Text);

                Label lbl_ProductTitle = new Label();
                lbl_ProductTitle = (Label)item.FindControl("lbl_ProductTitle");
                string productName = lbl_ProductTitle.Text;

                client.UpdateQuantity(productName, quantity, 0);
            }

            Response.Redirect(Request.RawUrl);
        }
Пример #15
0
        public string[] CompleteText(string prefixText, int count)
        {
            I_EshopserviceClient client = new I_EshopserviceClient();
            DataTable            result = new DataTable();

            try
            {
                result = client.GetProductsBySearch(prefixText);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Something went wrong with autocomplete: " + ex.Message);
            }

            var rowColl = result.AsEnumerable();    //Makes it possible to use linq on datatable

            //Selects only all results under the column PTitle to a string array
            string[] products = (from r in rowColl select r.Field <string>("PTitle")).ToArray();

            return(products);
        }
Пример #16
0
        private void LoadDetails()
        {
            Orderid   = Convert.ToInt32(Request.QueryString["orderid"]);
            OrderDate = Request.QueryString["orderdate"];

            //For debugging
            //System.Diagnostics.Debug.WriteLine("\nOrderid: " + Orderid + "\nOrderdate: " + OrderDate + "\n\n");

            I_EshopserviceClient client = new I_EshopserviceClient();

            try
            {
                DetailTable = client.GetOrderDetails(Orderid, OrderDate);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Something went wrong when orderdetails was loading: " + ex.Message);
            }

            Repeater_OrderDetails.DataSource = DetailTable;
            Repeater_OrderDetails.DataBind();
        }
Пример #17
0
        private void LoadProductValues()
        {
            //Show admin all products
            bool isAdmin = false;

            if (User.IsInRole("admin"))
            {
                isAdmin = true;
            }

            I_EshopserviceClient client = new I_EshopserviceClient();

            ProductTable = client.GetAllProductsByAmount(12, isAdmin);    //Gets the 5 latest added products

            Repeater_Products.DataSource = ProductTable;
            Repeater_Products.DataBind();

            Repeater_Slideshow.DataSource = ProductTable;
            Repeater_Slideshow.DataBind();

            //just to make sure that the arraylists are empty
            Productrows    = new ArrayList();
            ProductColumns = new ArrayList();
        }
Пример #18
0
        private void CreateSiteMap()
        {
            I_EshopserviceClient client = new I_EshopserviceClient();

            table = new DataTable();
            _siteList.Clear();  //Makes sure that the list is clear and ready to be used

            string key    = "";
            string url    = "";
            string title  = "";
            int    parent = 0;
            int    id     = 0;

            try
            {
                table = client.GetSiteMap().Copy();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Something went wrong when sitemap was loading: " + ex.Message);
            }

            foreach (DataRow row in table.Rows)
            {
                key    = row["Title"].ToString();
                url    = row["Url"].ToString();
                title  = row["Title"].ToString();
                parent = Convert.ToInt32(row["Parent"]);
                id     = Convert.ToInt32(row["ID"]);

                try
                {
                    if (parent == 0)
                    {
                        //Then it is root (first node)
                        CreateSiteMapRoot(key, url, title);
                        _siteList.Add(id, _siteMapRoot);  //Makes it possible for childnodes to find it
                    }
                    else
                    {
                        _siteList.Add(id, _siteMapRoot);  //Makes it possible for childnodes to find it

                        //Then it is a childnode
                        int         itemp = parent;           //Gets the parent for current row
                        SiteMapNode root  = _siteList[itemp]; //Finds the right root node
                        //SiteMapNode test = FindSiteMapNodeFromKey(itemp);
                        //CreateSiteMapNodes(row["Title"].ToString(), row["Url"].ToString(), row["Title"].ToString(), root);
                        CreateSiteMapNodes(key, url, title, root);
                        ChildNodes(id, _siteChildNode);
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine("Något gick fel med Menyn: " + ex.Message);
                    System.Diagnostics.Debug.WriteLine("Parent(itemp): " + parent);
                    System.Diagnostics.Debug.WriteLine("Key: " + key);
                    System.Diagnostics.Debug.WriteLine("Url: " + url);
                    System.Diagnostics.Debug.WriteLine("Title: " + title);
                    System.Diagnostics.Debug.WriteLine("ID: " + id);
                }

                //_siteMapRoot = null;  //Clears it...just in case
            }
        }