Exemple #1
0
        //handle cell click event
        private void ChangeQuantity(object sender, DataGridViewCellEventArgs e)
        {
            const int QUANTITY_INDEX    = 4;
            const int TOTAL_PRICE_INDEX = 5;

            if (e.ColumnIndex == QUANTITY_INDEX)
            {
                int newQuantity = int.Parse(this._orderList.Rows[e.RowIndex].Cells[QUANTITY_INDEX].Value.ToString());
                int result      = _itemOrder.UpdateQuantity(e.RowIndex, newQuantity);
                if (newQuantity != result)
                {
                    const string STOCK_STATUS     = "庫存狀態";
                    const string STOCK_NOT_ENOUGH = "庫存不足";
                    MessageBox.Show(STOCK_NOT_ENOUGH, STOCK_STATUS);
                }
                this._orderList.Rows[e.RowIndex].Cells[QUANTITY_INDEX].Value    = result.ToString();
                this._orderList.Rows[e.RowIndex].Cells[TOTAL_PRICE_INDEX].Value = _itemOrder.GetItemTotalPrice(e.RowIndex).ToString(Constants.NUMBER_BREAK_KEY_WORD);
                this._totalPrice.Text = TOTAL_PRICE_STRING + _itemOrder.GetTotalPrice().ToString(Constants.NUMBER_BREAK_KEY_WORD) + MONEY_UNIT;
            }
        }