コード例 #1
0
        private List<string> StatusKerja()
        {
            Admin A = new Admin();
            ArrayList data_att = A.GetAttendanceTime();
            List<string> statusKerjaList = null;
            for (int ar = 0; ar <= data_att.Count; ar = ar + 2)
            {
                string statusKerja;
                DateTime AttIn = (DateTime)data_att[ar];
                DateTime AttOut = (DateTime)data_att[ar + 1];

                TimeSpan rawTotalHoursWorked = AttOut - AttIn;

                var masuk = TimeSpan.Parse("08:00:00");
                var lembur = TimeSpan.Parse("09:00:00");

                if (rawTotalHoursWorked >= lembur)
                {
                    statusKerja = "Lembur";
                }
                else if (rawTotalHoursWorked >= masuk && rawTotalHoursWorked < lembur)
                {
                    statusKerja = "Masuk";
                }
                else
                {
                    statusKerja = "Setengah Hari";
                }

                statusKerjaList.Add(statusKerja);
            }
            return statusKerjaList;
        }