Esempio n. 1
0
        public static OpResult ReSave(StockTaking obj)
        {
            var op    = new OpResult();
            var stock = CurrentRepository.FindById(obj.Id);

            stock.ActualNumber = Math.Round(obj.ActualNumber.GetValueOrDefault(), 3);
            stock.CreateUID    = Sys.CurrentUser.UID;
            var CheckUID = HttpContext.Current.Request["CheckUID"];
            var log      = new StockTakingLog()
            {
                Barcode    = stock.Barcode,
                CheckBatch = stock.CheckBatch,
                CheckUID   = CheckUID,
                CreateUID  = stock.CreateUID,
                CreateDT   = DateTime.Now,
                Number     = stock.ActualNumber.GetValueOrDefault(),
                State      = 1,
                ActualDate = HttpContext.Current.Request["ActualDate"].ToType <DateTime>(),
                CompanyId  = CommonService.CompanyId,
                Source     = 1
            };

            op = BaseService <StockTakingLog> .Add(log);

            return(op);
        }
Esempio n. 2
0
        public static void ReSaveStock(string storeId, string checkBatch, string checkUID, string barcode, decimal?number, short sure)
        {
            if (string.IsNullOrWhiteSpace(storeId))
            {
                throw new MessageException("门店号为空!");
            }
            if (string.IsNullOrWhiteSpace(checkBatch))
            {
                throw new MessageException("盘点批次为空!");
            }
            if (string.IsNullOrWhiteSpace(checkUID))
            {
                throw new MessageException("盘点员为空!");
            }
            if (string.IsNullOrWhiteSpace(barcode))
            {
                throw new MessageException("条码为空!");
            }
            if (!number.HasValue)
            {
                throw new MessageException("实盘数量为空!");
            }

            var query = from a in BaseService <StockTaking> .CurrentRepository.QueryEntity
                        join b in BaseService <TreasuryLocks> .CurrentRepository.QueryEntity on new { a.CheckBatch, a.CompanyId } equals new { b.CheckBatch, b.CompanyId }
            where a.CompanyId == Sys.SysCommonRules.CompanyId && b.LockStoreID == storeId && a.CheckBatch == checkBatch && a.Barcode == barcode
            select new
            {
                a,
                a.Barcode,
                a.ActualNumber,
                a.CheckBatch,
                b.State,
                a.CompanyId,
                SysPrice = ProductService.CurrentRepository.QueryEntity.Where(o => o.CompanyId == a.CompanyId &&
                                                                              (o.Barcode == a.Barcode || ("," + o.Barcodes + ",").Contains("," + a.Barcode + ","))).Select(o => o.SysPrice).FirstOrDefault()
            };
            var stock = query.FirstOrDefault();

            if (stock == null)
            {
                throw new MessageException("批次或条码不存在!");
            }
            if (stock.State == 1)
            {
                throw new MessageException("该批次已通过审核,不能再盘点!");
            }

            var user = UserInfoService.Find(o => o.CompanyId == Sys.SysCommonRules.CompanyId && o.UserCode == checkUID);

            if (user == null)
            {
                throw new MessageException("用户编码不存在!");
            }
            stock.a.Sure = (short)(sure == 0?0:1);
            //var st= BaseService<StockTaking>.Find(o => o.CompanyId == stock.CompanyId && o.CheckBatch == stock.CheckBatch && o.Barcode == stock.Barcode);
            var log = new StockTakingLog()
            {
                Barcode    = stock.Barcode,
                CheckBatch = stock.CheckBatch,
                CheckUID   = user.UID,
                CreateUID  = user.UID,
                CreateDT   = DateTime.Now,
                ActualDate = DateTime.Now,
                SysPrice   = stock.SysPrice,
                Number     = number.GetValueOrDefault(),
                State      = 1,
                Source     = 2,
                CompanyId  = Sys.SysCommonRules.CompanyId
            };

            BaseService <StockTakingLog> .Add(log);
        }