Пример #1
0
        public ActionResult AddApplyLeave(Models.ApplyLeave.ApplyLeaveEditModel vm)
        {
            using (var db = new XkSystem.Models.DbContext())
            {
                var error = new List <string>();
                if (error.Count == decimal.Zero)
                {
                    //审批内容表记录
                    var tb = new Wechat.Entity.tbWeOAApplyLeave();
                    tb.CaseFileName    = vm.ApplyLeaveEditDto.CaseFileName;
                    tb.LeaveDayCount   = vm.ApplyLeaveEditDto.LeaveDayCount;
                    tb.LeaveFromTime   = vm.ApplyLeaveEditDto.LeaveFromTime;
                    tb.LeaveToTime     = vm.ApplyLeaveEditDto.LeaveToTime;
                    tb.Reason          = vm.ApplyLeaveEditDto.Reason;
                    tb.tbWeOALeaveType = db.Set <Wechat.Entity.tbWeOALeaveType>().Find(vm.ApplyLeaveEditDto.tbWeOALeaveTypeId);
                    tb.tbTeacherDept   = db.Set <Teacher.Entity.tbTeacherDept>().Find(vm.ApplyLeaveEditDto.tbTeacherDeptId);
                    db.Set <Wechat.Entity.tbWeOAApplyLeave>().Add(tb);
                    db.SaveChanges();

                    if (vm.ApplyLeaveEditDto.LeaveDayCount <= 0.5)
                    {
                        vm.ApplyLeaveEditDto.ConditionalFormula = "day=0.5";
                    }
                    else if (vm.ApplyLeaveEditDto.LeaveDayCount <= 2 && vm.ApplyLeaveEditDto.LeaveDayCount > 0.5)
                    {
                        vm.ApplyLeaveEditDto.ConditionalFormula = "day<=2&day>0.5";
                    }
                    else if (vm.ApplyLeaveEditDto.LeaveDayCount >= 3)
                    {
                        vm.ApplyLeaveEditDto.ConditionalFormula = "day>=3";
                    }

                    //执行流程引擎
                    OAWeWorkFlow.ExecuteWorkFlowEngine(db, flowTypeCode, tb.Id, vm.ApplyLeaveEditDto.ConditionalFormula, "发起流程", false, vm.ApplyLeaveEditDto.NextApproveUserId);
                }
                else
                {
                    vm.ErrorMsg = string.Join("\r\n", error);
                    return(View(vm));//包含文件表单的方式
                }
                return(Content("<script type='text/javascript'> window.parent.location.href = '" + Url.Action("ApplyLeaveIndex", "ApplyLeave", new { area = "wechat" }) + "';</script>"));
            }
        }
Пример #2
0
        public ActionResult AddApplyLeave()
        {
            using (var db = new XkSystem.Models.DbContext())
            {
                var vm    = new Models.ApplyLeave.ApplyLeaveEditModel();
                var depts = (from p in db.Table <Teacher.Entity.tbTeacherDept>()
                             select new Code.MuiJsonDataBind
                {
                    text = p.TeacherDeptName,
                    value = p.Id.ToString(),
                }).ToList();

                var leaves = (from p in db.Table <Wechat.Entity.tbWeOALeaveType>()
                              select new Code.MuiJsonDataBind
                {
                    text = p.LeaveTypeName,
                    value = p.Id.ToString(),
                }).ToList();
                vm.DepartListJson    = JsonConvert.SerializeObject(depts);
                vm.LeaveTypeListJson = JsonConvert.SerializeObject(leaves);
                return(View(vm));
            }
        }