public OrderForm(CreditCardPaymentForm creditCardPaymentFormData, OrderPresentationModel orderPresentationModelData, OrderModel orderModelData, Model modelData)
 {
     InitializeComponent();
     _creditCardPaymentForm  = creditCardPaymentFormData;
     _orderPresentationModel = orderPresentationModelData;
     _orderModel             = orderModelData;
     _model = modelData;
     InitializeProductTabPageButtonsContainers();
     // Observers
     _model.OrderChanged             += UpdateCartSectionViewOnOrderChanged;
     _model.OrderCleared             += UpdateViewOnOrderCleared;
     _model.OrderAdded               += (orderItem) => _cartDataGridView.Rows.Add(null, orderItem.Name, orderItem.Type, orderItem.Price.GetCurrencyFormat(), orderItem.OrderQuantity, orderItem.GetTotalPrice().GetCurrencyFormat());
     _model.OrderRemoved             += (orderItemIndex, removedProduct) => _cartDataGridView.Rows.RemoveAt(orderItemIndex);
     _model.OrderItemQuantityChanged += (orderItemIndex, orderItemTotalPrice) => _cartDataGridView.Rows[orderItemIndex].Cells[CART_PRODUCT_TOTAL_PRICE_COLUMN_INDEX].Value = orderItemTotalPrice;
     _model.OrderItemQuantityIsExceededStorageQuantity += UpdateViewOnOrderItemQuantityIsExceededStorageQuantity;
     _orderPresentationModel.AddButtonEnabledChanged   += () => _addButton.Enabled = _orderPresentationModel.AddButton.Enabled;
     _orderPresentationModel.OrderFormProductStorageQuantityTextChanged += () => _productStorageQuantity.Text = _orderPresentationModel.ProductStorageQuantity.Text;
     // UI
     _cartDataGridView.CellPainting     += (sender, eventArguments) => DataGridViewHelper.InitializeButtonImageOfButtonColumn(eventArguments, CART_DELETE_BUTTON_COLUMN_INDEX, Resources.img_trash_bin);
     _cartDataGridView.CellContentClick += ClickCartDataGridViewCellContent;
     _cartDataGridView.CellValueChanged += ChangeCartDataGridViewCellValue;
     _leftArrowButton.Click             += (sender, events) => GoToPreviousProductPage();
     _rightArrowButton.Click            += (sender, events) => GoToNextProductPage();
     _addButton.Click   += (sender, eventArguments) => _orderPresentationModel.AddCurrentSelectedProductToOrderIfProductIsNotInOrder();
     _orderButton.Click += ClickOrderButton;
     _productTabControl.SelectedIndexChanged += (sender, events) => SelectProductTabPage(_productTabControl.SelectedIndex);
     InitializeProductTabPages();
     // Initial UI States
     SelectProductTabPage(AppDefinition.MOTHER_BOARD_INDEX);
     UpdateCartSectionViewOnOrderChanged();
     RefreshControls();
 }
 public MainForm(CreditCardPaymentForm creditCardPaymentFormData, OrderPresentationModel orderPresentationModelData, ProductsManagementTabPagePresentationModel productsManagementTabPagePresentationModelData, ProductTypesManagementTabPagePresentationModel productTypesManagementTabPagePresentationModelData, Model modelData)
 {
     InitializeComponent();
     _creditCardPaymentForm  = creditCardPaymentFormData;
     _orderPresentationModel = orderPresentationModelData;
     _productsManagementTabPagePresentationModel     = productsManagementTabPagePresentationModelData;
     _productTypesManagementTabPagePresentationModel = productTypesManagementTabPagePresentationModelData;
     _model = modelData;
     _orderSystemButton.Click         += ClickOrderSystemButton;
     _inventorySystemButton.Click     += ClickInventorySystemButton;
     _productManageSystemButton.Click += ClickProductManageSystemButton;
     _exitButton.Click += ClickExitButton;
 }
 public MainForm(CreditCardPaymentForm creditCardPaymentFormData, InventoryPresentationModel inventoryPresentationModelData, MainPresentationModel mainPresentationModelData, OrderPresentationModel orderPresentationModelData, OrderModel orderModelData, Model modelData)
 {
     InitializeComponent();
     _creditCardPaymentForm      = creditCardPaymentFormData;
     _inventoryPresentationModel = inventoryPresentationModelData;
     _mainPresentationModel      = mainPresentationModelData;
     _orderPresentationModel     = orderPresentationModelData;
     _orderModel = orderModelData;
     _model      = modelData;
     _orderSystemButton.Click     += ClickOrderSystemButton;
     _inventorySystemButton.Click += ClickInventorySystemButton;
     _exitButton.Click            += ClickExitButton;
     RefreshControls();
 }
예제 #4
0
 public OrderForm(CreditCardPaymentForm creditCardPaymentFormData, OrderPresentationModel orderPresentationModelData, Model modelData)
 {
     InitializeComponent();
     _creditCardPaymentForm  = creditCardPaymentFormData;
     _orderPresentationModel = orderPresentationModelData;
     _model         = modelData;
     this.Disposed += RemoveEvents;
     // Observers
     _model.OrderChanged             += UpdateCartSectionViewOnOrderChanged;
     _model.OrderCleared             += ClearCartDataGridViewOnOrderCleared;
     _model.OrderAdded               += AddOrderItemToCartDataGridView;
     _model.OrderRemoved             += RemoveOrderItemAtFromCartDataGridView;
     _model.OrderItemQuantityChanged += UpdateOrderItemTotalPriceAtInCartDataGridView;
     _model.OrderItemQuantityIsExceededStorageQuantity += ShowMessageBoxAndSetOrderItemQuantityToStorageQuantityOnOrderItemQuantityIsExceededStorageQuantity;
     _model.ProductInfoChanged += UpdateViewOnProductInfoChanged;
     _model.ProductAdded       += UpdateViewOnProductAdded;
     _model.ProductTypeAdded   += UpdateViewOnProductTypeAdded;
     _orderPresentationModel.AddButtonEnabledChanged        += UpdateAddButtonView;
     _orderPresentationModel.CurrentProductInfoChanged      += UpdateProductInfoView;
     _orderPresentationModel.CurrentProductPageIndexChanged += UpdatePageLabelAndLeftRightArrowButtonsView;
     // UI
     _cartDataGridView.CellPainting     += (sender, eventArguments) => DataGridViewHelper.InitializeButtonImageOfButtonColumn(eventArguments, CART_DELETE_BUTTON_COLUMN_INDEX, Resources.img_trash_bin);
     _cartDataGridView.CellContentClick += ClickCartDataGridViewCellContent;
     _cartDataGridView.CellValueChanged += ChangeCartDataGridViewCellValue;
     _leftArrowButton.Click             += (sender, eventArguments) => GoToPreviousProductPage();
     _rightArrowButton.Click            += (sender, eventArguments) => GoToNextProductPage();
     _addButton.Click   += (sender, eventArguments) => _orderPresentationModel.AddCurrentSelectedProductToOrderIfProductIsNotInOrder();
     _orderButton.Click += ClickOrderButton;
     _productTabControl.SelectedIndexChanged += HandleSelectedIndexChanged;
     // Initial UI States
     InitializeProductTabPageButtonsContainers();
     InitializeTabPages();
     InitializeProductTabPages();
     SelectProductTabPage(FIRST_PRODUCT_TAB_PAGE_INDEX);
     InitializeCartDataGridView();
     UpdateCartSectionViewOnOrderChanged();
 }