Ejemplo n.º 1
0
        public static void CreateInventoryLedger(S_FileInfo file, InventoryType type, int totalAmount, int inventoryAmount,
                                                 string relateDetailInfoID, string targetUserID = "", string targetUserName = "", string detail = "")
        {
            DocConstEntities entities = FormulaHelper.GetEntities <DocConstEntities>();
            var currentUser           = FormulaHelper.GetUserInfo();
            var InventoryLedger       = new S_A_InventoryLedger
            {
                CarItemName        = "",
                CreateDate         = System.DateTime.Now,
                CreateUserID       = currentUser.UserID,
                CreateUserName     = currentUser.UserName,
                SpaceID            = file.Space.ID,
                Type               = type.ToString(),
                Detail             = detail,
                CreateDept         = currentUser.UserDeptNames,
                InventoryAmount    = inventoryAmount,
                TotalAmount        = totalAmount,
                RelateID           = file.ID,
                RelateName         = file.Name,
                RelateType         = ListConfigType.File.ToString(),
                RelateDetailInfoID = relateDetailInfoID,
                TargetUserID       = targetUserID,
                TargetUserName     = targetUserName
            };

            var qNum = int.Parse(string.IsNullOrEmpty(file.DataEntity.GetValue("Quantity")) ? "0" : file.DataEntity.GetValue("Quantity")) + totalAmount;

            file.DataEntity.SetValue("Quantity", qNum);
            var sNum = int.Parse(string.IsNullOrEmpty(file.DataEntity.GetValue("StorageNum")) ? "0" : file.DataEntity.GetValue("StorageNum")) + inventoryAmount;

            file.DataEntity.SetValue("StorageNum", sNum);
            if (qNum < 0 || sNum < 0)
            {
                throw new Formula.Exceptions.BusinessException("遗失份数大于库存,请重新填写");
            }

            file.Save(false);
            entities.Set <S_A_InventoryLedger>().Add(InventoryLedger);
            entities.SaveChanges();
        }
Ejemplo n.º 2
0
        public static void CreateNewInventoryLedger(S_NodeInfo node, string detail = "", InventoryType type = InventoryType.StorageIn)
        {
            DocConstEntities entities = FormulaHelper.GetEntities <DocConstEntities>();
            var currentUser           = FormulaHelper.GetUserInfo();
            var InventoryLedger       = new S_A_InventoryLedger
            {
                SpaceID            = node.Space.ID,
                RelateID           = node.ID,
                RelateName         = node.Name,
                RelateType         = InventoryRelateType.Node.ToString(),
                RelateDetailInfoID = "",
                CarItemName        = "",
                Type           = type.ToString(),
                Detail         = detail,
                CreateDept     = currentUser.UserDeptNames,
                CreateDate     = System.DateTime.Now,
                CreateUserID   = currentUser.UserID,
                CreateUserName = currentUser.UserName,
                TargetUserID   = "",
                TargetUserName = ""
            };

            if (!string.IsNullOrEmpty(node.DataEntity.GetValue("Quantity")))
            {
                var num = 0;
                if (int.TryParse(node.DataEntity.GetValue("Quantity"), out num))
                {
                    InventoryLedger.TotalAmount     = num;
                    InventoryLedger.InventoryAmount = num;
                }
                if (num == 0)
                {
                    return;
                }
            }
            entities.Set <S_A_InventoryLedger>().Add(InventoryLedger);
            entities.SaveChanges();
        }