Esempio n. 1
0
        public ActionResult DeleteMulti(string Id)
        {
            HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>();

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

            foreach (var item in arrId)
            {
                int         tid   = Convert.ToInt32(item);
                THR_Recruit model = ctx.THR_Recruit.FirstOrDefault(c => c.Id == tid);
                if (model != null)
                {
                    model.IsDelete   = 1;
                    model.DeleteBy   = this.AppUser().UserName;
                    model.DeleteTime = DateTime.Now;
                    // ctx.THR_Recruit.Remove(model);
                    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()));
        }
Esempio n. 2
0
        public ActionResult EditCreateBy(THR_Recruit dto)
        {
            if (dto.Id > 0)
            {
                HKSJRecruitmentContext ctx   = HttpContext.GetDbContext <HKSJRecruitmentContext>();
                THR_Recruit            model = ctx.THR_Recruit.FirstOrDefault(c => c.Id == dto.Id);
                model.CreateBy = dto.CreateBy;
                if (ctx.SaveChanges() >= 0)
                {
                    RecruitModel m = GetRecruitModel(dto.Id, ctx);

                    return(Content(this.GetJSON(new { Result = true, Msg = "成功", Dto = m }), 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()));
            }
        }
Esempio n. 3
0
        public ActionResult Edit(THR_Recruit dto)
        {
            if (dto.Id > 0)
            {
                HKSJRecruitmentContext ctx   = HttpContext.GetDbContext <HKSJRecruitmentContext>();
                THR_Recruit            model = ctx.THR_Recruit.FirstOrDefault(c => c.Id == dto.Id);
                //状态为已入职,不能修改
                if (model.EntryType == 3)
                {
                    return(Content(this.GetJSON(new { Result = false, Msg = "状态为【已入职】,不能修改!" }), this.JsonContentType()));
                }
                if (dto.EntryType == 3 && dto.HireTime == null)
                {
                    return(Content(this.GetJSON(new { Result = false, Msg = "已入职时,报到时间不能为空!" }), this.JsonContentType()));
                }
                if (dto.HireTime != null && DateTime.Compare(dto.HireTime.Value, DateTime.Now) > 0 && dto.EntryType == 3)
                {
                    return(Content(this.GetJSON(new { Result = false, Msg = "报到时间不能超过今天!" }), this.JsonContentType()));

                    //this.CopyObject<THR_Recruit>(model, dto);
                }
                model.HireTime  = dto.HireTime;
                model.EntryType = dto.EntryType.Value;
                model.Remark    = dto.Remark;
                model.EditTime  = DateTime.Now;
                model.EditBy    = this.AppUser().UserName;

                if (ctx.SaveChanges() >= 0)
                {
                    var m = ctx.THR_Recruit.Where(c => c.Id == dto.Id).Select(c => new RecruitModel
                    {
                        DptId       = c.DptId.Value,
                        DptName     = c.TErp_Department.DeptName,
                        Id          = c.Id,
                        PostId      = c.PostId.Value,
                        PostName    = c.TErp_Position.PositionName,
                        Userurl     = c.Userurl,
                        Remark      = c.Remark,
                        Name        = c.Name,
                        Tel         = c.Tel,
                        Status      = c.Status.Value,
                        Interview   = c.Interview,
                        Email       = c.Email,
                        EntryType   = c.EntryType.Value,
                        NeedsName   = c.THR_Needs.TErp_Department.DeptName + "  " + c.THR_Needs.TErp_Position.PositionName,
                        CreateBy    = c.CreateBy,
                        CreateTime  = c.CreateTime,
                        HireTime    = c.HireTime,
                        Interviewer = c.Interviewer
                    }).FirstOrDefault();
                    HR_Employee emp = ctx.HR_Employee.FirstOrDefault(c => c.uid == model.CreateBy);
                    if (emp != null)
                    {
                        m.CreateBy = emp.name;
                    }
                    if (model.EntryType == 3)//已入职
                    {
                        WcfRestClient       client     = new HKSJRecruitment.Web.WcfRestClientAppBase("Employee");
                        EditRecord <string> resultname = client.Get <EditRecord <string> >("Uid/" + m.Name);
                        string uid = resultname.Dto;
                        HKSJRecruitment.Models.proModels.EmployeeDto empdto = new HKSJRecruitment.Models.proModels.EmployeeDto
                        {
                            FullName   = model.Name,
                            CreateBy   = 0,
                            Uid        = uid,
                            CreateTime = DateTime.Now,
                            Sex        = "男",
                            Mobile     = model.Tel,
                            EntryDate  = model.HireTime.Value,
                            Status     = 2,
                            IsDelete   = 0,
                            Education  = "大专",
                            DeptId     = 0,
                            PostId     = 0,
                            EditBy     = 0,
                            DeleteBy   = 0,
                            Email      = model.Email
                        };
                        EditRecord <HKSJRecruitment.Models.proModels.EmployeeDto> result = client.Post <HKSJRecruitment.Models.proModels.EmployeeDto, EditRecord <HKSJRecruitment.Models.proModels.EmployeeDto> >(empdto);
                    }

                    return(Content(this.GetJSON(new { Result = true, Msg = "成功", Dto = m }), 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()));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 导入Excel
        /// </summary>
        /// <returns></returns>
        public ActionResult ImportData()
        {
            HttpPostedFileBase postFile  = HttpContext.Request.Files[0];
            string             extension = Path.GetExtension(postFile.FileName).ToLower();

            if (extension != ".xls" && extension != ".xlsx")
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "文件格式错误" }), this.JsonContentType()));
            }
            HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>();
            Tapp_User user             = this.AppUser();
            Workbook  workbook         = new Workbook(postFile.InputStream);
            Cells     cells            = workbook.Worksheets[0].Cells;
            int       rows             = cells.MaxDataRow;
            int       cols             = cells.MaxDataColumn;

            if (rows > 0)
            {
                int      dptId  = 0;
                int      postId = 0;
                int      status = 0;
                DateTime interview;
                DateTime hireTime;

                for (int i = 1; i <= rows; i++)
                {
                    THR_Recruit model = new THR_Recruit();
                    model.CreateBy   = user.UserName;
                    model.CreateTime = DateTime.Now;
                    model.IsDelete   = 0;
                    model.EntryType  = 1;

                    for (int j = 0; j <= cols; j++)
                    {
                        string itemValue = cells[i, j].StringValue;
                        #region InitModel
                        switch (j)
                        {
                        case 0:
                            if (string.IsNullOrEmpty(itemValue))
                            {
                                return(Content(this.GetJSON(new { Result = false, Msg = "第" + i + "行,姓名不能为空" }), this.JsonContentType()));
                            }
                            model.Name = itemValue;
                            break;

                        case 1:
                            if (string.IsNullOrEmpty(itemValue))
                            {
                                return(Content(this.GetJSON(new { Result = false, Msg = "第" + i + "行,电话不能为空" }), this.JsonContentType()));
                            }
                            if (!Regex.IsMatch(itemValue, @"^-?\d+$"))
                            {
                                return(Content(this.GetJSON(new { Result = false, Msg = "第" + i + "行,电话格式不合法" }), this.JsonContentType()));
                            }
                            if (IsTel(itemValue) > 0)
                            {
                                return(Content(this.GetJSON(new { Result = false, Msg = "第" + i + "行,电话已存在" }), this.JsonContentType()));
                            }
                            model.Tel = itemValue;
                            break;

                        case 2:
                            dptId = GetDeptId(itemValue);
                            if (dptId == 0)
                            {
                                return(Content(this.GetJSON(new { Result = false, Msg = "第" + i + "行,部门名称[" + itemValue + "]不存在" }), this.JsonContentType()));
                            }
                            model.DptId = dptId;
                            break;

                        case 3:
                            postId = GetPostId(itemValue);
                            if (postId == 0)
                            {
                                return(Content(this.GetJSON(new { Result = false, Msg = "第" + i + "行,职位名称[" + itemValue + "]不存在" }), this.JsonContentType()));
                            }
                            model.PostId = postId;
                            break;

                        case 4:
                            status = GetStatus(itemValue);
                            if (status == 0)
                            {
                                return(Content(this.GetJSON(new { Result = false, Msg = "第" + i + "行,状态名称[" + itemValue + "]不存在" }), this.JsonContentType()));
                            }
                            model.Status = status;
                            break;

                        case 5:
                            if (!DateTime.TryParse(itemValue, out interview) && !string.IsNullOrEmpty(itemValue))
                            {
                                return(Content(this.GetJSON(new { Result = false, Msg = "第" + i + "行,面试时间格式不正确" }), this.JsonContentType()));
                            }
                            if (string.IsNullOrEmpty(itemValue))
                            {
                                return(Content(this.GetJSON(new { Result = false, Msg = "第" + i + "行,面试时间格式不能为空" }), this.JsonContentType()));
                            }
                            model.Interview = interview;
                            break;

                        case 6:
                            model.Interviewer = itemValue;
                            break;

                        case 7:
                            model.Remark = itemValue;
                            break;

                        case 8:
                            model.Userurl = itemValue;
                            break;

                        case 9:
                            if (!DateTime.TryParse(itemValue, out hireTime) && !string.IsNullOrEmpty(itemValue))
                            {
                                return(Content(this.GetJSON(new { Result = false, Msg = "第" + i + "行,报到时间格式不正确" }), this.JsonContentType()));
                            }
                            if (string.IsNullOrEmpty(itemValue))
                            {
                                model.HireTime = null;
                            }
                            else
                            {
                                model.HireTime = hireTime;
                            }
                            break;

                        case 10:
                            model.Email = itemValue;
                            break;

                        default:
                            break;
                        }
                        #endregion
                    }
                    ctx.THR_Recruit.Add(model);
                }
                if (ctx.SaveChanges() > 0)
                {
                    //RecruitModel m = GetRecruitModel(model.Id, ctx);
                    return(Content(this.GetJSON(new { Result = true, Msg = "导入数据成功" }), this.JsonContentType()));
                }
            }
            return(Content(this.GetJSON(new { Result = false, Msg = "数据文件中无数据" }), this.JsonContentType()));
        }
Esempio n. 5
0
        public ActionResult Edit(THR_Recruit dto)
        {
            if (dto.Id > 0)
            {
                HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>();
                if (ctx.THR_Recruit.Count(c => c.Tel == dto.Tel && c.IsDelete == 0 && c.Id != dto.Id) > 0)
                {
                    return(Content(this.GetJSON(new { Result = false, Msg = "电话已存在" }), this.JsonContentType()));
                }
                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()));
                }

                //THR_Recruit model = ctx.THR_Recruit.Include("THR_Needs").FirstOrDefault(c => c.Id == dto.Id);
                THR_Recruit model = ctx.THR_Recruit.FirstOrDefault(c => c.Id == dto.Id);
                //if (model.Status == 82)
                //{
                //    return Content(this.GetJSON(new { Result = false, Msg = "已录用的招聘信息不能修改" }), this.JsonContentType());
                //}
                if (dto.Status == 82 && dto.Status != model.Status)//已录用
                {
                    THR_Needs needsmodel = 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 (needsmodel.NeedQuantity <= Quantity)
                    {
                        return(Content(this.GetJSON(new { Result = false, Msg = "招聘人数已达到招聘需求数,请新增或变更招聘需求!" }), this.JsonContentType()));
                    }
                }
                this.CopyObject <THR_Recruit>(model, dto);
                model.EditTime = DateTime.Now;
                model.EditBy   = this.AppUser().UserName;
                if (ctx.SaveChanges() >= 0)
                {
                    RecruitModel m = GetRecruitModel(dto.Id, ctx);

                    return(Content(this.GetJSON(new { Result = true, Msg = "成功", Dto = m }), 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()));
            }
        }
Esempio n. 6
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()));
        }
Esempio n. 7
0
 public ActionResult NeedsAdd(THR_Recruit dto)
 {
     return(Content(this.GetJSON(new { Result = false, Msg = "失败", Dto = dto }), this.JsonContentType()));
 }