コード例 #1
0
        public static void NonRecordedAttendance(int EmpId, DateTime day)
        {
            // 1. Check ExceptionAttendance for employee id.
            // 2. If employee exists, mark employee as present
            // 3. Else check for applications, mark employee as absent based on that.

            MEAPSDbEntities     context = new MEAPSDbEntities();
            ExceptionAttendance ea      = context.ExceptionAttendances.SingleOrDefault(x => (x.EmpId == EmpId) && (x.Date == day));

            if (ea != null) // if in exception attendance, mark as full present.
            {
                LeaveStatus ls = new LeaveStatus();
                ls.Date          = day;
                ls.EmployeeEmpId = EmpId;
                ls.PresenceState = "FP";
                context.LeaveStatuses.Add(ls);
                context.SaveChanges();
            }
            else                           // else check for applications
            {
                LeaveStatus ls = new LeaveStatus();
                ls.Date          = day;
                ls.EmployeeEmpId = EmpId;
                ls.PresenceState = "A";

                LeaveApplication la = context.LeaveApplications.SingleOrDefault(x => (x.Date == day) && (x.EmployeeEmpId == EmpId));
                if (la != null)
                {
                    string type = la.Type;
                    switch (type)
                    {
                    case "CL":
                        ls.FCL = 1;
                        break;

                    case "ML":
                        ls.FML = 1;
                        break;

                    case "EL":
                        ls.EL = 1;
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    ls.FCL = 1;
                }
                ls = LeaveDeduction.Deduct(ls);
                context.LeaveStatuses.Add(ls);
                context.SaveChanges();
            }
        }
コード例 #2
0
        public static void RecordedAttendance(int EmpId, DateTime day, TimeSpan EntryTime, TimeSpan ExitTime)
        {
            MEAPSDbEntities context          = new MEAPSDbEntities();
            TimeSpan        DefaultEntryTime = Convert.ToDateTime("9:50 AM").TimeOfDay;
            TimeSpan        DefaultExitTime  = Convert.ToDateTime("5:25 PM").TimeOfDay;
            LeaveStatus     ls = new LeaveStatus();

            ls.Date          = day;
            ls.EmployeeEmpId = EmpId;
            ls = Calculate(ls, EntryTime, ExitTime, day);
            ls = LeaveDeduction.Deduct(ls);
            context.LeaveStatuses.Add(ls);
            context.SaveChanges();
        }