예제 #1
0
        public ContentResult SearchSingle()
        {
            string         locationId = GetParam("ID");
            BMaterialGroup group      = mgService.GetMaterialGroupById(Convert.ToInt32(locationId));

            return(ReturnResult(group));
        }
예제 #2
0
 /// <summary>
 /// 判断父节点否等于节点本身
 /// </summary>
 /// <param name="MaterialGroup"></param>
 /// <returns></returns>
 public bool IsParentEqSelf(BMaterialGroup MaterialGroup)
 {
     if (MaterialGroup.ParentID == 0)
     {
         return(false);
     }
     return(MaterialGroup.ParentID == MaterialGroup.ID);
 }
예제 #3
0
 /// <summary>
 /// 非空验证
 /// </summary>
 /// <param name="group"></param>
 /// <returns></returns>
 public string CheckMaterialGroup(BMaterialGroup group)
 {
     if (string.IsNullOrWhiteSpace(group.GroupCode))
     {
         return("物料组编码不能为空.");
     }
     if (string.IsNullOrWhiteSpace(group.GroupName))
     {
         return("物料组名称码不能为空.");
     }
     return(string.Empty);
 }
예제 #4
0
        public ContentResult Add()
        {
            ResultData <string> rt = new ResultData <string>();

            BMaterialGroup location = GetAdd <BMaterialGroup>();

            //非空验证和属性格式验证
            string msg = mgService.CheckMaterialGroup(location);

            if (!string.IsNullOrEmpty(msg))
            {
                rt.message = msg;
                rt.status  = -1;
                return(ReturnResult(rt));
            }

            //判断是否子存储单元,添加顶级存储单元
            if (location.ParentID > 0)
            {
                BMaterialGroup parent = mgService.GetMaterialGroupById(location.ParentID);
                location.TopGroupID = parent.TopGroupID;
                location.GroupLevel = parent.GroupLevel + 1;
            }
            else
            {
                location.GroupLevel = 1;
            }

            //是否存在
            if (mgService.IsNotExits(location, false))
            {
                location.CreateBy   = this.CurrentUser.ID;
                location.CreateDate = DateTime.Now;
                location.UpdateDate = DateTime.Now;
                int mgId = mgService.AddMaterialGroup(location);

                //如果添加为仓库,则跟新顶级存储单元ID
                if (location.ParentID < 1)
                {
                    location.ID         = mgId;
                    location.TopGroupID = mgId;
                    mgService.UpdateMaterialGroup(location);
                }
            }
            else
            {
                rt.status  = -1;
                rt.message = "存储单元已经存在.";
            }


            return(ReturnResult(rt));
        }
예제 #5
0
        /// <summary>
        /// 递归
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="orgs"></param>
        /// <returns></returns>
        private void GetMaterialGroupChild(BMaterialGroup parent, List <BMaterialGroup> MaterialGroups)
        {
            List <BMaterialGroup> children = MaterialGroups.Where(o => o.ParentID == parent.ID).ToList();

            if (children.Count > 0)
            {
                parent.Children.AddRange(children);
                foreach (BMaterialGroup child in children)
                {
                    GetMaterialGroupChild(child, MaterialGroups);
                }
            }
        }
예제 #6
0
        /// <summary>
        /// 查询所有子记录(包括本身)
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="materialGroups"></param>
        public void GetMaterialGroupWithChildren(BMaterialGroup parent, List <BMaterialGroup> materialGroups)
        {
            if (parent == null)
            {
                return;
            }
            materialGroups.Add(parent);

            List <BMaterialGroup> children = GetChildMaterialGroups(parent.ID);

            foreach (BMaterialGroup child in children)
            {
                GetMaterialGroupWithChildren(child, materialGroups);
            }
        }
예제 #7
0
 /// <summary>
 /// 构建子节点
 /// </summary>
 /// <param name="mgation"></param>
 /// <param name="parentTn"></param>
 public void BuildChildTree(BMaterialGroup mgation, TreeNode parentTn)
 {
     foreach (BMaterialGroup mg in mgation.Children)
     {
         TreeNode tn = new TreeNode();
         tn.id   = mg.ID.ToString();
         tn.text = mg.GroupName;
         tn.name = mg.GroupName;
         if (mg.Children.Count > 0)
         {
             BuildChildTree(mg, tn);
         }
         parentTn.children.Add(tn);
     }
 }
예제 #8
0
        public ContentResult Update()
        {
            ResultData <string> rt = new ResultData <string>();

            BMaterialGroup group = GetUpdate <BMaterialGroup>();

            //非空验证和属性格式验证
            string msg = mgService.CheckMaterialGroup(group);

            if (!string.IsNullOrEmpty(msg))
            {
                rt.message = msg;
                rt.status  = -1;
                return(ReturnResult(rt));
            }
            if (mgService.IsParentEqSelf(group))
            {
                rt.message = "父物料组不能选择自身";
                rt.status  = -1;
                return(ReturnResult(rt));
            }

            group.UpdateDate = DateTime.Now;
            group.UpdateBy   = this.CurrentUser.ID;

            //是否存在
            if (mgService.IsNotExits(group, false))
            {
                mgService.UpdateMaterialGroup(group);
            }
            else
            {
                rt.status  = -1;
                rt.message = "存储单元已经存在.";
            }
            return(ReturnResult(rt));
        }
예제 #9
0
 /// <summary>
 /// 删除记录
 /// </summary>
 /// <param name="group"></param>
 /// <returns></returns>
 public bool RemoveMaterialGroup(BMaterialGroup group)
 {
     return(mgRepository.Delete(group));
 }
예제 #10
0
 /// <summary>
 /// 更新记录
 /// </summary>
 /// <param name="user"></param>
 /// <returns></returns>
 public bool UpdateMaterialGroup(BMaterialGroup group)
 {
     return(mgRepository.Update(group));
 }
예제 #11
0
        /// <summary>
        /// 插入记录
        /// </summary>
        /// <param name="group"></param>
        /// <returns></returns>
        public int AddMaterialGroup(BMaterialGroup group)
        {
            object groupId = mgRepository.Insert(group);

            return(Convert.ToInt32(groupId));
        }
예제 #12
0
 /// <summary>
 /// 分组是否存在
 /// </summary>
 /// <param name="group"></param>
 /// <param name="isAdd"></param>
 public bool IsNotExits(BMaterialGroup group, bool isAdd)
 {
     return(mgRepository.IsNotExits(group, isAdd));
 }