Ejemplo n.º 1
0
 public ActionResult Edit(TErp_Department dto)
 {
     if (dto.Id > 0)
     {
         HKSJRecruitmentContext ctx   = HttpContext.GetDbContext <HKSJRecruitmentContext>();
         TErp_Department        model = ctx.TErp_Department.FirstOrDefault(c => c.Id == dto.Id);
         string deptName = dto.DeptName;
         int    deptId   = dto.Id;
         if (ctx.TErp_Department.Count(c => c.IsDelete == 0 && c.DeptName == deptName && c.Id != deptId) > 0)
         {
             return(Content(this.GetJSON(new { Result = false, Msg = "部门名称[" + deptName + "]重复", Dto = dto }), this.JsonContentType()));
         }
         this.CopyObject <TErp_Department>(model, dto);
         Tapp_User user = this.AppUser();
         model.EditBy   = user.UserName;
         model.EditTime = DateTime.Now;
         if (ctx.SaveChanges() >= 0)
         {
             return(Content(this.GetJSON(new { Result = true, Msg = "成功", Dto = dto }), this.JsonContentType()));
         }
         return(Content(this.GetJSON(new { Result = false, Msg = "失败", Dto = dto }), this.JsonContentType()));
     }
     else
     {
         return(Content(this.GetJSON(new { Result = false, Msg = "失败,未找到要修改的数据", Dto = dto }), this.JsonContentType()));
     }
 }
Ejemplo n.º 2
0
        public ActionResult DeleteMulti(string Id)
        {
            HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>();

            string[]  arrId   = Id.Split(new char[] { ',', '-' }, StringSplitOptions.RemoveEmptyEntries);
            int       counter = 0;
            Tapp_User user    = this.AppUser();

            foreach (var item in arrId)
            {
                int             tid   = Convert.ToInt32(item);
                TErp_Department model = ctx.TErp_Department.FirstOrDefault(c => c.Id == tid);
                if (model != null)
                {
                    int deptId = model.Id;
                    if (ctx.THR_Needs.Count(c => c.DeptId == deptId && c.IsDelete == 0) > 0 ||
                        ctx.THR_Recruit.Count(c => c.DptId == deptId && c.IsDelete != 1) > 0)
                    {
                        return(Content(this.GetJSON(new { Result = false, Msg = "部门[" + model.DeptName + "]已被引用,不能删除", Id = counter }), this.JsonContentType()));
                    }
                    model.IsDelete   = 1;
                    model.DeleteBy   = user.UserName;
                    model.DeleteTime = DateTime.Now;
                    counter++;
                }
            }
            if (ctx.SaveChanges() >= 0)
            {
                return(Content(this.GetJSON(new { Result = true, Msg = "成功", Id = counter }), this.JsonContentType()));
            }
            return(Content(this.GetJSON(new { Result = false, Msg = "失败", id = counter }), this.JsonContentType()));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 根据部门名称获得部门ID
        /// </summary>
        /// <param name="dptName"></param>
        /// <returns></returns>
        private int GetDeptId(string dptName)
        {
            HKSJRecruitmentContext ctx    = HttpContext.GetDbContext <HKSJRecruitmentContext>();
            List <TErp_Department> models = ctx.TErp_Department
                                            .Where(c => c.IsDelete == 0).OrderUsingSortExpression("id asc").ToList();
            TErp_Department tDepartment = models.FirstOrDefault(c => c.DeptName.Equals(dptName, StringComparison.OrdinalIgnoreCase));

            if (tDepartment != null)
            {
                return(tDepartment.Id);
            }
            else
            {
                return(0);
            }
        }
Ejemplo n.º 4
0
        public ActionResult Add(TErp_Department dto)
        {
            HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>();
            string deptName            = dto.DeptName;

            if (ctx.TErp_Department.Count(c => c.DeptName == deptName && c.IsDelete == 0) > 0)
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "部门名称[" + deptName + "]重复", Dto = dto }), this.JsonContentType()));
            }
            Tapp_User user = this.AppUser();

            dto.CreateBy   = user.UserName;
            dto.CreateTime = DateTime.Now;
            ctx.TErp_Department.Add(dto);
            if (ctx.SaveChanges() >= 0)
            {
                return(Content(this.GetJSON(new { Result = true, Msg = "成功", Dto = dto }), this.JsonContentType()));
            }
            return(Content(this.GetJSON(new { Result = false, Msg = "失败", Dto = dto }), this.JsonContentType()));
        }
Ejemplo n.º 5
0
        public ActionResult Add(THR_Recruit dto)
        {
            HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>();

            if (!dto.DptId.HasValue)
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "部门不存在,请在组织架构中维护" }), this.JsonContentType()));
            }
            int dptId = dto.DptId.Value;

            if (ctx.TErp_Department.Count(c => c.Id == dptId) == 0)
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "部门不存在,请在组织架构中维护" }), this.JsonContentType()));
            }
            if (!dto.PostId.HasValue)
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "职位不存在,请在职位管理中维护" }), this.JsonContentType()));
            }
            int postId = dto.PostId.Value;

            if (ctx.TErp_Position.Count(c => c.Id == postId) == 0)
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "职位不存在,请在职位管理中维护" }), this.JsonContentType()));
            }
            if (!dto.Status.HasValue)
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "状态不存在,请在参数配置中维护" }), this.JsonContentType()));
            }
            int status = dto.Status.Value;

            if (ctx.Tapp_Param.Count(c => c.Id == status) == 0)
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "状态不存在,请在参数配置中维护" }), this.JsonContentType()));
            }
            if (string.IsNullOrEmpty(dto.Interview.ToString()))
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "面试时间不能为空" }), this.JsonContentType()));
            }
            DateTime interview;

            if (!DateTime.TryParse(dto.Interview.ToString(), out interview) && !string.IsNullOrEmpty(dto.Interview.ToString()))
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "面试时间格式不正确" }), this.JsonContentType()));
            }
            DateTime hireTime;

            if (!DateTime.TryParse(dto.HireTime.ToString(), out hireTime) && !string.IsNullOrEmpty(dto.HireTime.ToString()))
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "报道时间格式不正确" }), this.JsonContentType()));
            }
            if (dto.NeedsId == 0 || dto.NeedsId == null)
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "招聘需求不能为空" }), this.JsonContentType()));
            }
            if (dto.Status == 82)//已录用
            {
                THR_Needs needmodel = ctx.THR_Needs.FirstOrDefault(c => c.Id == dto.NeedsId);
                int       Quantity  = ctx.THR_Recruit
                                      .Where(c => c.IsDelete == 0 && c.NeedsId == dto.NeedsId && c.Status == dto.Status).ToList().Count;//已录用
                if (needmodel.NeedQuantity <= Quantity)
                {
                    return(Content(this.GetJSON(new { Result = false, Msg = "招聘人数已达到招聘需求数,请新增或变更招聘需求!" }), this.JsonContentType()));
                }
                //needmodel.HaveBeenQuantity = Quantity + 1;
                //if (needmodel.HaveBeenQuantity == needmodel.NeedQuantity)
                //{ needmodel.IsHaveBeen = 1; }
            }
            TErp_Department dept = ctx.TErp_Department.FirstOrDefault(c => c.Id == dto.DptId.Value);

            dept.SeqNo = dept.SeqNo + 1;
            if (ctx.THR_Recruit.Count(c => c.Tel == dto.Tel && c.IsDelete == 0) > 0)
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "电话已存在" }), this.JsonContentType()));
            }
            dto.CreateTime = DateTime.Now;
            dto.CreateBy   = this.AppUser().UserName;
            dto.IsDelete   = 0;
            dto.EntryType  = 1;
            ctx.THR_Recruit.Add(dto);
            if (ctx.SaveChanges() > 0)
            {
                RecruitModel model = GetRecruitModel(dto.Id, ctx);

                return(Content(this.GetJSON(new { Result = true, Msg = "成功", Dto = model }), this.JsonContentType()));
            }
            return(Content(this.GetJSON(new { Result = false, Msg = "失败", Dto = dto }), this.JsonContentType()));
        }