예제 #1
0
        private void RegisterCommand()
        {
            this.StorageQueryCmd = new RelayCommand(() =>
            {
                this._StorageCol.Clear();
                var data = CaculateLibrary.StorageModule.GetStorageByCondition(ConfigManager.StorageFileName, this.Area.Trim(), this.Code.Trim(), this.UserName.Trim(), this.AccountName.Trim(), this.FreeSpace);
                if (data == null)
                {
                    return;
                }
                foreach (var item in data)
                {
                    this._StorageCol.Add(new StorageModel(item));
                }
            });

            this.GoodsQueryCmd = new RelayCommand(() =>
            {
                this._GoodsCol.Clear();
                var data = GoodsModule.GetGoodsByCondition(ConfigManager.GoodsFileName, ConfigManager.StorageFileName, this.GoodsCode, this.GoodsLeftDay, this.GoodsStorage, this.GoodsStorage == Guid.Empty?this.GoodsArea:string.Empty);
                if (data == null)
                {
                    return;
                }
                foreach (var item in data)
                {
                    this._GoodsCol.Add(new GoodsModel(item));
                }
            });

            this.DelStorageCmd = new RelayCommand(() =>
            {
                if (this.StorageView.CurrentItem == null)
                {
                    return;
                }
                StorageModel model = this.StorageView.CurrentItem as StorageModel;
                StorageModule.DelStorage(ConfigManager.StorageFileName, ConfigManager.GoodsFileName, model.ID.ToString());
                this._StorageCol.Remove(model);
                var target = this._GoodsCol.Where(m => m.StorageId == model.ID).ToArray();
                foreach (var item in target)
                {
                    this._GoodsCol.Remove(item);
                }
            });

            this.DelGoodsCmd = new RelayCommand(() =>
            {
                if (this.GoodsView.CurrentItem == null)
                {
                    return;
                }
                GoodsModel model = this.GoodsView.CurrentItem as GoodsModel;
                GoodsModule.DelGoods(ConfigManager.GoodsFileName, model.ID.ToString());
                this._GoodsCol.Remove(model);
            });
        }
예제 #2
0
 void IEditableObject.EndEdit()
 {
     if (this.ID == Guid.Empty)
     {
         this.ID         = Guid.NewGuid();
         this.CreateDate = DateTime.Now;
         var target = new GoodsModule.Goods(this.ID, this.Code, this.Quantity, this.LeftDay, this.StorageId, this.Name, this.Desc, this.Price, this.CreateDate);
         GoodsModule.AddGoods(new GoodsModule.Goods[] { target }, ConfigManager.GoodsFileName);
     }
 }
예제 #3
0
 public GoodsModel(GoodsModule.Goods goods)
 {
     this.ID = goods.ID;
     this.Code = goods.Code;
     this.Name = goods.Name;
     this.Quantity = goods.Quantity;
     this.LeftDay = goods.LeftDay;
     this.StorageId = goods.StorageId;
     this.Desc = goods.Desc;
     this.Price = goods.Price;
     this.CreateDate = goods.CreateDate;
 }
예제 #4
0
        public void LoadGoodsData()
        {
            var data = GoodsModule.GetGoods(ConfigManager.GoodsFileName);

            if (data == null)
            {
                return;
            }
            foreach (var item in data)
            {
                this._GoodsCol.Add(new GoodsModel(item));
            }
        }