private void Recalculate() { // Recalculate the price. // Uses the building decorator to decorate the building with all of the selected options. // This allows us to get the final price. In time these options could decorate with extra rooms/facilities and these // would be exposed through the IOrder interface. List <BuildingDecorator> decoratedBuildingList = new List <BuildingDecorator>(); if (_ds.Tables["orderbuildingOptions"].Rows.Count > 0) { int i = 0; foreach (DataRow dr in _ds.Tables["orderbuildingOptions"].Rows) { BuildingDecorator decoratedBuilding = null; if (i == 0) { decoratedBuilding = new BuildingOptionDecorator(_frame, _ds.Tables["orderbuildingOptions"].Rows[i]["buildingoption"].ToString()); } else { decoratedBuilding = new BuildingOptionDecorator(decoratedBuildingList[i - 1], _ds.Tables["orderbuildingOptions"].Rows[i]["buildingoption"].ToString()); } decoratedBuildingList.Add(decoratedBuilding); i++; } _framePrice = _frame.Price; _totalPrice = decoratedBuildingList[decoratedBuildingList.Count - 1].Price; _optionsPrice = _totalPrice - _framePrice; _vat = _totalPrice * Properties.Settings.Default.vatrate; } else { // No options selected so price, area and VAT all based on the frame price only _framePrice = _frame.Price; _totalPrice = _frame.Price; _optionsPrice = 0; _vat = _totalPrice * Properties.Settings.Default.vatrate; } _requiresRecalculation = false; }
private void Recalculate() { //_building = BuildingFactory.Instance.GetBuildingType(_buildingType); List <BuildingDecorator> decoratedBuildingList = new List <BuildingDecorator>(); if (_buildingOptions.Count > 0) { for (int i = 0; i < _buildingOptions.Count; i++) { BuildingDecorator decoratedBuilding = null; if (i == 0) { decoratedBuilding = new BuildingOptionDecorator(_frame, _buildingOptions[i]); } else { decoratedBuilding = new BuildingOptionDecorator(decoratedBuildingList[i - 1], _buildingOptions[i]); } decoratedBuildingList.Add(decoratedBuilding); } _framePrice = _frame.Price; _totalPrice = decoratedBuildingList[decoratedBuildingList.Count - 1].Price; _vat = _totalPrice * Properties.Settings.Default.vatrate; } else { // No options selected so price, area and VAT all based on teh frame price only _framePrice = _frame.Price; _totalPrice = _frame.Price; _vat = _totalPrice * Properties.Settings.Default.vatrate; } _requiresRecalculation = false; }