public ActionResult DoResign([Bind(Include = "resignTypeId, staffNr, resignAt,resignChecker,remark")] ResignRecord record) { //用户创建员工离职记录: //• 离职原因(选择,不可空) //• 离职日期(选择,不可空) //• 离职批准人(输入,可空) //• 备注(输入,可空) //如果离职记录创建成功,则将人员在职状态改为:离职 ResultMessage msg = new ResultMessage(); IResignRecordService ss = new ResignRecordService(Settings.Default.db); msg = ss.Create(record); if (msg.Success) { IStaffService staffSi = new StaffService(Settings.Default.db); Staff staff = staffSi.FindByNr(record.staffNr); staff.workStatus = (int)WorkStatus.OffWork; staff.resignAt = record.resignAt; staffSi.Update(staff); } // 创建离职记录##User## try { IMessageRecordService mrs = new MessageRecordService(Settings.Default.db); mrs.CreateStaffResignMessage(record.staffNr, (Session["user"] as User).id); } catch { } return(Json(msg)); }
public JsonResult Delete(int id, FormCollection collection) { ResultMessage msg = new ResultMessage(); try { //存在员工时不可删除 IResignRecordService shfSi = new ResignRecordService(Settings.Default.db); List <ResignRecord> shf = shfSi.FindByResignType(id); if (null != shf && shf.Count() > 0) { msg.Success = false; msg.Content = "离职类型正在使用,不能删除!"; return(Json(msg, JsonRequestBehavior.AllowGet)); } else { IResignTypeService cs = new ResignTypeService(Settings.Default.db); bool isSucceed = cs.DeleteById(id); msg.Success = isSucceed; msg.Content = isSucceed ? "" : "删除失败"; return(Json(msg, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new ResultMessage() { Success = false, Content = ex.Message }, JsonRequestBehavior.AllowGet)); } }