// observer pattern // update status by observer public void ReceiveAndNotify(object obj) { StockBLL sbp = obj as StockBLL; if (sbp != null) { disableOrderStatus(sbp.StockID); } }
// invoke event private void fireObserverEvent(int stockID) { StockBLL stockBll = new StockBLL(stockID); InventoryForm invform = new InventoryForm(); OrderBLL orderBLL = new OrderBLL(); stockBll.AddObserver(new NotifyEventDelegate(invform.ReceiveAndNotify)); stockBll.AddObserver(new NotifyEventDelegate(orderBLL.ReceiveAndNotify)); stockBll.Update(); }