/// <summary>
        /// 객체를 생성할 때 생성자에서 호출됩니다.
        /// </summary>
        /// <param name="product"></param>
        protected virtual void Initialize(IProductWrapper product = null)
        {
            if (product == null) //새로운 데이터를 추가할 경우
            {
                Stock = new Inventory();
                Quantity = 1;
            }
            else                //기존의 데이터를 수정할 경우
            {
                Stock = product.Product.Clone() as Inventory;

                var inventory = product as InventoryWrapper;
                Item = inventory.Item;
                Specification = inventory.Specification;
                Warehouse = inventory.Warehouse;
            }
        }
        /// <summary>
        /// 수정 또는 새로 추가할 데이터를 데이터베이스와 ViewModel의 Items 속성에 각각 추가 및 적용한다.
        /// </summary>
        /// <returns></returns>
        public StockWrapper Update()
        {
            //추가 및 적용의 최소 조건들
            if (Item == null)
                throw new Exception("리스트박스에서 품목을 선택하세요.");
            if (Specification == null)
                throw new Exception("리스트박스에서 규격을 선택하세요.");

            InventoryWrapperDirector iwd = InventoryWrapperDirector.GetInstance();
            InventoryWrapper invenw = iwd.SearchAsSpecificationKey(Specification.ID);
            StockWrapper stockw = null;

            if (invenw != null)
            {
                //재고의 개수를 수정
                invenw.Quantity = InventoryQuantity;
            }
            else
            {
                //새로운 재고를 등록
                Inventory inven = new Inventory();
                inven.ItemID = this.Item.ID;
                inven.SpecificationID = this.Specification.ID;
                inven.Quantity = this.InventoryQuantity;
                inven.WarehouseID = this.Warehouse != null ? this.Warehouse.ID : null;
                invenw = new InventoryWrapper(inven);
                CollectionViewModelObserverSubject.GetInstance().NotifyNewItemAdded(invenw); //순서의 주의
                iwd.Add(invenw); //순서의 주의
            }

            if (_target != null) //InOutStock 데이터의 수정 코드
            {
                _target.Product = InOutStock;
                stockw = _target;
            }
            else //새로운 InOutStock 데이터의 추가 코드
            {
                InOutStock.InventoryID = invenw.ID;
                stockw = new StockWrapper(InOutStock);
                _viewModel.Add(stockw);
            }
            stockw.Product.Save<InOutStock>();
            return stockw;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// for 기존 기록 수정
 /// </summary>
 /// <param name="stockItem"></param>
 public InventoryHelper(Inventory stockItem)
 {
     _stockItem = stockItem;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// for 새로운 기록 추가
 /// </summary>
 public InventoryHelper()
 {
     _stockItem = new Inventory();
 }