Example #1
0
        public IEnumerable <LeaveDto> GetLeavesByState(LeaveState state)
        {
            var leaves = _leaveRepository.GetLeavesBySate(state);

            IEnumerable <LeaveDto> leavesDto = _mapper.Map <IEnumerable <Leave>, IEnumerable <LeaveDto> >(leaves);

            return(leavesDto);
        }
Example #2
0
        public bool addLeaveState(string name, LeaveState state)
        {
            if (state == null)
            {
                return(false);
            }

            if (m_leaveStates.ContainsKey(name))
            {
                return(false);
            }

            m_leaveStates[name] = state;
            return(true);
        }
Example #3
0
        private void SeedStates(ApplicationDbContext context)
        {
            LeaveState pending = new LeaveState()
            {
                Description = "Pending"
            };

            LeaveState denied = new LeaveState()
            {
                Description = "Denied"
            };

            LeaveState approved = new LeaveState()
            {
                Description = "Approved"
            };

            context.LeaveState.AddOrUpdate(
                tbl => tbl.Description,
                pending,
                approved,
                denied
                );
        }
Example #4
0
 public IEnumerable <LeaveDto> GetLeavesByEmploye(LeaveState state) => _leaveService.GetLeavesByState(state);
Example #5
0
        protected void btn_Submit_Click(object sender, EventArgs e)
        {
            try
            {
                LeaveState LeaveState = (LeaveState)Convert.ToInt32(this.ddl_Audit.SelectedValue);
                using (IFMPDBContext db = new IFMPDBContext())
                {
                    //这里应该有权限,很重要
                    LeaveAudit LeaveAudit = db.LeaveAudit.FirstOrDefault(t => t.ID == LeaveAuditID);
                    if (LeaveAudit != null)
                    {
                        Role Role = null;
                        if (LeaveAudit.RoleID != null)
                        {
                            Role = db.Role.FirstOrDefault(t => t.ID == LeaveAudit.RoleID);
                        }
                        Leave Leave = db.Leave.FirstOrDefault(t => t.ID == LeaveAudit.LeaveID);
                        if (Role == null || Role.Name == "总经理" || Role.Name == "生产副总")
                        {
                            Leave.LeaveState      = LeaveState;
                            LeaveAudit.AuditDate  = DateTime.Now;
                            LeaveAudit.LeaveState = LeaveState;

                            if (LeaveState == LeaveState.通过)
                            {
                                Notice Notice = new Notice();
                                Notice.Contenet = "您有一条请假申请通过"
                                                  + "|请假类型:" + Enum.GetName(typeof(LeaveType), Leave.LeaveType)
                                                  + "|请假日期:" + Leave.BeginDate.ToString("yyyy-MM-dd") + "至" + Leave.EndDate.ToString("yyyy-MM-dd")
                                                  + "|请假天数:" + Leave.Day
                                                  + "|请假描述:" + Leave.Content
                                                  + "|状态:通过";
                                Notice.IsSend       = false;
                                Notice.NoticeType   = NoticeType.系统通知;
                                Notice.ReciveUserID = Leave.UserID;
                                Notice.SendUserID   = UserID;
                                Notice.SourceID     = Leave.ID;
                                Notice.SendDate     = DateTime.Now;
                                db.Notice.Add(Notice);
                            }
                            else if (LeaveState == LeaveState.通过)
                            {
                                Notice Notice = new Notice();
                                Notice.Contenet = "您有一条请假申请被驳回"
                                                  + "|请假类型:" + Enum.GetName(typeof(LeaveType), Leave.LeaveType)
                                                  + "|请假日期:" + Leave.BeginDate.ToString("yyyy-MM-dd") + "至" + Leave.EndDate.ToString("yyyy-MM-dd")
                                                  + "|请假天数:" + Leave.Day
                                                  + "|请假描述:" + Leave.Content
                                                  + "|状态:驳回";
                                Notice.IsSend       = false;
                                Notice.NoticeType   = NoticeType.系统通知;
                                Notice.ReciveUserID = Leave.UserID;
                                Notice.SendUserID   = UserID;
                                Notice.SourceID     = Leave.ID;
                                Notice.SendDate     = DateTime.Now;
                                db.Notice.Add(Notice);
                            }
                            else
                            {
                                ShowMessage("请选择正确的审核结果");
                                return;
                            }
                        }
                        else if (Role.Name == "主管班长" || Role.Name == "车间主任")
                        {
                            int ReciveUserID = Convert.ToInt32(ddl_AuditUser.SelectedValue);

                            LeaveAudit.AuditDate  = DateTime.Now;
                            LeaveAudit.LeaveState = LeaveState;

                            if (LeaveState == LeaveState.通过)
                            {
                                Leave.LeaveState = LeaveState.审核中;

                                LeaveAudit NewLeaveAudit = new IFMPLibrary.Entities.LeaveAudit();
                                NewLeaveAudit.LeaveID  = Leave.ID;
                                NewLeaveAudit.UserID   = ReciveUserID;
                                NewLeaveAudit.SendDate = DateTime.Now;
                                if (Role.Name == "主管班长")
                                {
                                    NewLeaveAudit.RoleID = db.Role.FirstOrDefault(t => t.Name == "车间主任").ID;
                                }
                                else
                                {
                                    NewLeaveAudit.RoleID = db.Role.FirstOrDefault(t => t.Name == "生产副总").ID;
                                }
                                NewLeaveAudit.LeaveState = LeaveState.未审核;
                                db.LeaveAudit.Add(NewLeaveAudit);
                                //NewLeaveAudit.RoleID=
                                //NewLeaveAudit.

                                Notice Notice = new Notice();
                                Notice.Contenet = "当前有一条请假申请待审核"
                                                  + "|发起人:" + db.User.FirstOrDefault(t => t.ID == Leave.UserID).RealName
                                                  + "|请假类型:" + Enum.GetName(typeof(LeaveType), Leave.LeaveType)
                                                  + "|请假日期:" + Leave.BeginDate.ToString("yyyy-MM-dd") + "至" + Leave.EndDate.ToString("yyyy-MM-dd")
                                                  + "|请假天数:" + Leave.Day
                                                  + "|请假描述:" + Leave.Content
                                                  + "|状态:待审核";
                                Notice.IsSend       = false;
                                Notice.NoticeType   = NoticeType.系统通知;
                                Notice.ReciveUserID = ReciveUserID;
                                Notice.SendUserID   = UserID;
                                Notice.SourceID     = Leave.ID;
                                Notice.SendDate     = DateTime.Now;
                                db.Notice.Add(Notice);
                            }
                            else if (LeaveState == LeaveState.通过)
                            {
                                Leave.LeaveState = LeaveState.通过;
                                Notice Notice = new Notice();
                                Notice.Contenet = "您有一条请假申请被驳回"
                                                  + "|请假类型:" + Enum.GetName(typeof(LeaveType), Leave.LeaveType)
                                                  + "|请假日期:" + Leave.BeginDate.ToString("yyyy-MM-dd") + "至" + Leave.EndDate.ToString("yyyy-MM-dd")
                                                  + "|请假天数:" + Leave.Day
                                                  + "|请假描述:" + Leave.Content
                                                  + "|状态:驳回";
                                Notice.IsSend       = false;
                                Notice.NoticeType   = NoticeType.系统通知;
                                Notice.ReciveUserID = Leave.UserID;
                                Notice.SendUserID   = UserID;
                                Notice.SourceID     = Leave.ID;
                                Notice.SendDate     = DateTime.Now;
                                db.Notice.Add(Notice);
                            }
                            else
                            {
                                ShowMessage("请选择正确的审核结果");
                                return;
                            }
                        }
                        db.SaveChanges();
                        new SysLogDAO().AddLog(LogType.操作日志_添加, "请假审核", UserID);
                        ShowMessage();
                    }
                    else
                    {
                        ShowMessage("找不到该请假审核纪录");
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                ShowMessage(ex.Message);
                new SysLogDAO().AddLog(LogType.系统日志, ex.Message, UserID);
                return;
            }
        }
Example #6
0
 public IEnumerable <Leave> GetLeavesBySate(LeaveState state) =>
 Context.Set <Leave>().AsNoTracking().Include(l => l.Employe.EmployeArea).ThenInclude(ea => ea.Area).Include(l => l.Employe.EmployeArea).ThenInclude(ea => ea.Employe)
 .Where(l => l.State == state).OrderBy(l => l.Date).ToList();
Example #7
0
        private IList <Leave> GetLeavesEntity(IEnumerable <LeaveDto> leaves, Employe currentEmploye, LeaveState state)
        {
            var entities = _mapper.Map <IEnumerable <LeaveDto>, IEnumerable <Leave> >(leaves).ToList();

            entities.ForEach(l =>
            {
                l.Employe = currentEmploye;
                l.State   = state;
            });
            return(entities);
        }