コード例 #1
0
        /// <summary>
        /// 查询人员某月工作记录
        /// </summary>
        /// <param name="year">年</param>
        /// <param name="month">月</param>
        /// <param name="userID">用户ID</param>
        /// <returns></returns>
        public List <WorkItem> GetWorkItemByYearMonth(int year, int month, int userID)
        {
            var beginDT      = DateTime.Parse($"{year}-{month}-01 00:00:00.000");
            var endDT        = DateTime.Parse($"{year}-{month}-{DateTime.DaysInMonth(year, month)} 23:59:59.999");
            var workItems    = _workingDB.Query <WorkItem>("select * from workitems where recorddate>=@begindt and recorddate<=@enddt and createuserid=@userid", new { begindt = beginDT, enddt = endDT, userid = userID }).ToList();
            var newWrokItems = new List <WorkItem>();

            for (int i = 1; i <= DateTime.DaysInMonth(year, month); i++)
            {
                var beginDay       = DateTime.Parse($"{year}-{month}-{i} 00:00:00.000");
                var endDay         = DateTime.Parse($"{year}-{month}-{i} 23:59:59.999");
                var oneDayWorkItem = workItems.SingleOrDefault(s => s.RecordDate >= beginDay && s.RecordDate <= endDay);
                if (oneDayWorkItem == null)
                {
                    newWrokItems.Add(new WorkItem()
                    {
                        RecordDate = beginDay
                    });
                }
                else
                {
                    newWrokItems.Add(oneDayWorkItem);
                }
            }
            return(newWrokItems);
        }
コード例 #2
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <param name="password">密码</param>
        /// <returns></returns>
        public UserRole Login(string userName, string password)
        {
            var userRole = _workingDB.Query <UserRole>("select users.*,roles.rolename from users join roles on users.roleid=roles.id where username=@username and password=@password", new { username = userName, password = password }).SingleOrDefault();

            if (userRole == null)
            {
                throw new Exception("用户名或密码错误!");
            }
            else
            {
                return(userRole);
            }
        }
コード例 #3
0
 /// <summary>
 /// 查询全部部门带父部门
 /// </summary>
 /// <returns></returns>
 public List <FullDepartment> GetAllPDepartment()
 {
     return(_workingDB.Query <FullDepartment>("select d.*,pd.departmentname as pdepartmentname from departments as d join departments as pd on d.pdepartmentid=pd.id ").ToList());
 }
コード例 #4
0
 /// <summary>
 /// 本询角色
 /// </summary>
 /// <returns></returns>
 public List <Role> GetRoles()
 {
     return(_workingDB.Query <Role>("select * from roles").ToList());
 }