Esempio n. 1
0
        /// <summary>
        /// 添加公司
        /// </summary>
        /// <param name="entity">公司实例</param>
        public void CompanyAdd(T_HR_COMPANY entity)
        {
            try
            {
                var tempEnt = dal.GetObjects().FirstOrDefault(s => s.COMPANRYCODE == entity.COMPANRYCODE ||
                                                              s.CNAME == entity.CNAME);
                if (tempEnt != null)
                {
                    throw new Exception("Repetition");
                }
                T_HR_COMPANY ent = new T_HR_COMPANY();
                Utility.CloneEntity <T_HR_COMPANY>(entity, ent);

                //如果父公司为空,就不赋值
                if (entity.T_HR_COMPANY2 != null)
                {
                    ent.T_HR_COMPANY2Reference.EntityKey =
                        new System.Data.EntityKey(qualifiedEntitySetName + "T_HR_COMPANY", "COMPANYID", entity.T_HR_COMPANY2.COMPANYID);
                }
                dal.Add(ent);

                WorkflowUtility.CallWorkflow("公司申请审核工作流", ent);
                CacheManager.RemoveCache("T_HR_COMPANY");
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 撤消部门
        /// </summary>
        /// <param name="sourceEntity">部门实体</param>
        public void DepartmentCancel(T_HR_DEPARTMENT sourceEntity)
        {
            var entitys = (from ent in dal.GetTable()
                           where ent.DEPARTMENTID == sourceEntity.DEPARTMENTID
                           select ent);

            if (entitys.Count() > 0)
            {
                var entity = entitys.FirstOrDefault();
                if (IsExistChilds(sourceEntity.DEPARTMENTID))
                {
                    throw new Exception("此部门已关联岗位,不能撤消!");
                }
                entity.EDITSTATE    = sourceEntity.EDITSTATE;
                entity.CHECKSTATE   = sourceEntity.CHECKSTATE;
                entity.UPDATEUSERID = sourceEntity.UPDATEUSERID;
                entity.UPDATEDATE   = sourceEntity.UPDATEDATE;
                dal.Update(entity);
                WorkflowUtility.CallWorkflow("申请撤消工作流", entity);
                CacheManager.RemoveCache("T_HR_DEPARTMENT");
            }
            else
            {
                throw new Exception("没有找到对应实体!");
            }
        }