public void OutOfStockTest()
 {
     _ShopListPresentationModel.GetCurrentProduce("1", 0, "主機板");
     _ShopListPresentationModel.AddItemToCart();
     Assert.IsFalse(_ShopListPresentationModel.OutOfStock(0, 5));
     Assert.IsTrue(_ShopListPresentationModel.OutOfStock(0, 6));
 }
Ejemplo n.º 2
0
        // 更改單一商品總價錢
        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);
            }
        }