Beispiel #1
0
        public void CreateReorganize(string spaceKey, S_R_Reorganize reorganizeTask)
        {
            DocConstEntities entities = FormulaHelper.GetEntities <DocConstEntities>();
            var docConfigEntities     = FormulaHelper.GetEntities <DocConfigEntities>();
            var currentUser           = FormulaHelper.GetUserInfo();
            var space = docConfigEntities.Set <S_DOC_Space>().FirstOrDefault(a => a.SpaceKey == spaceKey);

            if (space == null)
            {
                throw new Formula.Exceptions.BusinessException("送整编错误:未能找到编号为【" + spaceKey + "】的图档空间配置");
            }
            if (reorganizeTask.S_R_Reorganize_DocumentList == null || reorganizeTask.S_R_Reorganize_DocumentList.Count == 0)
            {
                throw new Formula.Exceptions.BusinessException("送整编错误:明细列表不能为空");
            }
            if (string.IsNullOrEmpty(reorganizeTask.ID))
            {
                reorganizeTask.ID = FormulaHelper.CreateGuid();
            }
            if (string.IsNullOrEmpty(reorganizeTask.SendUser))
            {
                reorganizeTask.SendUser     = currentUser.UserID;
                reorganizeTask.SendUserName = currentUser.UserName;
            }
            if (reorganizeTask.SendDate == null)
            {
                reorganizeTask.SendDate = new DateTime?(DateTime.Now);
            }
            reorganizeTask.SpaceID         = space.ID;
            reorganizeTask.ReorganizeState = ReorganizeState.Create.ToString();
            reorganizeTask.DocumentList    = JsonHelper.ToJson <List <S_R_Reorganize_DocumentList> >(reorganizeTask.S_R_Reorganize_DocumentList.ToList <S_R_Reorganize_DocumentList>());
            foreach (var item in reorganizeTask.S_R_Reorganize_DocumentList)
            {
                if (string.IsNullOrEmpty(item.ID))
                {
                    item.ID = FormulaHelper.CreateGuid();
                }
                item.S_R_ReorganizeID = reorganizeTask.ID;
            }
            entities.Set <S_R_Reorganize>().Add(reorganizeTask);
            entities.SaveChanges();
        }
Beispiel #2
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();
        }
Beispiel #3
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();
        }
Beispiel #4
0
        //S_A_LoseReplenish补录数据存储
        public void AddReplenish(Dictionary <string, string> ReplenishForm, Dictionary <string, object> Replenish, DocConstEntities entities, ref List <Dictionary <string, object> > ReplenishList)
        {
            string loseReplenishID = Replenish.ContainsKey("S_A_LoseReplenishID") ? Replenish["S_A_LoseReplenishID"].ToString() : "";
            string replenishState  = null;

            //遗失损毁补录
            if (!string.IsNullOrEmpty(loseReplenishID))
            {
                S_A_LoseReplenish loseReplenish = entities.S_A_LoseReplenish.FirstOrDefault(b => b.ID.Equals(loseReplenishID));
                int lostCount = int.Parse(loseReplenish.LoseCount.ToString());
                if (loseReplenish.ReplenishCount == null || string.IsNullOrEmpty(loseReplenish.ReplenishCount.ToString()))
                {
                    loseReplenish.ReplenishCount = Convert.ToInt32(Replenish["ReplenishCount"].ToString());
                }
                else
                {
                    loseReplenish.ReplenishCount += Convert.ToInt32(Replenish["ReplenishCount"].ToString());
                }
                replenishState = lostCount > loseReplenish.ReplenishCount ? ReplenishState.PartReplenish.ToString() : ReplenishState.Replenish.ToString();
                loseReplenish.ReplenishState      = replenishState;
                loseReplenish.ReplenishPeopleName = ReplenishForm["ReplenishPeopleName"];
                loseReplenish.ReplenishPeople     = ReplenishForm["ReplenishPeople"];
                loseReplenish.ReplenishExplain    = !Replenish.ContainsKey("ReplenishExplain") || Replenish["ReplenishExplain"] == null ? "" : Replenish["ReplenishExplain"].ToString();
                loseReplenish.ReplenishDeptName   = ReplenishForm["ReplenishDeptName"];
                loseReplenish.ReplenishDept       = ReplenishForm["ReplenishDept"];
                loseReplenish.RelateDocID         = Replenish["RelateDocID"].ToString();
                loseReplenish.DocumentCode        = Replenish["DocumentCode"].ToString();
                loseReplenish.RelateDocType       = Replenish["RelateDocType"].ToString();
                loseReplenish.ReplenishDate       = Replenish["ReplenishDate"] == null || Replenish["ReplenishDate"].ToString() == "" ? DateTime.Now : Convert.ToDateTime(Replenish["ReplenishDate"]);

                loseReplenish.Quantity = Convert.ToInt32(Replenish["Quantity"]) + Convert.ToInt32(Replenish["ReplenishCount"].ToString());
            }
            else
            {
                replenishState = ReplenishState.Replenish.ToString();
                S_A_LoseReplenish loseReplenish = new S_A_LoseReplenish();
                loseReplenish.ID                  = Formula.FormulaHelper.CreateGuid();
                loseReplenish.State               = "";
                loseReplenish.ReplenishState      = replenishState;
                loseReplenish.ReplenishPeopleName = ReplenishForm["ReplenishPeopleName"];
                loseReplenish.ReplenishPeople     = ReplenishForm["ReplenishPeople"];
                loseReplenish.ReplenishExplain    = !Replenish.ContainsKey("ReplenishExplain") || Replenish["ReplenishExplain"] == null ? "" : Replenish["ReplenishExplain"].ToString();
                loseReplenish.ReplenishDeptName   = ReplenishForm["ReplenishDeptName"];
                loseReplenish.ReplenishDept       = ReplenishForm["ReplenishDept"];
                loseReplenish.RelateDocID         = Replenish["RelateDocID"].ToString();
                loseReplenish.DocumentCode        = Replenish.ContainsKey("DocumentCode") && Replenish["DocumentCode"] != null && !string.IsNullOrEmpty(Replenish["DocumentCode"].ToString()) ? Replenish["DocumentCode"].ToString() : "";
                // loseReplenish.DocumentCode = Replenish["DocumentCode"].ToString();
                loseReplenish.RelateDocType  = Replenish["RelateDocType"].ToString();
                loseReplenish.ReplenishCount = Convert.ToInt32(Replenish["ReplenishCount"].ToString());
                loseReplenish.Quantity       = Convert.ToInt32(Replenish["Quantity"]) + loseReplenish.ReplenishCount;
                loseReplenish.ConfigID       = Replenish["ConfigID"].ToString();
                loseReplenish.SpaceID        = Replenish["SpaceID"].ToString();
                loseReplenish.ReplenishDate  = Replenish["ReplenishDate"] == null || Replenish["ReplenishDate"].ToString() == "" ? DateTime.Now : Convert.ToDateTime(Replenish["ReplenishDate"]);
                loseReplenish.Name           = GetFinalFullPathName(loseReplenish.RelateDocID, loseReplenish.ConfigID, loseReplenish.RelateDocType, Replenish["Name"].ToString());
                if (string.IsNullOrEmpty(loseReplenish.Name))
                {
                    loseReplenish.Name = Replenish["Name"].ToString();
                }
                entities.S_A_LoseReplenish.Add(loseReplenish);
            }
            Replenish["ReplenishState"] = replenishState;
            ReplenishList.Add(Replenish);//用于修改子表中的数据
        }
Beispiel #5
0
        //S_A_LoseReplenish遗失登记数据存储
        public void AddLostDamage(Dictionary <string, string> lostForm, Dictionary <string, object> lostDamage, DocConstEntities entities)
        {
            S_A_LoseReplenish loseReplenish = new S_A_LoseReplenish();

            loseReplenish.ID             = Formula.FormulaHelper.CreateGuid();
            loseReplenish.LoseCount      = Convert.ToInt32(lostDamage["LoseCount"]);
            loseReplenish.LoseDate       = !lostDamage.ContainsKey("LoseDate") || lostDamage["LoseDate"] == null || lostDamage["LoseDate"].ToString() == "" ? DateTime.Now : Convert.ToDateTime(lostDamage["LoseDate"]);
            loseReplenish.LoseDept       = lostForm["LoseDept"].ToString();
            loseReplenish.LoseDeptName   = lostForm["LoseDeptName"].ToString();
            loseReplenish.LosePeople     = lostForm["LosePeople"].ToString();
            loseReplenish.LosePeopleName = lostForm["LosePeopleName"].ToString();
            loseReplenish.DocumentCode   = lostDamage.ContainsKey("DocumentCode") && lostDamage["DocumentCode"] != null && !string.IsNullOrEmpty(lostDamage["DocumentCode"].ToString()) ? lostDamage["DocumentCode"].ToString() : "";
            loseReplenish.LoseExplain    = lostDamage.ContainsKey("LoseExplain") && lostDamage["LoseExplain"] != null ? lostDamage["LoseExplain"].ToString() : "";
            //loseReplenish.Name = lostDamage["Name"].ToString();
            loseReplenish.Quantity       = Convert.ToInt32(lostDamage["Quantity"]) - loseReplenish.LoseCount;
            loseReplenish.RelateDocID    = lostDamage["RelateDocID"].ToString();
            loseReplenish.State          = lostDamage["LoseDamageState"].ToString();
            loseReplenish.ConfigID       = lostDamage["ConfigID"].ToString();
            loseReplenish.ReplenishState = ReplenishState.Unreplenished.ToString();
            loseReplenish.SpaceID        = lostDamage["SpaceID"].ToString();
            loseReplenish.RelateDocType  = lostDamage["RelateDocType"].ToString();
            loseReplenish.Name           = GetFinalFullPathName(loseReplenish.RelateDocID, loseReplenish.ConfigID, loseReplenish.RelateDocType, lostDamage["Name"].ToString());
            if (string.IsNullOrEmpty(loseReplenish.Name))
            {
                loseReplenish.Name = lostDamage["Name"].ToString();
            }
            entities.S_A_LoseReplenish.Add(loseReplenish);
        }