Beispiel #1
0
        private void BRemoveBrand_Click(object sender, EventArgs e)
        {
            List <BrandRawData> removeList = new List <BrandRawData>();

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

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

            BRefreshBrandList_Click(sender, e);
        }
        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);
        }
Beispiel #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");
     }
 }