private async Task ChangeQuantity(int equipmentId, int delta)
        {
            var equipment = _productDbContext.Equipments.FirstOrDefault(x => x.Id == equipmentId);

            if (equipment == null)
            {
                throw new Exception("Equipments not found");
            }

            var eqQuantity = _productDbContext.Inventory.FirstOrDefault(x => x.Equipment.Id == equipmentId);

            if (eqQuantity == null)
            {
                eqQuantity = new Entities.Inventory
                {
                    Equipment = new Entities.Equipment {
                        Id = equipmentId
                    },
                    Quantity = delta
                };

                _productDbContext.Inventory.Add(eqQuantity);
            }
            else
            {
                eqQuantity.Quantity += delta;
            }

            await _productDbContext.SaveChangesAsync();
        }
Example #2
0
 public Models.Inventory ParseInventory(Entities.Inventory inventory)
 {
     return(new Models.Inventory()
     {
         Quantity = inventory.Quantity,
         ProductId = (int)inventory.Productid,
         LocationId = (int)inventory.Locationid,
         Id = inventory.Id
     });
 }
Example #3
0
 public static Inventory MapInventory(Entities.Inventory i)
 {
     return(new Inventory
     {
         InventoryId = i.InventoryId,
         StoreId = i.StoreId,
         ProductId = i.ProductId,
         Amount = i.Amount
     });
 }
Example #4
0
        private void UpdateStoreCountInfo(int index)
        {
            DataGridViewRow row = dataGridView1.Rows[index];

            DrugShop.Entities.Inventory count = row.DataBoundItem as DrugShop.Entities.Inventory;

            if (count == null)
            {
                return;
            }

            if (count.State == 1)
            {
                MessageBox.Show("盘点信息已进行过库存调整,无法编辑!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            //弹出输入实际库存的对话框
            StoreCountNumberInput input = new StoreCountNumberInput();

            input.StoreNumber = count.Number;

            if (input.ShowDialog(this.ParentForm) != DialogResult.OK)
            {
                return;
            }

            //根据输入的实际值初始化相关的信息

            DrugShop.Entities.Inventory item = new Entities.Inventory();

            ColumnCollection cols = count.GetColumns();

            foreach (Property prop in cols)
            {
                if (item.ContainsProperty(prop.Name))
                {
                    item[prop.Name] = count[prop];
                }
            }

            item.RealNumber = input.Number;

            this.updateStoreCountList.Add(item);

            //重新绑定列表中的信息
            this.dmrcountBindingSource.DataSource = null;
            this.dmrcountBindingSource.DataSource = this.updateStoreCountList;
        }
        public InventoryRepositoryTests()
        {
            var contaxt     = new DataLayer.InventoryDBContext();
            var relateduser = contaxt.Users.FirstOrDefault(u => u.Username.Equals("admin"));
            var identity    = new GenericIdentity(relateduser.Username);
            var roles       = relateduser.Roles.Select(p => p.Title).ToArray();
            var principal   = new GenericPrincipal(identity, roles);

            System.Threading.Thread.CurrentPrincipal = principal;

            inve  = new InventoryRepository();
            EInve = new Entities.Inventory()
            {
                CorporationId = 1,
                Title         = "Title",
                Address       = "Address",
                Telephone     = "Telephone",
                Description   = "Description",
            };
        }
        void InternalDrugStoreInsert(IDataAccessor Accessor, params object[] parameters)
        {
            IList <Store> DrugStoreList = parameters[0] as IList <Store>;

            IDrugStoreCountService service = new DrugStoreCountService();
            DateTime currentTime           = new DateTimeService().GetCurrentTime();

            foreach (Store drugStore in DrugStoreList)
            {
                Inventory drugCount = new Entities.Inventory();

                drugCount.ChinseName = drugStore.ChinseName;
                drugCount.Code       = drugStore.Code;
                drugCount.DownLimit  = drugStore.DownLimit;
                drugCount.DrugID     = drugStore.DrugID;
                drugCount.InputCode1 = drugStore.InputCode1;
                drugCount.JobPrice   = drugStore.JobPrice;
                drugCount.Number     = drugStore.Number;
                drugCount.Provider   = drugStore.Provider;
                drugCount.RealNumber = drugStore.Number;
                drugCount.SalePrice  = drugStore.SalePrice;
                drugCount.Spec       = drugStore.Spec;
                drugCount.State      = 0;
                drugCount.TimeLimit  = drugStore.TimeLimit;
                drugCount.Type       = drugStore.Type;
                drugCount.Unit       = drugStore.Unit;
                drugCount.UpLimit    = drugStore.UpLimit;

                drugCount.EventTime = currentTime;
                drugCount.BatchID   = drugStore.BatchID;

                drugCount.ID = service.GetMaxID();

                drugCount.Insert();
            }
        }