Exemplo n.º 1
0
 public ActionResult Create(StocktakingModel model)
 {
     model.CreatedBy     = _context.CurrentAccount.AccountId;
     model.CreatedByName = _context.CurrentAccount.NickName;
     _stocktakingFacade.Create(model);
     return(Json(new { success = true }));
 }
Exemplo n.º 2
0
        public void Correct(StocktakingModel model)
        {
            var entity = model.MapTo <Stocktaking>();

            entity.Status          = StocktakingStatus.WaitAuditing;
            entity.StocktakingType = StocktakingType.StocktakingCorect;
            entity.Items           = JsonConvert.DeserializeObject <List <StocktakingItem> >(model.ItemsJson);
            entity.Code            = _billService.GenerateNewCode(BillIdentity.StoreStocktaking);
            _db.Insert(entity);
            _db.SaveChange();
        }
Exemplo n.º 3
0
        public void Create(StocktakingModel model)
        {
            var entity = model.MapTo <Stocktaking>();

            entity.Status          = StocktakingStatus.Audited;
            entity.StocktakingType = StocktakingType.Stocktaking;
            entity.Items           = JsonConvert.DeserializeObject <List <StocktakingItem> >(model.ItemsJson);
            if (entity.Items.Sum(n => n.CountQuantity) == 0)
            {
                throw new Exception("盘点数不能都为0");
            }
            entity.Code = _billService.GenerateNewCode(BillIdentity.StoreStocktaking);
            _db.Insert(entity);
            _db.SaveChange();
        }
Exemplo n.º 4
0
        public void Edit(StocktakingModel model)
        {
            var entity = _db.Table.Find <Stocktaking>(model.Id);

            // entity = model.MapTo<Stocktaking>(entity);
            // entity.Status = StocktakingStatus.Audited;
            // entity.StocktakingType = StocktakingType.StocktakingCorect;
            entity.Items = JsonConvert.DeserializeObject <List <StocktakingItem> >(model.ItemsJson);
            if (entity.Items.Count > 0)
            {
                _db.Delete <StocktakingItem>(n => n.StocktakingId == entity.Id);
                // _db.Delete(entity.Items.ToArray());
                _db.Insert(entity.Items.ToArray());
            }
            // _db.Update(entity);
            _db.SaveChange();
        }