首页 > 解决方案 > 有没有办法找到没有匹配的行?还是空?

问题描述

我目前正在创建一个考勤应用程序,但我很难匹配没有日志将其标记为缺席的日程安排。

截至目前,这就是我的桌子的样子

当前表 当前表

目前,该表将仅显示哪个日程表上有考勤日志。所以我看不到是否有员工没有出现的时间表,而他/她缺席了。

我尝试将它与 null 匹配,但它最终没有显示任何内容。

这是我填充表格的代码

public void Main()
        {
            // works but not the midnight cross stuff
            var final = (from a1 in EmployeeAttendanceLogs
                         join a2 in EmployeeAttendanceLogs on a1.ID equals a2.ID
                         join t1 in EmployeeScheduleList on a1.ID equals t1.ID
                         join t2 in EmployeeScheduleList on a2.ID equals t2.ID
                         join d1 in EmployeeDetails on t1.ID equals d1.EmployeeID
                         where ((a1.LogStatus == 0 && t1.In == t2.In) && (((((a1.ActualLog - t1.In ).Ticks) > TimeSpan.FromHours(1).Ticks) || t1.In.Date == a1.ActualLog.Date) && t1.In.Date == a1.ActualLog.Date )) && (a2.LogStatus == 1 && t1.Out == t2.Out && (t2.Out.Date == a2.ActualLog.Date) )
                         select new
                         {
                             User_ID = t1.ID,
                             Name = d1.EmployeeName,
                             Scheduled_In = t1.In,
                             Actual_Login = a1.ActualLog,
                             Scheduled_Out = t2.Out,
                             Actual_Out = a2.ActualLog
                         }).Distinct(). ToList();

            tbContainer = StaticClasses.ToDataTable(final);

            dgvAttendance.ItemsSource = emp.CalculateEmployeeAttendance(tbContainer);
        }

这些是我的数据来源

员工计划文件

员工时间表

员工考勤日志文件

考勤记录

根据日志,员工 5 没有记录,这是网格的输出

输出

所以它没有显示,但我也尝试将我的课程设置为有逻辑

员工时间表类

public class EmployeeSchedule
{
    public int ID { get; set; }
    private string _name;
    public string Name
    { get
        {
            if (_name == null)
            {
                _name = "";
            }
            return _name;
        }
        set { _name = value; }
    }

    public string scheduleeIn { get; set; }

    private string _actualIn;
    public string actualIn
    {
        get
        {
            if (_actualIn == null) 
            {
                _actualIn = "Absent";
            }
            return _actualIn;
        }
        set { _actualIn = value; }

    }

    public string scheduleOut { get; set; }

    public string _actualOut;
    public string actualOut
    {
        get
        {
            if (_actualOut == null)
            {
                _actualOut = "Absent";
            }
            return _actualOut;
        }
        set { _actualOut = value; }

    }

    private string _tardiness;
    public string tardiness
    {
        get
        {
            if (_tardiness == null) 
            {
                _tardiness = "Absent";
            }
            return _tardiness;
        }
        set { _tardiness = value; }
    }

    private string _workHours;
    public string workHours
    {
        get
        {
            if (_workHours == null) 
            {
                _workHours = "Absent";
            }
            return _workHours;
        }
        set { _workHours = value; }
    }    
}

我已经尝试弄清楚它已经一天了,但它似乎没有出现或将日程表标记为缺席。

任何想法或建议都会有很大帮助。谢谢

编辑:数据来源

这是我的考勤日志的数据来源

考勤记录

public class Actual
    {
        public int ID { get; set; }
        public DateTime ActualLog { get; set; }
        public int LogStatus { get; set; }
        public DateTime date { get; set; }
    }

员工时间表

public class Emp1
{
    public int ID { get; set; }
    public DateTime In { get; set; }
    public DateTime Out { get; set; }
}

标签: c#excellinqxamlwpfdatagrid

解决方案


推荐阅读