示例#1
0
        private void buttonGet_Click(object sender, EventArgs e)
        {
            try
            {
                List <Product> products = Client.GetAllProducts().ToList();
                switch (Filter)
                {
                case (int)ID:
                    products = products.FindAll(x => x.Id == int.Parse(textBoxAttribute.Text));
                    break;

                case (int)NAME:
                    products = products.FindAll(x => x.Name.Contains(textBoxAttribute.Text));
                    break;

                case (int)COUNT:
                    products = products.FindAll(x => x.Count == int.Parse(textBoxAttribute.Text));
                    break;

                case (int)PRICE:
                    products = products.FindAll(x => x.Price == float.Parse(textBoxAttribute.Text));
                    break;

                default:
                    break;
                }

                if (products.Count < 1)
                {
                    labelInfo.Text = "Product with such attributes doesn't exist.";
                    productBindingSource.Clear();
                }
                else
                {
                    labelInfo.Text = products.Count + " product(s) found";
                    productBindingSource.Clear();
                    foreach (Product p in products)
                    {
                        productBindingSource.Add(p);
                    }
                }
            }
            catch (FormatException)
            {
                labelInfo.Text = "Product with such attributes doesn't exist / Wrong input format";
                productBindingSource.Clear();
            }
        }
        public static object[] GetChartData()
        {
            ProductServiceClient prodService;

            Product[] products;
            prodService = new ProductServiceClient();

            products = prodService.GetAllProducts();
            List <Product> data = new List <Product>();

            data = products.ToList();

            var chartData = new object[products.Count() + 1];

            chartData[0] = new object[] {
                "Product Name",
                "Quantity in stock",
                "Ideal Quantity"
            };
            int j = 0;

            foreach (var i in data)
            {
                j++;
                chartData[j] = new object[] { i.P_Name, i.P_Quantity, 30 };
            }
            return(chartData);
        }
        public static object[] GetChartData()
        {
            ProductServiceClient ProService;

            Invoice[] invoice;
            ProService = new ProductServiceClient();
            Product[] product = ProService.GetAllProducts();
            invoice = ProService.GetAllInvoices();
            List <Invoice> data = new List <Invoice>();

            data = invoice.ToList();

            var chartData = new object[invoice.Count() + 1];

            chartData[0] = new object[]
            {
                "P_Code: ",
                "Product Quantity",
                "Invoice Quantity"
            };
            int j = 0;

            foreach (var i in data)
            {
                j++;
                foreach (Product u in product)
                {
                    //task per user
                    int taskcount = 0;
                    foreach (Invoice t in invoice)
                    {
                        if (u.P_Code.Equals(t.P_Code))
                        {
                            taskcount++;
                        }
                    }

                    //tasks done per user
                    int donecount = 0;

                    foreach (Invoice t in invoice)
                    {
                        if (u.P_Quantity.Equals(t.Quantity) && t.Inv_Type.Equals("dispatch"))
                        {
                            donecount++;
                        }
                    }

                    foreach (Invoice t in invoice)
                    {
                        if (u.P_Code.Equals(i.P_Code))
                        {
                            chartData[j] = new object[] { u.P_Code + ": " + i.Inv_Type, taskcount, donecount };
                        }
                    }
                }
            }
            return(chartData);
        }
示例#4
0
 public ActionResult Index()
 {
     using (ProductServiceClient service = new ProductServiceClient())
     {
         IEnumerable <Product> products = service.GetAllProducts();
         return(View(products));
     }
 }
        private void ProductSearch_Load(object sender, EventArgs e)
        {
            dataGridViewProducts.ReadOnly = true;
            ProductServiceClient product = new ProductServiceClient();

            products = product.GetAllProducts().ToList();
            dataGridViewProducts.DataSource = products;
            UpdateLables();
        }
示例#6
0
        public List <Product> GetAllProducts()
        {
            var allDbProducts = prdClient.GetAllProducts();

            return(allDbProducts.Select(product => new Product()
            {
                ProductId = product.ProductId, Name = product.Name, Description = product.Description, Price = product.Price, CategoryId = product.CategoryId
            }).ToList());
        }
 /// <summary>
 /// Displays current product stock by using service client.
 /// </summary>
 public void ShowAllProducts()
 {
     using (ProductServiceClient wcf = new ProductServiceClient())
     {
         foreach (var item in wcf.GetAllProducts())
         {
             Console.WriteLine($"{item.ID}. {item.Name} - ${item.Price}, Amount: {item.ItemsRemaining}");
         }
     }
 }
示例#8
0
        static void Main(string[] args)
        {
            ProductServiceClient serviceClient = new ProductServiceClient();
            List <Product>       products      = serviceClient.GetAllProducts().ToList();

            foreach (Product product in products)
            {
                Console.WriteLine(product.ProductName);
            }
        }
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            ProductServiceClient product = new ProductServiceClient();
            Product productToDelete      = products[dataGridViewProducts.CurrentRow.Index];

            product.DeleteProduct(productToDelete);
            products = product.GetAllProducts().ToList();
            dataGridViewProducts.DataSource = products;
            dataGridViewProducts.Refresh();
            UpdateLables();
        }
示例#10
0
        /// <summary>
        /// Allows user to modify price by using service client.
        /// </summary>
        public void ModifyPrice()
        {
            ShowAllProducts();
            int productCount;

            using (ProductServiceClient wcf = new ProductServiceClient())
            {
                productCount = wcf.GetAllProducts().Count();
            }
            bool   isValidId = false;
            string IdString;
            int    idNumber;

            do
            {
                Console.WriteLine("Please select one of the items which price you wish to modify:");
                IdString = Console.ReadLine();
                bool isNumber = int.TryParse(IdString, out idNumber);
                if (isNumber == false || idNumber < 1 || idNumber > productCount)
                {
                    Console.WriteLine($"Please enter a positive integer less than {productCount + 1}.");
                }
                else
                {
                    Console.WriteLine($"Item {idNumber} selected.");
                    isValidId = true;
                }
            } while (isValidId == false);
            bool   isValidPrice = false;
            string priceString;
            double price;

            do
            {
                Console.WriteLine("Please enter new price:");
                priceString = Console.ReadLine();
                bool isDouble = double.TryParse(priceString, out price);
                if (isDouble == false || price <= 0.0)
                {
                    Console.WriteLine("Please enter a positive price.");
                }
                else
                {
                    isValidPrice = true;
                }
            } while (isValidPrice == false);
            using (ProductServiceClient wcf = new ProductServiceClient())
            {
                wcf.ModifyProductPrice(idNumber, price);
            }
            Console.WriteLine("Product price modified successfully, displaying available products:");
            ShowAllProducts();
        }
        public List <CompanyProduct> GetAllProducts()
        {
            List <CompanyProduct> productList;

            ProductServiceClient proxy     = new ProductServiceClient();
            ConvertDataModel     converter = new ConvertDataModel();

            productList = converter.ConvertListFromServiceProduct(proxy.GetAllProducts().ToList());
            //productList = converter.

            return(productList);
        }
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            ProductServiceClient product = new ProductServiceClient();
            Product productToChange      = new Product();

            using (AddEdit edit = new AddEdit(productToChange, false))
            {
                edit.ShowDialog();
                product.AddProduct(edit.Product);
                products = product.GetAllProducts().ToList();
                dataGridViewProducts.DataSource = products;
                dataGridViewProducts.Refresh();
                UpdateLables();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            userService = new UserServiceClient();
            prodService = new ProductServiceClient();
            Invoice[] invoices = prodService.GetAllInvoices();
            Product[] products = prodService.GetAllProducts();
            User[]    users    = userService.GetAllUsers();
            string    display  = "";
            Product   pro      = null;
            User      u        = null;



            //foreach (Invoice inv in invoices)
            for (int i = invoices.Length - 1; i >= 0; i--)
            {
                //User u = userService.GetUserbyID(inv.UserID);
                foreach (User us in users)
                {
                    if (us.UserID.Equals(invoices[i].UserID))
                    {
                        u = us;
                    }
                }
                foreach (Product p in products)
                {
                    if (p.P_Code.Equals(invoices[i].P_Code))
                    {
                        pro = p;
                    }
                }
                if (pro != null)
                {
                    display += "<tr>"
                               + "<td><input type='checkbox' class='input-chk'></td>"
                               + "<td>"
                               + "<p class='text'>" + invoices[i].INV_Date + "</p>"
                               + "</td>"
                               + "<td><span class='badge badge-primary'>" + pro.P_Name + " " + invoices[i].P_Code + "</span></td>"
                               + "<td><p class='text'>" + invoices[i].Quantity + "</p></td>"
                               + "<td><span class='badge badge-danger'>" + u.Name + "</span></td>"
                               + "<td><span class='badge badge-primary'>" + invoices[i].Inv_Type + "</span></td>"
                               + "</tbody>"
                    ;
                }
            }
            trans.InnerHtml = display;
        }
示例#14
0
        public async Task <IActionResult> Index()
        {
            var productList = new List <ProductModel>();

            var productServiceClient = new ProductServiceClient();

            IAsyncEnumerator <ProductModel> products = productServiceClient.GetAllProducts();

            while (await products.MoveNextAsync())
            {
                productList.Add(products.Current);
            }
            await products.DisposeAsync();

            return(View(productList));
        }
示例#15
0
        public async Task <IActionResult> Index()
        {
            var productList = new List <ProductModel>();

            var productServiceClient = new ProductServiceClient();

            IAsyncEnumerator <ProductModel> products = productServiceClient.GetAllProducts();

            while (await products.MoveNextAsync())
            {
                productList.Add(products.Current);
            }
            await products.DisposeAsync();

            if (productList != null)
            {
                productList = productList.OrderByDescending(x => x.DateAdded).Take(3).ToList();
            }

            return(View(productList));

            // var productEntities = new List<ProductModel>();
            // productEntities.Add(new ProductModel(){
            //     Id = 1,
            //     Name = "Laptop",
            //     Price = 25000,
            //     OldPrice = 3000,
            //     Description = "Laptop",
            //     ProductImage = "/Images/asus gtx 1070 strix.png",
            //     Rating = 5,
            //     ReviewCount = 2,
            //     Category = "Hardware",
            //     Manufacturers = "Azus"
            // });
            // productEntities.Add(new ProductModel(){
            //     Id = 2,
            //     Name = "Mobile",
            //     Price = 10000,
            //     OldPrice = 10000,
            //     Description = "Mobile",
            //     ProductImage = "/Images/asus gtx 1070 strix.png",
            //     Rating = 5,
            //     ReviewCount = 4,
            //     Category = "Mobile",
            //     Manufacturers = "Azus"
            // });
        }
示例#16
0
        public Order AddOrder()
        {
            var service = new OrderServiceClient(new InstanceContext(this));

            var order = new Order()
            {
                Customer = new Customer()
                {
                    CompanyName = "Test", ContactName = "Contact", CustomerID = new Random().Next(1, 99999).ToString(), ContactTitle = "Title"
                },
                Employee = new Employee()
                {
                    FirstName = "FirstName", LastName = "EmpLastName"
                },
                Shipper = new Shipper()
                {
                    CompanyName = "Test Shipper", Phone = "123-456"
                },
                ShipAddress = "Address",
                ShipCity    = "City",
                ShipCountry = "Country"
            };

            var productService = new ProductServiceClient();
            var products       = productService.GetAllProducts();

            Order_Detail[] details =
            {
                new Order_Detail()
                {
                    Discount = 0, Quantity = 5, UnitPrice = 10, ProductID = products[0].ProductID
                },
                new Order_Detail()
                {
                    Discount = 0, Quantity = 1, UnitPrice = 100, ProductID = products[1].ProductID
                },
            };

            order.Order_Details = details;

            return(service.Add(order));
        }
示例#17
0
        public static object[] GetChartData()
        {
            ProductServiceClient prodService;

            Damaged[] products;
            Product[] product;
            object[]  retChartData = null;
            prodService = new ProductServiceClient();

            products = prodService.GetDamagedProducts();
            List <Damaged> data = new List <Damaged>();

            data = products.ToList();
            //int x = 0;
            product = prodService.GetAllProducts();
            Product prod = null;

            var chartData = new object[products.Count() + 1];

            chartData[0] = new object[] {
                "Date of Damage",
                "Amount Damaged",
                "Quantity in Stock"
            };
            int j = 0;

            foreach (var i in data)
            {
                foreach (Product p in product)
                {
                    if (i.P_ID.Equals(p.P_ID))
                    {
                        prod = p;
                    }
                }
                j++;
                chartData[j] = new object[] { prod.P_Name + "(" + i.DateDamaged + ")", i.Quantity, prod.P_Quantity };
            }
            retChartData = chartData;
            return(retChartData);
        }
        private void getData()
        {
            ProductServiceClient prodService;

            Invoice[] data;
            prodService = new ProductServiceClient();

            data = prodService.GetAllInvoices();

            string lowstock = "Suggestion: ";

            foreach (Product u in prodService.GetAllProducts())
            {
                foreach (var i in data)
                {
                    if (i.P_Code.Equals(u.P_Code))
                    {
                        bool isdone = true;
                        foreach (var j in data)
                        {
                            if (!i.Inv_Type.Equals("dispatch"))
                            {
                                isdone = false;
                            }
                        }
                        if (isdone)
                        {
                            lowstock += u.P_Name.ToUpper();
                        }
                    }
                }
            }
            if (!lowstock.Equals("Suggestion: "))
            {
                lowstock += " Sells the fastest (:- should get the next jobs !!!";
            }
            suggestiontask.InnerHtml = lowstock;
        }
示例#19
0
        public void UpdateOrderTest()
        {
            var order = new OrdersHelper().AddOrder();

            OrdersHelper.PrintFullOrderInfo(order);

            Product[] products;
            using (var productService = new ProductServiceClient())
            {
                products = productService.GetAllProducts();
            }

            order.ShipAddress   = "New Ship Address";
            order.Order_Details = new[]
            {
                new Order_Detail {
                    Discount = 0, ProductID = products[products.Length - 1 >= 0 ? products.Length - 1 : 0].ProductID, Quantity = 100, UnitPrice = 3
                },
                new Order_Detail {
                    Discount = 0, ProductID = products[products.Length - 2 >= 0 ? products.Length - 2 : 0].ProductID, Quantity = 200, UnitPrice = 2
                },
                new Order_Detail {
                    Discount = 0, ProductID = products[products.Length - 3 >= 0 ? products.Length - 3 : 0].ProductID, Quantity = 300, UnitPrice = 1
                }
            };

            Order updatedOrder;

            using (var service = new OrderServiceClient(new InstanceContext(this)))
            {
                updatedOrder = service.UpdateOrder(order);
            }

            Assert.AreEqual(updatedOrder.ShipAddress, "New Ship Address");
            Assert.AreEqual(updatedOrder.Order_Details.Length, 3);

            OrdersHelper.PrintFullOrderInfo(updatedOrder);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            prodService = new ProductServiceClient();
            Product[] products = prodService.GetAllProducts();

            string display = "";


            //foreach(Product prod in products)
            for (int i = products.Length - 1; i >= 0; i--)
            {
                display += "<div class='col-xl-4 col-md-6 col-12'>";
                display += "<div class='card'>";
                display += "<div class='text-center'>";
                display += "<div class='card-body'>";
                display += "<img src ='http://10.254.17.96:80/script/profile_image/prod" + products[i].P_Code + ".jpeg' class='rounded-circle  height-150' alt='Card image'>";
                display += "</div>";
                display += "<div class='card-body'>";
                display += "<h4 class='card-title'>" + products[i].P_Name + "</h4>";
                display += "<h6 class='text-center'>" + " Code: " + products[i].P_Code + "</h6>";
                display += "<h6 class='text-center'>" + " Price: R" + products[i].P_Price + "</h6>";
                display += "<h6 class='text-center'>" + " Quantity: " + products[i].P_Quantity + "</h6>";
                display += "<h6 class='text-center'>" + " Type: " + products[i].P_Type + "</h6>";
                display += "<h6 class='text-center'>" + " Warehouse: " + products[i].W_Name + "</h6>";
                display += "<h6 class='text-center'>" + " Supplier: " + products[i].Supplier_Name + "</h6>";
                display += "</div>";
                display += "<div class='card-body'>";
                display += "<a href=EditProducts.aspx?ID=" + products[i].P_ID + " class='btn btn-danger mr-1'><i class='la la-plus'></i> Edit</a>";
                display += "<a href=DeleteProduct.aspx?ID=" + products[i].P_ID + " class='btn btn-primary mr-1'><i class='ft-user'></i> Remove</a>";
                display += "</div>";
                display += "</div>";
                display += "</div>";
                display += "</div>";
            }

            prodlist.InnerHtml = display;
        }
示例#21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            prodService = new ProductServiceClient();
            string display = "";


            Product[] Mproducts = prodService.GetAllProducts();
            foreach (Product prod in Mproducts)
            {
                if (prod.P_Type.Equals("Mechanical"))
                {
                    display += "<div class='col-xl-4 col-md-6 col-12'>";
                    display += "<div class='card'>";
                    display += "<div class='text-center'>";
                    display += "<div class='card-body'>";
                    display += "<img src ='http://10.254.17.96:80/script/profile_image/prod" + prod.P_Code + ".jpeg' class='rounded-circle  height-150' alt='Card image'>";
                    display += "</div>";
                    display += "<div class='card-body'>";
                    display += "<h4 class='card-title'>" + prod.P_Name + "</h4>";
                    display += "<h6 class='text-center'>" + " Code: " + prod.P_Code + "</h6>";
                    display += "<h6 class='text-center'>" + " Price: R" + prod.P_Price + "</h6>";
                    display += "<h6 class='text-center'>" + " Quantity: " + prod.P_Quantity + "</h6>";
                    display += "<h6 class='text-center'>" + " Bin Number: " + prod.bin_location + "</h6>";
                    display += "<h6 class='text-center'>" + " Supplier: " + prod.Supplier_Name + "</h6>";
                    display += "</div>";
                    display += "<div class='card-body'>";
                    display += "<a href=EditProducts.aspx?ID=" + prod.P_ID + " class='btn btn-danger mr-1'><i class='la la-plus'></i> Edit</a>";
                    display += "<a href=DeleteProduct.aspx?ID=" + prod.P_ID + " class='btn btn-primary mr-1'><i class='ft-user'></i> Remove</a>";
                    display += "</div>";
                    display += "</div>";
                    display += "</div>";
                    display += "</div>";
                }
            }

            mec.InnerHtml = display;
        }
        private void getData()
        {
            ProductServiceClient prodService;

            Product[] products;
            prodService = new ProductServiceClient();

            products = prodService.GetAllProducts();
            List <Product> data = new List <Product>();

            data = products.ToList();

            string lowstock = "The following items are low in stock;</br> ";

            foreach (var i in data)
            {
                if (i.P_Quantity < 30)
                {
                    lowstock += i.P_Name + "(" + i.P_Code + ")</br>";
                }
            }
            lowstock            += "Suggestion: Order new Stock!!!";
            suggestion.InnerHtml = lowstock;
        }
示例#23
0
 public ActionResult Index()
 {
     return(View(psc.GetAllProducts()));
 }
 public ActionResult Index()
 {
     return(View(productServiceClient.GetAllProducts()));
 }
示例#25
0
        /// <summary>
        /// Allows user to select one or more products to purchase available in stock.
        /// </summary>
        public void PurchaseProduct()
        {
            Console.WriteLine("Displaying available products:");
            ShowAllProducts();
            Console.WriteLine("Please select one of the available products by typing product number:");
            int            selectedProduct;
            List <Product> productList   = new List <Product>();
            Product        productToFind = null;
            bool           isValidId     = false;

            do
            {
                selectedProduct = Convert.ToInt32(Console.ReadLine());
                using (ProductServiceClient wcf = new ProductServiceClient())
                {
                    foreach (var item in wcf.GetAllProducts())
                    {
                        if (item.ID == selectedProduct)
                        {
                            productToFind = item;
                        }
                    }
                    if (productToFind != null)
                    {
                        Console.WriteLine($"Product number {productToFind.ID} selected.");
                        Console.WriteLine("Please select product amount:");
                        int amount = Convert.ToInt32(Console.ReadLine());
                        if (amount > productToFind.ItemsRemaining)
                        {
                            Console.WriteLine("Amount selected exeeds currently available items in stock. Please choose another amount");
                        }
                        else
                        {
                            wcf.ModifyProductStock(productToFind.ID, amount);
                            productToFind.ItemsRemaining = amount;
                            productList.Add(productToFind);
                            int choice;
                            Console.WriteLine("Do you wish to purchase another product?");
                            Console.WriteLine("1 - Yes");
                            Console.WriteLine("2 - No");
                            choice = Convert.ToInt32(Console.ReadLine());
                            if (choice == 1)
                            {
                                Console.WriteLine("Returning to item selection:");
                                ShowAllProducts();
                                Console.WriteLine("Please select one of the available products by typing product number:");
                            }
                            else if (choice == 2)
                            {
                                Console.WriteLine("Concluding shopping and generating receipt:");
                                PrintReceipt(productList);
                                isValidId = true;
                            }
                            else
                            {
                                Console.WriteLine("Wrong choice.");
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("Product you selected doesn't exist. Please choose another product");
                    }
                }
            } while (isValidId == false);
        }
示例#26
0
 public ActionResult GetAll()
 {
     Products[] listProducts = psc.GetAllProducts();
     return(PartialView(listProducts));
 }