예제 #1
0
        public OperateResult Add(AssessmentInfo model)
        {
            using (SystemDB db = new SystemDB())
            {
                try
                {
                    var match = from m in db.assessmentInfoList
                                where m.employeeId == model.employeeId && m.month == model.month
                                select m;
                    if (match.Count() > 0)
                    {
                        return(new OperateResult
                        {
                            content = "数据已经存在",
                        });
                    }
                    model.inputDate = DateTime.Now;

                    db.assessmentInfoList.Add(model);
                    db.SaveChanges();

                    return(new OperateResult
                    {
                        status = OperateStatus.Success,
                    });
                }
                catch (Exception ex)
                {
                    return(new OperateResult
                    {
                        content = ex.Message,
                    });
                }
            }
        }
예제 #2
0
        public OperateResult Update(AssessmentInfo model)
        {
            using (SystemDB db = new SystemDB())
            {
                try
                {
                    db.Entry(model).State = System.Data.Entity.EntityState.Modified;

                    db.SaveChanges();

                    return(new OperateResult
                    {
                        status = OperateStatus.Success,
                        content = "更新成功"
                    });
                }
                catch (Exception ex)
                {
                    return(new OperateResult
                    {
                        content = ex.Message,
                    });
                }
            }
        }
예제 #3
0
        public static OperateResult Add(LogRecord model)
        {
            using (SystemDB db = new SystemDB())
            {
                try
                {
                    var match = from m in db.logRecordList
                                select m;
                    if (match.Count() > 0)
                    {
                        return(new OperateResult
                        {
                            content = "用户已经存在",
                        });
                    }

                    db.logRecordList.Add(model);
                    db.SaveChanges();

                    return(new OperateResult
                    {
                        status = OperateStatus.Success,
                    });
                }
                catch (Exception ex)
                {
                    return(new OperateResult
                    {
                        content = ex.Message,
                    });
                }
            }
        }
예제 #4
0
        public static OperateResult Update(AssessmentInfo model)
        {
            try
            {
                using (SystemDB db = new SystemDB())
                {
                    model.inputDate       = DateTime.Now;
                    db.Entry(model).State = System.Data.Entity.EntityState.Modified;

                    db.SaveChanges();

                    LogManager.Add(new LogRecord
                    {
                        userId  = SessionHelper.GetUserId(),
                        time    = DateTime.Now,
                        type    = "Info",
                        content = "修改考核:" + model.billSerial
                    });

                    return(new OperateResult
                    {
                        status = OperateStatus.Success,
                        content = "更新成功"
                    });
                }
            }
            catch (Exception ex)
            {
                return(new OperateResult
                {
                    content = Model.Utility.Utility.GetExceptionMsg(ex),
                });
            }
        }
예제 #5
0
        public OperateResult Add(Module model)
        {
            using (SystemDB db = new SystemDB())
            {
                try
                {
                    var match = from m in db.moduleList
                                where m.name.Equals(model.name)
                                select m;
                    if (match.Count() > 0)
                    {
                        return(new OperateResult
                        {
                            content = "该模块已经存在",
                        });
                    }

                    db.moduleList.Add(model);
                    db.SaveChanges();

                    return(new OperateResult
                    {
                        status = OperateStatus.Success,
                    });
                }
                catch (Exception ex)
                {
                    return(new OperateResult
                    {
                        content = ex.Message,
                    });
                }
            }
        }
예제 #6
0
        public static OperateResult  Add(Company model)
        {
            try
            {
                using (SystemDB db = new SystemDB())
                {
                    var match = from m in db.companyList
                                where m.name.Equals(model.name) || m.code.Equals(model.code)
                                select m;
                    if (match.Count() > 0)
                    {
                        return(new OperateResult
                        {
                            content = "该公司已经存在",
                        });
                    }

                    db.companyList.Add(model);
                    db.SaveChanges();

                    return(new OperateResult
                    {
                        status = OperateStatus.Success,
                    });
                }
            }
            catch (Exception ex)
            {
                return(new OperateResult
                {
                    content = Model.Utility.Utility.GetExceptionMsg(ex),
                });
            }
        }
예제 #7
0
        public static OperateResult RemoveAll()
        {
            try
            {
                using (SystemDB db = new SystemDB())
                {
                    db.postInfoList.RemoveRange(db.postInfoList.ToList());

                    db.SaveChanges();

                    LogManager.Add(new LogRecord
                    {
                        userId  = SessionHelper.GetUserId(),
                        time    = DateTime.Now,
                        type    = "Info",
                        content = "删除所有岗位信息"
                    });

                    return(new OperateResult
                    {
                        status = OperateStatus.Success,
                        content = "删除成功"
                    });
                }
            }
            catch (Exception ex)
            {
                return(new OperateResult
                {
                    content = Model.Utility.Utility.GetExceptionMsg(ex),
                });
            }
        }
예제 #8
0
        public static OperateResult Add(AssessmentInfo model)
        {
            try
            {
                using (SystemDB db = new SystemDB())
                {
                    var match = from m in db.assessmentInfoList
                                where m.employeeId == model.employeeId && m.month == model.month
                                select m;
                    if (match.Count() > 0)
                    {
                        return(new OperateResult
                        {
                            content = "单号为(" + model.billSerial + ")的员工数据已经存在;",
                        });
                    }

                    var salary = (from s in db.employeeList
                                  where s.id == model.employeeId &&
                                  s.salaryInfoId != null
                                  select s).FirstOrDefault();
                    if (salary == null)
                    {
                        return(new OperateResult
                        {
                            content = "单号为(" + model.billSerial + ")的员工还未设定薪酬;",
                        });
                    }


                    model.inputDate = DateTime.Now;
                    model.status    = "未审核";

                    db.assessmentInfoList.Add(model);
                    db.SaveChanges();

                    LogManager.Add(new LogRecord
                    {
                        userId  = SessionHelper.GetUserId(),
                        time    = DateTime.Now,
                        type    = "Info",
                        content = "添加考核:" + model.billSerial
                    });

                    return(new OperateResult
                    {
                        status = OperateStatus.Success,
                    });
                }
            }
            catch (Exception ex)
            {
                return(new OperateResult
                {
                    content = "单号为(" + model.billSerial + ")的员工,保存发生错误:"
                              + Model.Utility.Utility.GetExceptionMsg(ex) + ";",
                });
            }
        }
예제 #9
0
        public static OperateResult  ModifyPasswd(long id, string pwdOld, string pwd)
        {
            try
            {
                using (SystemDB db = new SystemDB())
                {
                    var element = (from m in db.userList
                                   where id == m.id
                                   select m
                                   ).FirstOrDefault();

                    if (element == null)
                    {
                        return(new OperateResult
                        {
                            content = "访问错误",
                        });
                    }

                    if (element.passwd != MD5Encode.Encode16(pwdOld))
                    {
                        return(new OperateResult
                        {
                            content = "原密码错误",
                        });
                    }


                    element.passwd = MD5Encode.Encode16(pwd);

                    db.Entry(element).State = System.Data.Entity.EntityState.Modified;

                    db.SaveChanges();

                    LogManager.Add(new LogRecord
                    {
                        userId  = SessionHelper.GetUserId(),
                        time    = DateTime.Now,
                        type    = "Info",
                        content = "重置密码:" + element.name
                    });


                    return(new OperateResult
                    {
                        status = OperateStatus.Success,
                        content = "更新成功"
                    });
                }
            }
            catch (Exception ex)
            {
                return(new OperateResult
                {
                    content = Model.Utility.Utility.GetExceptionMsg(ex),
                });
            }
        }
예제 #10
0
        public static OperateResult  Update(Department model)
        {
            try
            {
                using (SystemDB db = new SystemDB())
                {
                    var elements = (from e in db.departmentList
                                    where e.id != model.id && e.name == model.name
                                    select e
                                    ).ToList();
                    if (elements.Count() >= 1)
                    {
                        return(new OperateResult
                        {
                            content = "已经存在同名的部门",
                        });
                    }


                    var matchs = (from e in db.departmentList
                                  where e.id == model.parentId && e.parentId == model.id
                                  select e
                                  ).ToList();
                    if (matchs.Count() >= 1)
                    {
                        return(new OperateResult
                        {
                            content = "该部门与其上级部门互为上下部门",
                        });
                    }
                    db.Entry(model).State = EntityState.Modified;

                    db.SaveChanges();

                    LogManager.Add(new LogRecord
                    {
                        userId  = SessionHelper.GetUserId(),
                        time    = DateTime.Now,
                        type    = "Info",
                        content = "修改部门:" + model.name
                    });

                    return(new OperateResult
                    {
                        status = OperateStatus.Success,
                        content = "更新成功"
                    });
                }
            }
            catch (Exception ex)
            {
                return(new OperateResult
                {
                    content = Model.Utility.Utility.GetExceptionMsg(ex),
                });
            }
        }
예제 #11
0
        /// <summary>
        /// 先移除role所有的权限,然后重新加入
        /// </summary>
        /// <param name="roleId"></param>
        /// <param name="idList"></param>
        /// <returns></returns>
        public static OperateResult  AssignRight(long roleId, List <long> idList)
        {
            try
            {
                using (SystemDB db = new SystemDB())
                {
                    var role = (from e in db.roleList.Include("rightList")
                                where e.id == roleId
                                select e).FirstOrDefault();
                    if (role == null)
                    {
                        return(new OperateResult
                        {
                            content = "找不到角色"
                        });
                    }

                    role.rightList.Clear();

                    foreach (var rid in idList)
                    {
                        var model = db.rightList.Find(rid);
                        role.rightList.Add(model);
                    }

                    db.Entry(role).State = EntityState.Modified;

                    //db.Configuration.ValidateOnSaveEnabled = false;
                    db.SaveChanges();
                    //db.Configuration.ValidateOnSaveEnabled = true;

                    LogManager.Add(new LogRecord
                    {
                        userId  = SessionHelper.GetUserId(),
                        time    = DateTime.Now,
                        type    = "Info",
                        content = "分配权限:" + role.name
                    });


                    return(new OperateResult
                    {
                        status = OperateStatus.Success,
                        content = "更新成功"
                    });
                }
            }
            catch (Exception ex)
            {
                return(new OperateResult
                {
                    content = Model.Utility.Utility.GetExceptionMsg(ex),
                });
            }
        }
예제 #12
0
        public OperateResult Remove(long id)
        {
            using (SystemDB db = new SystemDB())
            {
                try
                {
                    var element  = db.departmentList.Find(id);
                    var elements = db.departmentList.ToList();

                    if (element == null)
                    {
                        return(new OperateResult
                        {
                            content = "不存在该部门",
                        });
                    }
                    var query = from e in elements
                                where e.parentId == element.id
                                select e;
                    if (query.Count() > 0)
                    {
                        return(new OperateResult
                        {
                            content = "该部门存在下级部门,不能删除",
                        });
                    }

                    db.departmentList.Remove(element);

                    db.Entry(element).State = System.Data.Entity.EntityState.Deleted;
                    db.SaveChanges();

                    LogManager.Add(new LogRecord
                    {
                        userId  = SessionHelper.GetUserId(),
                        time    = DateTime.Now,
                        type    = "Info",
                        content = "删除用户:" + element.name
                    });

                    return(new OperateResult
                    {
                        status = OperateStatus.Success,
                        content = "删除成功"
                    });
                }
                catch (Exception ex)
                {
                    return(new OperateResult
                    {
                        content = ex.Message,
                    });
                }
            }
        }
예제 #13
0
        public OperateResult Update(User model)
        {
            using (SystemDB db = new SystemDB())
            {
                try
                {
                    var element = (from e in db.userList
                                   where e.id != model.id && e.name == model.name
                                   select e
                                   ).FirstOrDefault();
                    if (element != null)
                    {
                        return(new OperateResult
                        {
                            content = "已经存在同名",
                        });
                    }
                    element = (from e in db.userList
                               where e.id == model.id
                               select e
                               ).AsNoTracking().FirstOrDefault();

                    model.passwd = element.passwd;

                    db.Configuration.ValidateOnSaveEnabled = false;
                    db.Entry(model).State = System.Data.Entity.EntityState.Modified;

                    db.SaveChanges();

                    LogManager.Add(new LogRecord
                    {
                        userId  = SessionHelper.GetUserId(),
                        time    = DateTime.Now,
                        type    = "Info",
                        content = "修改用户:" + model.name
                    });

                    return(new OperateResult
                    {
                        status = OperateStatus.Success,
                        content = "更新成功"
                    });
                }
                catch (Exception ex)
                {
                    return(new OperateResult
                    {
                        content = ex.Message,
                    });
                }
            }
        }
예제 #14
0
        public OperateResult Update(Module model)
        {
            using (SystemDB db = new SystemDB())
            {
                try
                {
                    var elements = (from e in db.moduleList
                                    where e.id != model.id && e.name == model.name
                                    select e
                                    ).ToList();
                    if (elements.Count() >= 1)
                    {
                        return(new OperateResult
                        {
                            content = "已经存在同名的模块",
                        });
                    }


                    var matchs = (from e in db.moduleList
                                  where e.id == model.parentId && e.parentId == model.id
                                  select e
                                  ).ToList();
                    if (matchs.Count() >= 1)
                    {
                        return(new OperateResult
                        {
                            content = "该部门与其上级部门互为上下部门",
                        });
                    }
                    db.Entry(model).State = EntityState.Modified;

                    db.SaveChanges();

                    return(new OperateResult
                    {
                        status = OperateStatus.Success,
                        content = "更新成功"
                    });
                }
                catch (Exception ex)
                {
                    return(new OperateResult
                    {
                        content = ex.Message,
                    });
                }
            }
        }
예제 #15
0
        public OperateResult Lock(long id)
        {
            using (SystemDB db = new SystemDB())
            {
                try
                {
                    var element = (from m in db.userList
                                   where id == m.id
                                   select m
                                   ).FirstOrDefault();

                    if (element == null)
                    {
                        return(new OperateResult
                        {
                            content = "访问错误",
                        });
                    }

                    element.status = "锁定";

                    db.Entry(element).State = System.Data.Entity.EntityState.Modified;

                    db.SaveChanges();

                    LogManager.Add(new LogRecord
                    {
                        userId  = SessionHelper.GetUserId(),
                        time    = DateTime.Now,
                        type    = "Info",
                        content = "锁定用户:" + element.name
                    });


                    return(new OperateResult
                    {
                        status = OperateStatus.Success,
                        content = "更新成功"
                    });
                }
                catch (Exception ex)
                {
                    return(new OperateResult
                    {
                        content = ex.Message,
                    });
                }
            }
        }
예제 #16
0
        public static OperateResult  Update(Company model)
        {
            try
            {
                using (SystemDB db = new SystemDB())
                {
                    var element = (from e in db.companyList
                                   where e.id == model.id
                                   select e
                                   ).AsNoTracking().FirstOrDefault();
                    if (element == null)
                    {
                        return(new OperateResult
                        {
                            content = "访问错误",
                        });
                    }

                    var elements = (from e in db.companyList
                                    where e.id != model.id && e.name == model.name
                                    select e
                                    ).ToList();
                    if (elements.Count() >= 1)
                    {
                        return(new OperateResult
                        {
                            content = "已经存在同名的公司",
                        });
                    }

                    db.Entry(model).State = EntityState.Modified;

                    db.SaveChanges();

                    return(new OperateResult
                    {
                        status = OperateStatus.Success,
                        content = "更新成功"
                    });
                }
            }
            catch (Exception ex)
            {
                return(new OperateResult
                {
                    content = Model.Utility.Utility.GetExceptionMsg(ex),
                });
            }
        }
예제 #17
0
        public OperateResult Remove(long id)
        {
            using (SystemDB db = new SystemDB())
            {
                try
                {
                    var element  = db.moduleList.Find(id);
                    var elements = db.moduleList.ToList();

                    if (element == null)
                    {
                        return(new OperateResult
                        {
                            content = "不存在该模块",
                        });
                    }
                    var query = from e in elements
                                where e.parentId == element.id
                                select e;
                    if (query.Count() > 0)
                    {
                        return(new OperateResult
                        {
                            content = "该模块存在下级模块,不能删除",
                        });
                    }

                    db.moduleList.Remove(element);

                    db.Entry(element).State = EntityState.Deleted;
                    db.SaveChanges();

                    return(new OperateResult
                    {
                        status = OperateStatus.Success,
                        content = "删除成功"
                    });
                }
                catch (Exception ex)
                {
                    return(new OperateResult
                    {
                        content = ex.Message,
                    });
                }
            }
        }
예제 #18
0
        public OperateResult AssignRight(long roleId, List <long> idList)
        {
            using (SystemDB db = new SystemDB())
            {
                try
                {
                    var role = (from e in db.roleList.Include("rightList")
                                where e.id == roleId
                                select e).FirstOrDefault();
                    if (role != null)
                    {
                        foreach (var rid in idList)
                        {
                            var model = db.rightList.Find(rid);

                            var query = (from e in role.rightList
                                         where e.id == rid
                                         select e).FirstOrDefault();

                            if (model != null && query == null)
                            {
                                role.rightList.Add(model);
                            }
                        }
                    }

                    db.Entry(role).State = EntityState.Modified;

                    //db.Configuration.ValidateOnSaveEnabled = false;
                    db.SaveChanges();
                    //db.Configuration.ValidateOnSaveEnabled = true;

                    return(new OperateResult
                    {
                        status = OperateStatus.Success,
                        content = "更新成功"
                    });
                }
                catch (Exception ex)
                {
                    return(new OperateResult
                    {
                        content = ex.Message,
                    });
                }
            }
        }
예제 #19
0
        public static OperateResult  Update(PerformanceInfo model)
        {
            try
            {
                using (SystemDB db = new SystemDB())
                {
                    var elements = (from e in db.performanceInfoList
                                    where e.id != model.id && e.code == model.code
                                    select e
                                    ).ToList();
                    if (elements.Count() >= 1)
                    {
                        return(new OperateResult
                        {
                            content = "已经存在同名的绩效代码",
                        });
                    }


                    db.Entry(model).State = EntityState.Modified;

                    db.SaveChanges();

                    LogManager.Add(new LogRecord
                    {
                        userId  = SessionHelper.GetUserId(),
                        time    = DateTime.Now,
                        type    = "Info",
                        content = "修改绩效:" + model.code
                    });

                    return(new OperateResult
                    {
                        status = OperateStatus.Success,
                        content = "更新成功"
                    });
                }
            }
            catch (Exception ex)
            {
                return(new OperateResult
                {
                    content = Model.Utility.Utility.GetExceptionMsg(ex),
                });
            }
        }
예제 #20
0
        public static OperateResult  Remove(long id)
        {
            try
            {
                using (SystemDB db = new SystemDB())
                {
                    var element = db.roleList.Find(id);

                    if (element == null)
                    {
                        return(new OperateResult
                        {
                            content = "不存在该记录",
                        });
                    }

                    db.roleList.Remove(element);

                    db.Entry(element).State = EntityState.Deleted;
                    db.SaveChanges();


                    LogManager.Add(new LogRecord
                    {
                        userId  = SessionHelper.GetUserId(),
                        time    = DateTime.Now,
                        type    = "Info",
                        content = "删除角色:" + element.name
                    });

                    return(new OperateResult
                    {
                        status = OperateStatus.Success,
                        content = "删除成功"
                    });
                }
            }
            catch (Exception ex)
            {
                return(new OperateResult
                {
                    content = Model.Utility.Utility.GetExceptionMsg(ex),
                });
            }
        }
예제 #21
0
        public OperateResult Add(User model)
        {
            using (SystemDB db = new SystemDB())
            {
                try
                {
                    var match = from m in db.userList
                                where m.name.Equals(model.name)
                                select m;
                    if (match.Count() > 0)
                    {
                        return(new OperateResult
                        {
                            content = "用户已经存在",
                        });
                    }

                    model.passwd = MD5Encode.Encode16(model.passwd);

                    db.userList.Add(model);
                    db.SaveChanges();

                    LogManager.Add(new LogRecord
                    {
                        userId  = SessionHelper.GetUserId(),
                        time    = DateTime.Now,
                        type    = "Info",
                        content = "添加用户:" + model.name
                    });

                    return(new OperateResult
                    {
                        status = OperateStatus.Success,
                    });
                }
                catch (Exception ex)
                {
                    return(new OperateResult
                    {
                        content = ex.Message,
                    });
                }
            }
        }
예제 #22
0
        public static OperateResult  Add(LevelInfo model)
        {
            try
            {
                using (SystemDB db = new SystemDB())
                {
                    var match = from m in db.levelInfoList
                                where m.name.Equals(model.name)
                                select m;
                    if (match.Count() > 0)
                    {
                        return(new OperateResult
                        {
                            content = "该岗位名称已经存在",
                        });
                    }

                    db.levelInfoList.Add(model);
                    db.SaveChanges();

                    LogManager.Add(new LogRecord
                    {
                        userId  = SessionHelper.GetUserId(),
                        time    = DateTime.Now,
                        type    = "Info",
                        content = "添加层级:" + model.name
                    });


                    return(new OperateResult
                    {
                        status = OperateStatus.Success,
                    });
                }
            }
            catch (Exception ex)
            {
                return(new OperateResult
                {
                    content = Model.Utility.Utility.GetExceptionMsg(ex),
                });
            }
        }
예제 #23
0
        public OperateResult Update(PerformanceInfo model)
        {
            using (SystemDB db = new SystemDB())
            {
                try
                {
                    var elements = (from e in db.performanceInfoList
                                    where e.id != model.id && e.code == model.code
                                    select e
                                    ).ToList();
                    if (elements.Count() >= 1)
                    {
                        return(new OperateResult
                        {
                            content = "已经存在同名的绩效代码",
                        });
                    }


                    db.Entry(model).State = EntityState.Modified;

                    db.SaveChanges();

                    return(new OperateResult
                    {
                        status = OperateStatus.Success,
                        content = "更新成功"
                    });
                }
                catch (Exception ex)
                {
                    return(new OperateResult
                    {
                        content = ex.Message,
                    });
                }
            }
        }
예제 #24
0
        public static OperateResult Add(LogRecord model)
        {
            try
            {
                using (SystemDB db = new SystemDB())
                {
                    db.logRecordList.Add(model);
                    db.SaveChanges();

                    return(new OperateResult
                    {
                        status = OperateStatus.Success,
                    });
                }
            }
            catch (Exception ex)
            {
                return(new OperateResult
                {
                    content = Model.Utility.Utility.GetExceptionMsg(ex),
                });
            }
        }
예제 #25
0
        public static OperateResult  Remove(long id)
        {
            try
            {
                using (SystemDB db = new SystemDB())
                {
                    var element  = db.companyList.Find(id);
                    var elements = db.companyList.ToList();

                    if (element == null)
                    {
                        return(new OperateResult
                        {
                            content = "不存在该公司",
                        });
                    }

                    db.companyList.Remove(element);

                    db.Entry(element).State = EntityState.Deleted;
                    db.SaveChanges();

                    return(new OperateResult
                    {
                        status = OperateStatus.Success,
                        content = "删除成功"
                    });
                }
            }
            catch (Exception ex)
            {
                return(new OperateResult
                {
                    content = Model.Utility.Utility.GetExceptionMsg(ex),
                });
            }
        }
예제 #26
0
        public OperateResult Add(SalaryRecord model)
        {
            using (SystemDB db = new SystemDB())
            {
                try
                {
                    var match = (from m in db.salaryRecordList.Include("assessmentInfo")
                                 where m.assessmentInfoId == model.assessmentInfoId
                                 select m
                                 ).FirstOrDefault();
                    if (match != null)
                    {
                        return(new OperateResult
                        {
                            content = "数据已经存在",
                        });
                    }

                    model.inputDate = DateTime.Now;

                    db.salaryRecordList.Add(model);
                    db.SaveChanges();

                    return(new OperateResult
                    {
                        status = OperateStatus.Success,
                    });
                }
                catch (Exception ex)
                {
                    return(new OperateResult
                    {
                        content = ex.Message,
                    });
                }
            }
        }
예제 #27
0
        public OperateResult Remove(long id)
        {
            using (SystemDB db = new SystemDB())
            {
                try
                {
                    var element = db.benefitInfoList.Find(id);

                    if (element == null)
                    {
                        return(new OperateResult
                        {
                            content = "不存在该绩效",
                        });
                    }

                    db.benefitInfoList.Remove(element);

                    db.Entry(element).State = System.Data.Entity.EntityState.Deleted;
                    db.SaveChanges();

                    return(new OperateResult
                    {
                        status = OperateStatus.Success,
                        content = "删除成功"
                    });
                }
                catch (Exception ex)
                {
                    return(new OperateResult
                    {
                        content = ex.Message,
                    });
                }
            }
        }
예제 #28
0
        public OperateResult Login(User model)
        {
            using (SystemDB db = new SystemDB())
            {
                try
                {
                    var passwd = MD5Encode.Encode16(model.passwd);

                    var element = (from e in db.userList.Include("role")
                                   where e.passwd == passwd && e.name == model.name
                                   select e
                                   ).FirstOrDefault();
                    if (element != null)
                    {
                        if (element.status == "锁定")
                        {
                            return(new OperateResult
                            {
                                content = "用户被锁定",
                            });
                        }

                        //更新最后一次登录
                        element.lastLogin = DateTime.Now;

                        if (element.status == "未激活")
                        {
                            element.status = "激活";
                        }

                        db.Entry(element).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();

                        LogManager.Add(new LogRecord
                        {
                            userId  = element.id,
                            time    = DateTime.Now,
                            type    = "Info",
                            content = "登录系统"
                        });

                        return(new OperateResult
                        {
                            status = OperateStatus.Success,
                            content = "登录成功",
                            data = element
                        });
                    }


                    return(new OperateResult
                    {
                        content = "用户名或密码不正确"
                    });
                }
                catch (Exception ex)
                {
                    return(new OperateResult
                    {
                        content = ex.Message,
                    });
                }
            }
        }
예제 #29
0
        /// <summary>
        /// 员工离职后,把该员工数据信息录入离职数据库
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static OperateResult Leave(Employee model)
        {
            if (model == null)
            {
                return(new OperateResult
                {
                    content = "离职员工数据为null"
                });
            }
            try
            {
                using (SystemDB db = new SystemDB())
                {
                    EmployeeLeave employee = Model.Utility.Utility.AutoCopy <Employee, EmployeeLeave>(model);

                    employee.employeeId = model.id;

                    // 岗位
                    #region
                    var postInfo = (from e in db.postInfoList
                                    where e.id == model.postId
                                    select e
                                    ).FirstOrDefault();
                    if (postInfo != null)
                    {
                        employee.postName = postInfo.name;
                    }
                    #endregion

                    //薪资
                    #region
                    var salary = (from e in db.salaryInfoList
                                  where e.id == model.salaryInfoId
                                  select e).FirstOrDefault();
                    if (salary != null)
                    {
                        OperateResult or = SalaryRecordManager.GetSalaryAveById(model.id);

                        if (or.status == OperateStatus.Success)
                        {
                            employee.salary        = salary.GetSalaryTotal();
                            employee.salaryAverage = (double)or.data;
                        }
                    }
                    #endregion


                    // 离职记录基数表
                    #region
                    db.EmployeeLeaveList.Add(employee);
                    db.SaveChanges();

                    #endregion

                    return(new OperateResult
                    {
                        status = OperateStatus.Success,
                    });
                }
            }
            catch (Exception ex)
            {
                return(new OperateResult
                {
                    content = Model.Utility.Utility.GetExceptionMsg(ex),
                });
            }
        }
예제 #30
0
        public static OperateResult UpdateStatus(long id, string status)
        {
            if (status != "未审核" && status != "已审核")
            {
                return(new OperateResult
                {
                    content = "数据错误",
                });
            }

            try
            {
                using (SystemDB db = new SystemDB())
                {
                    //如果工资记录已经锁定,则不能再修改状态
                    var salary = (from s in db.salaryRecordList
                                  where s.assessmentInfoId == id && s.status == "已审核"
                                  select s).FirstOrDefault();
                    if (salary != null)
                    {
                        return(new OperateResult
                        {
                            content = "已经存在审核通过的工资记录,不能修改",
                        });
                    }

                    var element = (from m in db.assessmentInfoList
                                   where id == m.id
                                   select m
                                   ).AsNoTracking().FirstOrDefault();

                    if (element == null)
                    {
                        return(new OperateResult
                        {
                            content = "访问错误",
                        });
                    }

                    element.status          = status;
                    db.Entry(element).State = EntityState.Modified;
                    db.SaveChanges();

                    LogManager.Add(new LogRecord
                    {
                        userId  = SessionHelper.GetUserId(),
                        time    = DateTime.Now,
                        type    = "Info",
                        content = "修改状态:" + element.billSerial + ", " + element.status
                    });

                    return(new OperateResult
                    {
                        status = OperateStatus.Success,
                    });
                }
            }
            catch (Exception ex)
            {
                return(new OperateResult
                {
                    content = Model.Utility.Utility.GetExceptionMsg(ex),
                });
            }
        }