Beispiel #1
0
        /// <summary>
        /// 检查听评对象用记是否存在,不存在则创建
        /// </summary>
        private bool CreatePConfirmDepartmentID(ResearchPlanInfo infoPlan)
        {
            DepartmentInfo infoDepartment = null;

            if (infoPlan.DepartmentID > 0)
            {
                infoDepartment = DepartmentBLL.GetList(a => a.ID == infoPlan.DepartmentID).FirstOrDefault();
                if (null != infoDepartment)
                {
                    infoPlan.DepartmentID   = infoDepartment.ID;
                    infoPlan.DepartmentInfo = infoDepartment;
                    return(true);
                }
            }
            infoDepartment          = new DepartmentInfo();
            infoDepartment.Name     = Function.GetRequestString("TxtDepartment");
            infoDepartment.ParentID = 0;
            infoDepartment.Enable   = false;
            infoDepartment.OrderID  = 0;
            infoDepartment.TypeEmun = infoPlan.AreaID;
            infoDepartment.Address  = string.Empty;
            if (string.IsNullOrEmpty(infoDepartment.Name))
            {
                return(false);
            }

            //再根据名称找一,如果就不要加啦
            var ExistItem = DepartmentBLL.GetList(a => a.Name == infoDepartment.Name && a.TypeEmun == infoPlan.AreaID).FirstOrDefault();

            if (null != ExistItem)
            {
                infoPlan.DepartmentID   = ExistItem.ID;
                infoPlan.DepartmentInfo = ExistItem;
                return(true);
            }

            if (DepartmentBLL.Create(infoDepartment).ID > 0)
            {
                infoPlan.DepartmentID   = infoDepartment.ID;
                infoPlan.DepartmentInfo = infoDepartment;
            }
            return(infoDepartment.ID > 0);
        }