示例#1
0
        private void AddToCart_Click(object sender, EventArgs e)
        {
            if (Products.SelectedItem == null)
            {
                return;
            }

            String       selected     = Products.SelectedItem.ToString();
            StoreProduct storeProduct = new StoreProduct();

            storeProduct.RefactorString(selected);

            int         ActualAmount = storeProduct.amount;
            ProductInfo temp         = new ProductInfo(ActualAmount);

            temp.ShowDialog();
            if (amount != 0)
            {
                DataTable firstTime = queries.isItFirstTime(controller.normalUser.Data.ID);
                if (firstTime.Rows.Count <= 0)
                {
                    cartObject = new CartItem(storeProduct.storeProductID, storeProduct.product.Name, storeProduct.price, storeProduct.amount, true);
                }
                else
                {
                    cartObject = new CartItem(storeProduct.storeProductID, storeProduct.product.Name, storeProduct.price, storeProduct.amount, false);
                }
                cartController.addCartItem(cartObject);
            }
            else
            {
                MessageBox.Show("failed to add items to the cart");
            }
        }
示例#2
0
        private void BShowProductStat_Click(object sender, EventArgs e)
        {
            if (ProductList.SelectedItem == null)
            {
                MessageBox.Show("Please select product");
                return;
            }
            String       product      = ProductList.SelectedItem.ToString();
            StoreProduct storeProduct = new StoreProduct();

            storeProduct.RefactorString(product);

            Statistics stat = controllerStoreProduct.GetProductStat(storeProduct.storeProductID);

            this.TProductView.Text = stat.CntView.ToString();
            this.TProductSold.Text = stat.CntSold.ToString();
        }
示例#3
0
        private void BDeleteStoreProduct_Click(object sender, EventArgs e)
        {
            if (ProductList.SelectedItem == null)
            {
                MessageBox.Show("Please select product");
                return;
            }
            String       product      = ProductList.SelectedItem.ToString();
            StoreProduct storeProduct = new StoreProduct();

            storeProduct.RefactorString(product);

            StoreCommandInvoker invoker = new StoreCommandInvoker();

            IStoreCommand command     = new DeleteCommand();
            CommandData   commandData = new CommandData();

            commandData.UserIDCollab   = controllerSO.storeOwner.Data.ID;
            commandData.UsernameCollab = controllerSO.storeOwner.Data.userName;
            commandData.CmdType        = "Delete";
            commandData.ProductID      = storeProduct.storeProductID;
            commandData.ProductName    = storeProduct.product.Name;
            commandData.PAmount        = storeProduct.amount;
            commandData.Price          = storeProduct.price;
            commandData.StoreID        = storeProduct.storeID;

            bool DONE = invoker.DoCommand(command, commandData, this.collMode, storeProduct);

            //bool DONE = controllerStoreProduct.RemoveStoreProduct(controllerStore.GetStoreID(), storeProduct.storeProductID);
            if (DONE)
            {
                MessageBox.Show("Product Deleted");
            }
            else
            {
                MessageBox.Show("Product Deleted failed");
            }

            BShowStoreProduct_Click(sender, e);
        }