Esempio n. 1
0
        public static void InsertWorkingHours(hrPerson person, DateTime dt)
        {
            hrWorkingHour wh = new hrWorkingHour();

            wh.EmpId        = person.Id;
            wh.hrPerson     = person;
            wh.UserName     = person.LSUser;
            wh.AccessCardID = person.AccessCardID;
            wh.DoorSysID    = person.DoorSysID;
            wh.WorkingDate  = dt;
            wh.RecYear      = dt.Year;
            wh.RecMonth     = dt.Month;
            wh.RecDay       = dt.Day;
            wh.DayOfWeek    = dt.DayOfWeek.ToString();
            wh.IsWorkingDay = IsStdWorkingDay(dt);
            wh.TotalHours   = 0;
            wh.TotalMinutes = 0;
            wh.Exception    = "NA";
            wh.Note         = "";
            if (IsStdWorkingDay(dt))
            {
                wh.StdWorkingHour      = 8;
                wh.AssignedWorkingHour = 8;
                wh.HourDiff            = -8;
            }
            else
            {
                wh.StdWorkingHour      = 0;
                wh.AssignedWorkingHour = 0;
                wh.HourDiff            = 0;
            }

            hrHoliday holiday = GetHoliday(dt);

            if (holiday != null)
            {
                //wh.Exception = "PH";
                wh.Note                = holiday.Name;
                wh.StdWorkingHour      = holiday.WorkingHour;
                wh.AssignedWorkingHour = holiday.WorkingHour;
                wh.HourDiff            = -1 * holiday.WorkingHour;
            }

            wh.MinuteDiff     = 0;
            wh.IsOTAccepted   = false;
            wh.OTAcceptedBy   = "";
            wh.AcceptedOTeHrs = 0;
            wh.AcceptedOTMin  = 0;
        }
Esempio n. 2
0
        public static void InsertDates(hrPerson person)
        {
            DateTime firstDate  = DateTime.Parse("2016-11-01");
            DateTime lastDate   = DateTime.Parse("2017-12-31");
            DateTime actualDate = firstDate;
            bool     isExist    = false;

            using (var serverContext = LightSwitchApplication.Application.Current.CreateDataWorkspace())
            {
                var           hrs = serverContext.ApplicationData.byPerson(person.Id);
                hrWorkingHour hr;

                if (hrs != null)
                {
                    while (actualDate <= lastDate)
                    {
                        isExist = false;
                        foreach (var item in hrs)
                        {
                            hr = (hrWorkingHour)item;

                            if (hr.WorkingDate.ToShortDateString() == actualDate.ToShortDateString())
                            {
                                isExist = true;
                            }
                        }

                        if (!isExist)
                        {
                            InsertWorkingHours(person, actualDate);
                        }

                        actualDate = actualDate.AddDays(1);
                    }
                }
                else
                {
                    while (actualDate <= lastDate)
                    {
                        InsertWorkingHours(person, actualDate);
                        actualDate = actualDate.AddDays(1);
                    }
                }
            }
        }
Esempio n. 3
0
 partial void hrPeople_Updated(hrPerson entity)
 {
     InsertDates(entity);
 }
Esempio n. 4
0
 partial void hrPeople_Updating(hrPerson entity)
 {
     entity.FullName = entity.Name + " " + entity.Surname;
 }
Esempio n. 5
0
        partial void hrPeople_Inserting(hrPerson entity)
        {
            string s = entity.Title.Trim() + " " + entity.Name + " " + entity.Surname;

            entity.FullName = s.Trim();
        }