// 更改單一商品總價錢 private void UpdateSubtotal(object sender, DataGridViewCellEventArgs e) { var senderGrid = (DataGridView)sender; if (senderGrid.Columns[e.ColumnIndex].Name == NUMBER_COLUMN) // 增減數量 { if (_shopListPresentationModel.OutOfStock(e.RowIndex, int.Parse(senderGrid.Rows[e.RowIndex].Cells[NUMBER_COLUMN_INDEX].Value.ToString()))) // 如果庫存不足 { NotifyOutOfStockAndChangeToMaximumStock(e); } _orderDataGridView.Rows[e.RowIndex].Cells[SUBTOTAL_COLUMN_INDEX].Value = _shopListPresentationModel.GetSubtotal(int.Parse(_orderDataGridView.CurrentCell.Value.ToString()), e.RowIndex).ToString(FORMAT); _totalPriceLabel.Text = this.GetTotalPrice().ToString(FORMAT); } }
public void GetSubtotalTest() { _ShopListPresentationModel.GetCurrentProduce("1", 0, "主機板"); _ShopListPresentationModel.AddItemToCart(); Assert.AreEqual(_ShopListPresentationModel.GetSubtotal(1, 0), 6990); }