public static void Confirm(string id, string userId, string hospitalId) { if (string.IsNullOrEmpty(id)) { throw new Exception("The id of movein form is empty."); } var movein = Get(id); if (movein == null) { throw new Exception(string.Format("The id({0}) does not exist.", id)); } var moveout = MoveoutFormRepository.Get(movein.MoveoutId); if (movein == null) { throw new Exception(string.Format("The id({0}) of moveout form does not exist.", id)); } var db = DatabaseFactory.CreateDatabase(); using (var conn = db.CreateConnection()) { conn.Open(); using (var trans = conn.BeginTransaction()) { try { Confirm(id, userId, db, trans); GoodsStateRepository.ChangeState(id, FormType.MoveIn, userId, db, trans); GoodsRepsitory.MoveStoreroom(moveout.NewStoreroomId, movein.Id, hospitalId, userId, db, trans); trans.Commit(); } catch { trans.Rollback(); throw; } } } }
private static void AllocateBarcodes(IList <GoodsSerialBarcodeEntity> barcodes, GoodsInventoryEntity inventory, ProductEntity product, Database db, DbTransaction trans) { foreach (var item in barcodes) { var goods = new GoodsEntity(); goods.Name = product.Name; goods.Barcode = item.Barcode; goods.SerialId = item.SerialId; goods.HospitalId = inventory.HospitalId; goods.VendorId = inventory.VendorId; goods.ProductId = inventory.ProductId; goods.BatchNo = inventory.BatchNo; goods.ExpiredDate = inventory.ExpiredDate; goods.StoreroomId = inventory.StoreroomId; goods.PackageCapacity = product.MiniPackageSpec; goods.PackageCount = product.MiniPackageCount; goods.MeasuringUnit = product.PackageUnit; goods.Status = GoodsStatus.Usable; goods.CreatedId = inventory.CreatedId; goods.CreatedTime = inventory.CreatedTime; GoodsRepsitory.Create(goods, db, trans); } }
private IList <string> GetBarcodesFromRuntime(string id, string productId) { return(GoodsRepsitory.FindRuntimes(id, productId).Select(item => item.Barcode).OrderBy(item => item).ToList()); }