Exemplo n.º 1
0
        private void RemoveCheckedProduct_Click(object sender, EventArgs e)
        {
            List <ProductRawData> removeList = new List <ProductRawData>();

            for (int i = 0; i < ProductsList.Items.Count; i++)
            {
                if (ProductsList.GetItemChecked(i))
                {
                    ProductRawData tempData = new ProductRawData();
                    tempData.RefactorString(ProductsList.Items[i].ToString());
                    removeList.Add(tempData);
                }
            }

            for (int i = 0; i < removeList.Count; i++)
            {
                bool DONE = controller.RemoveProduct(removeList[i].ID);
                if (DONE)
                {
                    MessageBox.Show(removeList[i].ToString() + " Removed");
                }
                else
                {
                    MessageBox.Show(removeList[i].ToString() + " Remove Failed");
                }
            }

            RefreshProductsList_Click(sender, e);
        }
Exemplo n.º 2
0
        private void BAddStoreProduct_Click(object sender, EventArgs e)
        {
            if (SystemProductsList.SelectedItem == null || SystemBrandsList.SelectedItem == null)
            {
                MessageBox.Show("Please select brand and product");
                return;
            }

            String product = SystemProductsList.SelectedItem.ToString();
            String Brand   = SystemBrandsList.SelectedItem.ToString();

            ProductRawData productRawData = new ProductRawData();

            productRawData.RefactorString(product);

            BrandRawData brandRawData = new BrandRawData();

            brandRawData.RefactorString(Brand);

            InputData inputData = new InputData("price", "amount", "Submit Product");

            inputData.ShowDialog();

            StoreProduct        storeProduct = new StoreProduct("0", controllerStore.GetStoreID(), productRawData, brandRawData, price, amount);
            StoreCommandInvoker invoker      = new StoreCommandInvoker();

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

            commandData.UserIDCollab   = controllerSO.storeOwner.Data.ID;
            commandData.UsernameCollab = controllerSO.storeOwner.Data.userName;
            commandData.CmdType        = "Add";
            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);

            //controllerStoreProduct.AddStoreProduct(controllerStore.GetStoreID(), storeProduct);
            if (DONE)
            {
                MessageBox.Show("Product Added");
            }
            else
            {
                MessageBox.Show("Product Add failed");
            }

            BShowStoreProduct_Click(sender, e);
        }
Exemplo n.º 3
0
 public void RefactorString(String str)
 {
     try
     {
         String[] tempData = str.Split(new String[] { " -> " }, StringSplitOptions.RemoveEmptyEntries);
         String[] re       = tempData[0].Split(' ');
         this.storeProductID = re[3];
         this.storeID        = re[6];
         MessageBox.Show(re[9] + "11" + re[12]);
         this.price  = Convert.ToDouble((String)re[9]);
         this.amount = Convert.ToInt32((String)re[12]);
         product.RefactorString(tempData[1]);
         brand.RefactorString(tempData[2]);
     }
     catch
     {
         MessageBox.Show("String: " + str + " is not in the right format");
     }
 }