Exemplo n.º 1
0
        private static void CreateInventory(IncomingFormEntity form, Database db, DbTransaction trans)
        {
            var goodsSerial = GoodsSerialRepository.Get(form.SerialId, db, trans);
            var barcodes    = GoodsSerialRepository.GetBarcodes(form.SerialId, db, trans);
            var product     = ProductRepository.Get(goodsSerial.ProductId);

            var inventory = new GoodsInventoryEntity
            {
                SerialId      = goodsSerial.Id,
                BatchNo       = goodsSerial.BatchNo,
                ProductId     = goodsSerial.ProductId,
                StoreroomId   = form.StoreroomId,
                ExpiredDate   = goodsSerial.ExpiredDate.Value,
                HospitalId    = goodsSerial.HospitalId,
                VendorId      = goodsSerial.VendorId,
                OriginalCount = form.IncomingCount,
                SplitCount    = 0,
                UsableCount   = form.IncomingCount, //goodsSerial.NeedSplit ? 0 : form.IncomingCount,
                GrantedCount  = 0,
                CreatedId     = form.ConfirmedId,
                CreatedTime   = form.ConfirmedTime
            };

            inventory.ApplyCount = inventory.UsableCount * product.MiniPackageCount;
            GoodsInventoryRepository.Create(inventory, db, trans);

            AllocateBarcodes(barcodes, inventory, product, db, trans);
        }
Exemplo n.º 2
0
        public static string PartPass(ReceiveFormEntity form, IList <string> barcodes, string userId)
        {
            var serialId    = form.SerialId;
            var passedCount = SumPassed(form.Id);

            if (form.ReceivedCount == passedCount)
            {
                return(serialId);
            }

            if (form.ReceivedCount == passedCount + barcodes.Count)
            {
                Pass(form);
                return(serialId);
            }

            var goodsSerial = GoodsSerialRepository.Get(form.SerialId);

            var db = DatabaseFactory.CreateDatabase();

            using (var conn = db.CreateConnection())
            {
                conn.Open();
                using (var trans = conn.BeginTransaction())
                {
                    try
                    {
                        var formItem = new ReceiveFormItemEntity
                        {
                            Id            = Guid.NewGuid().ToString(),
                            ReceiveId     = form.Id,
                            ReceivedCount = barcodes.Count,
                            ConfirmedId   = userId,
                            ConfirmedTime = DateTime.Now
                        };

                        formItem.SerialId = CreateGoodsSerial(goodsSerial, formItem, barcodes, db, trans);
                        CreateItem(formItem, db, trans);

                        //TODO: need to add inspection form
                        CreateIncomingForm(form, formItem, db, trans);

                        trans.Commit();
                        serialId = formItem.SerialId;
                    }
                    catch
                    {
                        trans.Rollback();
                        throw;
                    }
                }
            }
            return(serialId);
        }
Exemplo n.º 3
0
        public static string PartPass(ReceiveFormEntity form, IList <string> barcodes, string userId, Database db, DbTransaction trans)
        {
            var serialId    = form.SerialId;
            var passedCount = SumPassed(form.Id);

            if (form.ReceivedCount == passedCount)
            {
                return(serialId);
            }

            if (form.ReceivedCount == passedCount + barcodes.Count)
            {
                Pass(form);
                return(serialId);
            }

            var goodsSerial = GoodsSerialRepository.Get(form.SerialId);

            var formItem = new ReceiveFormItemEntity
            {
                Id            = Guid.NewGuid().ToString(),
                ReceiveId     = form.Id,
                ReceivedCount = barcodes.Count,
                ConfirmedId   = userId,
                ConfirmedTime = DateTime.Now
            };

            formItem.SerialId = CreateGoodsSerial(goodsSerial, formItem, barcodes, db, trans);
            CreateItem(formItem, db, trans);

            //TODO: need to add inspection form
            CreateIncomingForm(form, formItem, db, trans);

            serialId = formItem.SerialId;
            return(serialId);
        }