public CollabHistory(String StoreID) { InitializeComponent(); this.StoreID = StoreID; this.controller = new StoreCommandController(); this.invoker = new StoreCommandInvoker(); }
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); }
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); }