コード例 #1
0
 public void NUnit_Domain_AddCatOvertimeType()
 {
     Cat_OvertimeTypeServices service = new Cat_OvertimeTypeServices();
     bool result = false;
     int rs = 0;
     for (int i = 0; i < 10; i++)
     {
         var OvertimeType = new Cat_OvertimeType
         {
             OvertimeTypeCode = "tt" + i,
             OvertimeTypeName = "Overtime Type Name Test" + i,
             Rate = i,
             TaxRate = i,
             TimeOffInLieuRate = i
         };
         if (service.Add(OvertimeType) == "0")
         {
             result = true;
         }
         if (result == true)
         {
             rs += 1;
             Console.WriteLine("Process Success >>> Create >>> " + OvertimeType.Id + " | " + OvertimeType.OvertimeTypeCode + " | " + OvertimeType.OvertimeTypeName
                 + " | " + OvertimeType.Rate + " | " + OvertimeType.TaxRate + " | " + OvertimeType.TimeOffInLieuRate);
         }
     }
     Console.WriteLine("Total success record: " + rs);
 }
コード例 #2
0
        public void NUnit_Domain_UpdateCatOvertimeType()
        {
            Cat_OvertimeTypeServices service = new Cat_OvertimeTypeServices();
            var OvertimeType = new Cat_OvertimeType
            {
                Id = 3,
                OvertimeTypeCode  = "Overtime Type Name tt",
                OvertimeTypeName  = "Overtime Type Name Test",
                Rate              = 1,
                TaxRate           = 1,
                TimeOffInLieuRate = 1
            };
            var result = false;

            if (service.Edit(OvertimeType) == "0")
            {
                result = true;
            }
            NUnit.Framework.Assert.IsTrue(result);
            if (result == true)
            {
                Console.WriteLine("==>>> Result After Update:  " + OvertimeType.Id + " | " + OvertimeType.OvertimeTypeCode + " | " + OvertimeType.OvertimeTypeName
                                  + " | " + OvertimeType.Rate + " | " + OvertimeType.TaxRate + " | " + OvertimeType.TimeOffInLieuRate);
            }
        }
コード例 #3
0
        public void NUnit_Domain_AddCatOvertimeType()
        {
            Cat_OvertimeTypeServices service = new Cat_OvertimeTypeServices();
            bool result = false;
            int  rs     = 0;

            for (int i = 0; i < 10; i++)
            {
                var OvertimeType = new Cat_OvertimeType
                {
                    OvertimeTypeCode  = "tt" + i,
                    OvertimeTypeName  = "Overtime Type Name Test" + i,
                    Rate              = i,
                    TaxRate           = i,
                    TimeOffInLieuRate = i
                };
                if (service.Add(OvertimeType) == "0")
                {
                    result = true;
                }
                if (result == true)
                {
                    rs += 1;
                    Console.WriteLine("Process Success >>> Create >>> " + OvertimeType.Id + " | " + OvertimeType.OvertimeTypeCode + " | " + OvertimeType.OvertimeTypeName
                                      + " | " + OvertimeType.Rate + " | " + OvertimeType.TaxRate + " | " + OvertimeType.TimeOffInLieuRate);
                }
            }
            Console.WriteLine("Total success record: " + rs);
        }
コード例 #4
0
 public void NUnit_Domain_GetByIdCatOvertimeType()
 {
     string status = string.Empty;
     Cat_OvertimeTypeServices service = new Cat_OvertimeTypeServices();
     var OvertimeType = new Cat_OvertimeType { Id = 2 };
     var result = service.GetById<Cat_OvertimeTypeEntity>(OvertimeType.Id, ref status) as Cat_OvertimeTypeEntity;
     NUnit.Framework.Assert.IsNotNull(result);
     Console.Write("SearchResult: " + result.Id + " | " + result.OvertimeTypeCode + " | " + result.OvertimeTypeName + " | " +
         result.Rate + " | " + result.TaxRate + " | " + result.TimeOffInLieuRate + " | " + result.IsNightShift);
 }
コード例 #5
0
        public void NUnit_Domain_GetByIdCatOvertimeType()
        {
            string status = string.Empty;
            Cat_OvertimeTypeServices service = new Cat_OvertimeTypeServices();
            var OvertimeType = new Cat_OvertimeType {
                Id = 2
            };
            var result = service.GetById <Cat_OvertimeTypeEntity>(OvertimeType.Id, ref status) as Cat_OvertimeTypeEntity;

            NUnit.Framework.Assert.IsNotNull(result);
            Console.Write("SearchResult: " + result.Id + " | " + result.OvertimeTypeCode + " | " + result.OvertimeTypeName + " | " +
                          result.Rate + " | " + result.TaxRate + " | " + result.TimeOffInLieuRate + " | " + result.IsNightShift);
        }
コード例 #6
0
        public void NUnit_Domain_DeleteCatOvertimeType()
        {
            Cat_OvertimeTypeServices service = new Cat_OvertimeTypeServices();
            string result = string.Empty;
            int    rs     = 0;

            for (int i = 3; i <= 5; i++)
            {
                var OvertimeType = new Cat_OvertimeType {
                    Id = i
                };
                result = service.Delete <Cat_OvertimeTypeEntity>(OvertimeType.Id);
                if (result != string.Empty)
                {
                    rs += 1;
                    Console.WriteLine("Process Success >>> Delete >>> " + i);
                }
            }
            Console.WriteLine("Total success record: " + rs);

            //NUnit.Framework.Assert.IsTrue(result);
        }
コード例 #7
0
 public void NUnit_Domain_UpdateCatOvertimeType()
 {
     Cat_OvertimeTypeServices service = new Cat_OvertimeTypeServices();
     var OvertimeType = new Cat_OvertimeType
     {
         Id = 3,
         OvertimeTypeCode = "Overtime Type Name tt",
         OvertimeTypeName = "Overtime Type Name Test",
         Rate = 1,
         TaxRate = 1,
         TimeOffInLieuRate = 1
     };
     var result = false;
      if (service.Edit(OvertimeType) == "0")
     {
         result = true;
     }
     NUnit.Framework.Assert.IsTrue(result);
     if (result == true)
     {
         Console.WriteLine("==>>> Result After Update:  " + OvertimeType.Id + " | " + OvertimeType.OvertimeTypeCode + " | " + OvertimeType.OvertimeTypeName
             + " | " + OvertimeType.Rate + " | " + OvertimeType.TaxRate + " | " + OvertimeType.TimeOffInLieuRate);
     }
 }
コード例 #8
0
        public Cat_OvertimeType getOTType(DateTime dateWorkDate, bool isNightShift, Hre_Profile profile, List <Cat_DayOff> list_dayOff, List <Att_RosterGroup> lstRosterGroup, List <Att_Roster> lstRosterTypeGroup)
        {
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork           = (IUnitOfWork)(new UnitOfWork(context));
                var repoAtt_LeaveDay     = new CustomBaseRepository <Att_LeaveDay>(unitOfWork);
                var repoCat_OvertimeType = new CustomBaseRepository <Cat_OvertimeType>(unitOfWork);

                Cat_OvertimeType otType = null;
                try
                {
                    dateWorkDate = dateWorkDate.Date;

                    //LamLe : Them chuc nang neu tang ca vao ngay nghi thi chon loai tang ca phu thuoc vao cau hinh Tang ca trong ngay nghi.
                    List <Att_LeaveDay> lstLeave = repoAtt_LeaveDay
                                                   .FindBy(lv => lv.IsDelete == null && lv.DateStart <= dateWorkDate && lv.DateEnd >= dateWorkDate && lv.ProfileID == profile.ID)
                                                   .ToList();
                    if (lstLeave.Count > 0)
                    {
                        Att_LeaveDay leave = lstLeave[0];
                        if (leave != null && leave.Cat_LeaveDayType != null && leave.Cat_LeaveDayType.Cat_OvertimeType != null)
                        {
                            otType = leave.Cat_LeaveDayType.Cat_OvertimeType;
                            return(otType);
                        }
                    }

                    Att_Grade grade = Att_GradeServices.GetGrade(profile, dateWorkDate);
                    if (grade == null)
                    {
                        string status = OverTimeType.E_WORKDAY.ToString();
                        otType = repoCat_OvertimeType.FindBy(dayoff => dayoff.IsDelete == null && dayoff.Code == status).FirstOrDefault();
                        return(otType);
                    }
                    list_dayOff = list_dayOff.Where(df => df.DateOff.Date == dateWorkDate.Date).ToList();
                    Cat_GradeCfg gradecfg = grade.Cat_GradeCfg;

                    //Check overtime holiday
                    //List<Cat_DayOff> list_dayOff = EntityService.Instance.GetEntityList<Cat_DayOff>(GuidContext, _userId, dayoff => dayoff.DateOff == dateWorkDate);

                    if (list_dayOff.Count > 0)
                    {
                        //Cat_GradeCfg.FieldNames.Cat_OvertimeType1
                        bool isDayOffHollyDay = false;
                        foreach (var item in list_dayOff)
                        {
                            if (item.DateOff.Date == dateWorkDate.Date && item.Type == HolidayType.E_HOLIDAY_HLD.ToString())
                            {
                                isDayOffHollyDay = true;
                            }
                        }
                        //Ca dem ngay le
                        if (isDayOffHollyDay && isNightShift)
                        {
                            otType = gradecfg.Cat_OvertimeType5;
                        }
                        //Ca dem ngay nghi cuoi tuan
                        else if (!isDayOffHollyDay && isNightShift)
                        {
                            otType = gradecfg.Cat_OvertimeType4;
                        }
                        ////Ca ngay ngay le
                        else if (isDayOffHollyDay && !isNightShift)
                        {
                            otType = gradecfg.Cat_OvertimeType2;
                        }
                        ////Ca ngay ngay nghi cuoi tuan
                        else
                        {
                            otType = gradecfg.Cat_OvertimeType1;
                        }
                    }
                    else
                    {
                        Hashtable hsRoster = Att_RosterServices.GetRosterTable(false, profile, dateWorkDate, dateWorkDate, lstRosterGroup, lstRosterTypeGroup);

                        bool isWorkday = Att_AttendanceServices.IsWorkDay(grade.Cat_GradeAttendance, hsRoster, list_dayOff, dateWorkDate);
                        if (isWorkday)
                        {
                            if (isNightShift)
                            {
                                otType = gradecfg.Cat_OvertimeType3;
                            }
                            else
                            {
                                otType = gradecfg.Cat_OvertimeType;
                            }
                            //if (gradecfg.Cat_OvertimeType == null)
                            //{

                            //    string workday = OverTimeType.E_WORKDAY.ToString();
                            //    otType = EntityService.Instance.GetEntity<Cat_OvertimeType>(GuidContext, _userId, dayoff => dayoff.Code == workday);
                            //}
                            //else
                            //    otType = gradecfg.Cat_OvertimeType;
                        }
                        else
                        {
                            if (isNightShift)
                            {
                                otType = gradecfg.Cat_OvertimeType4;
                            }
                            else
                            {
                                otType = gradecfg.Cat_OvertimeType1;
                            }
                            //if (gradecfg.Cat_OvertimeType1 == null)
                            //{
                            //    string workday = OverTimeType.E_WORKDAY.ToString();
                            //    otType = EntityService.Instance.GetEntity<Cat_OvertimeType>(GuidContext, _userId, dayoff => dayoff.Code == workday);
                            //}
                            //else
                            //    otType = gradecfg.Cat_OvertimeType1;
                        }
                    }
                }
                catch (Exception ex)
                {
                }
                return(otType);
            }
        }
コード例 #9
0
        public void NUnit_Domain_DeleteCatOvertimeType()
        {
            Cat_OvertimeTypeServices service = new Cat_OvertimeTypeServices();
            string  result = string.Empty;
            int rs = 0;
            for (int i = 3; i <= 5; i++)
            {
                var OvertimeType = new Cat_OvertimeType { Id = i };
                result = service.Delete<Cat_OvertimeTypeEntity>(OvertimeType.Id);
                if (result != string.Empty)
                {
                    rs += 1;
                    Console.WriteLine("Process Success >>> Delete >>> " + i);
                }
            }
            Console.WriteLine("Total success record: " + rs);

            //NUnit.Framework.Assert.IsTrue(result);
        }